Skip to content

Commit 877e1bb

Browse files
committed
Fix supermartijn compat mixin on fabric
1 parent f0b1579 commit 877e1bb

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

common/src/main/resources/clientsort.mixins.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"client.accessor.AbstractContainerScreenAccessor",
1515
"client.accessor.ScreenAccessor",
1616
"client.compat.emi.ReloadWorkerMixin",
17-
"client.compat.supermartijn642corelib.WidgetContainerScreenMixin",
1817
"client.slot.CreativeSlotMixin",
1918
"client.slot.SlotMixin"
2019
],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2025 TerminalMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.terminalmc.clientsort.mixin.client.compat.supermartijn642corelib;
18+
19+
import dev.terminalmc.clientsort.client.gui.widget.ControlButton;
20+
import net.minecraft.client.gui.GuiGraphics;
21+
import net.minecraft.client.gui.screens.Screen;
22+
import net.minecraft.network.chat.Component;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.Pseudo;
25+
import org.spongepowered.asm.mixin.injection.At;
26+
import org.spongepowered.asm.mixin.injection.Inject;
27+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28+
29+
/**
30+
* For reasons unknown, SuperMartijn642's {@link com.supermartijn642.core.gui.WidgetContainerScreen}
31+
* implementation does not call the super render method, so the screen's children are never
32+
* rendered.
33+
* <p>
34+
* This mixin works around that by injecting into the render method and manually rendering the
35+
* ClientSort buttons.
36+
*/
37+
@Pseudo
38+
@Mixin(
39+
targets = "com.supermartijn642.core.gui.WidgetContainerScreen"
40+
)
41+
@SuppressWarnings("JavadocReference")
42+
public class WidgetContainerScreenMixin extends Screen {
43+
44+
protected WidgetContainerScreenMixin(Component title) {
45+
super(title);
46+
}
47+
48+
@SuppressWarnings("UnresolvedMixinReference")
49+
@Inject(
50+
method = "method_25394",
51+
at = @At("RETURN")
52+
)
53+
private void afterRender(
54+
GuiGraphics graphics,
55+
int mouseX,
56+
int mouseY,
57+
float partialTick,
58+
CallbackInfo ci
59+
) {
60+
this.children().forEach((child) -> {
61+
if (child instanceof ControlButton button) {
62+
button.render(graphics, mouseX, mouseY, partialTick);
63+
}
64+
});
65+
}
66+
}

fabric/src/main/resources/clientsort.fabric.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"package": "dev.terminalmc.clientsort.mixin",
55
"refmap": "${mod_id}.refmap.json",
66
"compatibilityLevel": "JAVA_${java_version}",
7+
"plugin": "dev.terminalmc.clientsort.util.MixinConfigPlugin",
78
"mixins": [
89
],
910
"client": [
11+
"client.compat.supermartijn642corelib.WidgetContainerScreenMixin"
1012
],
1113
"server": [
1214
],

common/src/main/java/dev/terminalmc/clientsort/mixin/client/compat/supermartijn642corelib/WidgetContainerScreenMixin.java renamed to neoforge/src/main/java/dev/terminalmc/clientsort/mixin/client/compat/supermartijn642corelib/WidgetContainerScreenMixin.java

File renamed without changes.

neoforge/src/main/resources/clientsort.neoforge.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"package": "dev.terminalmc.clientsort.mixin",
55
"refmap": "${mod_id}.refmap.json",
66
"compatibilityLevel": "JAVA_${java_version}",
7+
"plugin": "dev.terminalmc.clientsort.util.MixinConfigPlugin",
78
"mixins": [
89
],
910
"client": [
11+
"client.compat.supermartijn642corelib.WidgetContainerScreenMixin"
1012
],
1113
"server": [
1214
],

0 commit comments

Comments
 (0)