diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-04-29 12:55:19 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-04-29 12:55:19 +1000 |
commit | 4109c9575dd6d8a89f03e1242493dca228255570 (patch) | |
tree | cb71094617867ee843efb5ad1c456286f2269f4a /src/Java/gtPlusPlus/api/thermal/sample | |
parent | 47d2b68b66fb9958b57c3ff81f1e73e8f6afd91b (diff) | |
download | GT5-Unofficial-4109c9575dd6d8a89f03e1242493dca228255570.tar.gz GT5-Unofficial-4109c9575dd6d8a89f03e1242493dca228255570.tar.bz2 GT5-Unofficial-4109c9575dd6d8a89f03e1242493dca228255570.zip |
+ Added Framework for Thermal power based upon the code used for RF.
> This is more effective than trying to use the GT EU code for the exact same thing.
Diffstat (limited to 'src/Java/gtPlusPlus/api/thermal/sample')
-rw-r--r-- | src/Java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java | 84 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java | 42 |
2 files changed, 126 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java b/src/Java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java new file mode 100644 index 0000000000..e33a47d220 --- /dev/null +++ b/src/Java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java @@ -0,0 +1,84 @@ +package gtPlusPlus.api.thermal.sample; + +import gtPlusPlus.api.thermal.energy.IThermalContainerItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ItemThermalContainer extends Item implements IThermalContainerItem { + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public ItemThermalContainer() { + } + + public ItemThermalContainer(int arg0) { + this(arg0, arg0, arg0); + } + + public ItemThermalContainer(int arg0, int arg1) { + this(arg0, arg1, arg1); + } + + public ItemThermalContainer(int arg0, int arg1, int arg2) { + this.capacity = arg0; + this.maxReceive = arg1; + this.maxExtract = arg2; + } + + public ItemThermalContainer setCapacity(int arg0) { + this.capacity = arg0; + return this; + } + + public void setMaxTransfer(int arg0) { + this.setMaxReceive(arg0); + this.setMaxExtract(arg0); + } + + public void setMaxReceive(int arg0) { + this.maxReceive = arg0; + } + + public void setMaxExtract(int arg0) { + this.maxExtract = arg0; + } + + public int receiveThermalEnergy(ItemStack arg0, int arg1, boolean arg2) { + if (arg0.getTagCompound() == null) { + arg0.stackTagCompound = new NBTTagCompound(); + } + int arg3 = arg0.stackTagCompound.getInteger("Energy"); + int arg4 = Math.min(this.capacity - arg3, Math.min(this.maxReceive, arg1)); + if (!arg2) { + arg3 += arg4; + arg0.stackTagCompound.setInteger("Energy", arg3); + } + return arg4; + } + + public int extractThermalEnergy(ItemStack arg0, int arg1, boolean arg2) { + if (arg0.stackTagCompound != null && arg0.stackTagCompound.hasKey("Energy")) { + int arg3 = arg0.stackTagCompound.getInteger("Energy"); + int arg4 = Math.min(arg3, Math.min(this.maxExtract, arg1)); + if (!arg2) { + arg3 -= arg4; + arg0.stackTagCompound.setInteger("Energy", arg3); + } + return arg4; + } else { + return 0; + } + } + + public int getEnergyStored(ItemStack arg0) { + return arg0.stackTagCompound != null && arg0.stackTagCompound.hasKey("Energy") + ? arg0.stackTagCompound.getInteger("Energy") + : 0; + } + + public int getMaxThermalEnergyStored(ItemStack arg0) { + return this.capacity; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java b/src/Java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java new file mode 100644 index 0000000000..e2e3c50ab7 --- /dev/null +++ b/src/Java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java @@ -0,0 +1,42 @@ +package gtPlusPlus.api.thermal.sample; + +import gtPlusPlus.api.thermal.energy.IThermalHandler; +import gtPlusPlus.api.thermal.energy.ThermalStorage; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileThermalHandler extends TileEntity implements IThermalHandler { + + protected ThermalStorage storage = new ThermalStorage(32000); + + public void readFromNBT(NBTTagCompound arg0) { + super.readFromNBT(arg0); + this.storage.readFromNBT(arg0); + } + + public void writeToNBT(NBTTagCompound arg0) { + super.writeToNBT(arg0); + this.storage.writeToNBT(arg0); + } + + public boolean canConnectThermalEnergy(ForgeDirection arg0) { + return true; + } + + public int receiveThermalEnergy(ForgeDirection arg0, int arg1, boolean arg2) { + return this.storage.receiveThermalEnergy(arg1, arg2); + } + + public int extractThermalEnergy(ForgeDirection arg0, int arg1, boolean arg2) { + return this.storage.extractThermalEnergy(arg1, arg2); + } + + public int getThermalEnergyStored(ForgeDirection arg0) { + return this.storage.getThermalEnergyStored(); + } + + public int getMaxThermalEnergyStored(ForgeDirection arg0) { + return this.storage.getMaxThermalEnergyStored(); + } +}
\ No newline at end of file |