From f004f0a32d561486a09f5d16162991773c1dd927 Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Thu, 27 Mar 2025 00:00:29 +0100 Subject: [PATCH] compat: improve/fix Emotecraft compat --- common/build.gradle | 2 +- .../client/compat/EmotecraftCompat.java | 49 ++++++++++++------- gradle.properties | 2 +- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 19838f8..b8b160e 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -39,7 +39,7 @@ dependencies { modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0" modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric" modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}" - modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}" + modImplementation "maven.modrinth:emotecraft:${project.emotecraft_version}" modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}" modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}" modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}" diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/EmotecraftCompat.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/EmotecraftCompat.java index ffaece0..c307424 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/EmotecraftCompat.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/compat/EmotecraftCompat.java @@ -1,36 +1,51 @@ package eu.midnightdust.midnightcontrols.client.compat; import eu.midnightdust.midnightcontrols.client.controller.InputManager; -import io.github.kosmx.emotes.arch.gui.EmoteMenuImpl; -import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen; +import eu.midnightdust.midnightcontrols.client.mixin.MouseAccessor; +import io.github.kosmx.emotes.arch.screen.ingame.FastMenuScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; +import org.joml.Vector2i; +import org.lwjgl.glfw.GLFW; public class EmotecraftCompat { private static final MinecraftClient client = MinecraftClient.getInstance(); public static void openEmotecraftScreen(Screen parent) { - client.setScreen(new EmoteMenuImpl(parent)); + client.setScreen(new FastMenuScreen(parent)); } public static boolean isEmotecraftScreen(Screen screen) { - return screen instanceof FastChosseScreen; + return screen instanceof FastMenuScreen; } + static int prevIndex = -1; public static void handleEmoteSelector(int index) { - if (client.currentScreen instanceof FastChosseScreen) { - int x = client.getWindow().getWidth() / 2; - int y = client.getWindow().getHeight() / 2; - switch (index) { - case 0, 3, 5 -> x -= 200; - case 2, 4, 7 -> x += 200; - } - switch (index) { - case 0, 1, 2 -> y -= 200; - case 5, 6, 7 -> y += 200; - } - InputManager.queueMousePosition(x, y); + try { + if (client.currentScreen instanceof FastMenuScreen) { + boolean stickReleased = index == -1 && prevIndex != -1; + var pos = calcMousePos(stickReleased ? prevIndex : index); + InputManager.queueMousePosition(pos.x, pos.y); + InputManager.INPUT_MANAGER.updateMousePosition(client); - InputManager.INPUT_MANAGER.updateMousePosition(client); + if (stickReleased) { + ((MouseAccessor) client.mouse).midnightcontrols$onMouseButton(client.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT, GLFW.GLFW_PRESS, 0); + prevIndex = -1; + } + else prevIndex = index; + } else prevIndex = -1; + } catch (Exception ignored) {} + } + public static Vector2i calcMousePos(int index) { + int x = client.getWindow().getWidth() / 2; + int y = client.getWindow().getHeight() / 2; + switch (index) { + case 0, 3, 5 -> x -= 275; + case 2, 4, 7 -> x += 275; } + switch (index) { + case 0, 1, 2 -> y -= 275; + case 5, 6, 7 -> y += 275; + } + return new Vector2i(x, y); } } diff --git a/gradle.properties b/gradle.properties index 45a99ae..2f3c513 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,7 +29,7 @@ quilt_fabric_api_version=7.0.1+0.83.0-1.20 sodium_version=mc1.21-0.6.0-beta.1 obsidianui_version=0.2.10+mc1.21.3 modmenu_version=10.0.0-beta.1 -emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric +emotecraft_version=2.5.5+1.21.4-fabric bendylib_version=2.0.+ emi_version=1.1.10+1.21+fabric libgui_version=6.0.0+1.19