diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-10-19 00:27:17 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-10-19 00:27:17 +0200 |
| commit | 28c3ba952d69c8a654301c9211d536493513fdd5 (patch) | |
| tree | e5fc341fe7f12d2d5b7bc9d78474b9472d9af163 /src/main/kotlin | |
| parent | 9036f2f09cab47bc78c0d7e5ae4909da745e07ec (diff) | |
| download | Firmament-28c3ba952d69c8a654301c9211d536493513fdd5.tar.gz Firmament-28c3ba952d69c8a654301c9211d536493513fdd5.tar.bz2 Firmament-28c3ba952d69c8a654301c9211d536493513fdd5.zip | |
fix: strings in mc bindings
Diffstat (limited to 'src/main/kotlin')
5 files changed, 35 insertions, 24 deletions
diff --git a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt index 80b30ee..ded5e13 100644 --- a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt +++ b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt @@ -5,6 +5,7 @@ import io.github.notenoughupdates.moulconfig.xml.Bind import org.joml.Vector2i import kotlin.time.Duration.Companion.seconds import net.minecraft.entity.passive.PigEntity +import net.minecraft.text.Text import net.minecraft.util.math.BlockPos import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.EntityInteractionEvent @@ -202,12 +203,12 @@ object AnniversaryFeatures { @OptIn(ExpensiveItemCacheApi::class) @Bind - fun name(): String { + fun name(): Text { return when (backedBy) { - is Reward.Coins -> "Coins" - is Reward.EXP -> backedBy.skill - is Reward.Items -> itemStack.asImmutableItemStack().name.string - is Reward.Unknown -> backedBy.text + is Reward.Coins -> Text.literal("Coins") + is Reward.EXP -> Text.literal(backedBy.skill) + is Reward.Items -> itemStack.asImmutableItemStack().name + is Reward.Unknown -> Text.literal(backedBy.text) } } diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt index 3baf5a5..e675cc9 100644 --- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt +++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt @@ -45,7 +45,6 @@ object MinesweeperHelper { enum class Piece( - @get:Bind("fruitName") val fruitName: String, val points: Int, val specialAbility: String, @@ -118,24 +117,26 @@ object MinesweeperHelper { val textureUrl = "http://textures.minecraft.net/texture/$textureHash" val itemStack = createSkullItem(UUID.randomUUID(), textureUrl) .setSkyBlockFirmamentUiId("MINESWEEPER_$name") + @get:Bind("fruitName") + val textFruitName = Text.literal(fruitName) @Bind fun getIcon() = MoulConfigPlatform.wrap(itemStack) - @Bind - fun pieceLabel() = fruitColor.formattingCode + fruitName + @get:Bind("pieceLabel") + val pieceLabel = Text.literal(fruitColor.formattingCode + fruitName) - @Bind - fun boardLabel() = "§a$totalPerBoard§7/§rboard" + @get:Bind("boardLabel") + val boardLabel = Text.literal("§a$totalPerBoard§7/§rboard") - @Bind("description") - fun getDescription() = buildString { + @get:Bind("description") + val getDescription = Text.literal(buildString { append(specialAbility) if (points >= 0) { append(" Default points: $points.") } } - } +) } object TutorialScreen { @get:Bind("pieces") diff --git a/src/main/kotlin/features/misc/LicenseViewer.kt b/src/main/kotlin/features/misc/LicenseViewer.kt index 4219177..7a43554 100644 --- a/src/main/kotlin/features/misc/LicenseViewer.kt +++ b/src/main/kotlin/features/misc/LicenseViewer.kt @@ -6,6 +6,7 @@ import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import kotlinx.serialization.json.decodeFromStream +import net.minecraft.text.Text import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.thenExecute @@ -30,17 +31,18 @@ object LicenseViewer { fun hasWebPresence() = webPresence != null @Bind - fun webPresence() = webPresence ?: "<no web presence>" + fun webPresence() = Text.literal(webPresence ?: "<no web presence>") + @Bind fun open() { MC.openUrl(webPresence ?: return) } @Bind - fun projectName() = projectName + fun projectName() = Text.literal(projectName) @Bind - fun projectDescription() = projectDescription ?: "<no project description>" + fun projectDescription() = Text.literal(projectDescription ?: "<no project description>") @get:Bind("developers") @Transient @@ -53,10 +55,13 @@ object LicenseViewer { @Serializable data class Developer( - @get:Bind("name") val name: String, + val name: String, val webPresence: String? = null ) { + @Bind("name") + fun nameT() = Text.literal(name) + @Bind fun open() { MC.openUrl(webPresence ?: return) @@ -66,14 +71,17 @@ object LicenseViewer { fun hasWebPresence() = webPresence != null @Bind - fun webPresence() = webPresence ?: "<no web presence>" + fun webPresence() = Text.literal(webPresence ?: "<no web presence>") } @Serializable data class License( - @get:Bind("name") val licenseName: String, + val licenseName: String, val licenseUrl: String? = null ) { + @Bind("name") + fun nameG() = Text.literal(licenseName) + @Bind fun open() { MC.openUrl(licenseUrl ?: return) @@ -83,7 +91,7 @@ object LicenseViewer { fun hasUrl() = licenseUrl != null @Bind - fun url() = licenseUrl ?: "<no link to license text>" + fun url() = Text.literal(licenseUrl ?: "<no link to license text>") } data class LicenseList( diff --git a/src/main/kotlin/features/world/NpcWaypointGui.kt b/src/main/kotlin/features/world/NpcWaypointGui.kt index 6146e50..b6db7eb 100644 --- a/src/main/kotlin/features/world/NpcWaypointGui.kt +++ b/src/main/kotlin/features/world/NpcWaypointGui.kt @@ -2,6 +2,7 @@ package moe.nea.firmament.features.world import io.github.notenoughupdates.moulconfig.observer.ObservableList import io.github.notenoughupdates.moulconfig.xml.Bind +import net.minecraft.text.Text import moe.nea.firmament.features.events.anniversity.AnniversaryFeatures.atOnce import moe.nea.firmament.keybindings.SavedKeyBinding @@ -11,7 +12,7 @@ class NpcWaypointGui( data class NavigableWaypointW(val waypoint: NavigableWaypoint) { @Bind - fun name() = waypoint.name + fun name() = Text.literal(waypoint.name) @Bind fun isSelected() = NavigationHelper.targetWaypoint == waypoint diff --git a/src/main/kotlin/gui/config/AllConfigsGui.kt b/src/main/kotlin/gui/config/AllConfigsGui.kt index 345269d..869bda6 100644 --- a/src/main/kotlin/gui/config/AllConfigsGui.kt +++ b/src/main/kotlin/gui/config/AllConfigsGui.kt @@ -37,7 +37,7 @@ object AllConfigsGui { val configs = category.configs.map { EntryMapping(it) }.toObservableList() @Bind - fun name() = category.labelText.string + fun name() = category.labelText @Bind fun close() { @@ -46,7 +46,7 @@ object AllConfigsGui { class EntryMapping(val config: ManagedConfig) { @Bind - fun name() = Text.translatable("firmament.config.${config.name}").string + fun name() = Text.translatable("firmament.config.${config.name}") @Bind fun openEditor() { @@ -63,7 +63,7 @@ object AllConfigsGui { class CategoryEntry(val category: ManagedConfig.Category) { @Bind - fun name() = category.labelText.string + fun name() = category.labelText @Bind fun open() { |
