diff options
author | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
---|---|---|
committer | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
commit | 311ab89f93558233a40079f7cb16605b141b5346 (patch) | |
tree | c5f44ef47f441a57c5f57aa801f639c7879ed760 /src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java | |
parent | 896143b96132f5ac54aa8d8f7386f27487e5e530 (diff) | |
download | GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.gz GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.bz2 GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.zip |
Move sources and resources
Diffstat (limited to 'src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java')
-rw-r--r-- | src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java b/src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java new file mode 100644 index 0000000000..9c7bb0066c --- /dev/null +++ b/src/main/java/gtPlusPlus/api/thermal/energy/ThermalStorage.java @@ -0,0 +1,116 @@ +package gtPlusPlus.api.thermal.energy; + +import net.minecraft.nbt.NBTTagCompound; + +public class ThermalStorage implements IThermalStorage { + + protected int thermal_energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public ThermalStorage(int arg0) { + this(arg0, arg0, arg0); + } + + public ThermalStorage(int arg0, int arg1) { + this(arg0, arg1, arg1); + } + + public ThermalStorage(int arg0, int arg1, int arg2) { + this.capacity = arg0; + this.maxReceive = arg1; + this.maxExtract = arg2; + } + + public ThermalStorage readFromNBT(NBTTagCompound arg0) { + this.thermal_energy = arg0.getInteger("ThermalEnergy"); + if (this.thermal_energy > this.capacity) { + this.thermal_energy = this.capacity; + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound arg0) { + if (this.thermal_energy < 0) { + this.thermal_energy = 0; + } + arg0.setInteger("ThermalEnergy", this.thermal_energy); + return arg0; + } + + public void setCapacity(int arg0) { + this.capacity = arg0; + if (this.thermal_energy > arg0) { + this.thermal_energy = arg0; + } + + } + + 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 getMaxReceive() { + return this.maxReceive; + } + + public int getMaxExtract() { + return this.maxExtract; + } + + public void setEnergyStored(int arg0) { + this.thermal_energy = arg0; + if (this.thermal_energy > this.capacity) { + this.thermal_energy = this.capacity; + } else if (this.thermal_energy < 0) { + this.thermal_energy = 0; + } + + } + + public void modifyEnergyStored(int arg0) { + this.thermal_energy += arg0; + if (this.thermal_energy > this.capacity) { + this.thermal_energy = this.capacity; + } else if (this.thermal_energy < 0) { + this.thermal_energy = 0; + } + + } + + public int receiveThermalEnergy(int arg0, boolean arg1) { + int arg2 = Math.min(this.capacity - this.thermal_energy, Math.min(this.maxReceive, arg0)); + if (!arg1) { + this.thermal_energy += arg2; + } + + return arg2; + } + + public int extractThermalEnergy(int arg0, boolean arg1) { + int arg2 = Math.min(this.thermal_energy, Math.min(this.maxExtract, arg0)); + if (!arg1) { + this.thermal_energy -= arg2; + } + + return arg2; + } + + public int getThermalEnergyStored() { + return this.thermal_energy; + } + + public int getMaxThermalEnergyStored() { + return this.capacity; + } +}
\ No newline at end of file |