diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-15 23:13:50 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-15 23:13:50 +0100 |
| commit | 4d8399ff4d769def62e6a8241327c4f2dac47e71 (patch) | |
| tree | 703f8651cb680d2583d82c2b1b4aee0911ccb490 /src/main/kotlin | |
| parent | 215178c650d38a4a77fdef6dc8815c07bef29c25 (diff) | |
| download | Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.gz Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.bz2 Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.zip | |
snapshot: main source set compile
Diffstat (limited to 'src/main/kotlin')
29 files changed, 226 insertions, 236 deletions
diff --git a/src/main/kotlin/apis/UrsaManager.kt b/src/main/kotlin/apis/UrsaManager.kt index cee6904..e5d519e 100644 --- a/src/main/kotlin/apis/UrsaManager.kt +++ b/src/main/kotlin/apis/UrsaManager.kt @@ -48,7 +48,7 @@ object UrsaManager { withContext(Dispatchers.IO) { val mc = MinecraftClient.getInstance() val serverId = UUID.randomUUID().toString() - mc.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) + mc.apiServices.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) request.header("x-ursa-username", mc.session.username) request.header("x-ursa-serverid", serverId) } diff --git a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt index 12167f8..df1c3eb 100644 --- a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt +++ b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt @@ -14,13 +14,13 @@ data class FinalizeResourceManagerEvent( inline fun registerOnApply(name: String, crossinline function: () -> Unit) { resourceManager.registerReloader(object : ResourceReloader { override fun reload( - synchronizer: ResourceReloader.Synchronizer, - manager: ResourceManager, + store: ResourceReloader.Store, prepareExecutor: Executor, + reloadSynchronizer: ResourceReloader.Synchronizer, applyExecutor: Executor ): CompletableFuture<Void> { return CompletableFuture.completedFuture(Unit) - .thenCompose(synchronizer::whenPrepared) + .thenCompose(reloadSynchronizer::whenPrepared) .thenAcceptAsync({ function() }, applyExecutor) } diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt index a549f7e..fc36806 100644 --- a/src/main/kotlin/features/debug/PowerUserTools.kt +++ b/src/main/kotlin/features/debug/PowerUserTools.kt @@ -41,6 +41,7 @@ import moe.nea.firmament.util.mc.SNbtFormatter.Companion.toPrettyString import moe.nea.firmament.util.mc.displayNameAccordingToNbt import moe.nea.firmament.util.mc.iterableArmorItems import moe.nea.firmament.util.mc.loreAccordingToNbt +import moe.nea.firmament.util.mc.unsafeNbt import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.tr @@ -166,7 +167,7 @@ object PowerUserTools { Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString())) } else if (it.matches(TConfig.copyNbtData)) { // TODO: copy full nbt - val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.nbt?.toPrettyString() ?: "<empty>" + val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>" ClipboardUtils.setTextContent(nbt) lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt")) } else if (it.matches(TConfig.copyLoreData)) { diff --git a/src/main/kotlin/features/debug/SkinPreviews.kt b/src/main/kotlin/features/debug/SkinPreviews.kt index aff5c13..a853cd1 100644 --- a/src/main/kotlin/features/debug/SkinPreviews.kt +++ b/src/main/kotlin/features/debug/SkinPreviews.kt @@ -1,5 +1,6 @@ package moe.nea.firmament.features.debug +import com.mojang.authlib.GameProfile import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put @@ -35,18 +36,7 @@ object SkinPreviews { return val entity = event.entity as? LivingEntity ?: return val stack = entity.getEquippedStack(EquipmentSlot.HEAD) ?: return - val profile = stack.get(DataComponentTypes.PROFILE) ?: return - if (!profile.isCompleted) { - lastDiscard = TimeMark.now() - animation.clear() - MC.sendChat( - tr( - "firmament.dev.skinpreviews.discarding", - "Encountered unloaded skin, discarding all previews skin frames." - ) - ) - return - } + val profile = stack.get(DataComponentTypes.PROFILE)?.gameProfile ?: return if (profile == animation.lastOrNull()) return animation.add(profile) val shortened = animation.shortenCycle() @@ -59,7 +49,7 @@ object SkinPreviews { put( "textures", shortened.map { - it.gameProfile().id.toString() + ":" + it.properties()["textures"].first().value() + it.id.toString() + ":" + it.properties()["textures"].first().value() }.toJsonArray() ) } @@ -74,7 +64,7 @@ object SkinPreviews { } } - var animation = mutableListOf<ProfileComponent>() + var animation = mutableListOf<GameProfile>() var pos = Vec3d(-1.0, 72.0, -101.25) var isRecording = false var skinColor: String? = null diff --git a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt index 9356dd3..b3dc69a 100644 --- a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt +++ b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt @@ -6,6 +6,7 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import net.minecraft.client.network.AbstractClientPlayerEntity import net.minecraft.entity.decoration.ArmorStandEntity +import net.minecraft.util.AssetInfo import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.HandledScreenKeyPressedEvent @@ -67,7 +68,7 @@ object ExportRecipe { val id = generateName(reply) ItemExporter.exportStub(id, "§9$reply") { val playerEntity = entity as? AbstractClientPlayerEntity - val textureUrl = playerEntity?.skinTextures?.textureUrl + val textureUrl = (playerEntity?.skin?.body as? AssetInfo.SkinAssetInfo)?.url if (textureUrl != null) it.setSkullOwner(playerEntity.uuid, textureUrl) } diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt index f06eb43..65f9fa1 100644 --- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt @@ -291,12 +291,10 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) { fun copyLegacySkullNbt() { val profile = itemStack.get(DataComponentTypes.PROFILE) ?: return legacyNbt.put("SkullOwner", NbtCompound().apply { - profile.uuid.ifPresent { - putString("Id", it.toString()) - } + putString("Id", profile.gameProfile.id.toString()) putBoolean("hypixelPopulated", true) put("Properties", NbtCompound().apply { - profile.properties().forEach { prop, value -> + profile.gameProfile.properties().forEach { prop, value -> val list = getListOrEmpty(prop) put(prop, list) list.add(NbtCompound().apply { diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt index 5a54aca..c523661 100644 --- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt +++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt @@ -44,7 +44,7 @@ object SaveCursorPosition { (lastPosition.middle.second - middleY).absoluteValue < 1 ) { InputUtil.setCursorParameters( - MC.window.handle, + MC.window, InputUtil.GLFW_CURSOR_NORMAL, lastPosition.cursor.first, lastPosition.cursor.second diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt index 87edbe1..10c58cb 100644 --- a/src/main/kotlin/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/features/inventory/SlotLocking.kt @@ -393,12 +393,12 @@ object SlotLocking { hotX + sx, hotY + sy, color(anyHovered) ) - event.context.drawBorder( + event.context.drawStrokedRectangle( hotbarSlot.x + sx, hotbarSlot.y + sy, 16, 16, color(hotbarSlot in highlitSlots).color ) - event.context.drawBorder( + event.context.drawStrokedRectangle( // TODO: 1.21.10 inventorySlot.x + sx, inventorySlot.y + sy, 16, 16, color(inventorySlot in highlitSlots).color @@ -416,7 +416,7 @@ object SlotLocking { val sx = accScreen.x_Firmament val sy = accScreen.y_Firmament val (borderX, borderY) = draggingSlot.lineCenter() - event.context.drawBorder(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) + event.context.drawStrokedRectangle(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10 if (hoveredSlot == null) { event.context.drawLine( borderX + sx, borderY + sy, @@ -430,7 +430,7 @@ object SlotLocking { hovX + sx, hovY + sy, me.shedaniel.math.Color.ofOpaque(0x00FF00) ) - event.context.drawBorder( + event.context.drawStrokedRectangle( hoveredSlot.x + sx, hoveredSlot.y + sy, 16, 16, 0xFF00FF00u.toInt() diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt index ce074d8..d5d291c 100644 --- a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt +++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt @@ -9,9 +9,12 @@ import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import org.lwjgl.glfw.GLFW import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.widget.ButtonWidget +import net.minecraft.client.gui.widget.MultilineTextWidget import net.minecraft.client.gui.widget.TextWidget +import net.minecraft.client.input.KeyInput import net.minecraft.client.util.InputUtil import net.minecraft.text.Text import net.minecraft.util.math.MathHelper @@ -74,24 +77,20 @@ class InventoryButtonEditor( override fun init() { super.init() addDrawableChild( - TextWidget( + MultilineTextWidget( lastGuiRect.minX, 25, - lastGuiRect.width, - 9, Text.translatable("firmament.inventory-buttons.delete"), MC.font - ).alignCenter() + ).setCentered(true).setMaxWidth(lastGuiRect.width) ) addDrawableChild( - TextWidget( + MultilineTextWidget( lastGuiRect.minX, 40, - lastGuiRect.width, - 9, Text.translatable("firmament.inventory-buttons.info"), MC.font - ).alignCenter() + ).setCentered(true).setMaxWidth(lastGuiRect.width) ) addDrawableChild( ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.reset")) { @@ -216,27 +215,27 @@ class InventoryButtonEditor( renderPopup(context, mouseX, mouseY, delta) } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - if (super.keyPressed(keyCode, scanCode, modifiers)) return true - if (keyCode == GLFW.GLFW_KEY_ESCAPE) { + override fun keyPressed(input: KeyInput): Boolean { + if (super.keyPressed(input)) return true + if (input.keycode == GLFW.GLFW_KEY_ESCAPE) { close() return true } return false } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { - if (super.mouseReleased(mouseX, mouseY, button)) return true - val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(mouseX, mouseY)) } + override fun mouseReleased(click: Click): Boolean { + if (super.mouseReleased(click)) return true + val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(click.x, click.y)) } if (clickedButton != null && !justPerformedAClickAction) { if (InputUtil.isKeyPressed( - MC.window.handle, + MC.window, InputUtil.GLFW_KEY_LEFT_CONTROL ) ) Editor(clickedButton).delete() else createPopup( MoulConfigUtils.loadGui("button_editor_fragment", Editor(clickedButton)), - Point(mouseX, mouseY) + Point(click.x, click.y) ) return true } @@ -245,14 +244,14 @@ class InventoryButtonEditor( return false } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { - if (super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) return true + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { + if (super.mouseDragged(click, offsetX, offsetY)) return true - if (initialDragMousePosition.distanceSquared(Vec2f(mouseX.toFloat(), mouseY.toFloat())) >= 4 * 4) { + if (initialDragMousePosition.distanceSquared(Vec2f(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) { initialDragMousePosition = Vec2f(-10F, -10F) lastDraggedButton?.let { dragging -> justPerformedAClickAction = true - val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(mouseX.toInt(), mouseY.toInt()) + val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(click.x.toInt(), click.y.toInt()) ?: return true dragging.x = offsetX dragging.y = offsetY @@ -287,7 +286,7 @@ class InventoryButtonEditor( val anchorBottom = my > lastGuiRect.maxY var offsetX = mx - if (anchorRight) lastGuiRect.maxX else lastGuiRect.minX var offsetY = my - if (anchorBottom) lastGuiRect.maxY else lastGuiRect.minY - if (InputUtil.isKeyPressed(MC.window.handle, InputUtil.GLFW_KEY_LEFT_SHIFT)) { + if (InputUtil.isKeyPressed(MC.window, InputUtil.GLFW_KEY_LEFT_SHIFT)) { offsetX = MathHelper.floor(offsetX / 20F) * 20 offsetY = MathHelper.floor(offsetY / 20F) * 20 } @@ -297,16 +296,16 @@ class InventoryButtonEditor( return anchoredCoords } - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { - if (super.mouseClicked(mouseX, mouseY, button)) return true - val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(mouseX, mouseY)) } + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { + if (super.mouseClicked(click, doubled)) return true + val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(click.x, click.y) } if (clickedButton != null) { lastDraggedButton = clickedButton - initialDragMousePosition = Vec2f(mouseX.toFloat(), mouseY.toFloat()) + initialDragMousePosition = Vec2f(click.y.toFloat(), click.y.toFloat()) return true } - val mx = mouseX.toInt() - val my = mouseY.toInt() + val mx = click.x.toInt() + val my = click.y.toInt() val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(mx, my) ?: return true buttons.add(InventoryButton(offsetX, offsetY, anchorRight, anchorBottom, null, null)) justPerformedAClickAction = true diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt index e4d4e42..a4199c9 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt @@ -3,8 +3,11 @@ package moe.nea.firmament.features.inventory.storageoverlay import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.GenericContainerScreen +import net.minecraft.client.input.CharInput +import net.minecraft.client.input.KeyInput import net.minecraft.entity.player.PlayerInventory import net.minecraft.screen.slot.Slot import moe.nea.firmament.mixins.accessor.AccessorHandledScreen @@ -60,39 +63,41 @@ class StorageOverlayCustom( return false } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { - return overview.mouseReleased(mouseX, mouseY, button) + override fun mouseReleased(click: Click): Boolean { + return overview.mouseReleased(click) } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { - return overview.mouseDragged(mouseX, mouseY, button, deltaX, deltaY) + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { + return overview.mouseDragged(click, offsetX, offsetY) } - override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - return overview.keyReleased(keyCode, scanCode, modifiers) + override fun keyReleased(input: KeyInput): Boolean { + return overview.keyReleased(input) } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - return overview.keyPressed(keyCode, scanCode, modifiers) + override fun keyPressed(input: KeyInput): Boolean { + return overview.keyPressed(input) } - override fun charTyped(chr: Char, modifiers: Int): Boolean { - return overview.charTyped(chr, modifiers) + override fun charTyped(input: CharInput): Boolean { + return overview.charTyped(input) } - override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean { - return overview.mouseClicked(mouseX, mouseY, button, (handler as? StorageBackingHandle.Page)?.storagePageSlot) + override fun mouseClick(click: Click, doubled: Boolean): Boolean { + return overview.mouseClicked(click, doubled, (handler as? StorageBackingHandle.Page)?.storagePageSlot) } override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { overview.drawBackgrounds(drawContext) - overview.drawPages(drawContext, - mouseX, - mouseY, - delta, - (handler as? StorageBackingHandle.Page)?.storagePageSlot, - screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9), - Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament)) + overview.drawPages( + drawContext, + mouseX, + mouseY, + delta, + (handler as? StorageBackingHandle.Page)?.storagePageSlot, + screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9), + Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament) + ) overview.drawScrollBar(drawContext) overview.drawControls(drawContext, mouseX, mouseY) } diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt index c7ca6e4..d2fff9c 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt @@ -13,9 +13,12 @@ import io.github.notenoughupdates.moulconfig.observer.Property import java.util.TreeSet import me.shedaniel.math.Point import me.shedaniel.math.Rectangle +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.input.CharInput +import net.minecraft.client.input.KeyInput import net.minecraft.item.ItemStack import net.minecraft.screen.slot.Slot import net.minecraft.text.Text @@ -307,11 +310,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) { get() = guiContext.focusedElement == knobStub set(value) = knobStub.setFocus(value) - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { - return mouseClicked(mouseX, mouseY, button, null) + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { + return mouseClicked(click, doubled, null) } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseReleased(click: Click): Boolean { if (knobGrabbed) { knobGrabbed = false return true @@ -320,30 +323,32 @@ class StorageOverlayScreen : Screen(Text.literal("")) { controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - mouseX.toInt(), mouseY.toInt(), - MouseEvent.Click(button, false) + click.x.toInt(), click.y.toInt(), + MouseEvent.Click(click.button(), false) ) ) return true - return super.mouseReleased(mouseX, mouseY, button) + return super.mouseReleased(click) } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { if (knobGrabbed) { val sbRect = getScrollBarRect() - val percentage = (mouseY - sbRect.getY()) / sbRect.getHeight() + val percentage = (click.x - sbRect.getY()) / sbRect.getHeight() scroll = (getMaxScroll() * percentage).toFloat() mouseScrolled(0.0, 0.0, 0.0, 0.0) return true } - return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY) + return super.mouseDragged(click, offsetX, offsetY) } - fun mouseClicked(mouseX: Double, mouseY: Double, button: Int, activePage: StoragePageSlot?): Boolean { + fun mouseClicked(click: Click, doubled: Boolean, activePage: StoragePageSlot?): Boolean { guiContext.setFocusedElement(null) // Blur all elements. They will be refocused by clickMCComponentInPlace if in doubt, and we don't have any double click components. + val mouseX = click.x + val mouseY = click.y if (getScrollPanelInner().contains(mouseX, mouseY)) { - val data = StorageOverlay.Data.data ?: StorageData() + val data = StorageOverlay.Data.data layoutedForEach(data) { rect, page, _ -> - if (rect.contains(mouseX, mouseY) && activePage != page && button == 0) { + if (rect.contains(mouseX, mouseY) && activePage != page && click.button() == 0) { page.navigateTo() return true } @@ -363,53 +368,53 @@ class StorageOverlayScreen : Screen(Text.literal("")) { measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, mouseX.toInt(), mouseY.toInt(), - MouseEvent.Click(button, true) + MouseEvent.Click(click.button(), true) ) ) return true return false } - override fun charTyped(chr: Char, modifiers: Int): Boolean { + override fun charTyped(input: CharInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.CharTyped(chr) + KeyboardEvent.CharTyped(input.asString().first()) // TODO: i dont like this .first() ) ) { return true } - return super.charTyped(chr, modifiers) + return super.charTyped(input) } - override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { + override fun keyReleased(input: KeyInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.KeyPressed(keyCode, scanCode, false) + KeyboardEvent.KeyPressed(input.keycode, input.scancode, false) ) ) { return true } - return super.keyReleased(keyCode, scanCode, modifiers) + return super.keyReleased(input) } override fun shouldCloseOnEsc(): Boolean { return this === MC.screen // Fixes this UI closing the handled screen on Escape press. } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { + override fun keyPressed(input: KeyInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.KeyPressed(keyCode, scanCode, true) + KeyboardEvent.KeyPressed(input.keycode, input.scancode, true) ) ) { return true } - return super.keyPressed(keyCode, scanCode, modifiers) + return super.keyPressed(input) } @@ -506,7 +511,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) { val name = inventory.title val pageHeight = inv.rows * SLOT_SIZE + 8 + textRenderer.fontHeight if (slots != null && StorageOverlay.TConfig.outlineActiveStoragePage) - context.drawBorder( + context.drawStrokedRectangle( x, y + 3 + textRenderer.fontHeight, PAGE_WIDTH, diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt index 65d7e8c..a55b5ac 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt @@ -5,8 +5,10 @@ package moe.nea.firmament.features.inventory.storageoverlay import org.lwjgl.glfw.GLFW import kotlin.math.max import net.minecraft.block.Blocks +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen +import net.minecraft.client.input.KeyInput import net.minecraft.item.Item import net.minecraft.item.Items import net.minecraft.text.Text @@ -72,10 +74,10 @@ class StorageOverviewScreen() : Screen(Text.empty()) { lastRenderedHeight = totalHeight + currentMaxHeight } - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { layoutedForEach { (k, p), x, y -> - val rx = mouseX - x - val ry = mouseY - y + val rx = click.x - x + val ry = click.y - y if (rx in (0.0..pageWidth.toDouble()) && ry in (0.0..getStorePageHeight(p).toDouble())) { close() StorageOverlay.lastStorageOverlay = this @@ -83,7 +85,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) { return true } } - return super.mouseClicked(mouseX, mouseY, button) + return super.mouseClicked(click, doubled) } fun getStorePageHeight(page: StorageData.StorageInventory): Int { @@ -127,9 +129,9 @@ class StorageOverviewScreen() : Screen(Text.empty()) { } } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - if (keyCode == GLFW.GLFW_KEY_ESCAPE) + override fun keyPressed(input: KeyInput): Boolean { + if (input.keycode == GLFW.GLFW_KEY_ESCAPE) isClosing = true - return super.keyPressed(keyCode, scanCode, modifiers) + return super.keyPressed(input) } } diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt index aa45d82..97c9a7c 100644 --- a/src/main/kotlin/features/mining/HotmPresets.kt +++ b/src/main/kotlin/features/mining/HotmPresets.kt @@ -4,6 +4,7 @@ import me.shedaniel.math.Rectangle import kotlinx.serialization.Serializable import kotlin.time.Duration.Companion.seconds import net.minecraft.block.Blocks +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.entity.player.PlayerInventory @@ -99,14 +100,14 @@ object HotmPresets { var hasScrolled = false var hasAll = false - override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseClick(click: Click, doubled: Boolean): Boolean { if (!hasScrolled) { val slot = screen.screenHandler.getSlot(8) println("Clicking ${slot.stack}") slot.clickRightMouseButton(screen.screenHandler) } hasScrolled = true - return super.mouseClick(mouseX, mouseY, button) + return super.mouseClick(click, doubled) } override fun shouldDrawForeground(): Boolean { diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt index 086f2fb |
