Added capacitor
This commit is contained in:
parent
ee2dc80248
commit
f6ab9e1f9b
6 changed files with 63 additions and 6 deletions
|
@ -10,3 +10,4 @@ tile.resonantinduction\:battery.name=Modular Battery
|
|||
|
||||
## Items
|
||||
item.resonantinduction\:quantumEntangler.name=Quantum Entangler
|
||||
item.resonantinduction\:capacitor.name=Capacitor Cell
|
||||
|
|
BIN
resources/assets/resonantinduction/textures/items/capacitor.png
Normal file
BIN
resources/assets/resonantinduction/textures/items/capacitor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 930 B |
|
@ -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());
|
||||
|
|
15
src/resonantinduction/api/IBattery.java
Normal file
15
src/resonantinduction/api/IBattery.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package resonantinduction.api;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IBattery
|
||||
{
|
||||
public float getEnergyStored();
|
||||
|
||||
public float getMaxEnergyStored();
|
||||
}
|
23
src/resonantinduction/battery/ItemCapacitor.java
Normal file
23
src/resonantinduction/battery/ItemCapacitor.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -29,10 +30,22 @@ public class TileEntityBattery extends TileEntityBase implements IInventory
|
|||
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
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 0;
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue