From 7644aadf8065720a457bd2dbcd14483437acb9a3 Mon Sep 17 00:00:00 2001 From: Robert S Date: Mon, 5 May 2014 17:26:08 -0400 Subject: [PATCH] More work on tool prefabs, setup energy tiers, stack limits, and item settings --- .../electrical/laser/gun/ItemMiningLaser.java | 3 --- .../core/prefab/items/ItemEnergyTool.java | 20 +++++++++++-------- .../core/prefab/items/ItemTool.java | 3 +++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/electrical/src/main/scala/resonantinduction/electrical/laser/gun/ItemMiningLaser.java b/electrical/src/main/scala/resonantinduction/electrical/laser/gun/ItemMiningLaser.java index 1f8566a9..4e2edfec 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/laser/gun/ItemMiningLaser.java +++ b/electrical/src/main/scala/resonantinduction/electrical/laser/gun/ItemMiningLaser.java @@ -61,9 +61,6 @@ public class ItemMiningLaser extends ItemEnergyTool public ItemMiningLaser(int id) { super(id); - this.setUnlocalizedName("MiningLaser"); - this.setMaxStackSize(1); - this.setCreativeTab(CreativeTabs.tabTools); } @Override diff --git a/src/main/scala/resonantinduction/core/prefab/items/ItemEnergyTool.java b/src/main/scala/resonantinduction/core/prefab/items/ItemEnergyTool.java index 41d23957..4de7a6ad 100644 --- a/src/main/scala/resonantinduction/core/prefab/items/ItemEnergyTool.java +++ b/src/main/scala/resonantinduction/core/prefab/items/ItemEnergyTool.java @@ -2,8 +2,6 @@ package resonantinduction.core.prefab.items; import java.util.List; -import calclavia.lib.render.EnumColor; -import calclavia.lib.utility.LanguageUtility; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -16,15 +14,22 @@ import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.item.IEnergyItem; import universalelectricity.api.item.IVoltageItem; +import calclavia.lib.render.EnumColor; +import calclavia.lib.utility.LanguageUtility; /** Prefab for all eletric based tools * * @author DarkGurdsman */ public class ItemEnergyTool extends ItemTool implements IEnergyItem, IVoltageItem { + /** Default battery size */ protected long batterySize = 500000; + /** Does this item support energy tiers */ protected boolean hasTier = false; + /** Display energy in tool tips */ protected boolean showEnergy = true; + /** Number of energy tiers */ + protected int energyTiers = 0; public ItemEnergyTool(int id) { @@ -147,14 +152,14 @@ public class ItemEnergyTool extends ItemTool implements IEnergyItem, IVoltageIte return this.getEnergyCapacity(itemStack) / 100; } - public static ItemStack setTier(ItemStack itemStack, byte tier) + public static ItemStack setTier(ItemStack itemStack, int tier) { if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } - itemStack.getTagCompound().setByte("tier", tier); + itemStack.getTagCompound().setByte("tier", (byte) tier); return itemStack; } @@ -171,11 +176,10 @@ public class ItemEnergyTool extends ItemTool implements IEnergyItem, IVoltageIte @Override public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for (byte tier = 0; tier <= TileBattery.MAX_TIER; tier++) + for (int i = 0; i >= 0 && i < this.energyTiers; i++) { - par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), 0)); - par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier))); + par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), i), 0)); + par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), i), this.getEnergyCapacity(setTier(new ItemStack(this), i)))); } } - } diff --git a/src/main/scala/resonantinduction/core/prefab/items/ItemTool.java b/src/main/scala/resonantinduction/core/prefab/items/ItemTool.java index 329d9a2a..d77e1064 100644 --- a/src/main/scala/resonantinduction/core/prefab/items/ItemTool.java +++ b/src/main/scala/resonantinduction/core/prefab/items/ItemTool.java @@ -2,6 +2,7 @@ package resonantinduction.core.prefab.items; import java.util.List; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -23,6 +24,8 @@ public class ItemTool extends Item public ItemTool(int par1) { super(par1); + this.setMaxStackSize(1); + this.setCreativeTab(CreativeTabs.tabTools); } @Override