Added capacitor charge to creative
This commit is contained in:
parent
6537a7b7ae
commit
aef0e8f44e
1 changed files with 24 additions and 0 deletions
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package resonantinduction.battery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import resonantinduction.api.IBattery;
|
||||
|
@ -23,6 +27,13 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
this.setMaxDamage(1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
double energyStored = this.getEnergyStored(itemStack);
|
||||
par3List.add("Energy: " + energyStored + " J");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyStored(ItemStack itemStack, float amount)
|
||||
{
|
||||
|
@ -31,6 +42,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
itemStack.getTagCompound().setFloat("energyStored", amount);
|
||||
itemStack.setItemDamage((int) (amount / this.getMaxEnergyStored()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,4 +60,16 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
ItemStack chargedStack = new ItemStack(par1, 1, 0);
|
||||
this.setEnergyStored(chargedStack, this.getMaxEnergyStored());
|
||||
par3List.add(chargedStack);
|
||||
ItemStack unchargedStack = new ItemStack(par1, 1, 0);
|
||||
this.setEnergyStored(unchargedStack, 0);
|
||||
par3List.add(unchargedStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue