aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbasdxz <tudurap.com@gmail.com>2020-11-08 08:51:17 +0000
committerbasdxz <tudurap.com@gmail.com>2020-11-08 08:52:03 +0000
commitcc518e371ff8557877d3e3f33aac91c0881c6d7b (patch)
tree217441cbf52c7a4d325622264e811d838ba14b9e
parentdc236188d3de7217938518f3fa63ee4768db9966 (diff)
downloadGT5-Unofficial-cc518e371ff8557877d3e3f33aac91c0881c6d7b.tar.gz
GT5-Unofficial-cc518e371ff8557877d3e3f33aac91c0881c6d7b.tar.bz2
GT5-Unofficial-cc518e371ff8557877d3e3f33aac91c0881c6d7b.zip
Fixes tesla covers
Looks like GT5 covers are behaviors and not discrete objects, go figure! This is a horrible fix, but it works.
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java50
-rw-r--r--src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java46
-rw-r--r--src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java3
3 files changed, 55 insertions, 44 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
new file mode 100644
index 0000000000..99e0d75c1c
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java
@@ -0,0 +1,50 @@
+package com.github.technus.tectech.mechanics.tesla;
+
+import com.github.technus.tectech.util.Vec3Impl;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public class TeslaCoverConnection implements ITeslaConnectableSimple {
+ private final IGregTechTileEntity IGT;
+ private final byte teslaReceptionCapability;
+
+ public TeslaCoverConnection(IGregTechTileEntity IGT, byte teslaReceptionCapability) {
+ this.IGT = IGT;
+ this.teslaReceptionCapability = teslaReceptionCapability;
+ }
+
+ @Override
+ public byte getTeslaReceptionCapability() {
+ return teslaReceptionCapability;
+ }
+
+ @Override
+ public float getTeslaReceptionCoefficient() {
+ return 1;
+ }
+
+ @Override
+ public boolean isTeslaReadyToReceive() {
+ return true;
+ }
+
+ @Override
+ public long getTeslaStoredEnergy() {
+ return IGT.getStoredEU();
+ }
+
+ @Override
+ public Vec3Impl getTeslaPosition() {
+ return new Vec3Impl(IGT);
+ }
+
+ @Override
+ public Integer getTeslaDimension() {
+ return IGT.getWorld().provider.dimensionId;
+ }
+
+ @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;
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java
index 2efe2f3cbc..d3d9ead6d2 100644
--- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java
+++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java
@@ -1,9 +1,9 @@
package com.github.technus.tectech.thing.cover;
import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple;
+import com.github.technus.tectech.mechanics.tesla.TeslaCoverConnection;
import com.github.technus.tectech.util.Vec3Impl;
import gregtech.api.interfaces.tileentity.ICoverable;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
@@ -11,9 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*;
import static ic2.api.info.Info.DMG_ELECTRIC;
-public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior implements ITeslaConnectableSimple {
- private IGregTechTileEntity IGT;
-
+public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior {
public GT_Cover_TM_TeslaCoil() {
}
@@ -21,14 +19,10 @@ public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior implements ITeslaCon
public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
//Only do stuff if we're on top and have power
if (aSide == 1 || aTileEntity.getEUCapacity() > 0) {
- //Pull IGT onto the outside, should only execute first tick
- if (IGT == null) {
- IGT = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0);
- }
//Makes sure we're on the list
- teslaNodeSet.add(this);
+ teslaNodeSet.add(new TeslaCoverConnection(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0),
+ getTeslaReceptionCapability()));
}
-
return super.doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer);
}
@@ -57,39 +51,7 @@ public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior implements ITeslaCon
return 200;
}
- @Override
public byte getTeslaReceptionCapability() {
return 2;
}
-
- @Override
- public float getTeslaReceptionCoefficient() {
- return 1;
- }
-
- @Override
- public boolean isTeslaReadyToReceive() {
- return true;
- }
-
- @Override
- public long getTeslaStoredEnergy() {
- return IGT.getStoredEU();
- }
-
- @Override
- public Vec3Impl getTeslaPosition() {
- return new Vec3Impl(IGT);
- }
-
- @Override
- public Integer getTeslaDimension() {
- return IGT.getWorld().provider.dimensionId;
- }
-
- @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;
- }
}
diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java
index 028ac3a4d6..3417d7ae20 100644
--- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java
+++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java
@@ -31,8 +31,7 @@ public class GT_Cover_TM_TeslaCoil_Ultimate extends GT_Cover_TM_TeslaCoil {
public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
return true;
}
-
- @Override
+
public byte getTeslaReceptionCapability() {
return 1;
}