Fixed capacitor being changed on crafted
This commit is contained in:
parent
2c023d4902
commit
b6e5e22725
1 changed files with 13 additions and 6 deletions
|
@ -9,6 +9,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.api.IBattery;
|
||||
import resonantinduction.base.ItemBase;
|
||||
|
||||
|
@ -31,7 +32,13 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
double energyStored = this.getEnergyStored(itemStack);
|
||||
par3List.add("Energy: " + (int)energyStored + " KJ");
|
||||
par3List.add("Energy: " + (int) energyStored + " KJ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
this.setEnergyStored(par1ItemStack, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +50,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
}
|
||||
|
||||
itemStack.getTagCompound().setFloat("energyStored", amount);
|
||||
itemStack.setItemDamage((int)(100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +62,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
}
|
||||
|
||||
float amount = itemStack.getTagCompound().getFloat("energyStored");
|
||||
itemStack.setItemDamage((int)(100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue