From 35017667aa8bc893693fa26944d9ddbc3884c02d Mon Sep 17 00:00:00 2001 From: opekope2 Date: Wed, 25 Sep 2024 19:15:21 +0200 Subject: [PATCH] Backport to Minecraft 1.20 --- .../optigui/internal/selector/HorseSelectors.kt | 6 +++--- .../internal/selector/InteractionSelectors.kt | 2 +- .../optigui/internal/selector/LoadSelectors.kt | 2 +- .../kotlin/opekope2/optigui/toast/InspectorToast.kt | 4 +--- OptiGUI/src/main/resources/fabric.mod.json | 7 +++---- gradle/libs.versions.toml | 12 ++++++------ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/HorseSelectors.kt b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/HorseSelectors.kt index 170076fd2..94960b762 100644 --- a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/HorseSelectors.kt +++ b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/HorseSelectors.kt @@ -38,7 +38,7 @@ internal class HorseSaddleSelector : ISelector { } internal class HorseVariantSelector : AbstractListSelector() { - override fun parseSelector(selector: String) = HorseColor.entries.firstOrNull { it.name.lowercase() == selector } + override fun parseSelector(selector: String) = HorseColor.values().firstOrNull { it.name.lowercase() == selector } override fun parseFailed(invalidSelectors: Collection) = throw RuntimeException("Invalid horse variants: ${joinNotFound(invalidSelectors)}") @@ -55,7 +55,7 @@ internal class HorseVariantSelector : AbstractListSelector() { } internal class HorseMarkingSelector : AbstractListSelector() { - override fun parseSelector(selector: String) = HorseMarking.entries.firstOrNull { it.name.lowercase() == selector } + override fun parseSelector(selector: String) = HorseMarking.values().firstOrNull { it.name.lowercase() == selector } override fun parseFailed(invalidSelectors: Collection) = throw RuntimeException("Invalid horse markings: ${joinNotFound(invalidSelectors)}") @@ -92,7 +92,7 @@ internal class LlamaCarpetColorSelector : AbstractListSelector() { internal class LlamaVariantSelector : AbstractListSelector() { override fun parseSelector(selector: String) = - LlamaEntity.Variant.entries.firstOrNull { it.name.lowercase() == selector } + LlamaEntity.Variant.values().firstOrNull { it.name.lowercase() == selector } override fun parseFailed(invalidSelectors: Collection) = throw RuntimeException("Invalid llama variants: ${joinNotFound(invalidSelectors)}") diff --git a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/InteractionSelectors.kt b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/InteractionSelectors.kt index f3ff96474..3e4ed8200 100644 --- a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/InteractionSelectors.kt +++ b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/InteractionSelectors.kt @@ -22,7 +22,7 @@ internal class InteractionTextureSelector : ISelector { } internal class InteractionHandSelector : AbstractListSelector() { - override fun parseSelector(selector: String) = Hand.entries.firstOrNull { it.name.lowercase() == selector } + override fun parseSelector(selector: String) = Hand.values().firstOrNull { it.name.lowercase() == selector } override fun parseFailed(invalidSelectors: Collection) = throw RuntimeException("Invalid hands: ${joinNotFound(invalidSelectors)}") diff --git a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/LoadSelectors.kt b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/LoadSelectors.kt index 1d0143bc1..c2193d24d 100644 --- a/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/LoadSelectors.kt +++ b/OptiGUI/src/main/kotlin/opekope2/optigui/internal/selector/LoadSelectors.kt @@ -30,7 +30,7 @@ internal class ModsLoadSelector : (String) -> Boolean { private fun parseVersion(modWithVersion: String): Pair Boolean>? { return try { - val versionIndex = modWithVersion.indexOfAny(VersionComparisonOperator.entries.map { it.serialized }) + val versionIndex = modWithVersion.indexOfAny(VersionComparisonOperator.values().map { it.serialized }) if (versionIndex < 0) { return modWithVersion to { true } } diff --git a/OptiGUI/src/main/kotlin/opekope2/optigui/toast/InspectorToast.kt b/OptiGUI/src/main/kotlin/opekope2/optigui/toast/InspectorToast.kt index 9a01c99d3..db3b72526 100644 --- a/OptiGUI/src/main/kotlin/opekope2/optigui/toast/InspectorToast.kt +++ b/OptiGUI/src/main/kotlin/opekope2/optigui/toast/InspectorToast.kt @@ -4,7 +4,6 @@ import net.minecraft.client.gui.DrawContext import net.minecraft.client.toast.Toast import net.minecraft.client.toast.ToastManager import net.minecraft.text.Text -import net.minecraft.util.Identifier /** * A toast displaying the inspector message. @@ -12,7 +11,7 @@ import net.minecraft.util.Identifier class InspectorToast : Toast { override fun draw(context: DrawContext, manager: ToastManager, startTime: Long): Toast.Visibility { val textRenderer = manager.client.textRenderer - context.drawGuiTexture(TEXTURE, 0, 0, width, height) + context.drawTexture(Toast.TEXTURE, 0, 0, 0, 0, width, height) context.drawText(textRenderer, TITLE, 7, 7, 0xFF00FFFF.toInt(), false) context.drawText(textRenderer, DESCRIPTION, 7, 18, 0xFFFFFFFF.toInt(), false) @@ -21,7 +20,6 @@ class InspectorToast : Toast { } companion object { - private val TEXTURE = Identifier("toast/advancement") private val TITLE = Text.translatable("optigui.toast.inspector.title") private val DESCRIPTION = Text.translatable("optigui.toast.inspector.description") } diff --git a/OptiGUI/src/main/resources/fabric.mod.json b/OptiGUI/src/main/resources/fabric.mod.json index 32909ff01..996c58d13 100644 --- a/OptiGUI/src/main/resources/fabric.mod.json +++ b/OptiGUI/src/main/resources/fabric.mod.json @@ -91,7 +91,7 @@ "fabric-networking-api-v1": "*", "fabric-resource-loader-v0": "*", "fabric-language-kotlin": ">=$fabric_language_kotlin", - "minecraft": ">=$minecraft <1.20.5", + "minecraft": ">=$minecraft <1.20.2", "java": ">=$java" }, "recommends": { @@ -120,7 +120,6 @@ "minecraft:trapped_chest": "minecraft:textures/gui/container/generic_54.png", "minecraft:chest_boat": "minecraft:textures/gui/container/generic_54.png", "minecraft:chest_minecart": "minecraft:textures/gui/container/generic_54.png", - "minecraft:crafter": "minecraft:textures/gui/container/crafter.png", "minecraft:crafting_table": "minecraft:textures/gui/container/crafting_table.png", "minecraft:dispenser": "minecraft:textures/gui/container/dispenser.png", "minecraft:dropper": "minecraft:textures/gui/container/dispenser.png", @@ -182,8 +181,8 @@ "minecraft:yellow_shulker_box": "minecraft:textures/gui/container/shulker_box.png", "minecraft:smithing_table": "minecraft:textures/gui/container/smithing.png", "minecraft:stonecutter": "minecraft:textures/gui/container/stonecutter.png", - "minecraft:villager": "minecraft:textures/gui/container/villager.png", - "minecraft:wandering_trader": "minecraft:textures/gui/container/villager.png", + "minecraft:villager": "minecraft:textures/gui/container/villager2.png", + "minecraft:wandering_trader": "minecraft:textures/gui/container/villager2.png", "minecraft:writable_book": "minecraft:textures/gui/book.png", "minecraft:written_book": "minecraft:textures/gui/book.png", "minecraft:player": "minecraft:textures/gui/container/inventory.png" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6009f6a6a..d34c2ee96 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,13 @@ [versions] java = "17" # Don't forget to update *.mixins.json -kotlin = "1.9.22" -optigui = "2.3.0-beta.5+1.20.2" -minecraft = "1.20.2" -yarn = "1.20.2+build.4" +kotlin = "1.8.21" +optigui = "2.3.0-beta.5+1.20" +minecraft = "1.20" +yarn = "1.20+build.1" fabric-loom = "1.5-SNAPSHOT" fabric-loader = "0.15.7" -fabric-api = "0.91.6+1.20.2" -fabric-language-kotlin = "1.10.18+kotlin.1.9.22" +fabric-api = "0.83.0+1.20" +fabric-language-kotlin = "1.9.4+kotlin.1.8.21" commons-text = "1.11.0" ini4j = "0.5.4" dokka = "1.9.20"