mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
check loader state instead of relying on boolean
This commit is contained in:
1 parent
08a13cff4f
commit
9d70d06454
2 files changed
+6
-12
No files matched your search
@@ -3,14 +3,15 @@ package mekanism.api.gas;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
public class GasRegistry
|
||||
{
|
||||
private static ArrayList<Gas> registeredGasses = new ArrayList<>();
|
||||
|
||||
private static boolean initFinished = false;
|
||||
|
||||
/**
|
||||
* Register a new gas into GasRegistry. Call this BEFORE post-init.
|
||||
* @param gas - Gas to register
|
||||
@@ -18,9 +19,7 @@ public class GasRegistry
|
||||
*/
|
||||
public static Gas register(Gas gas)
|
||||
{
|
||||
if (initFinished){
|
||||
throw new IllegalStateException("Gasses must be registered before postInit.");
|
||||
}
|
||||
checkPhase();
|
||||
if(gas == null)
|
||||
{
|
||||
return null;
|
||||
@@ -116,10 +115,7 @@ public class GasRegistry
|
||||
return registeredGasses.indexOf(gas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use only, don't call this.
|
||||
*/
|
||||
public static void postInit(){
|
||||
initFinished = true;
|
||||
private static void checkPhase(){
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.INITIALIZATION.ordinal(), "Gasses must be registered before postInit.");
|
||||
}
|
||||
}
|
||||
@@ -834,8 +834,6 @@ public class Mekanism
|
||||
MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent());
|
||||
|
||||
logger.info("Hooking complete.");
|
||||
|
||||
GasRegistry.postInit();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
Reference in new issue
Block a user