aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/common')
-rw-r--r--src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java22
-rw-r--r--src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java45
2 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java b/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java
new file mode 100644
index 0000000000..053cb2c567
--- /dev/null
+++ b/src/main/java/common/itemBlocks/IB_SpaceElevatorCapacitor.java
@@ -0,0 +1,22 @@
+package common.itemBlocks;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+
+import java.util.List;
+
+public class IB_SpaceElevatorCapacitor extends ItemBlock {
+
+ public IB_SpaceElevatorCapacitor(Block block) {
+ super(block);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) {
+ lines.add(StatCollector.translateToLocal("tile.kekztech_spaceelevatorcapacitor_block.desc"));
+ }
+}
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++;
+ }
+}