Rework batteries
This commit is contained in:
parent
8280703eb4
commit
620bbfc1df
8 changed files with 118 additions and 297 deletions
102
src/main/java/techreborn/items/ItemBattery.java
Normal file
102
src/main/java/techreborn/items/ItemBattery.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 474 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
Loading…
Reference in a new issue