From a3c342dfb78232aba2bcf909dea4c7e19a206fff Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 5 Mar 2026 22:39:37 +1000 Subject: [PATCH 01/59] UScreen: create ConsumableInputHandler interface --- .../kotlin/gg/essential/universal/UScreen.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index ac200911..3be32d59 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -543,6 +543,37 @@ abstract class UScreen( @Suppress("DEPRECATION") onDrawBackground(tint) } + /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. + * I.e. The new input functions will return a boolean, indicating whether the input was consumed, to Minecraft. + * + * On versions below 1.16, the boolean returns are not passed to Minecraft as they are not used, + * the interface still replaces and executes the same for consistency. + * + * [UScreen] automatically handles this if it's subclass implements this interface. (via `consumableInputHandler`) + * To aid this, [UScreen] already implements `uSuperConsumableInputHandler()` itself which, by default, defers to the + * original non-returning functions. So you only need to override the functions you actually want to consume. + */ + interface ConsumableInputHandler { + fun uSuperConsumableInputHandler(): ConsumableInputHandler + + fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = + uSuperConsumableInputHandler().uMouseClicked(mouseX, mouseY, mouseButton) + + fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean = + uSuperConsumableInputHandler().uMouseReleased(mouseX, mouseY, state) + + fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean = + uSuperConsumableInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick) + + fun uMouseScrolled(delta: Double): Boolean = + uSuperConsumableInputHandler().uMouseScrolled(delta) + + fun uKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperConsumableInputHandler().uKeyPressed(keyCode, typedChar, modifiers) + + fun uKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperConsumableInputHandler().uKeyReleased(keyCode, typedChar, modifiers) + } companion object { @JvmStatic From 6e0b76a1cd0e42746bab2ab9cdbc63a519930198 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 5 Mar 2026 22:40:05 +1000 Subject: [PATCH 02/59] UScreen: add uSuperConsumableInputHandler() implementation --- .../kotlin/gg/essential/universal/UScreen.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 3be32d59..e9e70deb 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -543,6 +543,42 @@ abstract class UScreen( @Suppress("DEPRECATION") onDrawBackground(tint) } + + @Suppress("unused") // Becomes used if the child class is an instance of [ConsumableInputHandler] + fun uSuperConsumableInputHandler(): ConsumableInputHandler = object : ConsumableInputHandler { + override fun uSuperConsumableInputHandler(): ConsumableInputHandler = this + + override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { + onMouseClicked(mouseX, mouseY, mouseButton) + return false + } + + override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean { + onMouseReleased(mouseX, mouseY, state) + return false + } + + override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean { + onMouseDragged(x, y, clickedButton, timeSinceLastClick) + return false + } + + override fun uMouseScrolled(delta: Double): Boolean { + onMouseScrolled(delta) + return false + } + + override fun uKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { + onKeyPressed(keyCode, typedChar, modifiers) + return false + } + + override fun uKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { + onKeyReleased(keyCode, typedChar, modifiers) + return false + } + } + /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. * I.e. The new input functions will return a boolean, indicating whether the input was consumed, to Minecraft. * From 139666aaef20c167d9e68873e9a367472e8027c8 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 5 Mar 2026 22:40:54 +1000 Subject: [PATCH 03/59] UScreen: implement ConsumableInputHandler forwarding --- .../kotlin/gg/essential/universal/UScreen.kt | 89 +++++++++++++++++-- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index e9e70deb..9009588e 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -53,6 +53,7 @@ abstract class UScreen( private var guiScaleToRestore = -1 private var restoringGuiScale = false private val screenToRestore: GuiScreen? = if (restoreCurrentGuiOnClose) currentScreen else null + var consumableInputHandler: ConsumableInputHandler? = this as? ConsumableInputHandler //#if MC>=12106 //$$ // Background is now draw from the final `renderWithTooltip` method, before we ever get control, so we need //$$ // to suppress by default and can only allow during `onDrawScreen`. @@ -136,11 +137,19 @@ abstract class UScreen( //$$ //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ } + //$$ //$$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) //$$ return false //$$ } //$$ //$$ final override fun keyReleased(input: KeyInput): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ } + //$$ //$$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) //$$ return false //$$ } @@ -148,8 +157,17 @@ abstract class UScreen( //$$ final override fun charTyped(input: CharInput): Boolean { //$$ val codepoint = input.codepoint //$$ if (Character.isBmpCodePoint(codepoint)) { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) + //$$ } + //$$ //$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) //$$ } else if (Character.isValidCodePoint(codepoint)) { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) or + //$$ it.uKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) + //$$ } + //$$ //$$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ } @@ -163,6 +181,14 @@ abstract class UScreen( //$$ lastMouseInput = click.buttonInfo //$$ lastDoubled = doubled //$$ if (click.button() == 1) lastClick = UMinecraft.getTime() + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseClicked(click.x, click.y, click.button()).also { + //$$ lastMouseInput = null + //$$ lastDoubled = null + //$$ } + //$$ } + //$$ //$$ onMouseClicked(click.x, click.y, click.button()) //$$ lastMouseInput = null //$$ lastDoubled = null @@ -171,6 +197,13 @@ abstract class UScreen( //$$ //$$ final override fun mouseReleased(click: Click): Boolean { //$$ lastMouseInput = click.buttonInfo + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseReleased(click.x, click.y, click.button()).also { + //$$ lastMouseInput = null + //$$ } + //$$ } + //$$ //$$ onMouseReleased(click.x, click.y, click.button()) //$$ lastMouseInput = null //$$ return false @@ -180,22 +213,41 @@ abstract class UScreen( //$$ lastMouseInput = click.buttonInfo //$$ lastDraggedDx = offsetX //$$ lastDraggedDy = offsetY + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick).also { + //$$ lastMouseInput = null + //$$ } + //$$ } + //$$ //$$ onMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick) //$$ lastMouseInput = null //$$ return false //$$ } //#else //$$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ } + //$$ //$$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) //$$ return false //$$ } //$$ //$$ final override fun keyReleased(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ } + //$$ //$$ onKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) //$$ return false //$$ } //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uKeyPressed(0, char, modifierCode.toModifiers()) + //$$ } + //$$ //$$ onKeyPressed(0, char, modifierCode.toModifiers()) //$$ return false //$$ } @@ -203,11 +255,20 @@ abstract class UScreen( //$$ final override fun mouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { //$$ if (mouseButton == 1) //$$ lastClick = UMinecraft.getTime() + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton) + //$$ } + //$$ //$$ onMouseClicked(mouseX, mouseY, mouseButton) //$$ return false //$$ } //$$ //$$ final override fun mouseReleased(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { + //$$ consumableInputHandler?.let { + //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton) + //$$ } + //$$ //$$ onMouseReleased(mouseX, mouseY, mouseButton) //$$ return false //$$ } @@ -215,6 +276,11 @@ abstract class UScreen( //$$ final override fun mouseDragged(x: Double, y: Double, mouseButton: Int, dx: Double, dy: Double): Boolean { //$$ lastDraggedDx = dx //$$ lastDraggedDy = dy + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) + //$$ } + //$$ //$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) //$$ return false //$$ } @@ -228,6 +294,11 @@ abstract class UScreen( //#endif //$$ lastScrolledX = mouseX //$$ lastScrolledY = mouseY + //$$ + //$$ consumableInputHandler?.let { + //$$ return it.uMouseScrolled(delta) + //$$ } + //$$ //$$ onMouseScrolled(delta) //$$ return false //$$ } @@ -283,26 +354,32 @@ abstract class UScreen( } final override fun keyTyped(typedChar: Char, keyCode: Int) { - onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + consumableInputHandler?.uKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) + consumableInputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) + ?: onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) + consumableInputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) + ?: onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) + consumableInputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) + ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } final override fun handleMouseInput() { super.handleMouseInput() val scrollDelta = Mouse.getEventDWheel() - if (scrollDelta != 0) - onMouseScrolled(scrollDelta.toDouble()) + if (scrollDelta != 0) { + consumableInputHandler?.uMouseScrolled(scrollDelta.toDouble()) + ?: onMouseScrolled(scrollDelta.toDouble()) + } } final override fun updateScreen() { From 951e5a6f63c58d70fadd751816a9fc082d693c10 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 5 Mar 2026 23:03:10 +1000 Subject: [PATCH 04/59] UScreen: block ISO Control characters from super.charTyped() --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 9009588e..89868f72 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -483,7 +483,7 @@ abstract class UScreen( //$$ super.keyPressed(keyCode, 0, modifiers.toInt()) //#endif //$$ } - //$$ if (typedChar != 0.toChar()) { + //$$ if (!typedChar.isISOControl()) { //#if MC>=12109 //$$ super.charTyped(CharInput(typedChar.code, modifiers.toInt())) //#else From d8b45ce489a3c1d90f320ef576c4a12b17d8b3ed Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 5 Mar 2026 23:15:07 +1000 Subject: [PATCH 05/59] API: update --- api/UniversalCraft.api | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index 5b6faa2d..693ec405 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -849,6 +849,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public fun (ZLgg/essential/universal/GuiScale;)V public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screens/Screen;)V + public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screens/Screen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -892,9 +893,11 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge public final fun renderBackground (Lcom/mojang/blaze3d/vertex/PoseStack;I)V public final fun restorePreviousScreen ()V + public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V + public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public fun updateGuiScale ()V } @@ -913,6 +916,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric,1.21.6-fabric,1.21.7-fabric public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screen/Screen;)V + public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screen/Screen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -981,9 +985,11 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric public final fun renderBackground (Lnet/minecraft/client/util/math/MatrixStack;I)V public final fun restorePreviousScreen ()V + public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V + public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public fun updateGuiScale ()V } @@ -1000,6 +1006,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public static final fun displayScreen (Lnet/minecraft/client/gui/GuiScreen;)V public final fun drawScreen (IIF)V public final fun drawWorldBackground (I)V + public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/GuiScreen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -1026,8 +1033,10 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public fun onScreenClose ()V public fun onTick ()V public final fun restorePreviousScreen ()V + public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V + public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public fun updateGuiScale ()V public final fun updateScreen ()V } @@ -1047,6 +1056,16 @@ public final class gg/essential/universal/UScreen$Companion { public final fun getCurrentScreen ()Lnet/minecraft/client/gui/GuiScreen; } +public abstract interface class gg/essential/universal/UScreen$ConsumableInputHandler { + public fun uKeyPressed (ICLgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uKeyReleased (ICLgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uMouseClicked (DDI)Z + public fun uMouseDragged (DDIJ)Z + public fun uMouseReleased (DDI)Z + public fun uMouseScrolled (D)Z + public abstract fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; +} + public final class gg/essential/universal/USound { public static final field INSTANCE Lgg/essential/universal/USound; public final fun playButtonPress ()V From 838a66b24089de57b04da0232e5307603335adcf Mon Sep 17 00:00:00 2001 From: Traben Date: Fri, 6 Mar 2026 14:30:07 +1000 Subject: [PATCH 06/59] UScreen: revert diff to old behaviour --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 89868f72..9009588e 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -483,7 +483,7 @@ abstract class UScreen( //$$ super.keyPressed(keyCode, 0, modifiers.toInt()) //#endif //$$ } - //$$ if (!typedChar.isISOControl()) { + //$$ if (typedChar != 0.toChar()) { //#if MC>=12109 //$$ super.charTyped(CharInput(typedChar.code, modifiers.toInt())) //#else From c20a4baa44a6558002cfe7657b9ae605b91c0823 Mon Sep 17 00:00:00 2001 From: Traben Date: Fri, 6 Mar 2026 17:36:12 +1000 Subject: [PATCH 07/59] UScreen: prevent control code characters in older minecraft events to match modern mc --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 9009588e..fef60abc 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -354,7 +354,7 @@ abstract class UScreen( } final override fun keyTyped(typedChar: Char, keyCode: Int) { - consumableInputHandler?.uKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + consumableInputHandler?.uKeyPressed(keyCode, if (typedChar.isISOControl()) 0.toChar() else typedChar, UKeyboard.getModifiers()) ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } From 1cc2422e0335a95d0cc0fcd50697e43c9a5637db Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 10 Mar 2026 21:35:15 +1000 Subject: [PATCH 08/59] Review: - uSuperConsumableInputHandler() default instance should call super directly - separate uKeypress and uCharTyped Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 215 +++++++++++------- 1 file changed, 137 insertions(+), 78 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 89868f72..779d8568 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -138,7 +138,7 @@ abstract class UScreen( //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ return it.uKeyPressed(input.key, input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) @@ -158,7 +158,7 @@ abstract class UScreen( //$$ val codepoint = input.codepoint //$$ if (Character.isBmpCodePoint(codepoint)) { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) + //$$ return it.uCharTyped(input.codepoint.toChar(), input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) @@ -227,7 +227,7 @@ abstract class UScreen( //#else //$$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ return it.uKeyPressed(keyCode, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) @@ -245,7 +245,7 @@ abstract class UScreen( //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(0, char, modifierCode.toModifiers()) + //$$ return it.uCharTyped(char, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyPressed(0, char, modifierCode.toModifiers()) @@ -354,8 +354,10 @@ abstract class UScreen( } final override fun keyTyped(typedChar: Char, keyCode: Int) { - consumableInputHandler?.uKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) - ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + consumableInputHandler?.let { + val handled = it.uKeyPressed(keyCode, UKeyboard.getModifiers()) + if (!handled) it.uCharTyped(typedChar, UKeyboard.getModifiers()) + } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { @@ -474,6 +476,7 @@ abstract class UScreen( onDrawScreen(mouseX, mouseY, partialTicks) } + // Merged keycode & character universal function for < 1.15 format compatibility, does not correlate to just 1 super call open fun onKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { //#if MC>=11502 //$$ if (keyCode != 0) { @@ -483,7 +486,7 @@ abstract class UScreen( //$$ super.keyPressed(keyCode, 0, modifiers.toInt()) //#endif //$$ } - //$$ if (!typedChar.isISOControl()) { + //$$ if (typedChar != 0.toChar()) { //#if MC>=12109 //$$ super.charTyped(CharInput(typedChar.code, modifiers.toInt())) //#else @@ -500,61 +503,23 @@ abstract class UScreen( } open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { - //#if MC>=11502 - //$$ if (keyCode != 0) { - //#if MC>=12109 - //$$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) - //#else - //$$ super.keyReleased(keyCode, 0, modifiers.toInt()) - //#endif - //$$ } - //#endif + superKeyReleased(keyCode, modifiers) } open fun onMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int) { - //#if MC>=11502 - //$$ if (mouseButton == 1) - //$$ lastClick = UMinecraft.getTime() - //#if MC>=12109 - //$$ super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false) - //#else - //$$ super.mouseClicked(mouseX, mouseY, mouseButton) - //#endif - //#else - try { - super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) - } catch (e: IOException) { - e.printStackTrace() - } - //#endif + superMouseClicked(mouseX, mouseY, mouseButton) } open fun onMouseReleased(mouseX: Double, mouseY: Double, state: Int) { - //#if MC>=12109 - //$$ super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0))) - //#elseif MC>=11502 - //$$ super.mouseReleased(mouseX, mouseY, state) - //#else - super.mouseReleased(mouseX.toInt(), mouseY.toInt(), state) - //#endif + superMouseReleased(mouseX, mouseY, state) } open fun onMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long) { - //#if MC>=12109 - //$$ super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy) - //#elseif MC>=11502 - //$$ super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy) - //#else - super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick) - //#endif + superMouseDragged(x, y, clickedButton, timeSinceLastClick) } open fun onMouseScrolled(delta: Double) { - //#if MC>=12002 - //$$ super.mouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) - //#elseif MC>=11502 - //$$ super.mouseScrolled(lastScrolledX, lastScrolledY, delta) - //#endif + superMouseScrolled(delta) } open fun onTick() { @@ -621,39 +586,130 @@ abstract class UScreen( onDrawBackground(tint) } + private fun superMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { + //#if MC >= 1.15.2 + //$$ if (mouseButton == 1) + //$$ lastClick = UMinecraft.getTime() + //#if MC >= 1.21.9 + //$$ return super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false) + //#else + //$$ return super.mouseClicked(mouseX, mouseY, mouseButton) + //#endif + //#else + try { + super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) + } catch (e: IOException) { + e.printStackTrace() + } + return false + //#endif + } + + private fun superMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean { + //#if MC >= 1.21.9 + //$$ return super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0))) + //#elseif MC >= 1.15.2 + //$$ return super.mouseReleased(mouseX, mouseY, state) + //#else + super.mouseReleased(mouseX.toInt(), mouseY.toInt(), state) + return false + //#endif + } + + private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean { + //#if MC >= 1.21.9 + //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy) + //#elseif MC >= 1.15.2 + //$$ return super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy) + //#else + super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick) + return false + //#endif + } + + private fun superMouseScrolled(delta: Double): Boolean { + //#if MC >= 1.20.2 + //$$ return super.mouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) + //#elseif MC >= 1.15.2 + //$$ return super.mouseScrolled(lastScrolledX, lastScrolledY, delta) + //#else + return false // No super + //#endif + } + + private fun superCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { + if (typedChar.isISOControl()) return false + + //#if MC >= 1.21.9 + //$$ return super.charTyped(CharInput(typedChar.code, modifiers.toInt())) + //#elseif MC >= 1.15.2 + //$$ return super.charTyped(typedChar, modifiers.toInt()) + //#else + try { + super.keyTyped(typedChar, 0) + } catch (e: IOException) { + e.printStackTrace() + } + return false + //#endif + } + + private fun superKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + //#if MC >= 1.15.2 + //$$ if (keyCode != 0) { + //#if MC >= 1.21.9 + //$$ return super.keyPressed(KeyInput(keyCode, 0, modifiers.toInt())) + //#else + //$$ return super.keyPressed(keyCode, 0, modifiers.toInt()) + //#endif + //$$ } + //#else + try { + super.keyTyped(0.toChar(), keyCode) + } catch (e: IOException) { + e.printStackTrace() + } + //#endif + return false + } + + private fun superKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + //#if MC >= 1.15.2 + //$$ if (keyCode != 0) { + //#if MC >= 1.21.9 + //$$ return super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) + //#else + //$$ return super.keyReleased(keyCode, 0, modifiers.toInt()) + //#endif + //$$ } + //#endif + return false // No super + } + @Suppress("unused") // Becomes used if the child class is an instance of [ConsumableInputHandler] fun uSuperConsumableInputHandler(): ConsumableInputHandler = object : ConsumableInputHandler { override fun uSuperConsumableInputHandler(): ConsumableInputHandler = this - override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { - onMouseClicked(mouseX, mouseY, mouseButton) - return false - } + override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = + superMouseClicked(mouseX, mouseY, mouseButton) - override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean { - onMouseReleased(mouseX, mouseY, state) - return false - } + override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean = + superMouseReleased(mouseX, mouseY, state) - override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean { - onMouseDragged(x, y, clickedButton, timeSinceLastClick) - return false - } + override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean = + superMouseDragged(x, y, clickedButton, timeSinceLastClick) - override fun uMouseScrolled(delta: Double): Boolean { - onMouseScrolled(delta) - return false - } + override fun uMouseScrolled(delta: Double): Boolean = + superMouseScrolled(delta) - override fun uKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { - onKeyPressed(keyCode, typedChar, modifiers) - return false - } + override fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = + superCharTyped(typedChar, modifiers) - override fun uKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { - onKeyReleased(keyCode, typedChar, modifiers) - return false - } + override fun uKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superKeyPressed(keyCode, modifiers) + + override fun uKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superKeyReleased(keyCode, modifiers) } /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. @@ -681,11 +737,14 @@ abstract class UScreen( fun uMouseScrolled(delta: Double): Boolean = uSuperConsumableInputHandler().uMouseScrolled(delta) - fun uKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperConsumableInputHandler().uKeyPressed(keyCode, typedChar, modifiers) + fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperConsumableInputHandler().uCharTyped(typedChar, modifiers) + + fun uKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperConsumableInputHandler().uKeyPressed(keyCode, modifiers) - fun uKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperConsumableInputHandler().uKeyReleased(keyCode, typedChar, modifiers) + fun uKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperConsumableInputHandler().uKeyReleased(keyCode, modifiers) } companion object { From 73e8e284b42520bcbd3c0f6c951769f22f8724cc Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 10 Mar 2026 22:00:28 +1000 Subject: [PATCH 09/59] missed preprocessor block changes Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 779d8568..46f11279 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -147,7 +147,7 @@ abstract class UScreen( //$$ //$$ final override fun keyReleased(input: KeyInput): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ return it.uKeyReleased(input.key, input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) @@ -164,8 +164,8 @@ abstract class UScreen( //$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) //$$ } else if (Character.isValidCodePoint(codepoint)) { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) or - //$$ it.uKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) + //$$ return it.uCharTyped(Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) or + //$$ it.uCharTyped(Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) @@ -236,7 +236,7 @@ abstract class UScreen( //$$ //$$ final override fun keyReleased(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ return it.uKeyReleased(keyCode, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) From 7b3d1837bc94ddbe149bfbe1859681086a41ed8c Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 10 Mar 2026 22:00:44 +1000 Subject: [PATCH 10/59] api changes Linear: EM-1645 --- api/UniversalCraft.api | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index 693ec405..bd37991b 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -1057,8 +1057,9 @@ public final class gg/essential/universal/UScreen$Companion { } public abstract interface class gg/essential/universal/UScreen$ConsumableInputHandler { - public fun uKeyPressed (ICLgg/essential/universal/UKeyboard$Modifiers;)Z - public fun uKeyReleased (ICLgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uCharTyped (CLgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uKeyPressed (ILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uKeyReleased (ILgg/essential/universal/UKeyboard$Modifiers;)Z public fun uMouseClicked (DDI)Z public fun uMouseDragged (DDIJ)Z public fun uMouseReleased (DDI)Z From 705f7108f519dd605aa951ac579377f637a7d387 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 10 Mar 2026 22:15:28 +1000 Subject: [PATCH 11/59] Review: protect field Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 46f11279..e2ff3d92 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -53,7 +53,7 @@ abstract class UScreen( private var guiScaleToRestore = -1 private var restoringGuiScale = false private val screenToRestore: GuiScreen? = if (restoreCurrentGuiOnClose) currentScreen else null - var consumableInputHandler: ConsumableInputHandler? = this as? ConsumableInputHandler + protected var consumableInputHandler: ConsumableInputHandler? = this as? ConsumableInputHandler //#if MC>=12106 //$$ // Background is now draw from the final `renderWithTooltip` method, before we ever get control, so we need //$$ // to suppress by default and can only allow during `onDrawScreen`. From b235141e4ac9e97c166ef065c681609f39389cd4 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 10 Mar 2026 22:25:29 +1000 Subject: [PATCH 12/59] api change Linear: EM-1645 --- api/UniversalCraft.api | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index bd37991b..ef4ede68 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -849,7 +849,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public fun (ZLgg/essential/universal/GuiScale;)V public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screens/Screen;)V - public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screens/Screen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -893,7 +893,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge public final fun renderBackground (Lcom/mojang/blaze3d/vertex/PoseStack;I)V public final fun restorePreviousScreen ()V - public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V @@ -916,7 +916,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric,1.21.6-fabric,1.21.7-fabric public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screen/Screen;)V - public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screen/Screen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -985,7 +985,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric public final fun renderBackground (Lnet/minecraft/client/util/math/MatrixStack;I)V public final fun restorePreviousScreen ()V - public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V @@ -1006,7 +1006,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public static final fun displayScreen (Lnet/minecraft/client/gui/GuiScreen;)V public final fun drawScreen (IIF)V public final fun drawWorldBackground (I)V - public final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/GuiScreen; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @@ -1033,7 +1033,7 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public fun onScreenClose ()V public fun onTick ()V public final fun restorePreviousScreen ()V - public final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; From 2097acfe45e0f7d212ac6652c3f08085b98daf22 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 20:33:29 +1000 Subject: [PATCH 13/59] Review: drop consumable prefix Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index e2ff3d92..48754d1f 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -53,7 +53,7 @@ abstract class UScreen( private var guiScaleToRestore = -1 private var restoringGuiScale = false private val screenToRestore: GuiScreen? = if (restoreCurrentGuiOnClose) currentScreen else null - protected var consumableInputHandler: ConsumableInputHandler? = this as? ConsumableInputHandler + protected var inputHandler: InputHandler? = this as? InputHandler //#if MC>=12106 //$$ // Background is now draw from the final `renderWithTooltip` method, before we ever get control, so we need //$$ // to suppress by default and can only allow during `onDrawScreen`. @@ -354,24 +354,24 @@ abstract class UScreen( } final override fun keyTyped(typedChar: Char, keyCode: Int) { - consumableInputHandler?.let { + inputHandler?.let { val handled = it.uKeyPressed(keyCode, UKeyboard.getModifiers()) if (!handled) it.uCharTyped(typedChar, UKeyboard.getModifiers()) } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - consumableInputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) + inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) ?: onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - consumableInputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) + inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) ?: onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - consumableInputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) + inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } @@ -379,7 +379,7 @@ abstract class UScreen( super.handleMouseInput() val scrollDelta = Mouse.getEventDWheel() if (scrollDelta != 0) { - consumableInputHandler?.uMouseScrolled(scrollDelta.toDouble()) + inputHandler?.uMouseScrolled(scrollDelta.toDouble()) ?: onMouseScrolled(scrollDelta.toDouble()) } } @@ -687,8 +687,8 @@ abstract class UScreen( } @Suppress("unused") // Becomes used if the child class is an instance of [ConsumableInputHandler] - fun uSuperConsumableInputHandler(): ConsumableInputHandler = object : ConsumableInputHandler { - override fun uSuperConsumableInputHandler(): ConsumableInputHandler = this + fun uSuperInputHandler(): InputHandler = object : InputHandler { + override fun uSuperInputHandler(): InputHandler = this override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = superMouseClicked(mouseX, mouseY, mouseButton) @@ -722,29 +722,29 @@ abstract class UScreen( * To aid this, [UScreen] already implements `uSuperConsumableInputHandler()` itself which, by default, defers to the * original non-returning functions. So you only need to override the functions you actually want to consume. */ - interface ConsumableInputHandler { - fun uSuperConsumableInputHandler(): ConsumableInputHandler + interface InputHandler { + fun uSuperInputHandler(): InputHandler fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = - uSuperConsumableInputHandler().uMouseClicked(mouseX, mouseY, mouseButton) + uSuperInputHandler().uMouseClicked(mouseX, mouseY, mouseButton) fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean = - uSuperConsumableInputHandler().uMouseReleased(mouseX, mouseY, state) + uSuperInputHandler().uMouseReleased(mouseX, mouseY, state) fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean = - uSuperConsumableInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick) + uSuperInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick) fun uMouseScrolled(delta: Double): Boolean = - uSuperConsumableInputHandler().uMouseScrolled(delta) + uSuperInputHandler().uMouseScrolled(delta) fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperConsumableInputHandler().uCharTyped(typedChar, modifiers) + uSuperInputHandler().uCharTyped(typedChar, modifiers) fun uKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperConsumableInputHandler().uKeyPressed(keyCode, modifiers) + uSuperInputHandler().uKeyPressed(keyCode, modifiers) fun uKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperConsumableInputHandler().uKeyReleased(keyCode, modifiers) + uSuperInputHandler().uKeyReleased(keyCode, modifiers) } companion object { From db1fdc366520bdd755efe7d787094802e6c9b93d Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 20:40:26 +1000 Subject: [PATCH 14/59] Review: pass scancode Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 48754d1f..4fed352b 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -138,7 +138,7 @@ abstract class UScreen( //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(input.key, input.modifiers.toModifiers()) + //$$ return it.uKeyPressed(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) @@ -147,7 +147,7 @@ abstract class UScreen( //$$ //$$ final override fun keyReleased(input: KeyInput): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyReleased(input.key, input.modifiers.toModifiers()) + //$$ return it.uKeyReleased(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ //$$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) @@ -227,7 +227,7 @@ abstract class UScreen( //#else //$$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyPressed(keyCode, modifierCode.toModifiers()) + //$$ return it.uKeyPressed(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) @@ -236,7 +236,7 @@ abstract class UScreen( //$$ //$$ final override fun keyReleased(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uKeyReleased(keyCode, modifierCode.toModifiers()) + //$$ return it.uKeyReleased(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) @@ -355,7 +355,7 @@ abstract class UScreen( final override fun keyTyped(typedChar: Char, keyCode: Int) { inputHandler?.let { - val handled = it.uKeyPressed(keyCode, UKeyboard.getModifiers()) + val handled = it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) if (!handled) it.uCharTyped(typedChar, UKeyboard.getModifiers()) } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } @@ -503,7 +503,7 @@ abstract class UScreen( } open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { - superKeyReleased(keyCode, modifiers) + superKeyReleased(keyCode, 0 /* temp */, modifiers) } open fun onMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int) { @@ -654,13 +654,13 @@ abstract class UScreen( //#endif } - private fun superKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.15.2 //$$ if (keyCode != 0) { //#if MC >= 1.21.9 - //$$ return super.keyPressed(KeyInput(keyCode, 0, modifiers.toInt())) + //$$ return super.keyPressed(KeyInput(keyCode, scanCode, modifiers.toInt())) //#else - //$$ return super.keyPressed(keyCode, 0, modifiers.toInt()) + //$$ return super.keyPressed(keyCode, scanCode, modifiers.toInt()) //#endif //$$ } //#else @@ -673,13 +673,13 @@ abstract class UScreen( return false } - private fun superKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.15.2 //$$ if (keyCode != 0) { //#if MC >= 1.21.9 - //$$ return super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) + //$$ return super.keyReleased(KeyInput(keyCode, scanCode, modifiers.toInt())) //#else - //$$ return super.keyReleased(keyCode, 0, modifiers.toInt()) + //$$ return super.keyReleased(keyCode, scanCode, modifiers.toInt()) //#endif //$$ } //#endif @@ -705,11 +705,11 @@ abstract class UScreen( override fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = superCharTyped(typedChar, modifiers) - override fun uKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - superKeyPressed(keyCode, modifiers) + override fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superKeyPressed(keyCode, scanCode, modifiers) - override fun uKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - superKeyReleased(keyCode, modifiers) + override fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superKeyReleased(keyCode, scanCode, modifiers) } /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. @@ -740,11 +740,11 @@ abstract class UScreen( fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = uSuperInputHandler().uCharTyped(typedChar, modifiers) - fun uKeyPressed(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperInputHandler().uKeyPressed(keyCode, modifiers) + fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uKeyPressed(keyCode, scanCode, modifiers) - fun uKeyReleased(keyCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperInputHandler().uKeyReleased(keyCode, modifiers) + fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uKeyReleased(keyCode, scanCode, modifiers) } companion object { From eafc88b8a43afe36100c96ea3b17e82b44e271cc Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 20:50:40 +1000 Subject: [PATCH 15/59] Review: use codepoint Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 4fed352b..2cf3b1c6 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -156,18 +156,13 @@ abstract class UScreen( //$$ //$$ final override fun charTyped(input: CharInput): Boolean { //$$ val codepoint = input.codepoint - //$$ if (Character.isBmpCodePoint(codepoint)) { - //$$ consumableInputHandler?.let { - //$$ return it.uCharTyped(input.codepoint.toChar(), input.modifiers.toModifiers()) - //$$ } + //$$ consumableInputHandler?.let { + //$$ return it.uCharTyped(codepoint, input.modifiers.toModifiers()) + //$$ } //$$ + //$$ if (Character.isBmpCodePoint(codepoint)) { //$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) //$$ } else if (Character.isValidCodePoint(codepoint)) { - //$$ consumableInputHandler?.let { - //$$ return it.uCharTyped(Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) or - //$$ it.uCharTyped(Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) - //$$ } - //$$ //$$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ } @@ -245,7 +240,7 @@ abstract class UScreen( //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { //$$ consumableInputHandler?.let { - //$$ return it.uCharTyped(char, modifierCode.toModifiers()) + //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()) //$$ } //$$ //$$ onKeyPressed(0, char, modifierCode.toModifiers()) @@ -356,7 +351,7 @@ abstract class UScreen( final override fun keyTyped(typedChar: Char, keyCode: Int) { inputHandler?.let { val handled = it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) - if (!handled) it.uCharTyped(typedChar, UKeyboard.getModifiers()) + if (!handled) it.uCharTyped(typedChar.code, UKeyboard.getModifiers()) } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } @@ -637,16 +632,14 @@ abstract class UScreen( //#endif } - private fun superCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean { - if (typedChar.isISOControl()) return false - + private fun superCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.charTyped(CharInput(typedChar.code, modifiers.toInt())) + //$$ return super.charTyped(CharInput(codepoint, modifiers.toInt())) //#elseif MC >= 1.15.2 - //$$ return super.charTyped(typedChar, modifiers.toInt()) + //$$ return super.charTyped(codepoint.toChar(), modifiers.toInt()) //#else try { - super.keyTyped(typedChar, 0) + super.keyTyped(codepoint.toChar(), 0) } catch (e: IOException) { e.printStackTrace() } @@ -702,8 +695,8 @@ abstract class UScreen( override fun uMouseScrolled(delta: Double): Boolean = superMouseScrolled(delta) - override fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = - superCharTyped(typedChar, modifiers) + override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superCharTyped(codepoint, modifiers) override fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = superKeyPressed(keyCode, scanCode, modifiers) @@ -737,8 +730,8 @@ abstract class UScreen( fun uMouseScrolled(delta: Double): Boolean = uSuperInputHandler().uMouseScrolled(delta) - fun uCharTyped(typedChar: Char, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperInputHandler().uCharTyped(typedChar, modifiers) + fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uCharTyped(codepoint, modifiers) fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = uSuperInputHandler().uKeyPressed(keyCode, scanCode, modifiers) From 716576d1cf4f649baf46a470c5cb80487bf01b44 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 20:51:21 +1000 Subject: [PATCH 16/59] missed comment renames Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 2cf3b1c6..4761af95 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -137,7 +137,7 @@ abstract class UScreen( //$$ //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uKeyPressed(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ @@ -146,7 +146,7 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun keyReleased(input: KeyInput): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uKeyReleased(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ @@ -156,7 +156,7 @@ abstract class UScreen( //$$ //$$ final override fun charTyped(input: CharInput): Boolean { //$$ val codepoint = input.codepoint - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uCharTyped(codepoint, input.modifiers.toModifiers()) //$$ } //$$ @@ -177,7 +177,7 @@ abstract class UScreen( //$$ lastDoubled = doubled //$$ if (click.button() == 1) lastClick = UMinecraft.getTime() //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseClicked(click.x, click.y, click.button()).also { //$$ lastMouseInput = null //$$ lastDoubled = null @@ -193,7 +193,7 @@ abstract class UScreen( //$$ final override fun mouseReleased(click: Click): Boolean { //$$ lastMouseInput = click.buttonInfo //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseReleased(click.x, click.y, click.button()).also { //$$ lastMouseInput = null //$$ } @@ -209,7 +209,7 @@ abstract class UScreen( //$$ lastDraggedDx = offsetX //$$ lastDraggedDy = offsetY //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick).also { //$$ lastMouseInput = null //$$ } @@ -221,7 +221,7 @@ abstract class UScreen( //$$ } //#else //$$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uKeyPressed(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ @@ -230,7 +230,7 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun keyReleased(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uKeyReleased(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ @@ -239,7 +239,7 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()) //$$ } //$$ @@ -251,7 +251,7 @@ abstract class UScreen( //$$ if (mouseButton == 1) //$$ lastClick = UMinecraft.getTime() //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton) //$$ } //$$ @@ -260,7 +260,7 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun mouseReleased(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton) //$$ } //$$ @@ -272,7 +272,7 @@ abstract class UScreen( //$$ lastDraggedDx = dx //$$ lastDraggedDy = dy //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) //$$ } //$$ @@ -290,7 +290,7 @@ abstract class UScreen( //$$ lastScrolledX = mouseX //$$ lastScrolledY = mouseY //$$ - //$$ consumableInputHandler?.let { + //$$ inputHandler?.let { //$$ return it.uMouseScrolled(delta) //$$ } //$$ @@ -679,7 +679,7 @@ abstract class UScreen( return false // No super } - @Suppress("unused") // Becomes used if the child class is an instance of [ConsumableInputHandler] + @Suppress("unused") // Becomes used if the child class is an instance of [inputHandler] fun uSuperInputHandler(): InputHandler = object : InputHandler { override fun uSuperInputHandler(): InputHandler = this @@ -711,8 +711,8 @@ abstract class UScreen( * On versions below 1.16, the boolean returns are not passed to Minecraft as they are not used, * the interface still replaces and executes the same for consistency. * - * [UScreen] automatically handles this if it's subclass implements this interface. (via `consumableInputHandler`) - * To aid this, [UScreen] already implements `uSuperConsumableInputHandler()` itself which, by default, defers to the + * [UScreen] automatically handles this if it's subclass implements this interface. (via `inputHandler`) + * To aid this, [UScreen] already implements `uSuperinputHandler()` itself which, by default, defers to the * original non-returning functions. So you only need to override the functions you actually want to consume. */ interface InputHandler { From 970674e593a2018f9b526358a15b8bc58d49ed2a Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 21:03:14 +1000 Subject: [PATCH 17/59] Review: pass modifiers Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 4761af95..cf32ebaf 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -178,7 +178,7 @@ abstract class UScreen( //$$ if (click.button() == 1) lastClick = UMinecraft.getTime() //$$ //$$ inputHandler?.let { - //$$ return it.uMouseClicked(click.x, click.y, click.button()).also { + //$$ return it.uMouseClicked(click.x, click.y, click.button(), click.modifiers().toModifiers()).also { //$$ lastMouseInput = null //$$ lastDoubled = null //$$ } @@ -194,7 +194,7 @@ abstract class UScreen( //$$ lastMouseInput = click.buttonInfo //$$ //$$ inputHandler?.let { - //$$ return it.uMouseReleased(click.x, click.y, click.button()).also { + //$$ return it.uMouseReleased(click.x, click.y, click.button(), click.modifiers().toModifiers()).also { //$$ lastMouseInput = null //$$ } //$$ } @@ -210,7 +210,7 @@ abstract class UScreen( //$$ lastDraggedDy = offsetY //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick).also { + //$$ return it.uMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick, click.modifiers().toModifiers()).also { //$$ lastMouseInput = null //$$ } //$$ } @@ -252,7 +252,7 @@ abstract class UScreen( //$$ lastClick = UMinecraft.getTime() //$$ //$$ inputHandler?.let { - //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton) + //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton, null) //$$ } //$$ //$$ onMouseClicked(mouseX, mouseY, mouseButton) @@ -261,7 +261,7 @@ abstract class UScreen( //$$ //$$ final override fun mouseReleased(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { //$$ inputHandler?.let { - //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton) + //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton, null) //$$ } //$$ //$$ onMouseReleased(mouseX, mouseY, mouseButton) @@ -273,7 +273,7 @@ abstract class UScreen( //$$ lastDraggedDy = dy //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) + //$$ return it.uMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick, null) //$$ } //$$ //$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) @@ -356,17 +356,17 @@ abstract class UScreen( } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) + inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton, null) ?: onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) + inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state, null) ?: onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) + inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick, null) ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } @@ -498,19 +498,19 @@ abstract class UScreen( } open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { - superKeyReleased(keyCode, 0 /* temp */, modifiers) + superKeyReleased(keyCode, 0 /* TODO */, modifiers) } open fun onMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int) { - superMouseClicked(mouseX, mouseY, mouseButton) + superMouseClicked(mouseX, mouseY, mouseButton, null /* TODO */) } open fun onMouseReleased(mouseX: Double, mouseY: Double, state: Int) { - superMouseReleased(mouseX, mouseY, state) + superMouseReleased(mouseX, mouseY, state, null /* TODO */) } open fun onMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long) { - superMouseDragged(x, y, clickedButton, timeSinceLastClick) + superMouseDragged(x, y, clickedButton, timeSinceLastClick, null /* TODO */) } open fun onMouseScrolled(delta: Double) { @@ -581,12 +581,12 @@ abstract class UScreen( onDrawBackground(tint) } - private fun superMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { + private fun superMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.15.2 //$$ if (mouseButton == 1) //$$ lastClick = UMinecraft.getTime() //#if MC >= 1.21.9 - //$$ return super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false) + //$$ return super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, modifiers.toInt())), lastDoubled ?: false) //#else //$$ return super.mouseClicked(mouseX, mouseY, mouseButton) //#endif @@ -600,9 +600,9 @@ abstract class UScreen( //#endif } - private fun superMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean { + private fun superMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0))) + //$$ return super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, modifiers.toInt()))) //#elseif MC >= 1.15.2 //$$ return super.mouseReleased(mouseX, mouseY, state) //#else @@ -611,9 +611,9 @@ abstract class UScreen( //#endif } - private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean { + private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy) + //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, modifiers.toInt())), lastDraggedDx, lastDraggedDy) //#elseif MC >= 1.15.2 //$$ return super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy) //#else @@ -683,14 +683,14 @@ abstract class UScreen( fun uSuperInputHandler(): InputHandler = object : InputHandler { override fun uSuperInputHandler(): InputHandler = this - override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = - superMouseClicked(mouseX, mouseY, mouseButton) + override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superMouseClicked(mouseX, mouseY, mouseButton, modifiers) - override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean = - superMouseReleased(mouseX, mouseY, state) + override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = + superMouseReleased(mouseX, mouseY, state, modifiers) - override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean = - superMouseDragged(x, y, clickedButton, timeSinceLastClick) + override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean = + superMouseDragged(x, y, clickedButton, timeSinceLastClick, modifiers) override fun uMouseScrolled(delta: Double): Boolean = superMouseScrolled(delta) @@ -718,14 +718,14 @@ abstract class UScreen( interface InputHandler { fun uSuperInputHandler(): InputHandler - fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean = - uSuperInputHandler().uMouseClicked(mouseX, mouseY, mouseButton) + fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uMouseClicked(mouseX, mouseY, mouseButton, modifiers) - fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int): Boolean = - uSuperInputHandler().uMouseReleased(mouseX, mouseY, state) + fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uMouseReleased(mouseX, mouseY, state, modifiers) - fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long): Boolean = - uSuperInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick) + fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean = + uSuperInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick, modifiers) fun uMouseScrolled(delta: Double): Boolean = uSuperInputHandler().uMouseScrolled(delta) From b89c0f6e068d2edff0d3dd67740d9fd3a43708e2 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 21:06:09 +1000 Subject: [PATCH 18/59] Review: revert original functions Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index cf32ebaf..8bb65d01 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -471,7 +471,6 @@ abstract class UScreen( onDrawScreen(mouseX, mouseY, partialTicks) } - // Merged keycode & character universal function for < 1.15 format compatibility, does not correlate to just 1 super call open fun onKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { //#if MC>=11502 //$$ if (keyCode != 0) { @@ -498,23 +497,61 @@ abstract class UScreen( } open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { - superKeyReleased(keyCode, 0 /* TODO */, modifiers) + //#if MC>=11502 + //$$ if (keyCode != 0) { + //#if MC>=12109 + //$$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) + //#else + //$$ super.keyReleased(keyCode, 0, modifiers.toInt()) + //#endif + //$$ } + //#endif } open fun onMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int) { - superMouseClicked(mouseX, mouseY, mouseButton, null /* TODO */) + //#if MC>=11502 + //$$ if (mouseButton == 1) + //$$ lastClick = UMinecraft.getTime() + //#if MC>=12109 + //$$ super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false) + //#else + //$$ super.mouseClicked(mouseX, mouseY, mouseButton) + //#endif + //#else + try { + super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) + } catch (e: IOException) { + e.printStackTrace() + } + //#endif } open fun onMouseReleased(mouseX: Double, mouseY: Double, state: Int) { - superMouseReleased(mouseX, mouseY, state, null /* TODO */) + //#if MC>=12109 + //$$ super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0))) + //#elseif MC>=11502 + //$$ super.mouseReleased(mouseX, mouseY, state) + //#else + super.mouseReleased(mouseX.toInt(), mouseY.toInt(), state) + //#endif } open fun onMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long) { - superMouseDragged(x, y, clickedButton, timeSinceLastClick, null /* TODO */) + //#if MC>=12109 + //$$ super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy) + //#elseif MC>=11502 + //$$ super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy) + //#else + super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick) + //#endif } open fun onMouseScrolled(delta: Double) { - superMouseScrolled(delta) + //#if MC>=12002 + //$$ super.mouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) + //#elseif MC>=11502 + //$$ super.mouseScrolled(lastScrolledX, lastScrolledY, delta) + //#endif } open fun onTick() { From cea00b832bf77aa463e4dd5f928c0cef4b8fb883 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 21:15:06 +1000 Subject: [PATCH 19/59] Review: remove timeSinceLastClick and add x/y offsets in modern function Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 8bb65d01..b9050b59 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -210,7 +210,7 @@ abstract class UScreen( //$$ lastDraggedDy = offsetY //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick, click.modifiers().toModifiers()).also { + //$$ return it.uMouseDragged(click.x, click.y, click.button(), click.modifiers().toModifiers(), offsetX, offsetY).also { //$$ lastMouseInput = null //$$ } //$$ } @@ -273,7 +273,7 @@ abstract class UScreen( //$$ lastDraggedDy = dy //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick, null) + //$$ return it.uMouseDragged(x, y, mouseButton, null, dx, dy) //$$ } //$$ //$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) @@ -366,7 +366,7 @@ abstract class UScreen( } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick, null) + inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, null, 0.0, 0.0) ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } @@ -648,13 +648,13 @@ abstract class UScreen( //#endif } - private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, modifiers.toInt())), lastDraggedDx, lastDraggedDy) + //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, modifiers.toInt())), offsetX, offsetY) //#elseif MC >= 1.15.2 - //$$ return super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy) + //$$ return super.mouseDragged(x, y, clickedButton, offsetX, offsetY) //#else - super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick) + super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, 0L) return false //#endif } @@ -726,8 +726,8 @@ abstract class UScreen( override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = superMouseReleased(mouseX, mouseY, state, modifiers) - override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean = - superMouseDragged(x, y, clickedButton, timeSinceLastClick, modifiers) + override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean = + superMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) override fun uMouseScrolled(delta: Double): Boolean = superMouseScrolled(delta) @@ -761,8 +761,8 @@ abstract class UScreen( fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = uSuperInputHandler().uMouseReleased(mouseX, mouseY, state, modifiers) - fun uMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long, modifiers: UKeyboard.Modifiers?): Boolean = - uSuperInputHandler().uMouseDragged(x, y, clickedButton, timeSinceLastClick, modifiers) + fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean = + uSuperInputHandler().uMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) fun uMouseScrolled(delta: Double): Boolean = uSuperInputHandler().uMouseScrolled(delta) From b3ab8f045d7407909436ee2641a40a360456ece1 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 22:59:11 +1000 Subject: [PATCH 20/59] Review: only pass valid keycodes and chars Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index b9050b59..46d965ac 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -350,8 +350,12 @@ abstract class UScreen( final override fun keyTyped(typedChar: Char, keyCode: Int) { inputHandler?.let { - val handled = it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) - if (!handled) it.uCharTyped(typedChar.code, UKeyboard.getModifiers()) + val handled = if (keyCode != 0) false else { + it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) + } + if (!handled && !typedChar.isISOControl()) { + it.uCharTyped(typedChar.code, UKeyboard.getModifiers()) + } } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } From 56ea5e73c1b3ecf74bb33587d028a8c7c3e930d8 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:02:11 +1000 Subject: [PATCH 21/59] Review: remove catches Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 46d965ac..620c8bb5 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -632,11 +632,7 @@ abstract class UScreen( //$$ return super.mouseClicked(mouseX, mouseY, mouseButton) //#endif //#else - try { - super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) - } catch (e: IOException) { - e.printStackTrace() - } + super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) return false //#endif } @@ -679,11 +675,7 @@ abstract class UScreen( //#elseif MC >= 1.15.2 //$$ return super.charTyped(codepoint.toChar(), modifiers.toInt()) //#else - try { - super.keyTyped(codepoint.toChar(), 0) - } catch (e: IOException) { - e.printStackTrace() - } + super.keyTyped(codepoint.toChar(), 0) return false //#endif } @@ -698,11 +690,7 @@ abstract class UScreen( //#endif //$$ } //#else - try { - super.keyTyped(0.toChar(), keyCode) - } catch (e: IOException) { - e.printStackTrace() - } + super.keyTyped(0.toChar(), keyCode) //#endif return false } From c0cdcb05d4b8d9b6cde97272efbf528716b3e9f3 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:03:51 +1000 Subject: [PATCH 22/59] Review: remove pre caught conditions Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 620c8bb5..505c72e9 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -681,31 +681,24 @@ abstract class UScreen( } private fun superKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { - //#if MC >= 1.15.2 - //$$ if (keyCode != 0) { - //#if MC >= 1.21.9 - //$$ return super.keyPressed(KeyInput(keyCode, scanCode, modifiers.toInt())) - //#else - //$$ return super.keyPressed(keyCode, scanCode, modifiers.toInt()) - //#endif - //$$ } + //#if MC >= 1.21.9 + //$$ return super.keyPressed(KeyInput(keyCode, scanCode, modifiers.toInt())) + //#elseif MC >= 1.15.2 + //$$ return super.keyPressed(keyCode, scanCode, modifiers.toInt()) //#else super.keyTyped(0.toChar(), keyCode) - //#endif return false + //#endif } private fun superKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { - //#if MC >= 1.15.2 - //$$ if (keyCode != 0) { - //#if MC >= 1.21.9 - //$$ return super.keyReleased(KeyInput(keyCode, scanCode, modifiers.toInt())) - //#else - //$$ return super.keyReleased(keyCode, scanCode, modifiers.toInt()) - //#endif - //$$ } - //#endif + //#if MC >= 1.21.9 + //$$ return super.keyReleased(KeyInput(keyCode, scanCode, modifiers.toInt())) + //#elseif MC >= 1.15.2 + //$$ return super.keyReleased(keyCode, scanCode, modifiers.toInt()) + //#else return false // No super + //#endif } @Suppress("unused") // Becomes used if the child class is an instance of [inputHandler] From accfa3ca2c805b6d3a0094717e75cc30b4be0626 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:11:19 +1000 Subject: [PATCH 23/59] Review: remove nullable modifiers Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 505c72e9..dfada82d 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -252,7 +252,7 @@ abstract class UScreen( //$$ lastClick = UMinecraft.getTime() //$$ //$$ inputHandler?.let { - //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton, null) + //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton, UKeyboard.getModifiers()) //$$ } //$$ //$$ onMouseClicked(mouseX, mouseY, mouseButton) @@ -261,7 +261,7 @@ abstract class UScreen( //$$ //$$ final override fun mouseReleased(mouseX: Double, mouseY: Double, mouseButton: Int): Boolean { //$$ inputHandler?.let { - //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton, null) + //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton, UKeyboard.getModifiers()) //$$ } //$$ //$$ onMouseReleased(mouseX, mouseY, mouseButton) @@ -273,7 +273,7 @@ abstract class UScreen( //$$ lastDraggedDy = dy //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(x, y, mouseButton, null, dx, dy) + //$$ return it.uMouseDragged(x, y, mouseButton, UKeyboard.getModifiers(), dx, dy) //$$ } //$$ //$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) @@ -360,17 +360,17 @@ abstract class UScreen( } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton, null) + inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton, UKeyboard.getModifiers()) ?: onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state, null) + inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state, UKeyboard.getModifiers()) ?: onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, null, 0.0, 0.0) + inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, UKeyboard.getModifiers(), 0.0, 0.0) ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } @@ -705,25 +705,25 @@ abstract class UScreen( fun uSuperInputHandler(): InputHandler = object : InputHandler { override fun uSuperInputHandler(): InputHandler = this - override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean = + override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers): Boolean = superMouseClicked(mouseX, mouseY, mouseButton, modifiers) - override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = + override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers): Boolean = superMouseReleased(mouseX, mouseY, state, modifiers) - override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean = + override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = superMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) override fun uMouseScrolled(delta: Double): Boolean = superMouseScrolled(delta) - override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean = + override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = superCharTyped(codepoint, modifiers) - override fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + override fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = superKeyPressed(keyCode, scanCode, modifiers) - override fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + override fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = superKeyReleased(keyCode, scanCode, modifiers) } @@ -740,25 +740,25 @@ abstract class UScreen( interface InputHandler { fun uSuperInputHandler(): InputHandler - fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean = + fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uMouseClicked(mouseX, mouseY, mouseButton, modifiers) - fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean = + fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uMouseReleased(mouseX, mouseY, state, modifiers) - fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean = + fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = uSuperInputHandler().uMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) fun uMouseScrolled(delta: Double): Boolean = uSuperInputHandler().uMouseScrolled(delta) - fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean = + fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uCharTyped(codepoint, modifiers) - fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uKeyPressed(keyCode, scanCode, modifiers) - fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean = + fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uKeyReleased(keyCode, scanCode, modifiers) } From 77134dc3b4cb19b8318352a8e0bd01eb4a748647 Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:17:28 +1000 Subject: [PATCH 24/59] Review: parameter name nits Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index dfada82d..0f978283 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -622,39 +622,39 @@ abstract class UScreen( onDrawBackground(tint) } - private fun superMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.15.2 - //$$ if (mouseButton == 1) + //$$ if (button == 1) //$$ lastClick = UMinecraft.getTime() //#if MC >= 1.21.9 - //$$ return super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, modifiers.toInt())), lastDoubled ?: false) + //$$ return super.mouseClicked(Click(x, y, MouseInput(button, modifiers.toInt())), lastDoubled ?: false) //#else - //$$ return super.mouseClicked(mouseX, mouseY, mouseButton) + //$$ return super.mouseClicked(x, y, button) //#endif //#else - super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton) + super.mouseClicked(x.toInt(), y.toInt(), button) return false //#endif } - private fun superMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, modifiers.toInt()))) + //$$ return super.mouseReleased(Click(x, y, MouseInput(button, modifiers.toInt()))) //#elseif MC >= 1.15.2 - //$$ return super.mouseReleased(mouseX, mouseY, state) + //$$ return super.mouseReleased(x, y, button) //#else - super.mouseReleased(mouseX.toInt(), mouseY.toInt(), state) + super.mouseReleased(x.toInt(), y.toInt(), button) return false //#endif } - private fun superMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean { + private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseDragged(Click(x, y, MouseInput(clickedButton, modifiers.toInt())), offsetX, offsetY) + //$$ return super.mouseDragged(Click(x, y, MouseInput(button, modifiers.toInt())), offsetX, offsetY) //#elseif MC >= 1.15.2 - //$$ return super.mouseDragged(x, y, clickedButton, offsetX, offsetY) + //$$ return super.mouseDragged(x, y, button, offsetX, offsetY) //#else - super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, 0L) + super.mouseClickMove(x.toInt(), y.toInt(), button, 0L) return false //#endif } @@ -680,22 +680,22 @@ abstract class UScreen( //#endif } - private fun superKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.keyPressed(KeyInput(keyCode, scanCode, modifiers.toInt())) + //$$ return super.keyPressed(KeyInput(key, scanCode, modifiers.toInt())) //#elseif MC >= 1.15.2 - //$$ return super.keyPressed(keyCode, scanCode, modifiers.toInt()) + //$$ return super.keyPressed(key, scanCode, modifiers.toInt()) //#else - super.keyTyped(0.toChar(), keyCode) + super.keyTyped(0.toChar(), key) return false //#endif } - private fun superKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.keyReleased(KeyInput(keyCode, scanCode, modifiers.toInt())) + //$$ return super.keyReleased(KeyInput(key, scanCode, modifiers.toInt())) //#elseif MC >= 1.15.2 - //$$ return super.keyReleased(keyCode, scanCode, modifiers.toInt()) + //$$ return super.keyReleased(key, scanCode, modifiers.toInt()) //#else return false // No super //#endif @@ -705,14 +705,14 @@ abstract class UScreen( fun uSuperInputHandler(): InputHandler = object : InputHandler { override fun uSuperInputHandler(): InputHandler = this - override fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers): Boolean = - superMouseClicked(mouseX, mouseY, mouseButton, modifiers) + override fun uMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + superMouseClicked(x, y, button, modifiers) - override fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers): Boolean = - superMouseReleased(mouseX, mouseY, state, modifiers) + override fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + superMouseReleased(x, y, button, modifiers) - override fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = - superMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) + override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = + superMouseDragged(x, y, button, modifiers, offsetX, offsetY) override fun uMouseScrolled(delta: Double): Boolean = superMouseScrolled(delta) @@ -720,11 +720,11 @@ abstract class UScreen( override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = superCharTyped(codepoint, modifiers) - override fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = - superKeyPressed(keyCode, scanCode, modifiers) + override fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + superKeyPressed(key, scanCode, modifiers) - override fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = - superKeyReleased(keyCode, scanCode, modifiers) + override fun uKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + superKeyReleased(key, scanCode, modifiers) } /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. @@ -740,14 +740,14 @@ abstract class UScreen( interface InputHandler { fun uSuperInputHandler(): InputHandler - fun uMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int, modifiers: UKeyboard.Modifiers): Boolean = - uSuperInputHandler().uMouseClicked(mouseX, mouseY, mouseButton, modifiers) + fun uMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseClicked(x, y, button, modifiers) - fun uMouseReleased(mouseX: Double, mouseY: Double, state: Int, modifiers: UKeyboard.Modifiers): Boolean = - uSuperInputHandler().uMouseReleased(mouseX, mouseY, state, modifiers) + fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseReleased(x, y, button, modifiers) - fun uMouseDragged(x: Double, y: Double, clickedButton: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = - uSuperInputHandler().uMouseDragged(x, y, clickedButton, modifiers, offsetX, offsetY) + fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = + uSuperInputHandler().uMouseDragged(x, y, button, modifiers, offsetX, offsetY) fun uMouseScrolled(delta: Double): Boolean = uSuperInputHandler().uMouseScrolled(delta) @@ -755,11 +755,11 @@ abstract class UScreen( fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uCharTyped(codepoint, modifiers) - fun uKeyPressed(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = - uSuperInputHandler().uKeyPressed(keyCode, scanCode, modifiers) + fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uKeyPressed(key, scanCode, modifiers) - fun uKeyReleased(keyCode: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = - uSuperInputHandler().uKeyReleased(keyCode, scanCode, modifiers) + fun uKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uKeyReleased(key, scanCode, modifiers) } companion object { From f2d52e39d1996883409dbd4af3be184c44d0846a Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:19:35 +1000 Subject: [PATCH 25/59] Review: remove old code Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 0f978283..d1c7655a 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -623,14 +623,10 @@ abstract class UScreen( } private fun superMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { - //#if MC >= 1.15.2 - //$$ if (button == 1) - //$$ lastClick = UMinecraft.getTime() //#if MC >= 1.21.9 //$$ return super.mouseClicked(Click(x, y, MouseInput(button, modifiers.toInt())), lastDoubled ?: false) - //#else + //#elseif MC >= 1.15.2 //$$ return super.mouseClicked(x, y, button) - //#endif //#else super.mouseClicked(x.toInt(), y.toInt(), button) return false From 74df62795f95ade9901c2a70801af9302aaa831a Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:31:20 +1000 Subject: [PATCH 26/59] Review: kdocs Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index d1c7655a..f4d6fe5e 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -723,15 +723,12 @@ abstract class UScreen( superKeyReleased(key, scanCode, modifiers) } - /** Interface to replace [UScreen]'s input handling functions with consumable alternatives. - * I.e. The new input functions will return a boolean, indicating whether the input was consumed, to Minecraft. + /** Usually you can simply have your screen implement this interface, [UScreen] will then use it automatically. + * If you require more control, you can instead also manually set the [consumableInputHandler] property. + * [UScreen] provides a [uSuperConsumableInputHandler] implementation you can call from your handler. * * On versions below 1.16, the boolean returns are not passed to Minecraft as they are not used, * the interface still replaces and executes the same for consistency. - * - * [UScreen] automatically handles this if it's subclass implements this interface. (via `inputHandler`) - * To aid this, [UScreen] already implements `uSuperinputHandler()` itself which, by default, defers to the - * original non-returning functions. So you only need to override the functions you actually want to consume. */ interface InputHandler { fun uSuperInputHandler(): InputHandler From c70ade69059ebe61252125c98091e4ebc07eaafe Mon Sep 17 00:00:00 2001 From: Traben Date: Wed, 18 Mar 2026 23:43:59 +1000 Subject: [PATCH 27/59] Review: deprecation message Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index f4d6fe5e..f9b49bc9 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -31,6 +31,8 @@ import java.io.IOException //#endif +private const val INPUTHANDLER_DEP_MSG = "Implement [UScreen.InputHandler] for input functions that more closely adhere to newer MC input behaviour." + abstract class UScreen( val restoreCurrentGuiOnClose: Boolean = false, open var newGuiScale: Int = -1, @@ -141,7 +143,7 @@ abstract class UScreen( //$$ return it.uKeyPressed(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ - //$$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers()) //$$ return false //$$ } //$$ @@ -150,7 +152,7 @@ abstract class UScreen( //$$ return it.uKeyReleased(input.key, input.scancode, input.modifiers.toModifiers()) //$$ } //$$ - //$$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers()) //$$ return false //$$ } //$$ @@ -161,10 +163,10 @@ abstract class UScreen( //$$ } //$$ //$$ if (Character.isBmpCodePoint(codepoint)) { - //$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers()) //$$ } else if (Character.isValidCodePoint(codepoint)) { - //$$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) - //$$ onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers()) //$$ } //$$ return false //$$ } @@ -184,7 +186,7 @@ abstract class UScreen( //$$ } //$$ } //$$ - //$$ onMouseClicked(click.x, click.y, click.button()) + //$$ @Suppress("DEPRECATION") onMouseClicked(click.x, click.y, click.button()) //$$ lastMouseInput = null //$$ lastDoubled = null //$$ return false @@ -199,7 +201,7 @@ abstract class UScreen( //$$ } //$$ } //$$ - //$$ onMouseReleased(click.x, click.y, click.button()) + //$$ @Suppress("DEPRECATION") onMouseReleased(click.x, click.y, click.button()) //$$ lastMouseInput = null //$$ return false //$$ } @@ -215,7 +217,7 @@ abstract class UScreen( //$$ } //$$ } //$$ - //$$ onMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick) + //$$ @Suppress("DEPRECATION") onMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick) //$$ lastMouseInput = null //$$ return false //$$ } @@ -225,7 +227,7 @@ abstract class UScreen( //$$ return it.uKeyPressed(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ - //$$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers()) //$$ return false //$$ } //$$ @@ -234,7 +236,7 @@ abstract class UScreen( //$$ return it.uKeyReleased(keyCode, scanCode, modifierCode.toModifiers()) //$$ } //$$ - //$$ onKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyReleased(keyCode, 0.toChar(), modifierCode.toModifiers()) //$$ return false //$$ } //$$ @@ -243,7 +245,7 @@ abstract class UScreen( //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()) //$$ } //$$ - //$$ onKeyPressed(0, char, modifierCode.toModifiers()) + //$$ @Suppress("DEPRECATION") onKeyPressed(0, char, modifierCode.toModifiers()) //$$ return false //$$ } //$$ @@ -255,7 +257,7 @@ abstract class UScreen( //$$ return it.uMouseClicked(mouseX, mouseY, mouseButton, UKeyboard.getModifiers()) //$$ } //$$ - //$$ onMouseClicked(mouseX, mouseY, mouseButton) + //$$ @Suppress("DEPRECATION") onMouseClicked(mouseX, mouseY, mouseButton) //$$ return false //$$ } //$$ @@ -264,7 +266,7 @@ abstract class UScreen( //$$ return it.uMouseReleased(mouseX, mouseY, mouseButton, UKeyboard.getModifiers()) //$$ } //$$ - //$$ onMouseReleased(mouseX, mouseY, mouseButton) + //$$ @Suppress("DEPRECATION") onMouseReleased(mouseX, mouseY, mouseButton) //$$ return false //$$ } //$$ @@ -276,7 +278,7 @@ abstract class UScreen( //$$ return it.uMouseDragged(x, y, mouseButton, UKeyboard.getModifiers(), dx, dy) //$$ } //$$ - //$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) + //$$ @Suppress("DEPRECATION") onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) //$$ return false //$$ } //#endif @@ -294,7 +296,7 @@ abstract class UScreen( //$$ return it.uMouseScrolled(delta) //$$ } //$$ - //$$ onMouseScrolled(delta) + //$$ @Suppress("DEPRECATION") onMouseScrolled(delta) //$$ return false //$$ } //$$ @@ -356,22 +358,22 @@ abstract class UScreen( if (!handled && !typedChar.isISOControl()) { it.uCharTyped(typedChar.code, UKeyboard.getModifiers()) } - } ?: onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + } ?: @Suppress("DEPRECATION") onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton, UKeyboard.getModifiers()) - ?: onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) + ?: @Suppress("DEPRECATION") onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state, UKeyboard.getModifiers()) - ?: onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) + ?: @Suppress("DEPRECATION") onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, UKeyboard.getModifiers(), 0.0, 0.0) - ?: onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) + ?: @Suppress("DEPRECATION") onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } final override fun handleMouseInput() { @@ -379,7 +381,7 @@ abstract class UScreen( val scrollDelta = Mouse.getEventDWheel() if (scrollDelta != 0) { inputHandler?.uMouseScrolled(scrollDelta.toDouble()) - ?: onMouseScrolled(scrollDelta.toDouble()) + ?: @Suppress("DEPRECATION") onMouseScrolled(scrollDelta.toDouble()) } } @@ -475,6 +477,7 @@ abstract class UScreen( onDrawScreen(mouseX, mouseY, partialTicks) } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { //#if MC>=11502 //$$ if (keyCode != 0) { @@ -500,6 +503,7 @@ abstract class UScreen( //#endif } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { //#if MC>=11502 //$$ if (keyCode != 0) { @@ -512,6 +516,7 @@ abstract class UScreen( //#endif } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onMouseClicked(mouseX: Double, mouseY: Double, mouseButton: Int) { //#if MC>=11502 //$$ if (mouseButton == 1) @@ -530,6 +535,7 @@ abstract class UScreen( //#endif } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onMouseReleased(mouseX: Double, mouseY: Double, state: Int) { //#if MC>=12109 //$$ super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0))) @@ -540,6 +546,7 @@ abstract class UScreen( //#endif } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long) { //#if MC>=12109 //$$ super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy) @@ -550,6 +557,7 @@ abstract class UScreen( //#endif } + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onMouseScrolled(delta: Double) { //#if MC>=12002 //$$ super.mouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) From 82b82a1d9ac7b50abd86ecab063f07856486a490 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 00:08:29 +1000 Subject: [PATCH 28/59] Review: new mouse scroll method Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 3a8d5392..7df95b37 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -297,7 +297,7 @@ abstract class UScreen( //$$ lastScrolledY = mouseY //$$ //$$ inputHandler?.let { - //$$ return it.uMouseScrolled(delta) + //$$ return it.uMouseScrolled(mouseX, mouseY, lastScrolledDX, delta) //$$ } //$$ //$$ @Suppress("DEPRECATION") onMouseScrolled(delta) @@ -384,7 +384,9 @@ abstract class UScreen( super.handleMouseInput() val scrollDelta = Mouse.getEventDWheel() if (scrollDelta != 0) { - inputHandler?.uMouseScrolled(scrollDelta.toDouble()) + inputHandler?.uMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, 0.0, + // Revert LWJGL 2 delta scaling, see onMouseScrolled(Double) for more info + scrollDelta / 120.0) ?: @Suppress("DEPRECATION") onMouseScrolled(scrollDelta.toDouble()) } } @@ -563,7 +565,6 @@ abstract class UScreen( //#endif } - @Deprecated(INPUTHANDLER_DEP_MSG) // This function receives the delta from both lwjgl 2 and lwjgl 3. // The deltas obtained from lwjgl 2 are scaled by a constant factor and thus much higher than the ones provided by lwjgl 3. @Deprecated("Provided `delta` values have different units depending on Minecraft versions.", ReplaceWith("onMouseScrolled(mouseX, mouseY, deltaHorizontal, deltaVertical)")) @@ -575,6 +576,7 @@ abstract class UScreen( // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/LinuxMouse.java#L48 // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/MacOSXNativeMouse.java#L53 // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/MouseEventQueue.java#L52 + @Suppress("DEPRECATION") onMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, 0.0, delta / 120.0) //#endif } @@ -582,6 +584,7 @@ abstract class UScreen( // Must be called with consistently scaled deltas on all mc/lwjgl versions. // This is to ensure a consistent scrolling experience across all versions. // See older function above this for further explanation. + @Deprecated(INPUTHANDLER_DEP_MSG) open fun onMouseScrolled(mouseX: Double, mouseY: Double, deltaHorizontal: Double, deltaVertical: Double) { //#if MC>=12002 //$$ super.mouseScrolled(mouseX, mouseY, deltaHorizontal, deltaVertical) @@ -687,11 +690,11 @@ abstract class UScreen( //#endif } - private fun superMouseScrolled(delta: Double): Boolean { + private fun superMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean { //#if MC >= 1.20.2 - //$$ return super.mouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) + //$$ return super.mouseScrolled(x, y, deltaHorizontal, deltaVertical) //#elseif MC >= 1.15.2 - //$$ return super.mouseScrolled(lastScrolledX, lastScrolledY, delta) + //$$ return super.mouseScrolled(x, y, deltaVertical) //#else return false // No super //#endif @@ -742,8 +745,8 @@ abstract class UScreen( override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = superMouseDragged(x, y, button, modifiers, offsetX, offsetY) - override fun uMouseScrolled(delta: Double): Boolean = - superMouseScrolled(delta) + override fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = + superMouseScrolled(x, y, deltaHorizontal, deltaVertical) override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = superCharTyped(codepoint, modifiers) @@ -774,8 +777,11 @@ abstract class UScreen( fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = uSuperInputHandler().uMouseDragged(x, y, button, modifiers, offsetX, offsetY) - fun uMouseScrolled(delta: Double): Boolean = - uSuperInputHandler().uMouseScrolled(delta) + // Must be called with consistently scaled deltas on all mc/lwjgl versions. + // This is to ensure a consistent scrolling experience across all versions. + // See onMouseScrolled(Double) for further explanation. + fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = + uSuperInputHandler().uMouseScrolled(x, y, deltaHorizontal, deltaVertical) fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uCharTyped(codepoint, modifiers) From 7fd377c6b06d94f1ddb66d4122ccbe3db6961379 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 00:19:42 +1000 Subject: [PATCH 29/59] missing 26.1 block Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 7df95b37..2b7947c7 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -701,7 +701,9 @@ abstract class UScreen( } private fun superCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean { - //#if MC >= 1.21.9 + //#if MC >= 26.1 + //$$ return super.charTyped(CharacterEvent(codepoint)) + //#elseif MC >= 1.21.9 //$$ return super.charTyped(CharInput(codepoint, modifiers.toInt())) //#elseif MC >= 1.15.2 //$$ return super.charTyped(codepoint.toChar(), modifiers.toInt()) From c0e344c726a9d8656dbebb696325002ad7b29d2e Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 00:19:54 +1000 Subject: [PATCH 30/59] api bump Linear: EM-1645 --- api/UniversalCraft.api | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index fc7fcf55..6efe7ab1 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -860,12 +860,12 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge,1.20.4-neoforge,1.20.6-forge,1.20.6-neoforge,1.21-forge,1.21-neoforge,1.21.3-forge,1.21.3-neoforge,1.21.4-forge,1.21.4-neoforge,1.21.5-forge,1.21.5-neoforge,1.21.7-forge,1.21.7-neoforge public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screens/Screen;)V - protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; @26.1-fabric public final fun extractBackground (Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V @26.1-fabric public final fun extractRenderState (Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screens/Screen; + protected final fun getInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z public fun getTitle ()Lnet/minecraft/network/chat/Component; @@ -924,11 +924,11 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge public final fun renderBackground (Lcom/mojang/blaze3d/vertex/PoseStack;I)V public final fun restorePreviousScreen ()V - protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setInputHandler (Lgg/essential/universal/UScreen$InputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V - public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + public final fun uSuperInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun updateGuiScale ()V } @@ -947,8 +947,8 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.16.2-forge,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric,1.21.3-fabric,1.21.4-fabric,1.21.5-fabric,1.21.6-fabric,1.21.7-fabric public final fun charTyped (CI)Z public static final fun displayScreen (Lnet/minecraft/client/gui/screen/Screen;)V - protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/screen/Screen; + protected final fun getInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z @1.16.2-forge @@ -1017,11 +1017,11 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ @1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric public final fun renderBackground (Lnet/minecraft/client/util/math/MatrixStack;I)V public final fun restorePreviousScreen ()V - protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setInputHandler (Lgg/essential/universal/UScreen$InputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V public final fun tick ()V - public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + public final fun uSuperInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun updateGuiScale ()V } @@ -1038,8 +1038,8 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public static final fun displayScreen (Lnet/minecraft/client/gui/GuiScreen;)V public final fun drawScreen (IIF)V public final fun drawWorldBackground (I)V - protected final fun getConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; public static final fun getCurrentScreen ()Lnet/minecraft/client/gui/GuiScreen; + protected final fun getInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun getNewGuiScale ()I public final fun getRestoreCurrentGuiOnClose ()Z public fun getUnlocalizedName ()Ljava/lang/String; @@ -1066,10 +1066,10 @@ public abstract class gg/essential/universal/UScreen : net/minecraft/client/gui/ public fun onScreenClose ()V public fun onTick ()V public final fun restorePreviousScreen ()V - protected final fun setConsumableInputHandler (Lgg/essential/universal/UScreen$ConsumableInputHandler;)V + protected final fun setInputHandler (Lgg/essential/universal/UScreen$InputHandler;)V public fun setNewGuiScale (I)V public fun setUnlocalizedName (Ljava/lang/String;)V - public final fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; + public final fun uSuperInputHandler ()Lgg/essential/universal/UScreen$InputHandler; public fun updateGuiScale ()V public final fun updateScreen ()V } @@ -1089,15 +1089,15 @@ public final class gg/essential/universal/UScreen$Companion { public final fun getCurrentScreen ()Lnet/minecraft/client/gui/GuiScreen; } -public abstract interface class gg/essential/universal/UScreen$ConsumableInputHandler { - public fun uCharTyped (CLgg/essential/universal/UKeyboard$Modifiers;)Z - public fun uKeyPressed (ILgg/essential/universal/UKeyboard$Modifiers;)Z - public fun uKeyReleased (ILgg/essential/universal/UKeyboard$Modifiers;)Z - public fun uMouseClicked (DDI)Z - public fun uMouseDragged (DDIJ)Z - public fun uMouseReleased (DDI)Z - public fun uMouseScrolled (D)Z - public abstract fun uSuperConsumableInputHandler ()Lgg/essential/universal/UScreen$ConsumableInputHandler; +public abstract interface class gg/essential/universal/UScreen$InputHandler { + public fun uCharTyped (ILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uKeyPressed (IILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uKeyReleased (IILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uMouseClicked (DDILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uMouseDragged (DDILgg/essential/universal/UKeyboard$Modifiers;DD)Z + public fun uMouseReleased (DDILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uMouseScrolled (DDDD)Z + public abstract fun uSuperInputHandler ()Lgg/essential/universal/UScreen$InputHandler; } public final class gg/essential/universal/USound { From 5da550e7b9a4acd50faa974451a14a1eb681be0a Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:11:50 +1000 Subject: [PATCH 31/59] Review: drop char modifiers Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 2b7947c7..82d1e267 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -137,6 +137,10 @@ abstract class UScreen( //#endif //$$ } //$$ + //#if MC < 26.1 && MC >= 1.15.2 + //$$ // Smuggle this value for use in super calls, where intermediate functions have dropped it to match 26.1+ + //$$ private var charModifiers = 0 + //#endif //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { //$$ inputHandler?.let { @@ -162,9 +166,14 @@ abstract class UScreen( //$$ val modifiers = 0.toModifiers() //#else //$$ val modifiers = input.modifiers.toModifiers() + //$$ charModifiers = input.modifiers //#endif //$$ inputHandler?.let { - //$$ return it.uCharTyped(codepoint, modifiers) + //$$ return it.uCharTyped(codepoint, modifiers).also { + //#if MC < 26.1 + //$$ charModifiers = 0 + //#endif + //$$ } //$$ } //$$ if (Character.isBmpCodePoint(codepoint)) { //$$ @Suppress("DEPRECATION") onKeyPressed(0, input.codepoint.toChar(), modifiers) @@ -172,6 +181,9 @@ abstract class UScreen( //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.highSurrogate(input.codepoint), modifiers) //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.lowSurrogate(input.codepoint), modifiers) //$$ } + //#if MC < 26.1 + //$$ charModifiers = 0 + //#endif //$$ return false //$$ } //$$ @@ -245,11 +257,13 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { + //$$ charModifiers = modifierCode //$$ inputHandler?.let { - //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()) + //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()).also { charModifiers = 0 } //$$ } //$$ //$$ @Suppress("DEPRECATION") onKeyPressed(0, char, modifierCode.toModifiers()) + //$$ charModifiers = 0 //$$ return false //$$ } //$$ @@ -360,7 +374,7 @@ abstract class UScreen( it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) } if (!handled && !typedChar.isISOControl()) { - it.uCharTyped(typedChar.code, UKeyboard.getModifiers()) + it.uCharTyped(typedChar.code) } } ?: @Suppress("DEPRECATION") onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) } @@ -700,13 +714,13 @@ abstract class UScreen( //#endif } - private fun superCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superCharTyped(codepoint: Int): Boolean { //#if MC >= 26.1 //$$ return super.charTyped(CharacterEvent(codepoint)) //#elseif MC >= 1.21.9 - //$$ return super.charTyped(CharInput(codepoint, modifiers.toInt())) + //$$ return super.charTyped(CharInput(codepoint, charModifiers)) //#elseif MC >= 1.15.2 - //$$ return super.charTyped(codepoint.toChar(), modifiers.toInt()) + //$$ return super.charTyped(codepoint.toChar(), charModifiers) //#else super.keyTyped(codepoint.toChar(), 0) return false @@ -750,8 +764,8 @@ abstract class UScreen( override fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = superMouseScrolled(x, y, deltaHorizontal, deltaVertical) - override fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = - superCharTyped(codepoint, modifiers) + override fun uCharTyped(codepoint: Int): Boolean = + superCharTyped(codepoint) override fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = superKeyPressed(key, scanCode, modifiers) @@ -785,8 +799,8 @@ abstract class UScreen( fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = uSuperInputHandler().uMouseScrolled(x, y, deltaHorizontal, deltaVertical) - fun uCharTyped(codepoint: Int, modifiers: UKeyboard.Modifiers): Boolean = - uSuperInputHandler().uCharTyped(codepoint, modifiers) + fun uCharTyped(codepoint: Int): Boolean = + uSuperInputHandler().uCharTyped(codepoint) fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uKeyPressed(key, scanCode, modifiers) From b0a244f84849127c24f53e002ecc5a58420e7c01 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:12:38 +1000 Subject: [PATCH 32/59] Review: use 0 scancode Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 82d1e267..924d11ad 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -371,7 +371,7 @@ abstract class UScreen( final override fun keyTyped(typedChar: Char, keyCode: Int) { inputHandler?.let { val handled = if (keyCode != 0) false else { - it.uKeyPressed(keyCode, UKeyboard.KEY_NONE, UKeyboard.getModifiers()) + it.uKeyPressed(keyCode, 0, UKeyboard.getModifiers()) } if (!handled && !typedChar.isISOControl()) { it.uCharTyped(typedChar.code) From 36f0f98a5924ae8251f1714449f8c05a3c90edc1 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:14:42 +1000 Subject: [PATCH 33/59] Review: fix renames in comments Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 924d11ad..d5f65358 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -748,7 +748,7 @@ abstract class UScreen( //#endif } - @Suppress("unused") // Becomes used if the child class is an instance of [inputHandler] + @Suppress("unused") // Becomes used if the child class is an instance of [InputHandler] fun uSuperInputHandler(): InputHandler = object : InputHandler { override fun uSuperInputHandler(): InputHandler = this @@ -775,8 +775,8 @@ abstract class UScreen( } /** Usually you can simply have your screen implement this interface, [UScreen] will then use it automatically. - * If you require more control, you can instead also manually set the [consumableInputHandler] property. - * [UScreen] provides a [uSuperConsumableInputHandler] implementation you can call from your handler. + * If you require more control, you can instead also manually set the [inputHandler] property. + * [UScreen] provides a [uSuperInputHandler] implementation you can call from your handler. * * On versions below 1.16, the boolean returns are not passed to Minecraft as they are not used, * the interface still replaces and executes the same for consistency. From 200b317073f32adcba79968367feb77191373d34 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:16:20 +1000 Subject: [PATCH 34/59] Review: fix indent Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index d5f65358..19bd2c86 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -529,11 +529,11 @@ abstract class UScreen( open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) { //#if MC>=11502 //$$ if (keyCode != 0) { - //#if MC>=12109 - //$$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) - //#else - //$$ super.keyReleased(keyCode, 0, modifiers.toInt()) - //#endif + //#if MC>=12109 + //$$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt())) + //#else + //$$ super.keyReleased(keyCode, 0, modifiers.toInt()) + //#endif //$$ } //#endif } From 8e699a3d131d9654acd1c3b6d8149f1e9224dbd2 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:16:59 +1000 Subject: [PATCH 35/59] Review: move supression Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 19bd2c86..b08d0b30 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -583,6 +583,7 @@ abstract class UScreen( // The deltas obtained from lwjgl 2 are scaled by a constant factor and thus much higher than the ones provided by lwjgl 3. @Deprecated("Provided `delta` values have different units depending on Minecraft versions.", ReplaceWith("onMouseScrolled(mouseX, mouseY, deltaHorizontal, deltaVertical)")) open fun onMouseScrolled(delta: Double) { + @Suppress("DEPRECATION") //#if MC>=11502 //$$ onMouseScrolled(lastScrolledX, lastScrolledY, lastScrolledDX, delta) //#else @@ -590,7 +591,6 @@ abstract class UScreen( // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/LinuxMouse.java#L48 // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/MacOSXNativeMouse.java#L53 // https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/MouseEventQueue.java#L52 - @Suppress("DEPRECATION") onMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, 0.0, delta / 120.0) //#endif } From 840458503276333f3d25f12abb29735162d70bc1 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:19:18 +1000 Subject: [PATCH 36/59] Review: remove dragged x and y params Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index b08d0b30..d0181f70 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -228,7 +228,7 @@ abstract class UScreen( //$$ lastDraggedDy = offsetY //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(click.x, click.y, click.button(), click.modifiers().toModifiers(), offsetX, offsetY).also { + //$$ return it.uMouseDragged(click.x, click.y, click.button(), click.modifiers().toModifiers()).also { //$$ lastMouseInput = null //$$ } //$$ } @@ -293,7 +293,7 @@ abstract class UScreen( //$$ lastDraggedDy = dy //$$ //$$ inputHandler?.let { - //$$ return it.uMouseDragged(x, y, mouseButton, UKeyboard.getModifiers(), dx, dy) + //$$ return it.uMouseDragged(x, y, mouseButton, UKeyboard.getModifiers()) //$$ } //$$ //$$ @Suppress("DEPRECATION") onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick) @@ -390,7 +390,7 @@ abstract class UScreen( } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, UKeyboard.getModifiers(), 0.0, 0.0) + inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } @@ -693,11 +693,11 @@ abstract class UScreen( //#endif } - private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?, offsetX: Double, offsetY: Double): Boolean { + private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { //#if MC >= 1.21.9 - //$$ return super.mouseDragged(Click(x, y, MouseInput(button, modifiers.toInt())), offsetX, offsetY) + //$$ return super.mouseDragged(Click(x, y, MouseInput(button, modifiers.toInt())), lastDraggedDx, lastDraggedDy) //#elseif MC >= 1.15.2 - //$$ return super.mouseDragged(x, y, button, offsetX, offsetY) + //$$ return super.mouseDragged(x, y, button, lastDraggedDx, lastDraggedDy) //#else super.mouseClickMove(x.toInt(), y.toInt(), button, 0L) return false @@ -758,8 +758,8 @@ abstract class UScreen( override fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = superMouseReleased(x, y, button, modifiers) - override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = - superMouseDragged(x, y, button, modifiers, offsetX, offsetY) + override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + superMouseDragged(x, y, button, modifiers) override fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = superMouseScrolled(x, y, deltaHorizontal, deltaVertical) @@ -790,8 +790,8 @@ abstract class UScreen( fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uMouseReleased(x, y, button, modifiers) - fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers, offsetX: Double, offsetY: Double): Boolean = - uSuperInputHandler().uMouseDragged(x, y, button, modifiers, offsetX, offsetY) + fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseDragged(x, y, button, modifiers) // Must be called with consistently scaled deltas on all mc/lwjgl versions. // This is to ensure a consistent scrolling experience across all versions. From c8a438c099218835fa563407b30bb0f80ff162c1 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:20:19 +1000 Subject: [PATCH 37/59] remove params from preprocessor blocks Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index d0181f70..e5d058c7 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -169,7 +169,7 @@ abstract class UScreen( //$$ charModifiers = input.modifiers //#endif //$$ inputHandler?.let { - //$$ return it.uCharTyped(codepoint, modifiers).also { + //$$ return it.uCharTyped(codepoint).also { //#if MC < 26.1 //$$ charModifiers = 0 //#endif @@ -259,7 +259,7 @@ abstract class UScreen( //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { //$$ charModifiers = modifierCode //$$ inputHandler?.let { - //$$ return it.uCharTyped(char.code, modifierCode.toModifiers()).also { charModifiers = 0 } + //$$ return it.uCharTyped(char.code).also { charModifiers = 0 } //$$ } //$$ //$$ @Suppress("DEPRECATION") onKeyPressed(0, char, modifierCode.toModifiers()) From 07ef250a7c1cc614e53e3bc55a166babfd5d2b7a Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:22:16 +1000 Subject: [PATCH 38/59] Review: param name change Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index e5d058c7..783d54a1 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -704,11 +704,11 @@ abstract class UScreen( //#endif } - private fun superMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean { + private fun superMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean { //#if MC >= 1.20.2 - //$$ return super.mouseScrolled(x, y, deltaHorizontal, deltaVertical) + //$$ return super.mouseScrolled(x, y, scrollX, scrollY) //#elseif MC >= 1.15.2 - //$$ return super.mouseScrolled(x, y, deltaVertical) + //$$ return super.mouseScrolled(x, y, scrollY) //#else return false // No super //#endif @@ -761,8 +761,8 @@ abstract class UScreen( override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = superMouseDragged(x, y, button, modifiers) - override fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = - superMouseScrolled(x, y, deltaHorizontal, deltaVertical) + override fun uMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean = + superMouseScrolled(x, y, scrollX, scrollY) override fun uCharTyped(codepoint: Int): Boolean = superCharTyped(codepoint) @@ -793,11 +793,11 @@ abstract class UScreen( fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = uSuperInputHandler().uMouseDragged(x, y, button, modifiers) - // Must be called with consistently scaled deltas on all mc/lwjgl versions. + // Must be called with consistently scaled scroll deltas on all mc/lwjgl versions. // This is to ensure a consistent scrolling experience across all versions. // See onMouseScrolled(Double) for further explanation. - fun uMouseScrolled(x: Double, y: Double, deltaHorizontal: Double, deltaVertical: Double): Boolean = - uSuperInputHandler().uMouseScrolled(x, y, deltaHorizontal, deltaVertical) + fun uMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean = + uSuperInputHandler().uMouseScrolled(x, y, scrollX, scrollY) fun uCharTyped(codepoint: Int): Boolean = uSuperInputHandler().uCharTyped(codepoint) From d1a5cd4feda6cc05d900e6e5723334b1c46901bf Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:23:00 +1000 Subject: [PATCH 39/59] Review: Modifiers? -> Modifiers Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 783d54a1..f0566bcc 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -671,7 +671,7 @@ abstract class UScreen( onDrawBackground(tint) } - private fun superMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseClicked(Click(x, y, MouseInput(button, modifiers.toInt())), lastDoubled ?: false) //#elseif MC >= 1.15.2 @@ -682,7 +682,7 @@ abstract class UScreen( //#endif } - private fun superMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseReleased(Click(x, y, MouseInput(button, modifiers.toInt()))) //#elseif MC >= 1.15.2 @@ -693,7 +693,7 @@ abstract class UScreen( //#endif } - private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseDragged(Click(x, y, MouseInput(button, modifiers.toInt())), lastDraggedDx, lastDraggedDy) //#elseif MC >= 1.15.2 @@ -727,7 +727,7 @@ abstract class UScreen( //#endif } - private fun superKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.keyPressed(KeyInput(key, scanCode, modifiers.toInt())) //#elseif MC >= 1.15.2 @@ -738,7 +738,7 @@ abstract class UScreen( //#endif } - private fun superKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers?): Boolean { + private fun superKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.keyReleased(KeyInput(key, scanCode, modifiers.toInt())) //#elseif MC >= 1.15.2 From 53fb6c72f4b5052efd4263124b8b20a2774906f1 Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:24:12 +1000 Subject: [PATCH 40/59] Review: @Suppress("unused") Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index f0566bcc..754d858e 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -671,6 +671,7 @@ abstract class UScreen( onDrawBackground(tint) } + @Suppress("unused") private fun superMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseClicked(Click(x, y, MouseInput(button, modifiers.toInt())), lastDoubled ?: false) @@ -682,6 +683,7 @@ abstract class UScreen( //#endif } + @Suppress("unused") private fun superMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseReleased(Click(x, y, MouseInput(button, modifiers.toInt()))) @@ -693,6 +695,7 @@ abstract class UScreen( //#endif } + @Suppress("unused") private fun superMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.mouseDragged(Click(x, y, MouseInput(button, modifiers.toInt())), lastDraggedDx, lastDraggedDy) @@ -704,6 +707,7 @@ abstract class UScreen( //#endif } + @Suppress("unused") private fun superMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean { //#if MC >= 1.20.2 //$$ return super.mouseScrolled(x, y, scrollX, scrollY) @@ -727,6 +731,7 @@ abstract class UScreen( //#endif } + @Suppress("unused") private fun superKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.keyPressed(KeyInput(key, scanCode, modifiers.toInt())) @@ -738,6 +743,7 @@ abstract class UScreen( //#endif } + @Suppress("unused") private fun superKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean { //#if MC >= 1.21.9 //$$ return super.keyReleased(KeyInput(key, scanCode, modifiers.toInt())) From 250088c34d7642604b1233b287a587073194923c Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 19 Mar 2026 23:27:27 +1000 Subject: [PATCH 41/59] API bump Linear: EM-1645 --- api/UniversalCraft.api | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index 6efe7ab1..f037ab1e 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -1090,11 +1090,11 @@ public final class gg/essential/universal/UScreen$Companion { } public abstract interface class gg/essential/universal/UScreen$InputHandler { - public fun uCharTyped (ILgg/essential/universal/UKeyboard$Modifiers;)Z + public fun uCharTyped (I)Z public fun uKeyPressed (IILgg/essential/universal/UKeyboard$Modifiers;)Z public fun uKeyReleased (IILgg/essential/universal/UKeyboard$Modifiers;)Z public fun uMouseClicked (DDILgg/essential/universal/UKeyboard$Modifiers;)Z - public fun uMouseDragged (DDILgg/essential/universal/UKeyboard$Modifiers;DD)Z + public fun uMouseDragged (DDILgg/essential/universal/UKeyboard$Modifiers;)Z public fun uMouseReleased (DDILgg/essential/universal/UKeyboard$Modifiers;)Z public fun uMouseScrolled (DDDD)Z public abstract fun uSuperInputHandler ()Lgg/essential/universal/UScreen$InputHandler; From 16bab9748754fcfdc5fba30b5e5aec0ad6affad7 Mon Sep 17 00:00:00 2001 From: Traben Date: Mon, 23 Mar 2026 23:48:48 +1000 Subject: [PATCH 42/59] Review: spacing Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 754d858e..600d7be1 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -170,9 +170,9 @@ abstract class UScreen( //#endif //$$ inputHandler?.let { //$$ return it.uCharTyped(codepoint).also { - //#if MC < 26.1 - //$$ charModifiers = 0 - //#endif + //#if MC < 26.1 + //$$ charModifiers = 0 + //#endif //$$ } //$$ } //$$ if (Character.isBmpCodePoint(codepoint)) { @@ -181,9 +181,9 @@ abstract class UScreen( //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.highSurrogate(input.codepoint), modifiers) //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.lowSurrogate(input.codepoint), modifiers) //$$ } - //#if MC < 26.1 - //$$ charModifiers = 0 - //#endif + //#if MC < 26.1 + //$$ charModifiers = 0 + //#endif //$$ return false //$$ } //$$ From 43a79054ea55996d8c95838c0b228fe2abb21dd8 Mon Sep 17 00:00:00 2001 From: Traben Date: Mon, 23 Mar 2026 23:50:47 +1000 Subject: [PATCH 43/59] Review: var usage Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 600d7be1..20e31a16 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -257,13 +257,12 @@ abstract class UScreen( //$$ } //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { - //$$ charModifiers = modifierCode //$$ inputHandler?.let { + //$$ charModifiers = modifierCode //$$ return it.uCharTyped(char.code).also { charModifiers = 0 } //$$ } //$$ //$$ @Suppress("DEPRECATION") onKeyPressed(0, char, modifierCode.toModifiers()) - //$$ charModifiers = 0 //$$ return false //$$ } //$$ From 3fd53199b91ed26b1df864c2a1e1aed98e26db0a Mon Sep 17 00:00:00 2001 From: Traben Date: Mon, 23 Mar 2026 23:51:47 +1000 Subject: [PATCH 44/59] Review: var name Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 20e31a16..e3b0500e 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -139,7 +139,7 @@ abstract class UScreen( //$$ //#if MC < 26.1 && MC >= 1.15.2 //$$ // Smuggle this value for use in super calls, where intermediate functions have dropped it to match 26.1+ - //$$ private var charModifiers = 0 + //$$ private var lastCharModifiers = 0 //#endif //#if MC>=12109 //$$ final override fun keyPressed(input: KeyInput): Boolean { @@ -166,12 +166,12 @@ abstract class UScreen( //$$ val modifiers = 0.toModifiers() //#else //$$ val modifiers = input.modifiers.toModifiers() - //$$ charModifiers = input.modifiers + //$$ lastCharModifiers = input.modifiers //#endif //$$ inputHandler?.let { //$$ return it.uCharTyped(codepoint).also { //#if MC < 26.1 - //$$ charModifiers = 0 + //$$ lastCharModifiers = 0 //#endif //$$ } //$$ } @@ -182,7 +182,7 @@ abstract class UScreen( //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.lowSurrogate(input.codepoint), modifiers) //$$ } //#if MC < 26.1 - //$$ charModifiers = 0 + //$$ lastCharModifiers = 0 //#endif //$$ return false //$$ } @@ -258,8 +258,8 @@ abstract class UScreen( //$$ //$$ final override fun charTyped(char: Char, modifierCode: Int): Boolean { //$$ inputHandler?.let { - //$$ charModifiers = modifierCode - //$$ return it.uCharTyped(char.code).also { charModifiers = 0 } + //$$ lastCharModifiers = modifierCode + //$$ return it.uCharTyped(char.code).also { lastCharModifiers = 0 } //$$ } //$$ //$$ @Suppress("DEPRECATION") onKeyPressed(0, char, modifierCode.toModifiers()) @@ -721,9 +721,9 @@ abstract class UScreen( //#if MC >= 26.1 //$$ return super.charTyped(CharacterEvent(codepoint)) //#elseif MC >= 1.21.9 - //$$ return super.charTyped(CharInput(codepoint, charModifiers)) + //$$ return super.charTyped(CharInput(codepoint, lastCharModifiers)) //#elseif MC >= 1.15.2 - //$$ return super.charTyped(codepoint.toChar(), charModifiers) + //$$ return super.charTyped(codepoint.toChar(), lastCharModifiers) //#else super.keyTyped(codepoint.toChar(), 0) return false From 5402cf7fb82c3601afbe1199fec36182e6422486 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 24 Mar 2026 18:16:54 +1000 Subject: [PATCH 45/59] Review: 1.21.9 case too Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index e3b0500e..5fd3894f 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -166,9 +166,9 @@ abstract class UScreen( //$$ val modifiers = 0.toModifiers() //#else //$$ val modifiers = input.modifiers.toModifiers() - //$$ lastCharModifiers = input.modifiers //#endif //$$ inputHandler?.let { + //$$ lastCharModifiers = input.modifiers //$$ return it.uCharTyped(codepoint).also { //#if MC < 26.1 //$$ lastCharModifiers = 0 @@ -181,9 +181,6 @@ abstract class UScreen( //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.highSurrogate(input.codepoint), modifiers) //$$ @Suppress("DEPRECATION") onKeyPressed(0, Character.lowSurrogate(input.codepoint), modifiers) //$$ } - //#if MC < 26.1 - //$$ lastCharModifiers = 0 - //#endif //$$ return false //$$ } //$$ From 0c4c400f1f9f7b12fdf43be85d38f32d00a86db5 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 24 Mar 2026 18:41:30 +1000 Subject: [PATCH 46/59] implement in standalone UScreen Linear: EM-1645 --- .../kotlin/gg/essential/universal/UScreen.kt | 39 ++++++++++++++++++ .../universal/standalone/UCWindow.kt | 41 +++++++++++++++---- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt b/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt index 3a26229c..559ca1b9 100644 --- a/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -13,6 +13,9 @@ abstract class UScreen( private var guiScaleToRestore = -1 private val screenToRestore: UScreen? = if (restoreCurrentGuiOnClose) currentScreen else null + protected var inputHandler: InputHandler? = this as? InputHandler + + fun standaloneGetInputHandler(): InputHandler? = inputHandler fun initGui() { updateGuiScale() @@ -79,6 +82,42 @@ abstract class UScreen( open fun onDrawBackground(matrixStack: UMatrixStack, tint: Int) { } + fun uSuperInputHandler(): InputHandler = object : InputHandler { + override fun uSuperInputHandler(): InputHandler = this + override fun uMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = false + override fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = false + override fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = false + override fun uMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean = false + override fun uCharTyped(codepoint: Int): Boolean = false + override fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = false + override fun uKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = false + } + + interface InputHandler { + fun uSuperInputHandler(): InputHandler + + fun uMouseClicked(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseClicked(x, y, button, modifiers) + + fun uMouseReleased(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseReleased(x, y, button, modifiers) + + fun uMouseDragged(x: Double, y: Double, button: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uMouseDragged(x, y, button, modifiers) + + fun uMouseScrolled(x: Double, y: Double, scrollX: Double, scrollY: Double): Boolean = + uSuperInputHandler().uMouseScrolled(x, y, scrollX, scrollY) + + fun uCharTyped(codepoint: Int): Boolean = + uSuperInputHandler().uCharTyped(codepoint) + + fun uKeyPressed(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uKeyPressed(key, scanCode, modifiers) + + fun uKeyReleased(key: Int, scanCode: Int, modifiers: UKeyboard.Modifiers): Boolean = + uSuperInputHandler().uKeyReleased(key, scanCode, modifiers) + } + companion object { var currentScreen: UScreen? = null private set diff --git a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt index aeb1ec9c..f5ce84c8 100644 --- a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt +++ b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt @@ -39,17 +39,27 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { } } - GLFW.glfwSetMouseButtonCallback(glfwWindow.glfwId) { _, button, action, _ -> + GLFW.glfwSetMouseButtonCallback(glfwWindow.glfwId) { _, button, action, modifiers -> uiScope.launch { when (action) { GLFW.GLFW_PRESS -> { UKeyboard.keysDown.add(button) - UScreen.currentScreen?.onMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button, modifiers.toModifiers()) + ?: onMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button) + } + + } GLFW.GLFW_RELEASE -> { UKeyboard.keysDown.remove(button) - UScreen.currentScreen?.onMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, button) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, button, modifiers.toModifiers()) + ?: onMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, button) + } } } } @@ -57,29 +67,44 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.glfwSetScrollCallback(glfwWindow.glfwId) { _, x, y -> uiScope.launch { - UScreen.currentScreen?.onMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, x, y) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, x, y) + ?: onMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, x, y) + } } } GLFW.glfwSetCharModsCallback(glfwWindow.glfwId) { _, codepoint, modifiers -> uiScope.launch { for (char in Character.toChars(codepoint)) { - UScreen.currentScreen?.onKeyPressed(0, char, modifiers.toModifiers()) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uCharTyped(codepoint) + ?: onKeyPressed(0, char, modifiers.toModifiers()) } } } - GLFW.glfwSetKeyCallback(glfwWindow.glfwId) { _, key, _, action, modifiers -> + GLFW.glfwSetKeyCallback(glfwWindow.glfwId) { _, key, scancode, action, modifiers -> uiScope.launch { when (action) { GLFW.GLFW_PRESS, GLFW.GLFW_REPEAT -> { UKeyboard.keysDown.add(key) - UScreen.currentScreen?.onKeyPressed(key, 0.toChar(), modifiers.toModifiers()) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uKeyPressed(key, scancode, modifiers.toModifiers()) + ?: onKeyPressed(key, 0.toChar(), modifiers.toModifiers()) + } } GLFW.GLFW_RELEASE -> { UKeyboard.keysDown.remove(key) - UScreen.currentScreen?.onKeyReleased(key, 0.toChar(), modifiers.toModifiers()) + UScreen.currentScreen?.run { + standaloneGetInputHandler() + ?.uKeyReleased(key, scancode, modifiers.toModifiers()) + ?: onKeyReleased(key, 0.toChar(), modifiers.toModifiers()) + } } } } From 27212ed49d7a0cae5c2af88b038344547e1eeda6 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 24 Mar 2026 18:54:18 +1000 Subject: [PATCH 47/59] missing closing bracket Linear: EM-1645 --- .../main/kotlin/gg/essential/universal/standalone/UCWindow.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt index f5ce84c8..7fe79e3e 100644 --- a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt +++ b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt @@ -49,8 +49,6 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { ?.uMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button, modifiers.toModifiers()) ?: onMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button) } - - } GLFW.GLFW_RELEASE -> { @@ -82,6 +80,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { standaloneGetInputHandler() ?.uCharTyped(codepoint) ?: onKeyPressed(0, char, modifiers.toModifiers()) + } } } } From d9a1f6b48e0d30313e75163422aadf0aa5107bf1 Mon Sep 17 00:00:00 2001 From: Traben Date: Tue, 24 Mar 2026 18:54:44 +1000 Subject: [PATCH 48/59] missing preprocessor block Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 5fd3894f..2b21cf05 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -168,7 +168,9 @@ abstract class UScreen( //$$ val modifiers = input.modifiers.toModifiers() //#endif //$$ inputHandler?.let { - //$$ lastCharModifiers = input.modifiers + //#if MC < 26.1 + //$$ lastCharModifiers = input.modifiers + //#endif //$$ return it.uCharTyped(codepoint).also { //#if MC < 26.1 //$$ lastCharModifiers = 0 From 6669e89895d5f92c9775e929f7be9bcae9f9e6ab Mon Sep 17 00:00:00 2001 From: Traben Date: Fri, 27 Mar 2026 08:57:25 +1000 Subject: [PATCH 49/59] Review: fix indent Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 2b21cf05..47991179 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -168,9 +168,9 @@ abstract class UScreen( //$$ val modifiers = input.modifiers.toModifiers() //#endif //$$ inputHandler?.let { - //#if MC < 26.1 - //$$ lastCharModifiers = input.modifiers - //#endif + //#if MC < 26.1 + //$$ lastCharModifiers = input.modifiers + //#endif //$$ return it.uCharTyped(codepoint).also { //#if MC < 26.1 //$$ lastCharModifiers = 0 From dd0bf25bdcc4518dca3c42ad2557d175a3bc1d84 Mon Sep 17 00:00:00 2001 From: Traben Date: Fri, 27 Mar 2026 09:01:16 +1000 Subject: [PATCH 50/59] Review: use an internal property Linear: EM-1645 --- .../main/kotlin/gg/essential/universal/UScreen.kt | 3 ++- .../gg/essential/universal/standalone/UCWindow.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt b/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt index 559ca1b9..b2828427 100644 --- a/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/standalone/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -15,7 +15,8 @@ abstract class UScreen( private val screenToRestore: UScreen? = if (restoreCurrentGuiOnClose) currentScreen else null protected var inputHandler: InputHandler? = this as? InputHandler - fun standaloneGetInputHandler(): InputHandler? = inputHandler + internal val inputHandlerInternal: InputHandler? + get() = inputHandler fun initGui() { updateGuiScale() diff --git a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt index 7fe79e3e..ca75350d 100644 --- a/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt +++ b/standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt @@ -45,7 +45,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.GLFW_PRESS -> { UKeyboard.keysDown.add(button) UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button, modifiers.toModifiers()) ?: onMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, button) } @@ -54,7 +54,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.GLFW_RELEASE -> { UKeyboard.keysDown.remove(button) UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, button, modifiers.toModifiers()) ?: onMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, button) } @@ -66,7 +66,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.glfwSetScrollCallback(glfwWindow.glfwId) { _, x, y -> uiScope.launch { UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, x, y) ?: onMouseScrolled(UMouse.Scaled.x, UMouse.Scaled.y, x, y) } @@ -77,7 +77,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { uiScope.launch { for (char in Character.toChars(codepoint)) { UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uCharTyped(codepoint) ?: onKeyPressed(0, char, modifiers.toModifiers()) } @@ -91,7 +91,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.GLFW_PRESS, GLFW.GLFW_REPEAT -> { UKeyboard.keysDown.add(key) UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uKeyPressed(key, scancode, modifiers.toModifiers()) ?: onKeyPressed(key, 0.toChar(), modifiers.toModifiers()) } @@ -100,7 +100,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) { GLFW.GLFW_RELEASE -> { UKeyboard.keysDown.remove(key) UScreen.currentScreen?.run { - standaloneGetInputHandler() + inputHandlerInternal ?.uKeyReleased(key, scancode, modifiers.toModifiers()) ?: onKeyReleased(key, 0.toChar(), modifiers.toModifiers()) } From 0fa28106a8a607ef4c8f9ad2706407a06e103ece Mon Sep 17 00:00:00 2001 From: Traben Date: Mon, 6 Apr 2026 09:47:35 +1000 Subject: [PATCH 51/59] Review: pass fractional mouse pos in older mc Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 47991179..bee1f411 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -378,17 +378,17 @@ abstract class UScreen( } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - inputHandler?.uMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, mouseButton, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - inputHandler?.uMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state, UKeyboard.getModifiers()) + inputHandler?.uMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, state, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseDragged(UMouse.Scaled.x, UMouse.Scaled.y, clickedMouseButton, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } From e3f9a1f968dfc512595faaf4f165d6f34a76df3f Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 9 Apr 2026 11:53:40 +1000 Subject: [PATCH 52/59] Review: block PUA characters Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index e3b0500e..a5d75122 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -372,7 +372,10 @@ abstract class UScreen( val handled = if (keyCode != 0) false else { it.uKeyPressed(keyCode, 0, UKeyboard.getModifiers()) } - if (!handled && !typedChar.isISOControl()) { + if (!handled + && !typedChar.isISOControl() // Block control code characters. E.G. the 'CTRL + A' character. https://en.wikipedia.org/wiki/Control_character + && typedChar !in CharCategory.PRIVATE_USE // Block PUA characters. Known to be incorrectly sent by macOS + LWJGL2. https://en.wikipedia.org/wiki/Private_Use_Areas + ) { it.uCharTyped(typedChar.code) } } ?: @Suppress("DEPRECATION") onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) From ba5403ef0076823cc60094659cbe632c719c6d5b Mon Sep 17 00:00:00 2001 From: Traben Date: Thu, 9 Apr 2026 12:13:05 +1000 Subject: [PATCH 53/59] Review: restore fractional mouse without overriding the input positions Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UScreen.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 0a44d11d..57cf2e75 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -28,6 +28,7 @@ import net.minecraft.client.gui.GuiScreen //#else import org.lwjgl.input.Mouse import java.io.IOException +import kotlin.math.floor //#endif @@ -381,20 +382,25 @@ abstract class UScreen( } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - inputHandler?.uMouseClicked(UMouse.Scaled.x, UMouse.Scaled.y, mouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseClicked(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), mouseButton, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - inputHandler?.uMouseReleased(UMouse.Scaled.x, UMouse.Scaled.y, state, UKeyboard.getModifiers()) + inputHandler?.uMouseReleased(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), state, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(UMouse.Scaled.x, UMouse.Scaled.y, clickedMouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseDragged(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), clickedMouseButton, UKeyboard.getModifiers()) ?: @Suppress("DEPRECATION") onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } + // We want to restore the fractional part of the mouse click, but not outright override the mouse pos with the real one + // as the input mouse Int may have been modified by another mod. + private fun Int.restoreFrac(realMouseScaled: Double): Double = + this + (realMouseScaled - floor(realMouseScaled)) + final override fun handleMouseInput() { super.handleMouseInput() val scrollDelta = Mouse.getEventDWheel() From a9da60519120aeec3331ca89f693cf1d124ed4e2 Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 16:11:08 +1000 Subject: [PATCH 54/59] Review from elementa: add super key to modifiers Linear: EM-1645 --- .../gg/essential/universal/UKeyboard.kt | 49 +++++++++++++++---- .../kotlin/gg/essential/universal/UScreen.kt | 10 ++-- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index 06caa76c..dc94270e 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -270,40 +270,57 @@ object UKeyboard { //#endif } + @Deprecated("Use isOSModifierKeyDown() instead if you want the platform-appropriate modifier key (Ctrl on Windows/Linux, Command on Mac). " + + "Alternatively use isControlKeyDown() or isCommandKeyDown() if you specifically want to check for Ctrl or Command respectively.") @JvmStatic fun isCtrlKeyDown(): Boolean = if (UMinecraft.isRunningOnMac) { isKeyDown(KEY_LMETA) || isKeyDown(KEY_RMETA) } else isKeyDown(KEY_LCONTROL) || isKeyDown(KEY_RCONTROL) + @JvmStatic + fun isOSModifierKeyDown(): Boolean = + if (UMinecraft.isRunningOnMac) isCommandKeyDown() + else isControlKeyDown() + + @JvmStatic + fun isCommandKeyDown(): Boolean = isKeyDown(KEY_LMETA) || isKeyDown(KEY_RMETA) + + @JvmStatic + fun isControlKeyDown(): Boolean = isKeyDown(KEY_LCONTROL) || isKeyDown(KEY_RCONTROL) + @JvmStatic fun isShiftKeyDown(): Boolean = isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT) @JvmStatic fun isAltKeyDown(): Boolean = isKeyDown(KEY_LMENU) || isKeyDown(KEY_RMENU) + @Deprecated("Inconsistent ctrl modifier behaviour depending on OS and MC versions", replaceWith = ReplaceWith("getKeyModifiers()")) @JvmStatic - fun getModifiers(): Modifiers = Modifiers(isCtrlKeyDown(), isShiftKeyDown(), isAltKeyDown()) + fun getModifiers(): Modifiers = Modifiers(isCtrlKeyDown(), isShiftKeyDown(), isAltKeyDown(), isCommandKeyDown()) @JvmStatic - fun isKeyComboCtrlA(key: Int): Boolean = key == KEY_A && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun getKeyModifiers(): Modifiers = Modifiers(isControlKeyDown(), isShiftKeyDown(), isAltKeyDown(), isCommandKeyDown()) @JvmStatic - fun isKeyComboCtrlC(key: Int): Boolean = key == KEY_C && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlA(key: Int): Boolean = key == KEY_A && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() @JvmStatic - fun isKeyComboCtrlV(key: Int): Boolean = key == KEY_V && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlC(key: Int): Boolean = key == KEY_C && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() @JvmStatic - fun isKeyComboCtrlX(key: Int): Boolean = key == KEY_X && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlV(key: Int): Boolean = key == KEY_V && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() @JvmStatic - fun isKeyComboCtrlY(key: Int): Boolean = key == KEY_Y && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlX(key: Int): Boolean = key == KEY_X && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() @JvmStatic - fun isKeyComboCtrlZ(key: Int): Boolean = key == KEY_Z && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlY(key: Int): Boolean = key == KEY_Y && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() @JvmStatic - fun isKeyComboCtrlShiftZ(key: Int): Boolean = key == KEY_Z && isCtrlKeyDown() && isShiftKeyDown() && !isAltKeyDown() + fun isKeyComboCtrlZ(key: Int): Boolean = key == KEY_Z && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + + @JvmStatic + fun isKeyComboCtrlShiftZ(key: Int): Boolean = key == KEY_Z && isOSModifierKeyDown() && isShiftKeyDown() && !isAltKeyDown() //#if STANDALONE //$$ internal val keysDown = mutableSetOf() @@ -390,19 +407,33 @@ object UKeyboard { @JvmStatic fun getKeyName(keyCode: Int): String? = getKeyName(keyCode, -1) - data class Modifiers(val isCtrl: Boolean, val isShift: Boolean, val isAlt: Boolean) + data class Modifiers( + val isCtrl: Boolean, + val isShift: Boolean, + val isAlt: Boolean, + val isSuper: Boolean, + ) { + + /** + * Checks the OS specific modifier key (Ctrl on Windows/Linux, Command (super) on Mac). + */ + val isOSModifier = if (UMinecraft.isRunningOnMac) isSuper else isCtrl + + } //#if MC>=11502 //$$ internal fun Modifiers?.toInt() = listOf( //$$ this?.isCtrl to GLFW.GLFW_MOD_CONTROL, //$$ this?.isShift to GLFW.GLFW_MOD_SHIFT, //$$ this?.isAlt to GLFW.GLFW_MOD_ALT, + //$$ this?.isCmd to GLFW.GLFW_MOD_SUPER, //$$ ).sumOf { (modifier, value) -> if (modifier == true) value else 0 } //$$ //$$ internal fun Int.toModifiers() = Modifiers( //$$ isCtrl = (this and GLFW.GLFW_MOD_CONTROL) != 0, //$$ isShift = (this and GLFW.GLFW_MOD_SHIFT) != 0, //$$ isAlt = (this and GLFW.GLFW_MOD_ALT) != 0, + //$$ isCmd = (this and GLFW.GLFW_MOD_SUPER) != 0, //$$ ) //#endif } diff --git a/src/main/kotlin/gg/essential/universal/UScreen.kt b/src/main/kotlin/gg/essential/universal/UScreen.kt index 57cf2e75..8ee221e2 100644 --- a/src/main/kotlin/gg/essential/universal/UScreen.kt +++ b/src/main/kotlin/gg/essential/universal/UScreen.kt @@ -370,7 +370,7 @@ abstract class UScreen( final override fun keyTyped(typedChar: Char, keyCode: Int) { inputHandler?.let { val handled = if (keyCode != 0) false else { - it.uKeyPressed(keyCode, 0, UKeyboard.getModifiers()) + it.uKeyPressed(keyCode, 0, UKeyboard.getKeyModifiers()) } if (!handled && !typedChar.isISOControl() // Block control code characters. E.G. the 'CTRL + A' character. https://en.wikipedia.org/wiki/Control_character @@ -378,21 +378,21 @@ abstract class UScreen( ) { it.uCharTyped(typedChar.code) } - } ?: @Suppress("DEPRECATION") onKeyPressed(keyCode, typedChar, UKeyboard.getModifiers()) + } ?: @Suppress("DEPRECATION") onKeyPressed(keyCode, typedChar, UKeyboard.getKeyModifiers()) } final override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { - inputHandler?.uMouseClicked(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), mouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseClicked(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), mouseButton, UKeyboard.getKeyModifiers()) ?: @Suppress("DEPRECATION") onMouseClicked(mouseX.toDouble(), mouseY.toDouble(), mouseButton) } final override fun mouseReleased(mouseX: Int, mouseY: Int, state: Int) { - inputHandler?.uMouseReleased(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), state, UKeyboard.getModifiers()) + inputHandler?.uMouseReleased(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), state, UKeyboard.getKeyModifiers()) ?: @Suppress("DEPRECATION") onMouseReleased(mouseX.toDouble(), mouseY.toDouble(), state) } final override fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) { - inputHandler?.uMouseDragged(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), clickedMouseButton, UKeyboard.getModifiers()) + inputHandler?.uMouseDragged(mouseX.restoreFrac(UMouse.Scaled.x), mouseY.restoreFrac(UMouse.Scaled.y), clickedMouseButton, UKeyboard.getKeyModifiers()) ?: @Suppress("DEPRECATION") onMouseDragged(mouseX.toDouble(), mouseY.toDouble(), clickedMouseButton, timeSinceLastClick) } From 0e948fd0815ecea829564a61e40a8f76a82c8abb Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 16:17:16 +1000 Subject: [PATCH 55/59] Review from elementa: deprecation directing users to use provided key modifiers Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UKeyboard.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index dc94270e..df9b6d9b 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -277,20 +277,25 @@ object UKeyboard { isKeyDown(KEY_LMETA) || isKeyDown(KEY_RMETA) } else isKeyDown(KEY_LCONTROL) || isKeyDown(KEY_RCONTROL) + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isOSModifierKeyDown(): Boolean = if (UMinecraft.isRunningOnMac) isCommandKeyDown() else isControlKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isCommandKeyDown(): Boolean = isKeyDown(KEY_LMETA) || isKeyDown(KEY_RMETA) + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isControlKeyDown(): Boolean = isKeyDown(KEY_LCONTROL) || isKeyDown(KEY_RCONTROL) + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isShiftKeyDown(): Boolean = isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT) + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isAltKeyDown(): Boolean = isKeyDown(KEY_LMENU) || isKeyDown(KEY_RMENU) @@ -301,24 +306,31 @@ object UKeyboard { @JvmStatic fun getKeyModifiers(): Modifiers = Modifiers(isControlKeyDown(), isShiftKeyDown(), isAltKeyDown(), isCommandKeyDown()) + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlA(key: Int): Boolean = key == KEY_A && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlC(key: Int): Boolean = key == KEY_C && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlV(key: Int): Boolean = key == KEY_V && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlX(key: Int): Boolean = key == KEY_X && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlY(key: Int): Boolean = key == KEY_Y && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlZ(key: Int): Boolean = key == KEY_Z && isOSModifierKeyDown() && !isShiftKeyDown() && !isAltKeyDown() + @Deprecated("If using from a key event, use the provided modifiers instead of calling this method.") @JvmStatic fun isKeyComboCtrlShiftZ(key: Int): Boolean = key == KEY_Z && isOSModifierKeyDown() && isShiftKeyDown() && !isAltKeyDown() From 522acc467bb823bb0b4642f40a0ee6a8d7784d82 Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 16:53:11 +1000 Subject: [PATCH 56/59] fix non-final property name in preprocessed block Linear: EM-1645 --- src/main/kotlin/gg/essential/universal/UKeyboard.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index df9b6d9b..44d955b1 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -438,14 +438,14 @@ object UKeyboard { //$$ this?.isCtrl to GLFW.GLFW_MOD_CONTROL, //$$ this?.isShift to GLFW.GLFW_MOD_SHIFT, //$$ this?.isAlt to GLFW.GLFW_MOD_ALT, - //$$ this?.isCmd to GLFW.GLFW_MOD_SUPER, + //$$ this?.isSuper to GLFW.GLFW_MOD_SUPER, //$$ ).sumOf { (modifier, value) -> if (modifier == true) value else 0 } //$$ //$$ internal fun Int.toModifiers() = Modifiers( //$$ isCtrl = (this and GLFW.GLFW_MOD_CONTROL) != 0, //$$ isShift = (this and GLFW.GLFW_MOD_SHIFT) != 0, //$$ isAlt = (this and GLFW.GLFW_MOD_ALT) != 0, - //$$ isCmd = (this and GLFW.GLFW_MOD_SUPER) != 0, + //$$ isSuper = (this and GLFW.GLFW_MOD_SUPER) != 0, //$$ ) //#endif } From f3f15af9bd7d5dc9c2f803fcc8bb54a75178b0ad Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 17:03:54 +1000 Subject: [PATCH 57/59] api changes Linear: EM-1645 --- api/UniversalCraft.api | 12 ++++++++++-- src/main/kotlin/gg/essential/universal/UKeyboard.kt | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index f037ab1e..e335ae7a 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -529,6 +529,7 @@ public final class gg/essential/universal/UKeyboard { public static final field KEY_Y I public static final field KEY_Z I public static final fun allowRepeatEvents (Z)V + public static final fun getKeyModifiers ()Lgg/essential/universal/UKeyboard$Modifiers; public static final fun getKeyName (I)Ljava/lang/String; public static final fun getKeyName (II)Ljava/lang/String; @1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge,1.20.4-neoforge,1.20.6-forge,1.20.6-neoforge,1.21-forge,1.21-neoforge,1.21.3-forge,1.21.3-neoforge,1.21.4-forge,1.21.4-neoforge,1.21.5-forge,1.21.5-neoforge,1.21.7-forge,1.21.7-neoforge,26.1-fabric @@ -541,6 +542,8 @@ public final class gg/essential/universal/UKeyboard { public static final fun getKeyName (Lnet/minecraft/client/settings/KeyBinding;)Ljava/lang/String; public static final fun getModifiers ()Lgg/essential/universal/UKeyboard$Modifiers; public static final fun isAltKeyDown ()Z + public static final fun isCommandKeyDown ()Z + public static final fun isControlKeyDown ()Z public static final fun isCtrlKeyDown ()Z public static final fun isEnterKey (I)Z public static final fun isKeyComboCtrlA (I)Z @@ -551,21 +554,26 @@ public final class gg/essential/universal/UKeyboard { public static final fun isKeyComboCtrlY (I)Z public static final fun isKeyComboCtrlZ (I)Z public static final fun isKeyDown (I)Z + public static final fun isOSModifierKeyDown ()Z public static final fun isShiftKeyDown ()Z } public final class gg/essential/universal/UKeyboard$Modifiers { public fun (ZZZ)V + public fun (ZZZZ)V public final fun component1 ()Z public final fun component2 ()Z public final fun component3 ()Z - public final fun copy (ZZZ)Lgg/essential/universal/UKeyboard$Modifiers; - public static synthetic fun copy$default (Lgg/essential/universal/UKeyboard$Modifiers;ZZZILjava/lang/Object;)Lgg/essential/universal/UKeyboard$Modifiers; + public final fun component4 ()Z + public final fun copy (ZZZZ)Lgg/essential/universal/UKeyboard$Modifiers; + public static synthetic fun copy$default (Lgg/essential/universal/UKeyboard$Modifiers;ZZZZILjava/lang/Object;)Lgg/essential/universal/UKeyboard$Modifiers; public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I public final fun isAlt ()Z public final fun isCtrl ()Z + public final fun isOSModifier ()Z public final fun isShift ()Z + public final fun isSuper ()Z public fun toString ()Ljava/lang/String; } diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index 44d955b1..83525a16 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -425,6 +425,9 @@ object UKeyboard { val isAlt: Boolean, val isSuper: Boolean, ) { + @Deprecated("Old constructor") + constructor(isCtrl: Boolean, isShift: Boolean, isAlt: Boolean) : + this(isCtrl, isShift, isAlt, isSuper = isCommandKeyDown()) /** * Checks the OS specific modifier key (Ctrl on Windows/Linux, Command (super) on Mac). From 0a05061c3061f7dacc4a1c0bf4bf532d9cb0a454 Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 18:38:06 +1000 Subject: [PATCH 58/59] change check and naming Linear: EM-1645 --- api/UniversalCraft.api | 2 +- src/main/kotlin/gg/essential/universal/UKeyboard.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index e335ae7a..3475d6fb 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -571,7 +571,7 @@ public final class gg/essential/universal/UKeyboard$Modifiers { public fun hashCode ()I public final fun isAlt ()Z public final fun isCtrl ()Z - public final fun isOSModifier ()Z + public final fun isPlatformModifierActive ()Z public final fun isShift ()Z public final fun isSuper ()Z public fun toString ()Ljava/lang/String; diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index 83525a16..42f90dd4 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -430,9 +430,11 @@ object UKeyboard { this(isCtrl, isShift, isAlt, isSuper = isCommandKeyDown()) /** - * Checks the OS specific modifier key (Ctrl on Windows/Linux, Command (super) on Mac). + * Checks that only the OS specific modifier key is active (Ctrl on Windows/Linux, Command (super) on Mac). */ - val isOSModifier = if (UMinecraft.isRunningOnMac) isSuper else isCtrl + fun isPlatformModifierActive() = + if (UMinecraft.isRunningOnMac) isSuper && !isShift && !isAlt && !isCtrl + else isCtrl && !isShift && !isAlt && !isSuper } From c0a5cc5be5872e68ab2119e0fb7757685e7fd91a Mon Sep 17 00:00:00 2001 From: Traben Date: Sun, 26 Apr 2026 20:01:13 +1000 Subject: [PATCH 59/59] further modifier options Linear: EM-1645 --- api/UniversalCraft.api | 1 + src/main/kotlin/gg/essential/universal/UKeyboard.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/UniversalCraft.api b/api/UniversalCraft.api index 3475d6fb..d580c79e 100644 --- a/api/UniversalCraft.api +++ b/api/UniversalCraft.api @@ -571,6 +571,7 @@ public final class gg/essential/universal/UKeyboard$Modifiers { public fun hashCode ()I public final fun isAlt ()Z public final fun isCtrl ()Z + public final fun isOnlyPlatformModifierActive ()Z public final fun isPlatformModifierActive ()Z public final fun isShift ()Z public final fun isSuper ()Z diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index 42f90dd4..9d0098fe 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -432,7 +432,9 @@ object UKeyboard { /** * Checks that only the OS specific modifier key is active (Ctrl on Windows/Linux, Command (super) on Mac). */ - fun isPlatformModifierActive() = + fun isPlatformModifierActive() = if (UMinecraft.isRunningOnMac) isSuper else isCtrl + + fun isOnlyPlatformModifierActive() = if (UMinecraft.isRunningOnMac) isSuper && !isShift && !isAlt && !isCtrl else isCtrl && !isShift && !isAlt && !isSuper