diff --git a/src/main/java/io/pyke/vitri/finorza/inference/rpc/RemoteControlService.java b/src/main/java/io/pyke/vitri/finorza/inference/rpc/RemoteControlService.java index f59a2f0..8ed517c 100644 --- a/src/main/java/io/pyke/vitri/finorza/inference/rpc/RemoteControlService.java +++ b/src/main/java/io/pyke/vitri/finorza/inference/rpc/RemoteControlService.java @@ -50,7 +50,7 @@ public RemoteControlService(@NotNull Screenshot screenshot, @NotNull Minecraft m this.minecraft = minecraft; } - private static int vitriKeyToCode(Key key) { + private int vitriKeyToCode(Key key) { return switch (key) { case FORWARD -> GLFW.GLFW_KEY_W; case BACK -> GLFW.GLFW_KEY_S; @@ -60,7 +60,14 @@ private static int vitriKeyToCode(Key key) { case SNEAK -> GLFW.GLFW_KEY_LEFT_SHIFT; case SPRINT -> GLFW.GLFW_KEY_LEFT_CONTROL; case ESC -> GLFW.GLFW_KEY_ESCAPE; - case INVENTORY -> GLFW.GLFW_KEY_E; + case INVENTORY -> { + if (minecraft.screen instanceof AbstractContainerScreen) { + // Use escape instead of E to prevent a race condition which crashes the game. + yield GLFW.GLFW_KEY_ESCAPE; + } else { + yield GLFW.GLFW_KEY_E; + } + } case SWAP_HANDS -> GLFW.GLFW_KEY_F; case DROP -> GLFW.GLFW_KEY_Q; case HOTBAR_1 -> GLFW.GLFW_KEY_1;