diff options
| author | Tec <daniel112092@gmail.com> | 2019-03-10 17:55:54 +0100 |
|---|---|---|
| committer | Tec <daniel112092@gmail.com> | 2019-03-10 17:55:54 +0100 |
| commit | 77299aca53c2a96760fe76c078e1ddad4df1aa0a (patch) | |
| tree | 88160dd5458e1b8b9931ebdce67bcb67c06bba20 /src/main/java | |
| parent | 57e41df46f9479a054f903bfe297cb08a7edbf21 (diff) | |
| download | GT5-Unofficial-77299aca53c2a96760fe76c078e1ddad4df1aa0a.tar.gz GT5-Unofficial-77299aca53c2a96760fe76c078e1ddad4df1aa0a.tar.bz2 GT5-Unofficial-77299aca53c2a96760fe76c078e1ddad4df1aa0a.zip | |
done
Diffstat (limited to 'src/main/java')
2 files changed, 108 insertions, 175 deletions
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 4551ef3b17..5f072b3196 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 @@ -4,11 +4,12 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.NameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.StatusFunction; -import java.util.ArrayList; import java.util.Arrays; -import java.util.function.BiFunction; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; @@ -22,18 +23,33 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behavi private float radius, maxRPM, maxRCF, maxForce, maxCapacity; private Parameters.Group.ParameterIn settingRPM, settingFraction; private final static NameFunction<GT_MetaTileEntity_EM_machine> rpmName= (gt_metaTileEntity_em_machine, iParameter) -> "RPM Setting"; - private static final StatusFunction<GT_MetaTileEntity_EM_machine> rpmStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + private final StatusFunction<GT_MetaTileEntity_EM_machine> rpmStatus= (gt_metaTileEntity_em_machine, iParameter) -> { double v=iParameter.get(); if(Double.isNaN(v)){ return STATUS_WRONG; } - + if (v <=0) { + return STATUS_TOO_LOW; + }else if (v>maxRPM){ + return STATUS_TOO_HIGH; + } + return STATUS_OK; }; private final static NameFunction<GT_MetaTileEntity_EM_machine> fractionName= (gt_metaTileEntity_em_machine, iParameter) -> "Fraction Count"; private static final StatusFunction<GT_MetaTileEntity_EM_machine> fractionStatus= (gt_metaTileEntity_em_machine, iParameter) -> { - + double v=iParameter.get(); + if(Double.isNaN(v)){ + return STATUS_WRONG; + } + v=(int)v; + if (v <= 1) { + return STATUS_TOO_LOW; + }else if (v>6){ + return STATUS_TOO_HIGH; + } + return STATUS_OK; }; - private final static String[] DESCRIPTION_O =new String[]{"RPM Setting","RCF Setting","Radius [mm]","Max RPM","Max Force [eV/c^2 * m/s]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; + //private final static String[] DESCRIPTION_O =new String[]{"RPM Setting","RCF Setting","Radius [mm]","Max RPM","Max Force [eV/c^2 * m/s]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; private static final double[/*tier+5*/][/*outputHatches+2*/] MIXING_FACTORS =new double[][]{ {.45,.85,.95,1,1,}, @@ -57,13 +73,6 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behavi maxCapacity = maxSafeMass * 4f * radius;// eV/c^2 } - @Override - protected void getFullLedDescriptionOut(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=2) { - baseDescr.add(DESCRIPTION_O[(hatchNo<<1)+paramID]); - } - } - private double getRCF(double RPM) { return RPM * RPM * radius * 0.001118; } @@ -87,63 +96,13 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behavi @Override public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { Parameters.Group hatch1=parameters.getGroup(7); - settingRPM=hatch1.makeInParameter(0,0,,); - settingFraction=hatch1.makeInParameter(1,2,,); + settingRPM=hatch1.makeInParameter(0,0,rpmName,rpmStatus); + settingFraction=hatch1.makeInParameter(1,2,fractionName,fractionStatus); } @Override public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { - boolean check=true; - - double RPM = settingRPM.get(); - if (RPM > maxRPM) { - 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, STATUS_HIGH); - } else if (RPM > maxRPM / 3f) { - te.setStatusOfParameterIn(0, 0, STATUS_OK); - } else if (RPM > 0) { - te.setStatusOfParameterIn(0, 0, STATUS_LOW); - } else if (RPM <= 0) { - 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, STATUS_WRONG); - te.setParameterOut(0, 0, 0);//rpm - te.setParameterOut(0, 1, 0);//rcf - check=false; - } - - if(check) { - te.setParameterOut(0, 0, RPM); - te.setParameterOut(0, 1, getRCF(RPM)); - } - - double fractionCount = settingFraction.get(); - if (fractionCount > 6) { - parametersToCheckAndFix[1] = 6; - te.setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); - check=false; - } else if (fractionCount >= 2) { - te.setStatusOfParameterIn(0, 1, STATUS_OK); - } else if (fractionCount < 2) { - parametersToCheckAndFix[1] = 2; - te.setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); - check=false; - } else { - te.setStatusOfParameterIn(0, 1, STATUS_WRONG); - check=false; - } - - te.setParameterOut(3,0,(int) (Math.pow(parametersToCheckAndFix[0] / maxRPM, 3f) * V[tier]));//max eut - te.setParameterOut(3,1,(int) (20 * (fractionCount - 1)));//max time - - return check; + return settingRPM.getStatus(true).isOk && settingFraction.getStatus(true).isOk; } @Override @@ -172,11 +131,11 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behavi inputMass = Math.abs(input.getMass()); - double RCF = getRCF(checkedAndFixedParameters[0]); + double RCF = getRCF(settingRPM.get()); if (inputMass * RCF > maxForce) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES // how many output hatches to use - int fractionCount = (int) checkedAndFixedParameters[1]; + int fractionCount = (int) settingFraction.get(); cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[fractionCount]; for (int i = 0; i < fractionCount; i++) { outputs[i] = new cElementalInstanceStackMap(); @@ -188,7 +147,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behavi TecTech.LOGGER.info("mixingFactor "+mixingFactor); } - int mEut = (int) (Math.pow(checkedAndFixedParameters[0] / maxRPM, 3f) * V[tier]); + int mEut = (int) (Math.pow(settingRPM.get() / maxRPM, 3f) * V[tier]); mEut = Math.max(mEut, 512); mEut = -mEut; int mTicks = (int) (20 * (inputMass / maxCapacity) * (fractionCount - 1)); 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 e8b0ac7401..d2b08f0960 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 @@ -4,10 +4,10 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; - -import java.util.ArrayList; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.NameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.StatusFunction; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; @@ -17,14 +17,70 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStat */ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_machine.Behaviour { private final byte tier; - private final int ticks; - private final byte precisionFull; - private final byte precisionMinimal; - private final float maxCapacity; - private final long maxCharge; - private final int offsetMax; - private final static String[] DESCRIPTION_I =new String[]{"Full Precision Input [e/3]","Minimal Precision Input [e/3]","Offset Input [e/3]",null}; - private final static String[] DESCRIPTION_O =new String[]{"Full Precision Limit [e/3]","Minimal Precision Limit [e/3]","Offset Limit [e/3]",null,"Max Charge [e/3]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; + private int ticks; + private byte precisionFull,precisionMinimal; + private float maxCapacity; + private long maxCharge; + private int offsetMax; + private Parameters.Group.ParameterIn fullSetting,minimalSetting,offsetSetting; + private final static NameFunction<GT_MetaTileEntity_EM_machine> fullName= (gt_metaTileEntity_em_machine, iParameter) -> "Full Precision Input [e/3]"; + private final StatusFunction<GT_MetaTileEntity_EM_machine> fullStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double v=iParameter.get(); + if(Double.isNaN(v)){ + return STATUS_WRONG; + } + v=(int)v; + if(Double.isInfinite(v) && v>0) { + return STATUS_TOO_HIGH; + }else if(v>precisionFull){ + return STATUS_HIGH; + }else if(v<precisionFull){ + return STATUS_TOO_LOW; + } + return STATUS_OK; + }; + private final static NameFunction<GT_MetaTileEntity_EM_machine> minimalName= (gt_metaTileEntity_em_machine, iParameter) -> "Minimal Precision Input [e/3]"; + private final StatusFunction<GT_MetaTileEntity_EM_machine> minimalStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double minimal=iParameter.get(); + double full=fullSetting.get(); + if(Double.isInfinite(minimal) && minimal>0) { + return STATUS_TOO_HIGH; + }else if(minimal>precisionMinimal){ + if(minimal>full){ + return STATUS_TOO_HIGH; + }else { + return STATUS_HIGH; + } + }else if(minimal==precisionMinimal){ + if(minimal>full){ + return STATUS_TOO_HIGH; + }else { + return STATUS_OK; + } + }else if(minimal<precisionMinimal){ + return STATUS_TOO_LOW; + }else { + return STATUS_WRONG; + } + }; + private final static NameFunction<GT_MetaTileEntity_EM_machine> offsetName= (gt_metaTileEntity_em_machine, iParameter) -> "Offset Input [e/3]"; + private final StatusFunction<GT_MetaTileEntity_EM_machine> offsetStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double offset=iParameter.get(); + if(offset>offsetMax){ + return STATUS_TOO_HIGH; + }else if(offset>0){ + return STATUS_HIGH; + }else if(offset==0){ + return STATUS_OK; + }else if(offset>=-offsetMax){ + return STATUS_LOW; + }else if(offset<-offsetMax){ + return STATUS_TOO_LOW; + }else { + return STATUS_WRONG; + } + }; + //private final static String[] DESCRIPTION_O =new String[]{"Full Precision Limit [e/3]","Minimal Precision Limit [e/3]","Offset Limit [e/3]",null,"Max Charge [e/3]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; public Behaviour_ElectromagneticSeparator(int desiredTier){ tier=(byte) desiredTier; @@ -70,103 +126,21 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ } @Override - protected void getFullLedDescriptionIn(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=1) { - String desc=DESCRIPTION_I[(hatchNo << 1) + paramID]; - if(desc!=null){ - baseDescr.add(desc); - } - } + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + Parameters.Group hatch1=parameters.getGroup(7); + fullSetting=hatch1.makeInParameter(0,0,fullName,fullStatus); + minimalSetting=hatch1.makeInParameter(1,2,minimalName,minimalStatus); + Parameters.Group hatch2=parameters.getGroup(8); + offsetSetting=hatch2.makeInParameter(0,0,offsetName,offsetStatus); } @Override - protected void getFullLedDescriptionOut(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=3){ - String desc=DESCRIPTION_O[(hatchNo<<1)+paramID]; - if(desc!=null){ - baseDescr.add(desc); - } - } - } - - @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { - boolean check=true; - - te.setParameterOut(0,0,precisionFull); - te.setParameterOut(0,1,precisionMinimal); - te.setParameterOut(1,0,offsetMax); - 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); - - double full=parametersToCheckAndFix[0]; - if(Double.isInfinite(full) && full>0) { - te.setStatusOfParameterIn(0,0,STATUS_TOO_HIGH); - check=false; - }else if(full>precisionFull){ - te.setStatusOfParameterIn(0,0, STATUS_HIGH); - }else if(full==precisionFull){ - te.setStatusOfParameterIn(0,0,STATUS_OK); - }else if(full<precisionFull){ - te.setStatusOfParameterIn(0,0,STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(0,0,STATUS_WRONG); - check=false; - } - - double minimal=parametersToCheckAndFix[1]; - if(Double.isInfinite(minimal) && minimal>0) { - te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); - check=false; - }else if(minimal>precisionMinimal){ - if(minimal>full){ - te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); - check=false; - }else { - te.setStatusOfParameterIn(0,1, STATUS_HIGH); - } - }else if(minimal==precisionMinimal){ - if(minimal>full){ - te.setStatusOfParameterIn(0,1,STATUS_TOO_HIGH); - check=false; - }else { - te.setStatusOfParameterIn(0,1, STATUS_OK); - } - }else if(minimal<precisionMinimal){ - te.setStatusOfParameterIn(0,1,STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(0,1,STATUS_WRONG); - check=false; - } - - double offset=parametersToCheckAndFix[2]; - if(offset>offsetMax){ - te.setStatusOfParameterIn(1,0,STATUS_TOO_HIGH); - check=false; - }else if(offset>0){ - te.setStatusOfParameterIn(1,0,STATUS_HIGH); - }else if(offset==0){ - te.setStatusOfParameterIn(1,0,STATUS_OK); - }else if(offset>=-offsetMax){ - te.setStatusOfParameterIn(1,0,STATUS_LOW); - }else if(offset<-offsetMax){ - te.setStatusOfParameterIn(1,0,STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(1,0,STATUS_WRONG); - check=false; - } - - return check; + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + return fullSetting.getStatus(true).isOk && minimalSetting.getStatus(true).isOk && offsetSetting.getStatus(true).isOk; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { cElementalInstanceStackMap input = inputs[0]; if (input == null || input.isEmpty()) return null;//nothing in only valid input @@ -202,9 +176,9 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ outputs[i] = new cElementalInstanceStackMap(); } - double offsetIn=checkedAndFixedParameters[2]; - double precisionFullIn=checkedAndFixedParameters[0]; - double precisionMinimalIn=checkedAndFixedParameters[1]; + double offsetIn=offsetSetting.get(); + double precisionFullIn=fullSetting.get(); + double precisionMinimalIn=minimalSetting.get(); double levelsCountPlus1=precisionFullIn-precisionMinimalIn+1; //take all from hatch handler and put into new map - this takes from hatch to inner data storage |
