From f6ab9e1f9b9828d729c5145407d32ce29d5d1c4b Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 3 Aug 2013 22:23:06 -0400 Subject: [PATCH] Added capacitor --- .../languages/en_US.properties | 3 ++- .../textures/items/capacitor.png | Bin 0 -> 930 bytes src/resonantinduction/ResonantInduction.java | 5 ++++ src/resonantinduction/api/IBattery.java | 15 ++++++++++++ .../battery/ItemCapacitor.java | 23 ++++++++++++++++++ .../battery/TileEntityBattery.java | 23 ++++++++++++++---- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 resources/assets/resonantinduction/textures/items/capacitor.png create mode 100644 src/resonantinduction/api/IBattery.java create mode 100644 src/resonantinduction/battery/ItemCapacitor.java 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 0000000000000000000000000000000000000000..181019ec3d217a17833cf7cfe74e0d185fa849b8 GIT binary patch literal 930 zcmV;T16}-yP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv0009KNklJEN`OJoqz#X9fNr1q?G^8M>0SyH4$+RX}Zcb8~~Mt1BVV zEV$T7J3BZ$JVd=-$LZ-Q8jXgQL{ke$V0wC5013>{ zSwIpDs&Q~|;G6&zSXfwi0FD>&*7F@kq<|OQUtpw9(9t~xBb3K$*H>%Z?(VLrqDx$@ z0-;byJm*I5KE+`~i+KMz0VC5e-(xVo70}@d!k9Wi*VrPA>>pW6D_Wv}-|x4i@AUpO z0UCJK6EII+N2l)>j2~5#koo&m4R73G^SvwtXhE%3bFKghL?V#~3w~GdaV!HPSw+{V zdE(q(eDJ4COGMUtddeqAh$T5zeX87mGz~Zf-g!FfcHHk&zKmAel@G z34#%vN>CA!ASphxJFc&ef5 zA<&W}bi3W~csv*$9>(P4q~$+lCjo-;nF^@y1XW-OvKcv6fEM)i^?~I`8{+Y}rNZMx zRNo4YOxEM$V;mhFIVaHD+Y6V=1uDU042Q!=rBXsdRRr@vslkzXLJJ&!3*_EzHXcQS zJ%QE0&Zrs_i4gR0kPxduC%>)#1*-Gi-QD5x@>1Igl`VF!X4)&6QsMmk93;`~RGhoG zxR8plb9!3}SeM6kT}pL#MyK<(EN}|a^xnxy)3dh4KO+hRF|D0aga7~l07*qoM6N<$ Ef`)ID3jhEB literal 0 HcmV?d00001 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; } /**