aboutsummaryrefslogtreecommitdiff
path: root/src/Java/cofh/api/energy/ItemEnergyContainer.java
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-08-04 01:48:24 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-08-04 01:48:24 +1000
commitfeb1963f65a43ee3d8ff17e5601991f51143cd9e (patch)
tree8aaa357c5d9bc6fd41c9dfb138d9a6fed9a905ab /src/Java/cofh/api/energy/ItemEnergyContainer.java
parent14d8c3cd7cc73caed9c073f76307be6be5fa4f0f (diff)
downloadGT5-Unofficial-feb1963f65a43ee3d8ff17e5601991f51143cd9e.tar.gz
GT5-Unofficial-feb1963f65a43ee3d8ff17e5601991f51143cd9e.tar.bz2
GT5-Unofficial-feb1963f65a43ee3d8ff17e5601991f51143cd9e.zip
+ Added a universal battery, accepting both IC2 EU and RF, holding 100mil/400mil of each respectively. (The batteries internal buffer accepts or outputs either)
+ Added COFH Core api for RF power support. + Added basic work for the Sinter Furnace and some debug rendering classes.
Diffstat (limited to 'src/Java/cofh/api/energy/ItemEnergyContainer.java')
-rw-r--r--src/Java/cofh/api/energy/ItemEnergyContainer.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/Java/cofh/api/energy/ItemEnergyContainer.java b/src/Java/cofh/api/energy/ItemEnergyContainer.java
new file mode 100644
index 0000000000..86defc0ae3
--- /dev/null
+++ b/src/Java/cofh/api/energy/ItemEnergyContainer.java
@@ -0,0 +1,98 @@
+package cofh.api.energy;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ItemEnergyContainer
+ extends Item
+ implements IEnergyContainerItem
+{
+ protected int capacity;
+ protected int maxReceive;
+ protected int maxExtract;
+
+ public ItemEnergyContainer() {}
+
+ public ItemEnergyContainer(int capacity)
+ {
+ this(capacity, capacity, capacity);
+ }
+
+ public ItemEnergyContainer(int capacity, int maxTransfer)
+ {
+ this(capacity, maxTransfer, maxTransfer);
+ }
+
+ public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract)
+ {
+ this.capacity = capacity;
+ this.maxReceive = maxReceive;
+ this.maxExtract = maxExtract;
+ }
+
+ public ItemEnergyContainer setCapacity(int capacity)
+ {
+ this.capacity = capacity;
+ return this;
+ }
+
+ public void setMaxTransfer(int maxTransfer)
+ {
+ setMaxReceive(maxTransfer);
+ setMaxExtract(maxTransfer);
+ }
+
+ public void setMaxReceive(int maxReceive)
+ {
+ this.maxReceive = maxReceive;
+ }
+
+ public void setMaxExtract(int maxExtract)
+ {
+ this.maxExtract = maxExtract;
+ }
+
+ public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate)
+ {
+ if (container.stackTagCompound == null) {
+ container.stackTagCompound = new NBTTagCompound();
+ }
+ int energy = container.stackTagCompound.getInteger("Energy");
+ int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive));
+ if (!simulate)
+ {
+ energy += energyReceived;
+ container.stackTagCompound.setInteger("Energy", energy);
+ }
+ return energyReceived;
+ }
+
+ public int extractEnergy(ItemStack container, int maxExtract, boolean simulate)
+ {
+ if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) {
+ return 0;
+ }
+ int energy = container.stackTagCompound.getInteger("Energy");
+ int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
+ if (!simulate)
+ {
+ energy -= energyExtracted;
+ container.stackTagCompound.setInteger("Energy", energy);
+ }
+ return energyExtracted;
+ }
+
+ public int getEnergyStored(ItemStack container)
+ {
+ if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) {
+ return 0;
+ }
+ return container.stackTagCompound.getInteger("Energy");
+ }
+
+ public int getMaxEnergyStored(ItemStack container)
+ {
+ return this.capacity;
+ }
+}