Skip to content

Commit 0c7a4ad

Browse files
committed
临时解决一些奇怪的报错
1 parent 16022de commit 0c7a4ad

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.circulation.random_complement.mixin.ae2.jei;
2+
3+
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
4+
import it.unimi.dsi.fastutil.objects.ObjectLists;
5+
import mezz.jei.config.Config;
6+
import mezz.jei.gui.overlay.bookmarks.group.BookmarkGroupDisplay;
7+
import mezz.jei.gui.overlay.bookmarks.group.BookmarkGroupOrganizer;
8+
import net.minecraft.client.Minecraft;
9+
import org.spongepowered.asm.mixin.Final;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Mutable;
12+
import org.spongepowered.asm.mixin.Overwrite;
13+
import org.spongepowered.asm.mixin.Shadow;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
18+
import java.util.List;
19+
20+
@Mixin(value = BookmarkGroupOrganizer.class, remap = false, priority = 1001)
21+
public abstract class MixinBookmarkGroupOrganizer {
22+
23+
@Mutable
24+
@Shadow
25+
@Final
26+
private List<BookmarkGroupDisplay> groups;
27+
28+
@Shadow
29+
protected abstract void drawGroup(Minecraft minecraft, int mouseX, int mouseY, BookmarkGroupDisplay display);
30+
31+
@Inject(method = "<init>", at = @At("TAIL"))
32+
public void onInit(CallbackInfo ci) {
33+
groups = ObjectLists.synchronize(new ObjectArrayList<>());
34+
}
35+
36+
/**
37+
* @author circulation
38+
* @reason 测试性修改
39+
*/
40+
@Overwrite
41+
public void draw(Minecraft minecraft, int mouseX, int mouseY) {
42+
if (Config.areRecipeBookmarksEnabled()) {
43+
for (var i = 0; i < this.groups.size(); i++) {
44+
this.drawGroup(minecraft, mouseX, mouseY, this.groups.get(i));
45+
}
46+
}
47+
}
48+
49+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.circulation.random_complement.mixin.jei;
2+
3+
import mezz.jei.render.IngredientListBatchRenderer;
4+
import mezz.jei.render.IngredientListSlot;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
import java.util.List;
9+
10+
@Mixin(value = IngredientListBatchRenderer.class, remap = false)
11+
public interface AccessorIngredientListBatchRenderer {
12+
13+
@Accessor("slots")
14+
List<List<IngredientListSlot>> getSlots();
15+
}

src/main/java/com/circulation/random_complement/mixin/jeiu/MixinAdvancedIngredientGrid.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
package com.circulation.random_complement.mixin.jeiu;
22

3+
import com.circulation.random_complement.mixin.jei.AccessorIngredientListBatchRenderer;
34
import com.github.vfyjxf.jeiutilities.gui.history.AdvancedIngredientGrid;
45
import mezz.jei.gui.ingredients.IIngredientListElement;
56
import mezz.jei.gui.overlay.GridAlignment;
67
import mezz.jei.gui.overlay.IngredientGrid;
78
import mezz.jei.input.MouseHelper;
89
import mezz.jei.render.IngredientListBatchRenderer;
10+
import mezz.jei.render.IngredientListSlot;
11+
import org.objectweb.asm.Opcodes;
912
import org.spongepowered.asm.mixin.Final;
1013
import org.spongepowered.asm.mixin.Mixin;
1114
import org.spongepowered.asm.mixin.Shadow;
15+
import org.spongepowered.asm.mixin.injection.At;
16+
import org.spongepowered.asm.mixin.injection.Redirect;
17+
18+
import java.util.List;
1219

1320
@Mixin(value = AdvancedIngredientGrid.class, remap = false)
1421
public class MixinAdvancedIngredientGrid extends IngredientGrid {
@@ -17,6 +24,9 @@ public class MixinAdvancedIngredientGrid extends IngredientGrid {
1724
@Final
1825
private IngredientListBatchRenderer guiHistoryIngredientSlots;
1926

27+
@Shadow
28+
private boolean showHistory;
29+
2030
public MixinAdvancedIngredientGrid(IngredientListBatchRenderer guiIngredientSlots, GridAlignment alignment) {
2131
super(guiIngredientSlots, alignment);
2232
}
@@ -29,4 +39,14 @@ public IIngredientListElement<?> getElementUnderMouse() {
2939
return r != null ? r.getElement() : null;
3040
}
3141

42+
@Redirect(method = "draw", at = @At(value = "INVOKE", target = "Lmezz/jei/render/IngredientListBatchRenderer;getAllGuiIngredientSlots()Ljava/util/List;"))
43+
public List<IngredientListSlot> draw(IngredientListBatchRenderer instance) {
44+
return ((AccessorIngredientListBatchRenderer) instance).getSlots().get(0);
45+
}
46+
47+
@Redirect(method = "draw", at = @At(value = "FIELD", target = "Lcom/github/vfyjxf/jeiutilities/gui/history/AdvancedIngredientGrid;showHistory:Z", ordinal = 0, opcode = Opcodes.GETFIELD))
48+
public boolean draw(AdvancedIngredientGrid instance) {
49+
return this.showHistory && guiHistoryIngredientSlots.size() > 0;
50+
}
51+
3252
}

src/main/resources/mixins.random_complement.ae2.jei.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"compatibilityLevel": "JAVA_8",
77
"mixins": [
88
"MixinAEGuiHandler",
9+
"MixinBookmarkGroupOrganizer",
910
"MixinIngredientListBatchRenderer"
1011
],
1112
"server": [],

src/main/resources/mixins.random_complement.jei.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
],
1212
"mixins": [
1313
"AccessorGhostIngredientDragManager",
14+
"AccessorIngredientListBatchRenderer",
1415
"AccessorInputHandler",
1516
"AccessorRecipeLayout",
1617
"MixinGhostIngredientDrag"

0 commit comments

Comments
 (0)