From f742a0739ddebb05d4241139f888f94452a0818e Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Sun, 2 Mar 2025 21:35:45 +0800 Subject: [PATCH] update --- .../StockingDualInputHatchME.java | 5 +++ .../mixins/MixinAwarenessForDualHatch.java | 37 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/StockingDualInputHatchME.java b/src/main/java/reobf/proghatches/gt/metatileentity/StockingDualInputHatchME.java index 712c7a3..30cf640 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/StockingDualInputHatchME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/StockingDualInputHatchME.java @@ -869,6 +869,11 @@ public void program() { try { for (IAEItemStack s : getProxy().getStorage().getItemInventory().getStorageList()) { + if(s==null)continue; + if(!(s.getItem() instanceof ItemProgrammingCircuit)){ + continue; + } + IAEItemStack ext = getProxy().getStorage().getItemInventory().extractItems(s, Actionable.MODULATE, getRequestSource()); if (ext != null && ext.getStackSize() > 0) { diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAwarenessForDualHatch.java b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAwarenessForDualHatch.java index 7a07071..76a936d 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAwarenessForDualHatch.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinAwarenessForDualHatch.java @@ -5,6 +5,7 @@ import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; @@ -16,6 +17,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.GTUtility; import gregtech.common.tileentities.machines.IDualInputHatch; import reobf.proghatches.gt.metatileentity.util.IRecipeProcessingAwareDualHatch; @@ -37,6 +39,12 @@ public abstract class MixinAwarenessForDualHatch { // @Shadow // public abstract void setResultIfFailure(CheckRecipeResult result) ; + + private MTEMultiBlockBase cast(){ + Object o=this; + return (MTEMultiBlockBase) o; + } + /* @Unique private static MethodHandle MH_mDualInputHatches; @Unique @@ -79,20 +87,21 @@ private ArrayList mDualInputHatches0() { throw new AssertionError(e); } } - +*/ + + + + + + @Inject(method = "startRecipeProcessing", at = { @At(value = "RETURN") } ,require=1 ) public void startRecipeProcessing(CallbackInfo c) { - ArrayList collection = mDualInputHatches0(); - Iterator it = collection.iterator(); - while (it.hasNext()) { - IDualInputHatch hatch = it.next(); - if (hatch == null) continue; - if (!((MetaTileEntity) hatch).isValid()) { - if (hatch instanceof IRecipeProcessingAwareDualHatch) { - it.remove(); - } - continue; - } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + List l=(List)(List) GTUtility.validMTEList((List)(Object)(cast().mDualInputHatches)); + for (IDualInputHatch hatch:l) { + if (hatch instanceof IRecipeProcessingAwareDualHatch) { ((IRecipeProcessingAwareDualHatch) hatch).startRecipeProcessing(); } @@ -106,10 +115,10 @@ public void endRecipeProcessing(CallbackInfo c) { * (!result.wasSuccessful()) { this.checkRecipeResult = result; } }; */ - for (IDualInputHatch hatch : (mDualInputHatches0())) { + for (IDualInputHatch hatch : (cast().mDualInputHatches)) { if (hatch == null || !((MetaTileEntity) hatch).isValid()) continue; if (hatch instanceof IRecipeProcessingAwareDualHatch) { - setResultIfFailure0( + cast().setResultIfFailure( ((IRecipeProcessingAwareDualHatch) hatch).endRecipeProcessing((MTEMultiBlockBase) (Object) this)); } }