From 620bbfc1df327f399143ded2b32eb4f71e01ed0d Mon Sep 17 00:00:00 2001 From: Prospector Date: Mon, 28 Mar 2016 16:02:39 -0700 Subject: [PATCH] Rework batteries --- .../java/techreborn/items/ItemBattery.java | 102 ++++++++++++++++++ .../techreborn/items/ItemEnergyCrystal.java | 62 +---------- .../techreborn/items/ItemLapotronCrystal.java | 62 +---------- .../techreborn/items/ItemLithiumBattery.java | 92 +--------------- .../java/techreborn/items/ItemReBattery.java | 91 +--------------- .../assets/techreborn/lang/en_US.lang | 6 +- .../items/{ => tool}/energyCrystal.png | Bin .../items/{ => tool}/lapotronCrystal.png | Bin 8 files changed, 118 insertions(+), 297 deletions(-) create mode 100644 src/main/java/techreborn/items/ItemBattery.java rename src/main/resources/assets/techreborn/textures/items/{ => tool}/energyCrystal.png (100%) rename src/main/resources/assets/techreborn/textures/items/{ => tool}/lapotronCrystal.png (100%) diff --git a/src/main/java/techreborn/items/ItemBattery.java b/src/main/java/techreborn/items/ItemBattery.java new file mode 100644 index 000000000..6f73be371 --- /dev/null +++ b/src/main/java/techreborn/items/ItemBattery.java @@ -0,0 +1,102 @@ +package techreborn.items; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import reborncore.api.power.IEnergyItemInfo; +import reborncore.common.powerSystem.PoweredItem; +import techreborn.client.TechRebornCreativeTab; + +public class ItemBattery extends ItemTextureBase implements IEnergyItemInfo +{ + + String name = "null"; + int maxEnergy = 0; + int maxTransfer = 0; + int tier = 0; + + public ItemBattery(String name, int maxEnergy, int maxTransfer, int tier) + { + super(); + setMaxStackSize(1); + setMaxDamage(1); + setUnlocalizedName("techreborn."+name); + this.name=name; + this.maxEnergy=maxEnergy; + this.maxTransfer=maxTransfer; + this.tier=tier; + setCreativeTab(TechRebornCreativeTab.instance); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + itemList.add(itemStack); + + ItemStack charged = new ItemStack(this, 1); + PoweredItem.setEnergy(getMaxPower(charged), charged); + itemList.add(charged); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack)); + return 1 - charge; + + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + @Override + public double getMaxPower(ItemStack stack) + { + return maxEnergy; + } + + @Override + public boolean canAcceptEnergy(ItemStack stack) + { + return true; + } + + @Override + public boolean canProvideEnergy(ItemStack stack) + { + return true; + } + + @Override + public double getMaxTransfer(ItemStack stack) + { + return maxTransfer; + } + + @Override + public int getStackTier(ItemStack stack) + { + return tier; + } + + @Override + public String getTextureName(int damage) + { + return "techreborn:items/tool/"+name; + } + + @Override + public int getMaxMeta() + { + return 1; + } +} diff --git a/src/main/java/techreborn/items/ItemEnergyCrystal.java b/src/main/java/techreborn/items/ItemEnergyCrystal.java index a29e940bd..47656e1e0 100644 --- a/src/main/java/techreborn/items/ItemEnergyCrystal.java +++ b/src/main/java/techreborn/items/ItemEnergyCrystal.java @@ -1,64 +1,8 @@ package techreborn.items; -import net.minecraft.item.ItemStack; -import reborncore.api.power.IEnergyItemInfo; -import techreborn.client.TechRebornCreativeTab; +public class ItemEnergyCrystal extends ItemBattery { -public class ItemEnergyCrystal extends ItemTextureBase implements IEnergyItemInfo -{ - - public static final int maxCharge = 100000; - public static final int tier = 1; - public double transferLimit = 512; - - public ItemEnergyCrystal() - { - super(); - setMaxStackSize(1); - setMaxDamage(13); - setUnlocalizedName("techreborn.energycrystal"); - setCreativeTab(TechRebornCreativeTab.instance); - } - - @Override - public double getMaxPower(ItemStack stack) - { - return maxCharge; - } - - @Override - public boolean canAcceptEnergy(ItemStack stack) - { - return true; - } - - @Override - public boolean canProvideEnergy(ItemStack stack) - { - return true; - } - - @Override - public double getMaxTransfer(ItemStack stack) - { - return transferLimit; - } - - @Override - public int getStackTier(ItemStack stack) - { - return tier; - } - - @Override - public String getTextureName(int damage) - { - return "techreborn:items/energyCrystal"; - } - - @Override - public int getMaxMeta() - { - return 1; + public ItemEnergyCrystal() { + super("energyCrystal", 100000, 512, 1); } } diff --git a/src/main/java/techreborn/items/ItemLapotronCrystal.java b/src/main/java/techreborn/items/ItemLapotronCrystal.java index 5bfdfd9b3..4bb2ce52b 100644 --- a/src/main/java/techreborn/items/ItemLapotronCrystal.java +++ b/src/main/java/techreborn/items/ItemLapotronCrystal.java @@ -1,64 +1,8 @@ package techreborn.items; -import net.minecraft.item.ItemStack; -import reborncore.api.power.IEnergyItemInfo; -import techreborn.client.TechRebornCreativeTab; +public class ItemLapotronCrystal extends ItemBattery { -public class ItemLapotronCrystal extends ItemTextureBase implements IEnergyItemInfo -{ - - public static final int maxCharge = 100000; - public static final int tier = 2; - public double transferLimit = 512; - - public ItemLapotronCrystal() - { - super(); - setMaxStackSize(1); - setMaxDamage(13); - setUnlocalizedName("techreborn.lapotroncrystal"); - setCreativeTab(TechRebornCreativeTab.instance); - } - - @Override - public double getMaxPower(ItemStack stack) - { - return maxCharge; - } - - @Override - public boolean canAcceptEnergy(ItemStack stack) - { - return true; - } - - @Override - public boolean canProvideEnergy(ItemStack stack) - { - return true; - } - - @Override - public double getMaxTransfer(ItemStack stack) - { - return transferLimit; - } - - @Override - public int getStackTier(ItemStack stack) - { - return tier; - } - - @Override - public String getTextureName(int damage) - { - return "techreborn:items/lapotronCrystal"; - } - - @Override - public int getMaxMeta() - { - return 1; + public ItemLapotronCrystal() { + super("lapotronCrystal", 1000000, 512, 2); } } diff --git a/src/main/java/techreborn/items/ItemLithiumBattery.java b/src/main/java/techreborn/items/ItemLithiumBattery.java index 9f55a3a46..e5b497a95 100644 --- a/src/main/java/techreborn/items/ItemLithiumBattery.java +++ b/src/main/java/techreborn/items/ItemLithiumBattery.java @@ -1,93 +1,9 @@ package techreborn.items; -import java.util.List; +public class ItemLithiumBattery extends ItemBattery { -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.api.power.IEnergyItemInfo; -import reborncore.common.powerSystem.PoweredItem; -import techreborn.client.TechRebornCreativeTab; - -public class ItemLithiumBattery extends ItemTextureBase implements IEnergyItemInfo -{ - - public ItemLithiumBattery() - { - super(); - setMaxStackSize(1); - setMaxDamage(1); - setUnlocalizedName("techreborn.lithiumBattery"); - setCreativeTab(TechRebornCreativeTab.instance); - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack)); - return 1 - charge; - - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) - { - ItemStack itemStack = new ItemStack(this, 1); - itemList.add(itemStack); - - ItemStack charged = new ItemStack(this, 1); - PoweredItem.setEnergy(getMaxPower(charged), charged); - itemList.add(charged); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getMaxPower(ItemStack stack) - { - return 100000; - } - - @Override - public boolean canAcceptEnergy(ItemStack stack) - { - return true; - } - - @Override - public boolean canProvideEnergy(ItemStack stack) - { - return true; - } - - @Override - public double getMaxTransfer(ItemStack stack) - { - return 64; - } - - @Override - public int getStackTier(ItemStack stack) - { - return 1; - } - - @Override - public String getTextureName(int damage) - { - return "techreborn:items/lithiumBattery"; - } - - @Override - public int getMaxMeta() - { - return 1; + public ItemLithiumBattery() { + super("lithiumBattery", 100000, 512, 1); } } + diff --git a/src/main/java/techreborn/items/ItemReBattery.java b/src/main/java/techreborn/items/ItemReBattery.java index 53467a59d..567088fc5 100644 --- a/src/main/java/techreborn/items/ItemReBattery.java +++ b/src/main/java/techreborn/items/ItemReBattery.java @@ -1,93 +1,8 @@ package techreborn.items; -import java.util.List; +public class ItemReBattery extends ItemBattery { -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.api.power.IEnergyItemInfo; -import reborncore.common.powerSystem.PoweredItem; -import techreborn.client.TechRebornCreativeTab; - -public class ItemReBattery extends ItemTextureBase implements IEnergyItemInfo -{ - - public ItemReBattery() - { - super(); - setMaxStackSize(1); - setMaxDamage(1); - setUnlocalizedName("techreborn.rebattery"); - setCreativeTab(TechRebornCreativeTab.instance); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) - { - ItemStack itemStack = new ItemStack(this, 1); - itemList.add(itemStack); - - ItemStack charged = new ItemStack(this, 1); - PoweredItem.setEnergy(getMaxPower(charged), charged); - itemList.add(charged); - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack)); - return 1 - charge; - - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getMaxPower(ItemStack stack) - { - return 10000; - } - - @Override - public boolean canAcceptEnergy(ItemStack stack) - { - return true; - } - - @Override - public boolean canProvideEnergy(ItemStack stack) - { - return true; - } - - @Override - public double getMaxTransfer(ItemStack stack) - { - return 64; - } - - @Override - public int getStackTier(ItemStack stack) - { - return 1; - } - - @Override - public String getTextureName(int damage) - { - return "techreborn:items/tool/rebattery"; - } - - @Override - public int getMaxMeta() - { - return 1; + public ItemReBattery() { + super("rebattery", 10000, 64, 1); } } diff --git a/src/main/resources/assets/techreborn/lang/en_US.lang b/src/main/resources/assets/techreborn/lang/en_US.lang index 6bcba7db5..684071c5a 100644 --- a/src/main/resources/assets/techreborn/lang/en_US.lang +++ b/src/main/resources/assets/techreborn/lang/en_US.lang @@ -284,8 +284,6 @@ item.techreborn.dust.galena.name=Galena Dust item.techreborn.dust.greenSapphire.name=Green Sapphire Dust item.techreborn.dust.sawDust.name=Saw Dust item.techreborn.dust.olivine.name=Olivine Dust -item.techreborn.lapotroncrystal.name=Lapotron Crystal -item.techreborn.energycrystal.name=Energy Crystal item.techreborn.ingot.refinedIron.name=Refined Iron Ingot item.techreborn.wrench.name=Wrench item.techreborn.cable.COPPER.name=Copper Cable @@ -432,7 +430,9 @@ item.techreborn.cell.empty.name=Empty Cell item.techreborn.cell.water.name=Water Cell item.techreborn.cell.lava.name=Lava Cell item.techreborn.rebattery.name=Battery -item.techreborn.lithiumBattery.name=Lithium Battery +item.techreborn.lithiumBattery.name=Lithium Battery +item.techreborn.energyCrystal.name=Energy Crystal +item.techreborn.lapotronCrystal.name=Lapotron Crystal item.techreborn.treetap.name=Treetap item.techreborn.nanosaber.name=Nanosaber diff --git a/src/main/resources/assets/techreborn/textures/items/energyCrystal.png b/src/main/resources/assets/techreborn/textures/items/tool/energyCrystal.png similarity index 100% rename from src/main/resources/assets/techreborn/textures/items/energyCrystal.png rename to src/main/resources/assets/techreborn/textures/items/tool/energyCrystal.png diff --git a/src/main/resources/assets/techreborn/textures/items/lapotronCrystal.png b/src/main/resources/assets/techreborn/textures/items/tool/lapotronCrystal.png similarity index 100% rename from src/main/resources/assets/techreborn/textures/items/lapotronCrystal.png rename to src/main/resources/assets/techreborn/textures/items/tool/lapotronCrystal.png