33import appeng .api .networking .crafting .ICraftingGrid ;
44import appeng .api .networking .security .IActionSource ;
55import appeng .api .storage .data .IAEItemStack ;
6+ import appeng .crafting .CraftBranchFailure ;
67import appeng .crafting .CraftingJob ;
78import appeng .crafting .CraftingTreeNode ;
89import appeng .crafting .MECraftingInventory ;
@@ -48,6 +49,7 @@ public abstract class MixinCraftingJob implements RCCraftingJob {
4849 @ Unique
4950 private boolean r$specialDeficiency ;
5051
52+ @ SuppressWarnings ("DiscouragedShift" )
5153 @ Inject (method = "run" , at = @ At (value = "INVOKE" , target = "Lappeng/crafting/MECraftingInventory;ignore(Lappeng/api/storage/data/IAEItemStack;)V" , ordinal = 0 , shift = At .Shift .BEFORE ))
5254 public void record (CallbackInfo ci , @ Share ("rcOutput" ) LocalLongRef stackLocalRef , @ Local (name = "craftingInventory" ) MECraftingInventory craftingInventory ) {
5355 if (canIgnoredInput ()) {
@@ -75,23 +77,25 @@ public boolean canIgnoredInput() {
7577 private boolean rc$miss = false ;
7678
7779 @ Inject (method = "run" , at = @ At (value = "INVOKE" , target = "Lappeng/crafting/CraftingTreeNode;request(Lappeng/crafting/MECraftingInventory;JLappeng/api/networking/security/IActionSource;)Lappeng/api/storage/data/IAEItemStack;" , shift = At .Shift .AFTER , ordinal = 0 ))
78- public void supplementaryOutput (CallbackInfo ci , @ Share ("rcOutput" ) LocalLongRef stackLocalRef ) {
80+ public void supplementaryOutput (CallbackInfo ci , @ Share ("rcOutput" ) LocalLongRef stackLocalRef ) throws Exception {
7981 if (!canIgnoredInput ()) return ;
8082 var tree = (AccessorCraftingTreeNode ) this .tree ;
8183 if (tree .isCanEmit ()) return ;
8284 final long out = stackLocalRef .get ();
85+ var details = this .cc .getCraftingFor (this .output , null , 0 , this .world );
86+ if (details == null || details .isEmpty ()) throw new CraftBranchFailure (this .output , 0 );
8387 if (out > 0 ) {
84- for (var details : this . cc . getCraftingFor ( this . output , null , 0 , this . world ) ) {
88+ for (var detail : details ) {
8589 IAEItemStack repeatInput = this .output .copy ().setStackSize (0 );
86- for (var input : details .getCondensedInputs ()) {
90+ for (var input : detail .getCondensedInputs ()) {
8791 if (this .output .equals (input )) {
8892 repeatInput .incStackSize (input .getStackSize ());
8993 }
9094 }
9195 if (repeatInput .getStackSize () == 0 ) return ;
9296
9397 IAEItemStack repeatOutput = this .output .copy ().setStackSize (0 );
94- for (var input : details .getCondensedOutputs ()) {
98+ for (var input : detail .getCondensedOutputs ()) {
9599 if (this .output .equals (input )) {
96100 repeatOutput .incStackSize (input .getStackSize ());
97101 }
@@ -111,17 +115,17 @@ public void supplementaryOutput(CallbackInfo ci, @Share("rcOutput") LocalLongRef
111115 break ;
112116 }
113117 } else {
114- for (var details : this . cc . getCraftingFor ( this . output , null , 0 , this . world ) ) {
118+ for (var detail : details ) {
115119 IAEItemStack repeatInput = this .output .copy ().setStackSize (0 );
116- for (var input : details .getCondensedInputs ()) {
120+ for (var input : detail .getCondensedInputs ()) {
117121 if (this .output .equals (input )) {
118122 repeatInput .incStackSize (input .getStackSize ());
119123 }
120124 }
121125 if (repeatInput .getStackSize () == 0 ) return ;
122126
123127 IAEItemStack repeatOutput = this .output .copy ().setStackSize (0 );
124- for (var input : details .getCondensedOutputs ()) {
128+ for (var input : detail .getCondensedOutputs ()) {
125129 if (this .output .equals (input )) {
126130 repeatOutput .incStackSize (input .getStackSize ());
127131 }
0 commit comments