diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2022-12-12 23:45:17 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2022-12-12 23:45:17 +0800 |
commit | cf42256336806e60928351634575c50451122119 (patch) | |
tree | 9c68753447e990fed2d884bd61b2d5d46dfb39ec /src | |
parent | 821359eacd58950716552786b4d79b78d98cb91b (diff) | |
download | GT5-Unofficial-cf42256336806e60928351634575c50451122119.tar.gz GT5-Unofficial-cf42256336806e60928351634575c50451122119.tar.bz2 GT5-Unofficial-cf42256336806e60928351634575c50451122119.zip |
fix numerous bugs with adv assline
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java index 63f6a1feea..a51e2034b3 100644 --- a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java +++ b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java @@ -125,6 +125,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { private long inputVoltage; private long baseEUt; private boolean stuck; + private final ConcatList<GT_MetaTileEntity_Hatch> allEnergyHatchesView = new ConcatList<>(mExoticEnergyHatches, mEnergyHatches); public MTE_AdvAssLine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -302,9 +303,15 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { } @Override + public void clearHatches() { + super.clearHatches(); + mExoticEnergyHatches.clear(); + } + + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { if (super.checkMachine(aBaseMetaTileEntity, aStack)) { - if (mEnergyHatches.isEmpty() && mExoticEnergyHatches.isEmpty()) + if (mEnergyHatches.isEmpty() || mExoticEnergyHatches.isEmpty()) return false; inputVoltage = Integer.MAX_VALUE; for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) { @@ -321,6 +328,11 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { } @Override + public boolean drainEnergyInput(long aEU) { + return GT_ExoticEnergyInputHelper.drainEnergy(aEU, allEnergyHatchesView); + } + + @Override protected void startRecipeProcessing() { if (!processing) super.startRecipeProcessing(); @@ -567,7 +579,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { l.appendTag(new NBTTagInt(slices[i].progress)); } tag.setTag(TAG_KEY_PROGRESS_TIMES, l); - tag.setInteger("mDuration", currentRecipe.mDuration / currentRecipe.mInputs.length); + tag.setInteger("mDuration", mMaxProgresstime / currentRecipe.mInputs.length); } private void drainAllFluids(GT_Recipe.GT_Recipe_AssemblyLine recipe) { @@ -578,9 +590,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { @Override public void stopMachine() { - for (Slice slice : slices) { - slice.reset(); - } + clearCurrentRecipe(); super.stopMachine(); } @@ -682,4 +692,30 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { return t.mDataAccessHatches.size(); } } + + private static class ConcatList<T> extends AbstractList<T> { + private final List<? extends T> la, lb; + + public ConcatList(List<? extends T> la, List<? extends T> lb) { + this.la = la; + this.lb = lb; + } + + @Override + public T get(int index) { + int lasize = la.size(); + return index < lasize ? la.get(index) : lb.get(index - lasize); + } + + @Override + public int size() { + return la.size() + lb.size(); + } + + @Override + public T remove(int index) { + int lasize = la.size(); + return index < lasize ? la.remove(index) : lb.remove(index - lasize); + } + } } |