Skip to content

Commit

Permalink
Backport to Minecraft 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
opekope2 committed Sep 25, 2024
1 parent 1353769 commit 3501766
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class HorseSaddleSelector : ISelector {
}

internal class HorseVariantSelector : AbstractListSelector<HorseColor>() {
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<String>) =
throw RuntimeException("Invalid horse variants: ${joinNotFound(invalidSelectors)}")
Expand All @@ -55,7 +55,7 @@ internal class HorseVariantSelector : AbstractListSelector<HorseColor>() {
}

internal class HorseMarkingSelector : AbstractListSelector<HorseMarking>() {
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<String>) =
throw RuntimeException("Invalid horse markings: ${joinNotFound(invalidSelectors)}")
Expand Down Expand Up @@ -92,7 +92,7 @@ internal class LlamaCarpetColorSelector : AbstractListSelector<DyeColor>() {

internal class LlamaVariantSelector : AbstractListSelector<LlamaEntity.Variant>() {
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<String>) =
throw RuntimeException("Invalid llama variants: ${joinNotFound(invalidSelectors)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class InteractionTextureSelector : ISelector {
}

internal class InteractionHandSelector : AbstractListSelector<Hand>() {
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<String>) =
throw RuntimeException("Invalid hands: ${joinNotFound(invalidSelectors)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class ModsLoadSelector : (String) -> Boolean {

private fun parseVersion(modWithVersion: String): Pair<String, (Version) -> 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 }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ 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.
*/
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)
Expand All @@ -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")
}
Expand Down
7 changes: 3 additions & 4 deletions OptiGUI/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 3501766

Please sign in to comment.