diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 19d875db..b5a3baec 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -9,9 +9,12 @@ import ic2.core.block.type.ResourceBlock; import ic2.core.item.type.CraftingItemType; import ic2.core.ref.BlockName; import ic2.core.ref.ItemName; +import net.minecraft.item.Item; import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.*; import net.minecraftforge.fml.common.event.*; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import forestry.api.recipes.ICentrifugeRecipe; import forestry.api.recipes.ISqueezerRecipe; @@ -69,12 +72,22 @@ public class GT_Mod implements IGT_Mod { public static GT_Achievements achievements; + //@SubscribeEvent + //public void onOreDictReg(OreDictionary.OreRegisterEvent event) { + // if(event.getOre().getItem() == Item.getItemFromBlock(Blocks.STONE)) { + // System.out.println("Register stone as " + event.getName()); + // new Throwable().printStackTrace(); + // } + //} + @Mod.EventHandler public void onPreLoad(FMLPreInitializationEvent aEvent) { if (GregTech_API.sPreloadStarted) { return; } + //MinecraftForge.EVENT_BUS.register(this); + GT_Values.GT = this; GT_Values.DW = new GT_DummyWorld(); GT_Values.NW = new GT_PacketHandler(); diff --git a/src/main/java/gregtech/api/items/GT_Generic_Item.java b/src/main/java/gregtech/api/items/GT_Generic_Item.java index 24c3cf9a..f210f8b4 100644 --- a/src/main/java/gregtech/api/items/GT_Generic_Item.java +++ b/src/main/java/gregtech/api/items/GT_Generic_Item.java @@ -31,6 +31,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.IForgeRegistryEntry; @@ -204,4 +205,10 @@ public class GT_Generic_Item extends Item implements IProjectileItem, IIconRegis } } + public void invokeOnClient(Runnable runnable) { + if(FMLCommonHandler.instance().getSide().isClient()) { + runnable.run(); + } + } + } \ No newline at end of file diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java index d1716344..b2ed2545 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java @@ -91,6 +91,14 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements mItemAmount = (short) Math.min(aItemAmount, 32766 - mOffset); sInstances.put(getUnlocalizedName(), this); + invokeOnClient(this::initClient); + } + + + + @SideOnly(Side.CLIENT) + public void initClient() { + mIconList = new TextureAtlasSprite[mItemAmount][1]; } /** @@ -213,15 +221,13 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements if (aMaxCharge == 0) mElectricStats.remove((short) aMetaValue); else { mElectricStats.put((short) aMetaValue, new Long[]{aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); - if(FMLCommonHandler.instance().getSide().isClient()) { - setIconElectricStats(aMetaValue, aUseAnimations); - } + invokeOnClient(() -> setElectricStatsIcon(aMetaValue, aUseAnimations)); } return this; } @SideOnly(Side.CLIENT) - public void setIconElectricStats(int aMetaValue, boolean aUseAnimations) { + public void setElectricStatsIcon(int aMetaValue, boolean aUseAnimations) { if (aMetaValue >= mOffset && aUseAnimations) mIconList[aMetaValue - mOffset] = Arrays.copyOf(mIconList[aMetaValue - mOffset], Math.max(9, mIconList[aMetaValue - mOffset].length)); } @@ -342,7 +348,6 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements @SideOnly(Side.CLIENT) public final void registerIcons(TextureMap aIconRegister) { System.out.println("Registering item icons"); - mIconList = new TextureAtlasSprite[mItemAmount][1]; for (short i = 0, j = (short) mEnabledItems.length(); i < j; i++) if (mEnabledItems.get(i)) { for (byte k = 1; k < mIconList[i].length; k++) { diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 3617813b..05e2d79a 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -307,7 +307,7 @@ public class GT_ModHandler { stack.stackSize = (int) aAmount; return stack; } - return new ItemStack(Blocks.STONE); + return null; } /**