diff options
author | Tec <daniel112092@gmail.com> | 2019-02-16 10:43:14 +0100 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2019-02-16 10:43:14 +0100 |
commit | 5965915bd0549cd289846ea20c9de6037e7faed1 (patch) | |
tree | 0e74f5b38b4ebeb99e52f3f531a37d3f98d4ad2b /src/main/java | |
parent | 4ca646553ba3969915ed30c2db05705ebf6ffac3 (diff) | |
download | GT5-Unofficial-5965915bd0549cd289846ea20c9de6037e7faed1.tar.gz GT5-Unofficial-5965915bd0549cd289846ea20c9de6037e7faed1.tar.bz2 GT5-Unofficial-5965915bd0549cd289846ea20c9de6037e7faed1.zip |
Refactor to LedStatus enum
Diffstat (limited to 'src/main/java')
13 files changed, 169 insertions, 130 deletions
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 471870b13b..69bebb4a78 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -37,6 +37,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index c021f93260..77db52f4b1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -34,6 +34,7 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -208,55 +209,55 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double ocRatio = getParameterIn(0, 0); if (ocRatio < 0) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); } else if (ocRatio < 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 0, STATUS_LOW); } else if (ocRatio == 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 0, STATUS_OK); } else if (ocRatio <= 3) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterIn(0, 0, STATUS_HIGH); } else if (Double.isNaN(ocRatio)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 0, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); } double ovRatio = getParameterIn(0, 1); if (ovRatio < 0.7f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); } else if (ovRatio < 0.8f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 1, STATUS_LOW); } else if (ovRatio <= 1.2f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 1, STATUS_OK); } else if (ovRatio <= 2) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterIn(0, 1, STATUS_HIGH); } else if (Double.isNaN(ovRatio)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); } setParameterOut(0, 0, maxCurrentTemp); setParameterOut(0, 1, eAvailableData); if (maxCurrentTemp < -10000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterOut(0, 0, STATUS_TOO_LOW); } else if (maxCurrentTemp < 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterOut(0, 0, STATUS_LOW); } else if (maxCurrentTemp == 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterOut(0, 0, STATUS_OK); } else if (maxCurrentTemp <= 5000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterOut(0, 0, STATUS_HIGH); } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterOut(0, 0, STATUS_TOO_HIGH); } if (!machineBusy) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterOut(0, 1, STATUS_NEUTRAL); } else if (eAvailableData <= 0) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterOut(0, 1, STATUS_TOO_LOW); } else { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterOut(0, 1, STATUS_OK); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java index da2e06c873..e79675f016 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java @@ -32,6 +32,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_UNUSED; public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { private final ArrayList<GT_MetaTileEntity_Hatch_OutputDataItems> eStacksDataOutputs = new ArrayList<>(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index bd8ed9c6bb..a295a5c7f1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -15,6 +15,7 @@ import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -84,27 +85,27 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB for (int i = 0; i < 10; i++) { src = getParameterIn(i, 0); if (src <= 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (src > eInputHatches.size()) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (Double.isNaN(src)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, STATUS_OK); dest = getParameterIn(i, 1); if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (dest > eOutputHatches.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index 1ddb655105..767bd676d6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -25,6 +25,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -182,24 +183,24 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas for (int i = 0; i < 10; i++) { weight = getParameterIn(i, 0); if (weight < 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (Double.isNaN(weight)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else { - setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:STATUS_OK); dest = getParameterIn(i, 1); if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (dest > eOutputData.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 67c390ab7c..1fdf8d6943 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -28,6 +28,7 @@ import java.util.HashSet; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.loader.MainLoader.microwaving; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static gregtech.api.GregTech_API.sBlockCasings4; /** @@ -218,28 +219,28 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double powerParameter = getParameterIn(0, 0); if (powerParameter < 300) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); } else if (powerParameter < 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 0, STATUS_LOW); } else if (powerParameter == 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 0, STATUS_OK); } else if (powerParameter == Double.POSITIVE_INFINITY) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); } else if (Double.isNaN(powerParameter)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 0, STATUS_WRONG); } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterOut(0, 0, STATUS_HIGH); } double timerParameter = getParameterIn(0, 1); if (timerParameter <= 1) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); } else if (timerParameter <= 3000) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 1, STATUS_OK); } else if (Double.isNaN(timerParameter)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); } setParameterOut(0, 0, timerValue); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java index 91b2635001..4845117a99 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java @@ -11,8 +11,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { - public byte[] eParamsInStatus = new byte[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 - public byte[] eParamsOutStatus = new byte[20]; + public LedStatus[] eParamsInStatus = new LedStatus[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 + public LedStatus[] eParamsOutStatus = new LedStatus[20]; public byte eCertainMode = 5, eCertainStatus = 127; public boolean ePowerPass = false, eSafeVoid = false, allowedToWork = false; public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; @@ -118,9 +118,9 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { ICrafting var1 = (ICrafting) crafter; int i = 100; for (int j = 0; j < eParamsInStatus.length; j++) { - var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | eParamsOutStatus[j] << 8); + var1.sendProgressBarUpdate(this, i++, (eParamsInStatus[j].getOrdinalByte() | (eParamsOutStatus[j].getOrdinalByte() << 8))); } - var1.sendProgressBarUpdate(this, 120, eCertainMode | eCertainStatus << 8); + var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0)); } } @@ -132,8 +132,8 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { return; } if (par1 >= 100 && par1 < 120) { - eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); - eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); + eParamsInStatus[par1 - 100] = LedStatus.getStatus ((byte) (par2 & 0xff)); + eParamsOutStatus[par1 - 100] = LedStatus.getStatus ((byte) (par2 >>> 8)); } else if (par1 == 120) { eCertainMode = (byte) (par2 & 0xff); eCertainStatus = (byte) (par2 >>> 8); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java index 40285cc5e7..90ad4e7388 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java @@ -13,6 +13,7 @@ import org.lwjgl.opengl.GL12; import java.util.List; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.*; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_UNUSED; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; /** @@ -200,7 +201,7 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach } } - private void LEDdrawP(int x, int y, int i, int j, byte status) { + private void LEDdrawP(int x, int y, int i, int j, LedStatus status) { int v = 192, su = 8, sv = 6, u = 11; switch (status) { case STATUS_WRONG: //fallthrough diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index ebcc0ef622..a6ec5b561a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -105,12 +105,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt private final int[] iParamsOut = new int[20];//number O to parametrizers private final boolean[] bParamsAreFloats = new boolean[10]; - final byte[] eParamsInStatus = new byte[20];//LED status for I - final byte[] eParamsOutStatus = new byte[20];//LED status for O - public static final byte STATUS_UNUSED =7, STATUS_NEUTRAL = 0, - STATUS_TOO_LOW = 1, STATUS_LOW = 2, - STATUS_WRONG = 3, STATUS_OK = 4, - STATUS_TOO_HIGH = 5, STATUS_HIGH = 6; + final LedStatus[] eParamsInStatus = new LedStatus[20];//LED status for I + final LedStatus[] eParamsOutStatus = new LedStatus[20];//LED status for O // 0,2,4,6 - ok // 1,3,5 - nok @@ -699,11 +695,11 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt // return false; //} - public final void setStatusOfParameterIn(int hatchNo, int paramID, byte status){ + public final void setStatusOfParameterIn(int hatchNo, int paramID, LedStatus status){ eParamsInStatus[hatchNo+10*paramID]=status; } - public final void setStatusOfParameterOut(int hatchNo, int paramID, byte status){ + public final void setStatusOfParameterOut(int hatchNo, int paramID, LedStatus status){ eParamsOutStatus[hatchNo+10*paramID]=status; } @@ -965,13 +961,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt NBTTagCompound paramIs = new NBTTagCompound(); for (int i = 0; i < eParamsInStatus.length; i++) { - paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); + paramIs.setByte(Integer.toString(i), eParamsInStatus[i].getOrdinalByte()); } aNBT.setTag("eParamsInS", paramIs); NBTTagCompound paramOs = new NBTTagCompound(); for (int i = 0; i < eParamsOutStatus.length; i++) { - paramOs.setByte(Integer.toString(i), eParamsOutStatus[i]); + paramOs.setByte(Integer.toString(i), eParamsOutStatus[i].getOrdinalByte()); } aNBT.setTag("eParamsOutS", paramOs); } @@ -1055,12 +1051,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); for (int i = 0; i < eParamsInStatus.length; i++) { - eParamsInStatus[i] = paramIs.getByte(Integer.toString(i)); + eParamsInStatus[i] = LedStatus.getStatus(paramIs.getByte(Integer.toString(i))); } NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); for (int i = 0; i < eParamsOutStatus.length; i++) { - eParamsOutStatus[i] = paramOs.getByte(Integer.toString(i)); + eParamsOutStatus[i] = LedStatus.getStatus(paramOs.getByte(Integer.toString(i))); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java new file mode 100644 index 0000000000..fba5910532 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java @@ -0,0 +1,33 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +public enum LedStatus { + STATUS_UNUSED, + STATUS_TOO_LOW, + STATUS_LOW, + STATUS_WRONG, + STATUS_OK, + STATUS_TOO_HIGH, + STATUS_HIGH, + STATUS_UNDEFINED, + STATUS_NEUTRAL; + + public boolean isOk(){ + return (ordinal()&1)==0; + } + + public boolean isBad(){ + return (ordinal()&1)==1; + } + + public byte getOrdinalByte(){ + return (byte)ordinal(); + } + + public static LedStatus getStatus(byte value){ + try{ + return LedStatus.values()[value]; + }catch (IndexOutOfBoundsException e){ + return STATUS_UNDEFINED; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java index 4b7d41494b..efbca82c8f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java @@ -13,6 +13,7 @@ import java.util.Comparator; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 24.12.2017. @@ -69,33 +70,33 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour te.setParameterOut(2, 1, maxCapacity);// eV/c^2 for(int i=4;i<=9;i++) { - te.setStatusOfParameterOut(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterOut(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterOut(i, 0, STATUS_UNUSED); + te.setStatusOfParameterOut(i, 1, STATUS_UNUSED); } for(int i=1;i<=3;i++) { - te.setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterIn(i, 0, STATUS_UNUSED); + te.setStatusOfParameterIn(i, 1, STATUS_UNUSED); } double RPM = parametersToCheckAndFix[0]; if (RPM > maxRPM) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); te.setParameterOut(0, 0, maxRPM);//rpm te.setParameterOut(0, 1, maxRCF);//rcf check=false; } else if (RPM > maxRPM / 3f * 2f) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + te.setStatusOfParameterIn(0, 0, STATUS_HIGH); } else if (RPM > maxRPM / 3f) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + te.setStatusOfParameterIn(0, 0, STATUS_OK); } else if (RPM > 0) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + te.setStatusOfParameterIn(0, 0, STATUS_LOW); } else if (RPM <= 0) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); te.setParameterOut(0, 0, 0);//rpm te.setParameterOut(0, 1, 0);//rcf check=false; } else { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setStatusOfParameterIn(0, 0, STATUS_WRONG); te.setParameterOut(0, 0, 0);//rpm te.setParameterOut(0, 1, 0);//rcf check=false; @@ -109,16 +110,16 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour double fractionCount = parametersToCheckAndFix[1]; if (fractionCount > 6) { parametersToCheckAndFix[1] = 6; - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); check=false; } else if (fractionCount >= 2) { - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + te.setStatusOfParameterIn(0, 1, STATUS_OK); } else if (fractionCount < 2) { parametersToCheckAndFix[1] = 2; - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); check=false; } else { - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setStatusOfParameterIn(0, 1, STATUS_WRONG); check=false; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java index 8c912dd38d..94f00ece1b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java @@ -10,6 +10,7 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockCont import java.util.ArrayList; import static com.github.technus.tectech.CommonValues.V; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 24.12.2017. @@ -95,79 +96,79 @@ public class Behaviour_ElectromagneticSeparator extends GT_MetaTileEntity_EM_mac te.setParameterOut(0,0,precisionFull); te.setParameterOut(0,1,precisionMinimal); te.setParameterOut(1,0,offsetMax); - te.setStatusOfParameterOut(1,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterOut(1,1,STATUS_UNUSED); te.setParameterOut(2,0,maxCharge); te.setParameterOut(2,1,maxCapacity); te.setParameterOut(3,0,V[tier]); te.setParameterOut(3,1,ticks); for(int i=4;i<=9;i++) { - te.setStatusOfParameterOut(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterOut(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterOut(i, 0, STATUS_UNUSED); + te.setStatusOfParameterOut(i, 1, STATUS_UNUSED); } - te.setStatusOfParameterIn(1, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterIn(1, 1, STATUS_UNUSED); for(int i=2;i<=3;i++) { - te.setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + te.setStatusOfParameterIn(i, 0, STATUS_UNUSED); + te.setStatusOfParameterIn(i, 1, STATUS_UNUSED); } double full=parametersToCheckAndFix[0]; if(Double.isInfinite(full) && full>0) { - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0,0,STATUS_TOO_HIGH); check=false; }else if(full>precisionFull){ - te.setStatusOfParameterIn(0,0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + te.setStatusOfParameterIn(0,0, STATUS_HIGH); }else if(full==precisionFull){ - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + te.setStatusOfParameterIn(0,0,STATUS_OK); }else if(full<precisionFull){ - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setStatusOfParameterIn(0,0,STATUS_TOO_LOW); check=false; }else { - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setStatusOfParameterIn(0,0,STATUS_WRONG); check=false; } double minimal=parametersToCheckAndFix[1]; if(Double.isInfinite(minimal) && minimal>0) { - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); check=false; }else if(minimal>precisionMinimal){ if(minimal>full){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); check=false; }else { - te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + te.setStatusOfParameterIn(0,1, STATUS_HIGH); } }else if(minimal==precisionMinimal){ if(minimal>full){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); check=false; }else { - te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + te.setStatusOfParameterIn(0,1, STATUS_OK); } }else if(minimal<precisionMinimal){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setStatusOfParameterIn(0,1,STATUS_TOO_LOW); check=false; }else { - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setStatusOfParameterIn(0,1,STATUS_WRONG); check=false; } double offset=parametersToCheckAndFix[2]; if(offset>offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setStatusOfParameterIn(1,0,STATUS_TOO_HIGH); check=false; }else if(offset>0){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + te.setStatusOfParameterIn(1,0,STATUS_HIGH); }else if(offset==0){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + te.setStatusOfParameterIn(1,0,STATUS_OK); }else if(offset>=-offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + te.setStatusOfParameterIn(1,0,STATUS_LOW); }else if(offset<-offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setStatusOfParameterIn(1,0,STATUS_TOO_LOW); check=false; }else { - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setStatusOfParameterIn(1,0,STATUS_WRONG); check=false; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java index 46e4ede660..ad10d70cbf 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java @@ -25,6 +25,7 @@ import java.util.HashMap; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -286,37 +287,37 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa for (int i = 4; i <= 6; i++) { pointer = getParameterInInt(i, 0); if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 0, STATUS_WRONG); } else if (pointer <= 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); }//else if(pointer==0) // setStatusOfParameterIn(i,0,STATUS_LOW); else if (pointer <= eInputHatches.size()) { if (checkArray.get(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 0, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, STATUS_OK); checkArray.set(pointer); } } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); } pointer = getParameterInInt(i, 1); if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else if (pointer < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (pointer == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (pointer <= eInputHatches.size()) { if (checkArray.get(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); checkArray.set(pointer); } } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } } } @@ -324,27 +325,27 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa for (int i = 7; i <= 9; i++) { pointer = getParameterInInt(i, 0); if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 0, STATUS_WRONG); } else if (pointer < 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); } else if (pointer == 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 0, STATUS_LOW); } else if (pointer <= eOutputHatches.size()) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, STATUS_OK); } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); } pointer = getParameterInInt(i, 1); if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else if (pointer < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (pointer == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (pointer <= eOutputHatches.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } } } |