mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
compat: improve/fix Emotecraft compat
This commit is contained in:
@@ -39,7 +39,7 @@ dependencies {
|
|||||||
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
||||||
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
||||||
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
|
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 "io.github.kosmx:bendy-lib:${project.bendylib_version}"
|
||||||
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
||||||
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
||||||
|
|||||||
@@ -1,36 +1,51 @@
|
|||||||
package eu.midnightdust.midnightcontrols.client.compat;
|
package eu.midnightdust.midnightcontrols.client.compat;
|
||||||
|
|
||||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||||
import io.github.kosmx.emotes.arch.gui.EmoteMenuImpl;
|
import eu.midnightdust.midnightcontrols.client.mixin.MouseAccessor;
|
||||||
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
|
import io.github.kosmx.emotes.arch.screen.ingame.FastMenuScreen;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import org.joml.Vector2i;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class EmotecraftCompat {
|
public class EmotecraftCompat {
|
||||||
private static final MinecraftClient client = MinecraftClient.getInstance();
|
private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
public static void openEmotecraftScreen(Screen parent) {
|
public static void openEmotecraftScreen(Screen parent) {
|
||||||
client.setScreen(new EmoteMenuImpl(parent));
|
client.setScreen(new FastMenuScreen(parent));
|
||||||
}
|
}
|
||||||
public static boolean isEmotecraftScreen(Screen screen) {
|
public static boolean isEmotecraftScreen(Screen screen) {
|
||||||
return screen instanceof FastChosseScreen;
|
return screen instanceof FastMenuScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int prevIndex = -1;
|
||||||
public static void handleEmoteSelector(int index) {
|
public static void handleEmoteSelector(int index) {
|
||||||
if (client.currentScreen instanceof FastChosseScreen) {
|
try {
|
||||||
int x = client.getWindow().getWidth() / 2;
|
if (client.currentScreen instanceof FastMenuScreen) {
|
||||||
int y = client.getWindow().getHeight() / 2;
|
boolean stickReleased = index == -1 && prevIndex != -1;
|
||||||
switch (index) {
|
var pos = calcMousePos(stickReleased ? prevIndex : index);
|
||||||
case 0, 3, 5 -> x -= 200;
|
InputManager.queueMousePosition(pos.x, pos.y);
|
||||||
case 2, 4, 7 -> x += 200;
|
InputManager.INPUT_MANAGER.updateMousePosition(client);
|
||||||
}
|
|
||||||
switch (index) {
|
|
||||||
case 0, 1, 2 -> y -= 200;
|
|
||||||
case 5, 6, 7 -> y += 200;
|
|
||||||
}
|
|
||||||
InputManager.queueMousePosition(x, y);
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
sodium_version=mc1.21-0.6.0-beta.1
|
||||||
obsidianui_version=0.2.10+mc1.21.3
|
obsidianui_version=0.2.10+mc1.21.3
|
||||||
modmenu_version=10.0.0-beta.1
|
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.+
|
bendylib_version=2.0.+
|
||||||
emi_version=1.1.10+1.21+fabric
|
emi_version=1.1.10+1.21+fabric
|
||||||
libgui_version=6.0.0+1.19
|
libgui_version=6.0.0+1.19
|
||||||
|
|||||||
Reference in New Issue
Block a user