aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/java/dev/isxander/yacl/mixin/client/AbstractSelectionListMixin.java26
-rw-r--r--src/client/resources/yet-another-config-lib.client.mixins.json3
-rw-r--r--src/main/resources/yacl.accesswidener1
3 files changed, 30 insertions, 0 deletions
diff --git a/src/client/java/dev/isxander/yacl/mixin/client/AbstractSelectionListMixin.java b/src/client/java/dev/isxander/yacl/mixin/client/AbstractSelectionListMixin.java
new file mode 100644
index 0000000..978fd16
--- /dev/null
+++ b/src/client/java/dev/isxander/yacl/mixin/client/AbstractSelectionListMixin.java
@@ -0,0 +1,26 @@
+package dev.isxander.yacl.mixin.client;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.AbstractSelectionList;
+import org.objectweb.asm.Opcodes;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import java.util.List;
+
+@Mixin(AbstractSelectionList.class)
+public abstract class AbstractSelectionListMixin<E extends AbstractSelectionList.Entry<E>> {
+ @Shadow public abstract List<E> children();
+
+ /**
+ * Mojang use the field access of children to get max index to loop through keyboard navigation to find the next entry.
+ * YACL modifies these children() method to filter out hidden entries, so we need to redirect the field access to the
+ * method, so we don't get ArrayIndexOutOfBoundsException.
+ */
+ @Redirect(method = "nextEntry(Lnet/minecraft/client/gui/navigation/ScreenDirection;Ljava/util/function/Predicate;Lnet/minecraft/client/gui/components/AbstractSelectionList$Entry;)Lnet/minecraft/client/gui/components/AbstractSelectionList$Entry;", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/components/AbstractSelectionList;children:Ljava/util/List;", opcode = Opcodes.GETFIELD))
+ private List<E> modifyChildrenCall(AbstractSelectionList<E> instance) {
+ return children();
+ }
+}
diff --git a/src/client/resources/yet-another-config-lib.client.mixins.json b/src/client/resources/yet-another-config-lib.client.mixins.json
index 6aeab10..69c0f25 100644
--- a/src/client/resources/yet-another-config-lib.client.mixins.json
+++ b/src/client/resources/yet-another-config-lib.client.mixins.json
@@ -7,5 +7,8 @@
},
"client": [
"OptionInstanceAccessor"
+ ],
+ "mixins": [
+ "AbstractSelectionListMixin"
]
}
diff --git a/src/main/resources/yacl.accesswidener b/src/main/resources/yacl.accesswidener
index 99093ea..35ebaa6 100644
--- a/src/main/resources/yacl.accesswidener
+++ b/src/main/resources/yacl.accesswidener
@@ -2,3 +2,4 @@ accessWidener v1 named
extendable method net/minecraft/client/gui/components/AbstractSelectionList children ()Ljava/util/List;
extendable method net/minecraft/client/gui/components/AbstractSelectionList getEntryAtPosition (DD)Lnet/minecraft/client/gui/components/AbstractSelectionList$Entry;
+accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry