aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/dev/isxander/yacl/mixin
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-03-15 18:07:44 +0000
committerisXander <xandersmith2008@gmail.com>2023-03-15 18:07:44 +0000
commitc02229186aa13b1d699e2d00d24865260f158a54 (patch)
tree253a1b6adb72ef4299bc256b03482dd4b79d41c1 /src/client/java/dev/isxander/yacl/mixin
parentc8a86cff89aa9072b6917c628406d3a06f4934ae (diff)
parente51e9bc95e2e271c8d55b063f9117eda0a100ab0 (diff)
downloadYetAnotherConfigLib-c02229186aa13b1d699e2d00d24865260f158a54.tar.gz
YetAnotherConfigLib-c02229186aa13b1d699e2d00d24865260f158a54.tar.bz2
YetAnotherConfigLib-c02229186aa13b1d699e2d00d24865260f158a54.zip
Merge branch 'update/1.19.4' into 1.19.x/dev
# Conflicts: # build.gradle.kts
Diffstat (limited to 'src/client/java/dev/isxander/yacl/mixin')
-rw-r--r--src/client/java/dev/isxander/yacl/mixin/client/AbstractSelectionListMixin.java26
1 files changed, 26 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();
+ }
+}