From cf42256336806e60928351634575c50451122119 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 12 Dec 2022 23:45:17 +0800 Subject: fix numerous bugs with adv assline --- .../java/net/glease/ggfab/mte/MTE_AdvAssLine.java | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'src/main/java/net/glease') 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 allEnergyHatchesView = new ConcatList<>(mExoticEnergyHatches, mEnergyHatches); public MTE_AdvAssLine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -301,10 +302,16 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_AssemblyLine { return STRUCTURE_DEFINITION; } + @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) { @@ -320,6 +327,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) @@ -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 extends AbstractList { + private final List la, lb; + + public ConcatList(List la, List 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); + } + } } -- cgit