Added capacitor

This commit is contained in:
Calclavia 2013-08-03 22:23:06 -04:00
parent ee2dc80248
commit f6ab9e1f9b
6 changed files with 63 additions and 6 deletions

View file

@ -9,4 +9,5 @@ tile.resonantinduction\:contractor.name=Electromagnetic Contractor
tile.resonantinduction\:battery.name=Modular Battery
## Items
item.resonantinduction\:quantumEntangler.name=Quantum Entangler
item.resonantinduction\:quantumEntangler.name=Quantum Entangler
item.resonantinduction\:capacitor.name=Capacitor Cell

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

View file

@ -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());

View file

@ -0,0 +1,15 @@
/**
*
*/
package resonantinduction.api;
/**
* @author Calclavia
*
*/
public interface IBattery
{
public float getEnergyStored();
public float getMaxEnergyStored();
}

View file

@ -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);
}
}

View file

@ -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;
}
/**