@@ -2,6 +2,13 @@ package gg.essential.universal
22
33import net.minecraft.client.gui.GuiScreen
44
5+ // #if MC>=12109
6+ // $$ import net.minecraft.client.gui.Click
7+ // $$ import net.minecraft.client.input.CharInput
8+ // $$ import net.minecraft.client.input.KeyInput
9+ // $$ import net.minecraft.client.input.MouseInput
10+ // #endif
11+
512// #if MC>=12106
613// $$ import com.mojang.blaze3d.systems.RenderSystem
714// #endif
@@ -127,6 +134,57 @@ abstract class UScreen(
127134 // #endif
128135 // $$ }
129136 // $$
137+ // #if MC>=12109
138+ // $$ final override fun keyPressed(input: KeyInput): Boolean {
139+ // $$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers())
140+ // $$ return false
141+ // $$ }
142+ // $$
143+ // $$ final override fun keyReleased(input: KeyInput): Boolean {
144+ // $$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers())
145+ // $$ return false
146+ // $$ }
147+ // $$
148+ // $$ final override fun charTyped(input: CharInput): Boolean {
149+ // $$ val codepoint = input.codepoint
150+ // $$ if (Character.isBmpCodePoint(codepoint)) {
151+ // $$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers())
152+ // $$ } else if (Character.isValidCodePoint(codepoint)) {
153+ // $$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers())
154+ // $$ onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers())
155+ // $$ }
156+ // $$ return false
157+ // $$ }
158+ // $$
159+ // $$ private var lastMouseInput: MouseInput? = null
160+ // $$ private var lastDoubled: Boolean? = null
161+ // $$
162+ // $$ final override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
163+ // $$ lastMouseInput = click.buttonInfo
164+ // $$ lastDoubled = doubled
165+ // $$ if (click.button() == 1) lastClick = UMinecraft.getTime()
166+ // $$ onMouseClicked(click.x, click.y, click.button())
167+ // $$ lastMouseInput = null
168+ // $$ lastDoubled = null
169+ // $$ return false
170+ // $$ }
171+ // $$
172+ // $$ final override fun mouseReleased(click: Click): Boolean {
173+ // $$ lastMouseInput = click.buttonInfo
174+ // $$ onMouseReleased(click.x, click.y, click.button())
175+ // $$ lastMouseInput = null
176+ // $$ return false
177+ // $$ }
178+ // $$
179+ // $$ override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
180+ // $$ lastMouseInput = click.buttonInfo
181+ // $$ lastDraggedDx = offsetX
182+ // $$ lastDraggedDy = offsetY
183+ // $$ onMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick)
184+ // $$ lastMouseInput = null
185+ // $$ return false
186+ // $$ }
187+ // #else
130188 // $$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean {
131189 // $$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers())
132190 // $$ return false
@@ -160,6 +218,7 @@ abstract class UScreen(
160218 // $$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick)
161219 // $$ return false
162220 // $$ }
221+ // #endif
163222 // $$
164223 // #if MC>=12002
165224 // $$ override fun mouseScrolled(mouseX: Double, mouseY: Double, horizontalAmount: Double, delta: Double): Boolean {
@@ -341,10 +400,18 @@ abstract class UScreen(
341400 open fun onKeyPressed (keyCode : Int , typedChar : Char , modifiers : UKeyboard .Modifiers ? ) {
342401 // #if MC>=11502
343402 // $$ if (keyCode != 0) {
344- // $$ super.keyPressed(keyCode, 0, modifiers.toInt())
403+ // #if MC>=12109
404+ // $$ super.keyPressed(KeyInput(keyCode, 0, modifiers.toInt()))
405+ // #else
406+ // $$ super.keyPressed(keyCode, 0, modifiers.toInt())
407+ // #endif
345408 // $$ }
346409 // $$ if (typedChar != 0.toChar()) {
347- // $$ super.charTyped(typedChar, modifiers.toInt())
410+ // #if MC>=12109
411+ // $$ super.charTyped(CharInput(typedChar.code, modifiers.toInt()))
412+ // #else
413+ // $$ super.charTyped(typedChar, modifiers.toInt())
414+ // #endif
348415 // $$ }
349416 // #else
350417 try {
@@ -358,7 +425,11 @@ abstract class UScreen(
358425 open fun onKeyReleased (keyCode : Int , typedChar : Char , modifiers : UKeyboard .Modifiers ? ) {
359426 // #if MC>=11502
360427 // $$ if (keyCode != 0) {
361- // $$ super.keyReleased(keyCode, 0, modifiers.toInt())
428+ // #if MC>=12109
429+ // $$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt()))
430+ // #else
431+ // $$ super.keyReleased(keyCode, 0, modifiers.toInt())
432+ // #endif
362433 // $$ }
363434 // #endif
364435 }
@@ -367,7 +438,11 @@ abstract class UScreen(
367438 // #if MC>=11502
368439 // $$ if (mouseButton == 1)
369440 // $$ lastClick = UMinecraft.getTime()
441+ // #if MC>=12109
442+ // $$ super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false)
443+ // #else
370444 // $$ super.mouseClicked(mouseX, mouseY, mouseButton)
445+ // #endif
371446 // #else
372447 try {
373448 super .mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton)
@@ -378,15 +453,19 @@ abstract class UScreen(
378453 }
379454
380455 open fun onMouseReleased (mouseX : Double , mouseY : Double , state : Int ) {
381- // #if MC>=11502
456+ // #if MC>=12109
457+ // $$ super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0)))
458+ // #elseif MC>=11502
382459 // $$ super.mouseReleased(mouseX, mouseY, state)
383460 // #else
384461 super .mouseReleased(mouseX.toInt(), mouseY.toInt(), state)
385462 // #endif
386463 }
387464
388465 open fun onMouseDragged (x : Double , y : Double , clickedButton : Int , timeSinceLastClick : Long ) {
389- // #if MC>=11502
466+ // #if MC>=12109
467+ // $$ super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy)
468+ // #elseif MC>=11502
390469 // $$ super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy)
391470 // #else
392471 super .mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick)
0 commit comments