aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities
diff options
context:
space:
mode:
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++;
+ }
+}