Skip to content

Commit 5492ee8

Browse files
committed
修复alt点击无样板的物品时也能打开合成数量GUI的问题
1 parent 9f9c8fc commit 5492ee8

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/main/java/com/circulation/random_complement/mixin/ae2/gui/MixinAEBaseGui.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.circulation.random_complement.client.RCAECraftablesGui;
88
import com.circulation.random_complement.client.handler.RCInputHandler;
99
import com.circulation.random_complement.common.util.MEHandler;
10+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12+
import com.llamalad7.mixinextras.sugar.Local;
1013
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
1114
import it.unimi.dsi.fastutil.objects.ObjectSets;
1215
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -122,4 +125,8 @@ private void drawPin(float f, int x, int y, CallbackInfo ci) {
122125
}
123126
}
124127

128+
@WrapOperation(method = "handleMouseClick",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiScreen;isAltKeyDown()Z"))
129+
protected boolean fixNoCraftable(Operation<Boolean> original, @Local(name = "stack") IAEItemStack stack) {
130+
return original.call() && stack.isCraftable();
131+
}
125132
}

src/main/java/com/circulation/random_complement/mixin/ae2/miss_craft/MixinCraftingJob.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import appeng.api.networking.crafting.ICraftingGrid;
44
import appeng.api.networking.security.IActionSource;
55
import appeng.api.storage.data.IAEItemStack;
6+
import appeng.crafting.CraftBranchFailure;
67
import appeng.crafting.CraftingJob;
78
import appeng.crafting.CraftingTreeNode;
89
import 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

Comments
 (0)