aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities
diff options
context:
space:
mode:
authorkekzdealer <kekzdealer@gmail.com>2020-05-18 22:57:11 +0200
committerkekzdealer <kekzdealer@gmail.com>2020-05-18 22:57:11 +0200
commite763bd08b1ac3800ca259e1d16d63821b28e0067 (patch)
treefce8bf7aeda3b53ff094e50d34b87e5dc3fafb18 /src/main/java/common/tileentities
parenta785ef53e7e135fe59a95d3412b73a3a6a31da38 (diff)
downloadGT5-Unofficial-e763bd08b1ac3800ca259e1d16d63821b28e0067.tar.gz
GT5-Unofficial-e763bd08b1ac3800ca259e1d16d63821b28e0067.tar.bz2
GT5-Unofficial-e763bd08b1ac3800ca259e1d16d63821b28e0067.zip
Implemented TESR for Space Elevator Capacitors. This allows me to change their colour saturation on the fly to sync it with the elevator charge state. - Added tooltip to the caps to tell players that the invisible top/bot faces are intended as a performance improvement
Diffstat (limited to 'src/main/java/common/tileentities')
-rw-r--r--src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java b/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java
new file mode 100644
index 0000000000..22a4954b0f
--- /dev/null
+++ b/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java
@@ -0,0 +1,45 @@
+package common.tileentities;
+
+import net.minecraft.tileentity.TileEntity;
+
+public class TE_SpaceElevatorCapacitor extends TileEntity {
+
+ private float chargeLevel = 0.0F;
+
+ /**
+ * Called by the space elevator controller while charging
+ * @param charge
+ * Current elevator charge
+ * @param maxCharge
+ * Charge level it is trying to reach
+ */
+ public void updateChargeLevel(int charge, int maxCharge) {
+ chargeLevel = ((float) charge) / ((float) maxCharge);
+ }
+
+ /**
+ * Called by this block's renderer to calculate the block's colour saturation
+ * @return
+ * Charge level from 0.0F to 1.0F
+ */
+ public float getChargeLevel() {
+ return chargeLevel;
+ }
+
+ /**
+ * Called by the space elevator in case of power loss
+ */
+ public void resetChargeLevel() {
+ chargeLevel = 0.0F;
+ }
+
+ long tickCounter = 0;
+ @Override
+ public void updateEntity() {
+ if(tickCounter == 20){
+ chargeLevel = Float.compare(chargeLevel, 0.0F) == 0 ? 1.0F : 0.0F;
+ tickCounter = 0;
+ }
+ tickCounter++;
+ }
+}