Oops (x2)

This commit is contained in:
Dragon2488 2016-09-16 00:39:19 +07:00
parent 0080b1a69b
commit a5d2eaffa3
4 changed files with 31 additions and 6 deletions

View file

@ -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();

View file

@ -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();
}
}
}

View file

@ -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++) {

View file

@ -307,7 +307,7 @@ public class GT_ModHandler {
stack.stackSize = (int) aAmount;
return stack;
}
return new ItemStack(Blocks.STONE);
return null;
}
/**