mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
Relax Gas registry phase requirements so that BC integration works. Now just logs if it was registered without a valid texture entry. Fixes #4827
This commit is contained in:
1 parent
5d8b5c8f91
commit
17ce49434f
2 files changed
+23
-4
No files matched your search
@@ -153,6 +153,10 @@ public class Gas
|
||||
return sprite;
|
||||
}
|
||||
|
||||
TextureAtlasSprite getSpriteRaw(){
|
||||
return sprite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this gas's icon.
|
||||
* @param map - IIcon to associate with this Gas
|
||||
|
||||
@@ -4,14 +4,22 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GasRegistry
|
||||
{
|
||||
private static ArrayList<Gas> registeredGasses = new ArrayList<>();
|
||||
|
||||
private static Logger LOG = LogManager.getLogger("Mekanism GasRegistry");
|
||||
|
||||
/**
|
||||
* Register a new gas into GasRegistry. Call this BEFORE post-init.
|
||||
* @param gas - Gas to register
|
||||
@@ -19,12 +27,20 @@ public class GasRegistry
|
||||
*/
|
||||
public static Gas register(Gas gas)
|
||||
{
|
||||
checkPhase();
|
||||
if(gas == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
|
||||
if (hasAlreadyStitched()){
|
||||
gas.updateIcon(Minecraft.getMinecraft().getTextureMapBlocks());
|
||||
if (gas.getSpriteRaw() == null){
|
||||
LOG.error("Gas {} registered post texture stitch without valid sprite!", gas.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registeredGasses.add(gas);
|
||||
|
||||
return getGas(gas.getName());
|
||||
@@ -115,8 +131,7 @@ public class GasRegistry
|
||||
return registeredGasses.indexOf(gas);
|
||||
}
|
||||
|
||||
private static void checkPhase()
|
||||
{
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() < LoaderState.INITIALIZATION.ordinal(), "Gasses must be registered before postInit.");
|
||||
private static boolean hasAlreadyStitched(){
|
||||
return Loader.instance().getLoaderState().ordinal() > LoaderState.PREINITIALIZATION.ordinal();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user