aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-09-24 15:48:15 +0100
committerisXander <xandersmith2008@gmail.com>2023-09-24 15:48:15 +0100
commitd2b67633c1d3ca0c46682b05955dafafd3597f1d (patch)
tree7e7ae123d0cb945a45eb940a12eb03a4d4e04d80 /fabric
parent554646dbd857e2fab1be8339ce8d0231ef2dbb4c (diff)
downloadYetAnotherConfigLib-d2b67633c1d3ca0c46682b05955dafafd3597f1d.tar.gz
YetAnotherConfigLib-d2b67633c1d3ca0c46682b05955dafafd3597f1d.tar.bz2
YetAnotherConfigLib-d2b67633c1d3ca0c46682b05955dafafd3597f1d.zip
1.20.2
Diffstat (limited to 'fabric')
-rw-r--r--fabric/build.gradle.kts1
-rw-r--r--fabric/src/main/java/dev/isxander/yacl3/fabric/mixin/ContainerEventHandlerMixin.java35
-rw-r--r--fabric/src/main/resources/fabric.mod.json3
-rw-r--r--fabric/src/main/resources/yacl-fabric.mixins.json11
4 files changed, 48 insertions, 2 deletions
diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts
index de256bd..b73de3a 100644
--- a/fabric/build.gradle.kts
+++ b/fabric/build.gradle.kts
@@ -38,7 +38,6 @@ dependencies {
listOf(
"fabric-resource-loader-v0",
).forEach { modApi(fabricApi.module(it, libs.versions.fabric.api.get())) }
- modApi(libs.mod.menu)
libs.bundles.twelvemonkeys.imageio.let {
implementation(it)
diff --git a/fabric/src/main/java/dev/isxander/yacl3/fabric/mixin/ContainerEventHandlerMixin.java b/fabric/src/main/java/dev/isxander/yacl3/fabric/mixin/ContainerEventHandlerMixin.java
new file mode 100644
index 0000000..7e1be75
--- /dev/null
+++ b/fabric/src/main/java/dev/isxander/yacl3/fabric/mixin/ContainerEventHandlerMixin.java
@@ -0,0 +1,35 @@
+package dev.isxander.yacl3.fabric.mixin;
+
+import net.minecraft.client.gui.components.events.ContainerEventHandler;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.components.tabs.TabNavigationBar;
+import net.minecraft.client.gui.navigation.FocusNavigationEvent;
+import net.minecraft.client.gui.navigation.ScreenAxis;
+import net.minecraft.client.gui.navigation.ScreenDirection;
+import net.minecraft.client.gui.navigation.ScreenRectangle;
+import org.jetbrains.annotations.Nullable;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import java.util.List;
+
+/**
+ * This is in Fabric-only because only the Fabric fork of mixin supports @Redirect on interfaces.
+ * This will change in the next release of Mixin.
+ */
+@Mixin(ContainerEventHandler.class)
+public interface ContainerEventHandlerMixin {
+ /**
+ * This mixin is used to prevent the tab bar from being focused when navigating left or right
+ * through the YACL options screen. This can also apply to vanilla as navigating left or right
+ * should never result in focusing the always-at-the-top tab bar.
+ * Without this, navigating right from the option list focuses the tab bar, not the action buttons/description.
+ */
+ @Redirect(method = {"nextFocusPathVaguelyInDirection", "nextFocusPathInDirection"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/events/ContainerEventHandler;children()Ljava/util/List;"))
+ default List<?> modifyFocusCandidates(ContainerEventHandler instance, ScreenRectangle screenArea, ScreenDirection direction, @Nullable GuiEventListener focused, FocusNavigationEvent event) {
+ if (direction.getAxis() == ScreenAxis.HORIZONTAL)
+ return instance.children().stream().filter(child -> !(child instanceof TabNavigationBar)).toList();
+ return instance.children();
+ }
+}
diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json
index 21a6336..f74fcd5 100644
--- a/fabric/src/main/resources/fabric.mod.json
+++ b/fabric/src/main/resources/fabric.mod.json
@@ -22,7 +22,8 @@
"fabric-resource-loader-v0": "*"
},
"mixins": [
- "yacl.mixins.json"
+ "yacl.mixins.json",
+ "yacl-fabric.mixins.json"
],
"custom": {
"modmenu": {
diff --git a/fabric/src/main/resources/yacl-fabric.mixins.json b/fabric/src/main/resources/yacl-fabric.mixins.json
new file mode 100644
index 0000000..5374dd3
--- /dev/null
+++ b/fabric/src/main/resources/yacl-fabric.mixins.json
@@ -0,0 +1,11 @@
+{
+ "required": true,
+ "package": "dev.isxander.yacl3.fabric.mixin",
+ "compatibilityLevel": "JAVA_17",
+ "injectors": {
+ "defaultRequire": 1
+ },
+ "client": [
+ "ContainerEventHandlerMixin"
+ ]
+}