diff --git a/src/main/java/co/neeve/nae2/mixin/jei/craft/shared/MixinCraftingCPUCluster.java b/src/main/java/co/neeve/nae2/mixin/jei/craft/shared/MixinCraftingCPUCluster.java index 088da77..c5a9656 100644 --- a/src/main/java/co/neeve/nae2/mixin/jei/craft/shared/MixinCraftingCPUCluster.java +++ b/src/main/java/co/neeve/nae2/mixin/jei/craft/shared/MixinCraftingCPUCluster.java @@ -2,12 +2,13 @@ import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; import appeng.me.cache.CraftingGridCache; import appeng.me.cluster.implementations.CraftingCPUCluster; import co.neeve.nae2.common.helpers.VirtualPatternDetails; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,9 +20,6 @@ @Mixin(value = CraftingCPUCluster.class, remap = false) public abstract class MixinCraftingCPUCluster { - @Shadow - private IItemList waitingFor; - @SuppressWarnings("rawtypes") @Shadow @Final @@ -39,16 +37,27 @@ public abstract class MixinCraftingCPUCluster { @Inject(method = "executeCrafting", at = @At( value = "INVOKE", target = "Lappeng/me/cluster/implementations/CraftingCPUCluster;canCraft" + - "(Lappeng/api/networking/crafting/ICraftingPatternDetails;[Lappeng/api/storage/data/IAEItemStack;)Z" + "(Lappeng/api/networking/crafting/ICraftingPatternDetails;[Lappeng/api/storage/data/IAEItemStack;)Z", + shift = At.Shift.AFTER ), cancellable = true) public void executeCrafting(IEnergyGrid eg, CraftingGridCache cc, CallbackInfo ci, - @Local ICraftingPatternDetails details) { - if (details instanceof VirtualPatternDetails) { - if (this.tasks.size() <= 1 && this.waitingFor.isEmpty()) { - this.completeJob(); - this.cancel(); - ci.cancel(); - } + @Local ICraftingPatternDetails details, + @Share(value = "canCraft") LocalBooleanRef canCraftRef) { + if (details instanceof VirtualPatternDetails && canCraftRef != null && canCraftRef.get()) { + this.completeJob(); + this.cancel(); + ci.cancel(); } } + + @ModifyExpressionValue(method = "executeCrafting", at = @At( + value = "INVOKE", + target = "Lappeng/me/cluster/implementations/CraftingCPUCluster;canCraft" + + "(Lappeng/api/networking/crafting/ICraftingPatternDetails;[Lappeng/api/storage/data/IAEItemStack;)Z" + )) + public boolean canCraft(boolean canCraft, @Share(value = "canCraft") LocalBooleanRef canCraftRef) { + canCraftRef.set(canCraft); + + return canCraft; + } }