diff options
author | basdxz <tudurap.com@gmail.com> | 2020-11-29 17:28:00 +0000 |
---|---|---|
committer | basdxz <tudurap.com@gmail.com> | 2020-11-29 17:28:00 +0000 |
commit | bd9322e8352b50f5d816bb65d92bfaeea7bd072c (patch) | |
tree | 7b39d860a7c60324b09ac727ead28de8e2cde517 | |
parent | 08e3d560737749ed9e8b9848c5f98303e2a9d190 (diff) | |
download | GT5-Unofficial-bd9322e8352b50f5d816bb65d92bfaeea7bd072c.tar.gz GT5-Unofficial-bd9322e8352b50f5d816bb65d92bfaeea7bd072c.tar.bz2 GT5-Unofficial-bd9322e8352b50f5d816bb65d92bfaeea7bd072c.zip |
More robust Tesla covers
-rw-r--r-- | src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java index 99e0d75c1c..385ad8d74e 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java @@ -3,12 +3,17 @@ package com.github.technus.tectech.mechanics.tesla; import com.github.technus.tectech.util.Vec3Impl; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; + public class TeslaCoverConnection implements ITeslaConnectableSimple { private final IGregTechTileEntity IGT; + private final Vec3Impl pos; private final byte teslaReceptionCapability; public TeslaCoverConnection(IGregTechTileEntity IGT, byte teslaReceptionCapability) { this.IGT = IGT; + this.pos = new Vec3Impl(IGT); this.teslaReceptionCapability = teslaReceptionCapability; } @@ -34,7 +39,7 @@ public class TeslaCoverConnection implements ITeslaConnectableSimple { @Override public Vec3Impl getTeslaPosition() { - return new Vec3Impl(IGT); + return pos; } @Override @@ -45,6 +50,14 @@ public class TeslaCoverConnection implements ITeslaConnectableSimple { @Override public boolean teslaInjectEnergy(long teslaVoltageInjected) { //Same as in the microwave transmitters, this does not account for amp limits - return IGT.injectEnergyUnits((byte) 1, teslaVoltageInjected, 1L) > 0L; + boolean output = false; + + if (!IGT.isDead()){ + output = IGT.injectEnergyUnits((byte) 1, teslaVoltageInjected, 1L) > 0L; + } else { + teslaSimpleNodeSetRemove(this); + } + + return output; } } |