From bdf93e12ba4f64ef738a2641fc24f9262ced5ffd Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 26 Oct 2013 03:14:23 -0700 Subject: [PATCH] Register chipset stacks with FML for good measure --- common/buildcraft/BuildCraftSilicon.java | 5 ++- .../buildcraft/core/ItemRedstoneChipset.java | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 5f763a41..b15a4200 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -32,7 +32,6 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -43,7 +42,7 @@ import net.minecraftforge.common.Property; @NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerSilicon.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftSilicon { - public static Item redstoneChipset; + public static ItemRedstoneChipset redstoneChipset; public static BlockLaser laserBlock; public static BlockLaserTable assemblyTableBlock; @Instance("BuildCraft|Silicon") @@ -72,7 +71,7 @@ public class BuildCraftSilicon { redstoneChipset = new ItemRedstoneChipset(redstoneChipsetId.getInt()); redstoneChipset.setUnlocalizedName("redstoneChipset"); CoreProxy.proxy.registerItem(redstoneChipset); - + redstoneChipset.registerItemStacks(); } @EventHandler diff --git a/common/buildcraft/core/ItemRedstoneChipset.java b/common/buildcraft/core/ItemRedstoneChipset.java index ff3bd7e5..73f706bf 100644 --- a/common/buildcraft/core/ItemRedstoneChipset.java +++ b/common/buildcraft/core/ItemRedstoneChipset.java @@ -1,5 +1,6 @@ package buildcraft.core; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; @@ -10,8 +11,8 @@ import net.minecraft.util.Icon; public class ItemRedstoneChipset extends ItemBuildCraft { - @SideOnly(Side.CLIENT) - private Icon[] icons; + @SideOnly(Side.CLIENT) + private Icon[] icons; public ItemRedstoneChipset(int i) { super(i); @@ -20,10 +21,10 @@ public class ItemRedstoneChipset extends ItemBuildCraft { setMaxDamage(0); } - @SuppressWarnings({ "all" }) + @SuppressWarnings({"all"}) @Override public Icon getIconFromDamage(int i) { - return i < icons.length ? icons[i] : null; + return i < icons.length ? icons[i] : null; } @Override @@ -31,7 +32,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(itemstack.getItemDamage()).toString(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) { @@ -39,16 +40,21 @@ public class ItemRedstoneChipset extends ItemBuildCraft { itemList.add(new ItemStack(this, 1, i)); } } + private static String[] chipsetNames = {"redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating"}; - private static String[] chipsetNames = { "redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating" }; @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - icons = new Icon[chipsetNames.length]; - int i = 0; - for (String csName : chipsetNames) { - icons[i++] = par1IconRegister.registerIcon("buildcraft:"+csName+"_chipset"); - } + public void registerIcons(IconRegister par1IconRegister) { + icons = new Icon[chipsetNames.length]; + int i = 0; + for (String csName : chipsetNames) { + icons[i++] = par1IconRegister.registerIcon("buildcraft:" + csName + "_chipset"); + } + } + + public void registerItemStacks() { + for (int i = 0; i < 5; i++) { + GameRegistry.registerCustomItemStack(chipsetNames[i] + "_chipset", new ItemStack(this, 1, i)); + } } }