|
1 | 1 | package com.circulation.random_complement.mixin.ae2.miss_craft; |
2 | 2 |
|
3 | 3 | import appeng.api.networking.crafting.ICraftingGrid; |
| 4 | +import appeng.api.networking.crafting.ICraftingPatternDetails; |
4 | 5 | import appeng.api.networking.security.IActionSource; |
5 | 6 | import appeng.api.storage.data.IAEItemStack; |
6 | 7 | import appeng.crafting.CraftBranchFailure; |
7 | 8 | import appeng.crafting.CraftingJob; |
8 | 9 | import appeng.crafting.CraftingTreeNode; |
9 | 10 | import appeng.crafting.MECraftingInventory; |
| 11 | +import co.neeve.nae2.common.helpers.VirtualPatternDetails; |
10 | 12 | import com.circulation.random_complement.common.interfaces.AEIgnoredInputMachine; |
11 | 13 | import com.circulation.random_complement.common.interfaces.RCCraftingJob; |
12 | 14 | import com.circulation.random_complement.mixin.ae2.AccessorCraftingTreeNode; |
| 15 | +import com.circulation.random_complement.mixin.ae2.AccessorCraftingTreeProcess; |
| 16 | +import com.google.common.collect.ImmutableCollection; |
13 | 17 | import com.llamalad7.mixinextras.sugar.Local; |
14 | 18 | import com.llamalad7.mixinextras.sugar.Share; |
15 | 19 | import com.llamalad7.mixinextras.sugar.ref.LocalLongRef; |
| 20 | +import it.unimi.dsi.fastutil.objects.ObjectArrayList; |
16 | 21 | import net.minecraft.world.World; |
| 22 | +import net.minecraftforge.fml.common.Loader; |
17 | 23 | import org.spongepowered.asm.mixin.Final; |
18 | 24 | import org.spongepowered.asm.mixin.Intrinsic; |
19 | 25 | import org.spongepowered.asm.mixin.Mixin; |
|
23 | 29 | import org.spongepowered.asm.mixin.injection.Inject; |
24 | 30 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
25 | 31 |
|
| 32 | +import java.util.Collection; |
| 33 | + |
26 | 34 | @Mixin(value = CraftingJob.class, remap = false) |
27 | 35 | public abstract class MixinCraftingJob implements RCCraftingJob { |
28 | 36 |
|
@@ -61,6 +69,10 @@ public void setLock(boolean lock) { |
61 | 69 | private IAEItemStack r$wait; |
62 | 70 | @Unique |
63 | 71 | private boolean r$specialDeficiency; |
| 72 | + @Unique |
| 73 | + private static final boolean r$loadNae2 = Loader.isModLoaded("nae2"); |
| 74 | + @Unique |
| 75 | + private static final boolean r$loadNee = Loader.isModLoaded("neenergistics"); |
64 | 76 |
|
65 | 77 | @SuppressWarnings("DiscouragedShift") |
66 | 78 | @Inject(method = "run", at = @At(value = "INVOKE", target = "Lappeng/crafting/MECraftingInventory;ignore(Lappeng/api/storage/data/IAEItemStack;)V", ordinal = 0, shift = At.Shift.BEFORE)) |
@@ -95,8 +107,20 @@ public void supplementaryOutput(CallbackInfo ci, @Share("rcOutput") LocalLongRef |
95 | 107 | var tree = (AccessorCraftingTreeNode) this.tree; |
96 | 108 | if (tree.isCanEmit()) return; |
97 | 109 | final long out = stackLocalRef.get(); |
98 | | - var details = this.cc.getCraftingFor(this.output, null, 0, this.world); |
99 | | - if (details == null || details.isEmpty()) throw new CraftBranchFailure(this.output, 0); |
| 110 | + Collection<ICraftingPatternDetails> details = this.cc.getCraftingFor(this.output, null, 0, this.world); |
| 111 | + if (details == null) return; |
| 112 | + if (r$loadNae2 && !r$loadNee) { |
| 113 | + for (var node : tree.getNodes()) { |
| 114 | + var d = ((AccessorCraftingTreeProcess) node).getDetails(); |
| 115 | + if (d instanceof VirtualPatternDetails) { |
| 116 | + if (details instanceof ImmutableCollection<?>) { |
| 117 | + details = new ObjectArrayList<>(details); |
| 118 | + } |
| 119 | + details.add(d); |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + if (details.isEmpty()) throw new CraftBranchFailure(this.output, 0); |
100 | 124 | if (out > 0) { |
101 | 125 | for (var detail : details) { |
102 | 126 | IAEItemStack repeatInput = this.output.copy().setStackSize(0); |
|
0 commit comments