diff options
author | Technus <daniel112092@gmail.com> | 2017-12-16 21:51:37 +0100 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-12-16 21:51:37 +0100 |
commit | ffce854a03b63f1f37f22261536bf98a4f05d030 (patch) | |
tree | 77ad2717367cb037e3871db079ce05cb1d9a91cd | |
parent | 87d55337181db58328af35601d0d58405b9d591a (diff) | |
download | GT5-Unofficial-ffce854a03b63f1f37f22261536bf98a4f05d030.tar.gz GT5-Unofficial-ffce854a03b63f1f37f22261536bf98a4f05d030.tar.bz2 GT5-Unofficial-ffce854a03b63f1f37f22261536bf98a4f05d030.zip |
More tweaks
5 files changed, 141 insertions, 140 deletions
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 32dbbb8ee4..e8edf9f307 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 @@ -101,9 +101,15 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB if (noParametrizers) { overVoltageRatio=overClockRatio=1; } else { - overClockRatio=getParameterInSafely(0,0); - overVoltageRatio=getParameterInSafely(0,1); - if(Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) return false; + overClockRatio= getParameterIn(0,0); + overVoltageRatio= getParameterIn(0,1); + if(Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) + r.getBaseMetaTileEntity().setActive(false);//todo might be not needed + return false; + } } if(overClockRatio>0 && overVoltageRatio>=0.7f && overClockRatio<=3 && overVoltageRatio<=2){ float eut=V[8] * (float)overVoltageRatio * (float)overClockRatio; @@ -114,7 +120,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB mMaxProgresstime = 0; mEfficiencyIncrease = 0; for (GT_MetaTileEntity_Hatch_Rack r : eRacks) - r.getBaseMetaTileEntity().setActive(false); + r.getBaseMetaTileEntity().setActive(false);//todo might be not needed return false; } short thingsActive = 0; @@ -164,50 +170,34 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public void updateParameters_EM(boolean busy) { - double ocRatio=getParameterInSafely(0,0); - if (ocRatio < 0) - setStatusOfParameterIn(0,0,STATUS_TOO_LOW); - else if (ocRatio < 1) - setStatusOfParameterIn(0,0,STATUS_LOW); - else if (ocRatio == 1) - setStatusOfParameterIn(0,0,STATUS_OK); - else if (ocRatio <= 3) - setStatusOfParameterIn(0,0,STATUS_HIGH); - else if(Double.isNaN(ocRatio)) - setStatusOfParameterIn(0,0,STATUS_WRONG); - else setStatusOfParameterIn(0,0,STATUS_TOO_HIGH); - - double ovRatio=getParameterInSafely(0,1); - if (ovRatio < 0.7f) - setStatusOfParameterIn(0,1,STATUS_TOO_LOW); - else if (ovRatio < 0.8f) - setStatusOfParameterIn(0,1,STATUS_LOW); - else if (ovRatio <= 1.2f) - setStatusOfParameterIn(0,1,STATUS_OK); - else if (ovRatio <= 2) - setStatusOfParameterIn(0,1,STATUS_HIGH); - else if(Double.isNaN(ovRatio)) - setStatusOfParameterIn(0,1,STATUS_WRONG); - else setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); - - setParameterOutSafely(0,0, maxCurrentTemp); - setParameterOutSafely(0,1, eAvailableData); - - if (maxCurrentTemp < -10000) - setStatusOfParameterOut(0,0,STATUS_TOO_LOW); - else if (maxCurrentTemp < 0) - setStatusOfParameterOut(0,0,STATUS_LOW); - else if (maxCurrentTemp == 0) - setStatusOfParameterOut(0,0,STATUS_OK); - else if (maxCurrentTemp <= 5000) - setStatusOfParameterOut(0,0,STATUS_HIGH); - else setStatusOfParameterOut(0,0,STATUS_TOO_HIGH); - - if(!busy) - setStatusOfParameterOut(0,1,STATUS_WRONG); - else if(eAvailableData<=0) - setStatusOfParameterOut(0,1,STATUS_TOO_LOW); - else setStatusOfParameterOut(0,1,STATUS_OK); + double ocRatio = getParameterIn(0, 0); + if (ocRatio < 0) setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); + else if (ocRatio < 1) setStatusOfParameterIn(0, 0, STATUS_LOW); + else if (ocRatio == 1) setStatusOfParameterIn(0, 0, STATUS_OK); + else if (ocRatio <= 3) setStatusOfParameterIn(0, 0, STATUS_HIGH); + else if (Double.isNaN(ocRatio)) setStatusOfParameterIn(0, 0, STATUS_WRONG); + else setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); + + double ovRatio = getParameterIn(0, 1); + if (ovRatio < 0.7f) setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); + else if (ovRatio < 0.8f) setStatusOfParameterIn(0, 1, STATUS_LOW); + else if (ovRatio <= 1.2f) setStatusOfParameterIn(0, 1, STATUS_OK); + else if (ovRatio <= 2) setStatusOfParameterIn(0, 1, STATUS_HIGH); + else if (Double.isNaN(ovRatio)) setStatusOfParameterIn(0, 1, STATUS_WRONG); + else setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); + + setParameterOut(0, 0, maxCurrentTemp); + setParameterOut(0, 1, eAvailableData); + + if (maxCurrentTemp < -10000) setStatusOfParameterOut(0, 0, STATUS_TOO_LOW); + else if (maxCurrentTemp < 0) setStatusOfParameterOut(0, 0, STATUS_LOW); + else if (maxCurrentTemp == 0) setStatusOfParameterOut(0, 0, STATUS_OK); + else if (maxCurrentTemp <= 5000) setStatusOfParameterOut(0, 0, STATUS_HIGH); + else setStatusOfParameterOut(0, 0, STATUS_TOO_HIGH); + + if (!busy) setStatusOfParameterOut(0, 1, STATUS_WRONG); + else if (eAvailableData <= 0) setStatusOfParameterOut(0, 1, STATUS_TOO_LOW); + else setStatusOfParameterOut(0, 1, STATUS_OK); } @Override 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 28dbb61e83..044b7177e3 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 @@ -79,26 +79,26 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public void updateParameters_EM(boolean busy) { - double src,dest; + double src, dest; for (int i = 0; i < 10; i++) { - src=getParameterInSafely(i,0); - if (src <= 0){ - setStatusOfParameterIn(i,0,STATUS_TOO_LOW); - setStatusOfParameterIn(i,1,STATUS_UNUSED); - } else if (src > eInputHatches.size()){ - setStatusOfParameterIn(i,0,STATUS_TOO_HIGH); - setStatusOfParameterIn(i,1,STATUS_UNUSED); - } else if(Double.isNaN(src)){ - setStatusOfParameterIn(i,0,STATUS_WRONG); - setStatusOfParameterIn(i,1,STATUS_UNUSED); + src = getParameterIn(i, 0); + if (src <= 0) { + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_UNUSED); + } else if (src > eInputHatches.size()) { + setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_UNUSED); + } else if (Double.isNaN(src)) { + setStatusOfParameterIn(i, 0, STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_UNUSED); } else { - setStatusOfParameterIn(i,0,STATUS_OK); - dest=getParameterInSafely(i,1); - if(dest<0) setStatusOfParameterIn(i,1,STATUS_TOO_LOW); - else if(dest==0) setStatusOfParameterIn(i,1,STATUS_LOW); - else if(dest>eOutputHatches.size()) setStatusOfParameterIn(i,1,STATUS_TOO_HIGH); - else if(Double.isNaN(dest)) setStatusOfParameterIn(i,1,STATUS_WRONG); - else setStatusOfParameterIn(i,1,STATUS_OK); + setStatusOfParameterIn(i, 0, STATUS_OK); + dest = getParameterIn(i, 1); + if (dest < 0) setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); + else if (dest == 0) setStatusOfParameterIn(i, 1, STATUS_LOW); + else if (dest > eOutputHatches.size()) setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); + else if (Double.isNaN(dest)) setStatusOfParameterIn(i, 1, STATUS_WRONG); + else setStatusOfParameterIn(i, 1, STATUS_OK); } } } @@ -122,10 +122,11 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB public void outputAfterRecipe_EM() { double src,dest; for (int i = 0; i < 10; i++) { - src=getParameterInSafely(i,0); - dest=getParameterInSafely(i,1); + src= getParameterIn(i,0); + dest= getParameterIn(i,1); + if(Double.isNaN(src) || Double.isNaN(dest)) continue; final int inIndex = (int)src - 1; - if (inIndex < 0 || inIndex >= eInputHatches.size() || Double.isNaN(src) || Double.isNaN(dest)) continue; + if (inIndex < 0 || inIndex >= eInputHatches.size()) continue; final int outIndex = (int)dest - 1; GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); if (outIndex == -1) {//param==0 -> null the content 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 059b7386ca..bfd2ffd3fe 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 @@ -102,13 +102,13 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public void outputAfterRecipe_EM() { if (eOutputData.size() > 0) { - float total = 0; + double total = 0; double dest; double weight; for (int i = 0; i < 10; i++) {//each param pair - dest=getParameterInSafely(i,1); - weight=getParameterInSafely(i,0); - if (weight > 0 && dest >= 0 && !Double.isNaN(dest)) + dest= getParameterIn(i,1); + weight= getParameterIn(i,0); + if (weight > 0 && dest >= 0) total += weight;//Total weighted div } @@ -123,21 +123,27 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas long remaining = pack.computation; for (int i = 0; i < 10; i++) { - dest=getParameterInSafely(i,1); - weight=getParameterInSafely(i,0); - if (weight > 0 && dest >= 0 && !Double.isNaN(dest)) { + dest= getParameterIn(i,1); + weight= getParameterIn(i,0); + if (weight > 0 && dest >= 0) { final int outIndex = (int)dest - 1; if (outIndex < 0 || outIndex >= eOutputData.size()) continue; GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex); - final long part = (long)Math.floor((pack.computation * weight) / total); - if (part > 0) { - remaining -= part; - if (remaining > 0) - out.q = new QuantumDataPacket(pack, part); - else if (part + remaining > 0) { - out.q = new QuantumDataPacket(pack, part + remaining); + if(Double.isInfinite(total)){ + if(Double.isInfinite(weight)){ + out.q = new QuantumDataPacket(pack, remaining); break; - } else break; + } + }else{ + final long part = (long) Math.floor((pack.computation * weight) / total); + if (part > 0) { + remaining -= part; + if (remaining > 0) out.q = new QuantumDataPacket(pack, part); + else if (part + remaining > 0) { + out.q = new QuantumDataPacket(pack, part + remaining); + break; + } else break; + } } } } @@ -146,27 +152,23 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public void updateParameters_EM(boolean busy) { - double weight,dest; + double weight, dest; for (int i = 0; i < 10; i++) { - weight=getParameterInSafely(i,0); - if(weight<=0) { + weight = getParameterIn(i, 0); + if (weight <= 0) { setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); setStatusOfParameterIn(i, 1, STATUS_UNUSED); - }else if (Double.isNaN(weight)) { + } else if (Double.isNaN(weight)) { setStatusOfParameterIn(i, 0, STATUS_WRONG); setStatusOfParameterIn(i, 1, STATUS_UNUSED); - }else { - setStatusOfParameterIn(i,0,STATUS_OK); - dest=getParameterInSafely(i,1); - if(dest<0) - setStatusOfParameterIn(i,1,STATUS_TOO_LOW); - else if(dest==0) - setStatusOfParameterIn(i,1,STATUS_LOW); - else if(dest>eOutputData.size()) - setStatusOfParameterIn(i,1,STATUS_TOO_HIGH); - else if(Double.isNaN(dest)) - setStatusOfParameterIn(i,1,STATUS_WRONG); - else setStatusOfParameterIn(i,1,STATUS_OK); + } else { + setStatusOfParameterIn(i, 0, STATUS_OK); + dest = getParameterIn(i, 1); + if (dest < 0) setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); + else if (dest == 0) setStatusOfParameterIn(i, 1, STATUS_LOW); + else if (dest > eOutputData.size()) setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); + else if (Double.isNaN(dest)) setStatusOfParameterIn(i, 1, STATUS_WRONG); + else 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 5173a2bec5..b5ad2429e9 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 @@ -242,35 +242,27 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public void updateParameters_EM(boolean machineIsBusy) { - double powerParameter= getParameterInSafely(0,0); - if (powerParameter < 300) - setStatusOfParameterIn(0,0, STATUS_TOO_LOW); - else if (powerParameter < 1000) - setStatusOfParameterIn(0,0, STATUS_LOW); - else if (powerParameter == 1000) - setStatusOfParameterIn(0,0, STATUS_OK); - else if (powerParameter==Double.POSITIVE_INFINITY) - setStatusOfParameterIn(0,0, STATUS_TOO_HIGH); - else if (Double.isNaN(powerParameter)) - setStatusOfParameterIn(0,0, STATUS_WRONG); - else setStatusOfParameterOut(0,0,STATUS_HIGH); - - double timerParameter= getParameterInSafely(0,1); - if (timerParameter <= 1) - setStatusOfParameterIn(0,1,STATUS_TOO_LOW); - else if (timerParameter <= 3000) - setStatusOfParameterIn(0,0,STATUS_OK); - else if (Double.isNaN(timerParameter)) - setStatusOfParameterIn(0,1,STATUS_WRONG); - else setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); - - setParameterOutSafely(0,0,timerValue); - setParameterOutSafely(0,1,timerSetting-timerValue); - - if(machineIsBusy) return; - - powerSetting = (int)powerParameter; - timerSetting = (int)timerParameter; + double powerParameter = getParameterIn(0, 0); + if (powerParameter < 300) setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); + else if (powerParameter < 1000) setStatusOfParameterIn(0, 0, STATUS_LOW); + else if (powerParameter == 1000) setStatusOfParameterIn(0, 0, STATUS_OK); + else if (powerParameter == Double.POSITIVE_INFINITY) setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); + else if (Double.isNaN(powerParameter)) setStatusOfParameterIn(0, 0, STATUS_WRONG); + else setStatusOfParameterOut(0, 0, STATUS_HIGH); + + double timerParameter = getParameterIn(0, 1); + if (timerParameter <= 1) setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); + else if (timerParameter <= 3000) setStatusOfParameterIn(0, 0, STATUS_OK); + else if (Double.isNaN(timerParameter)) setStatusOfParameterIn(0, 1, STATUS_WRONG); + else setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); + + setParameterOut(0, 0, timerValue); + setParameterOut(0, 1, timerSetting - timerValue); + + if (machineIsBusy) return; + + powerSetting = (int) powerParameter; + timerSetting = (int) timerParameter; } @Override 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 ef426ab71b..93197b504e 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 @@ -409,7 +409,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return bParamsAreFloats[hatchNo]; } - public final double getParameterInSafely(int hatchNo, int paramID){ + public final double getParameterIn(int hatchNo, int paramID){ return bParamsAreFloats[hatchNo]?Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]):iParamsIn[hatchNo+10*paramID]; } @@ -421,7 +421,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); } - public final void setParameterOutSafely(int hatchNo, int paramID, double value){ + public final void setParameterOut(int hatchNo, int paramID, double value){ if(bParamsAreFloats[hatchNo]) { iParamsOut[hatchNo+10*paramID]=Float.floatToIntBits((float) value); }else{ @@ -1119,17 +1119,33 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } private void hatchesStatusUpdate_EM() { - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { - if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; - final int paramID = hatch.param; - iParamsIn[paramID] = hatch.value0i; - iParamsIn[paramID + 10] = hatch.value1i; - hatch.input0i = iParamsOut[paramID]; - hatch.input1i = iParamsOut[paramID + 10]; - bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); + if(mMaxProgresstime==0) { + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { + if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; + final int paramID = hatch.param; + bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); + iParamsIn[paramID] = hatch.value0i; + iParamsIn[paramID + 10] = hatch.value1i; + hatch.input0i = iParamsOut[paramID]; + hatch.input1i = iParamsOut[paramID + 10]; + } + }else {//write only + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { + if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; + final int paramID = hatch.param; + if(bParamsAreFloats[hatch.param] == hatch.isUsingFloats()){ + hatch.input0i = iParamsOut[paramID]; + hatch.input1i = iParamsOut[paramID + 10]; + }else if(hatch.isUsingFloats()){ + hatch.input0i = Float.floatToIntBits((float)iParamsOut[paramID]); + hatch.input1i = Float.floatToIntBits((float)iParamsOut[paramID + 10]); + }else { + hatch.input0i = (int)Float.intBitsToFloat(iParamsOut[paramID]); + hatch.input1i = (int)Float.intBitsToFloat(iParamsOut[paramID + 10]); + } + } } updateParameters_EM(mMaxProgresstime>0); - eAvailableData = getAvailableData_EM(); for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) |