diff --git a/resources/assets/resonantinduction/languages/en_US.properties b/resources/assets/resonantinduction/languages/en_US.properties index aef4675f..cdeeb1a7 100755 --- a/resources/assets/resonantinduction/languages/en_US.properties +++ b/resources/assets/resonantinduction/languages/en_US.properties @@ -9,4 +9,5 @@ tile.resonantinduction\:contractor.name=Electromagnetic Contractor tile.resonantinduction\:battery.name=Modular Battery ## Items -item.resonantinduction\:quantumEntangler.name=Quantum Entangler \ No newline at end of file +item.resonantinduction\:quantumEntangler.name=Quantum Entangler +item.resonantinduction\:capacitor.name=Capacitor Cell diff --git a/resources/assets/resonantinduction/textures/items/capacitor.png b/resources/assets/resonantinduction/textures/items/capacitor.png new file mode 100644 index 00000000..181019ec Binary files /dev/null and b/resources/assets/resonantinduction/textures/items/capacitor.png differ diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index 06f63da0..93fae1de 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.Configuration; import net.minecraftforge.oredict.ShapedOreRecipe; import resonantinduction.battery.BlockBattery; +import resonantinduction.battery.ItemCapacitor; import resonantinduction.battery.TileEntityBattery; import resonantinduction.contractor.BlockEMContractor; import resonantinduction.contractor.ItemBlockContractor; @@ -109,6 +110,7 @@ public class ResonantInduction // Items public static Item itemQuantumEntangler; + public static Item itemCapacitor; // Blocks public static Block blockTesla; @@ -135,7 +137,10 @@ public class ResonantInduction // Items itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID()); + itemCapacitor = new ItemCapacitor(getNextItemID()); + GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName()); + GameRegistry.registerItem(itemCapacitor, itemCapacitor.getUnlocalizedName()); // Blocks blockTesla = new BlockTesla(getNextBlockID()); diff --git a/src/resonantinduction/api/IBattery.java b/src/resonantinduction/api/IBattery.java new file mode 100644 index 00000000..714324f3 --- /dev/null +++ b/src/resonantinduction/api/IBattery.java @@ -0,0 +1,15 @@ +/** + * + */ +package resonantinduction.api; + +/** + * @author Calclavia + * + */ +public interface IBattery +{ + public float getEnergyStored(); + + public float getMaxEnergyStored(); +} diff --git a/src/resonantinduction/battery/ItemCapacitor.java b/src/resonantinduction/battery/ItemCapacitor.java new file mode 100644 index 00000000..04ed4ae0 --- /dev/null +++ b/src/resonantinduction/battery/ItemCapacitor.java @@ -0,0 +1,23 @@ +/** + * + */ +package resonantinduction.battery; + +import resonantinduction.base.ItemBase; + +/** + * Stores power. + * + * @author Calclavia + * + */ +public class ItemCapacitor extends ItemBase +{ + public ItemCapacitor(int id) + { + super("capacitor", id); + this.setMaxStackSize(1); + this.setMaxDamage(1000); + } + +} diff --git a/src/resonantinduction/battery/TileEntityBattery.java b/src/resonantinduction/battery/TileEntityBattery.java index c4b7f13e..ef14f874 100644 --- a/src/resonantinduction/battery/TileEntityBattery.java +++ b/src/resonantinduction/battery/TileEntityBattery.java @@ -6,6 +6,7 @@ package resonantinduction.battery; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import resonantinduction.api.IBattery; import resonantinduction.base.TileEntityBase; /** @@ -18,7 +19,7 @@ public class TileEntityBattery extends TileEntityBase implements IInventory private ItemStack[] inventory = new ItemStack[4 * 4]; private byte[] sideStatus = new byte[] { 0, 0, 0, 0, 0, 0 }; - //TODO: Multiblock power storage. + // TODO: Multiblock power storage. private BatteryController controller; @Override @@ -29,10 +30,22 @@ public class TileEntityBattery extends TileEntityBase implements IInventory public float getMaxEnergyStored() { - - - - return 0; + float max = 0; + + for (int i = 0; i < this.getSizeInventory(); i++) + { + ItemStack itemStack = this.getStackInSlot(i); + + if (itemStack != null) + { + if (itemStack.getItem() instanceof IBattery) + { + max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(); + } + } + } + + return max; } /**