This commit is contained in:
Aidan Brady 2013-08-03 22:35:47 -04:00
commit a57f8fb022
2 changed files with 40 additions and 2 deletions

View file

@ -3,13 +3,23 @@
*/
package resonantinduction.api;
import net.minecraft.item.ItemStack;
/**
* TODO: Use UE interface after ModJAm
*
* @author Calclavia
*
*/
public interface IBattery
{
public float getEnergyStored();
public float getEnergyStored(ItemStack itemStack);
public float getMaxEnergyStored();
/**
* @param itemStack
* @param amount
*/
public void setEnergyStored(ItemStack itemStack, float amount);
}

View file

@ -3,6 +3,9 @@
*/
package resonantinduction.battery;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import resonantinduction.api.IBattery;
import resonantinduction.base.ItemBase;
/**
@ -11,7 +14,7 @@ import resonantinduction.base.ItemBase;
* @author Calclavia
*
*/
public class ItemCapacitor extends ItemBase
public class ItemCapacitor extends ItemBase implements IBattery
{
public ItemCapacitor(int id)
{
@ -20,4 +23,29 @@ public class ItemCapacitor extends ItemBase
this.setMaxDamage(1000);
}
@Override
public void setEnergyStored(ItemStack itemStack, float amount)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setFloat("energyStored", amount);
}
@Override
public float getEnergyStored(ItemStack itemStack)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
return itemStack.getTagCompound().getFloat("energyStored");
}
@Override
public float getMaxEnergyStored()
{
return 100;
}
}