diff options
Diffstat (limited to 'src/main/kotlin/features/events/carnival')
| -rw-r--r-- | src/main/kotlin/features/events/carnival/CarnivalFeatures.kt | 13 | ||||
| -rw-r--r-- | src/main/kotlin/features/events/carnival/MinesweeperHelper.kt | 53 |
2 files changed, 33 insertions, 33 deletions
diff --git a/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt b/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt index 840fb8c..3f149ff 100644 --- a/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt +++ b/src/main/kotlin/features/events/carnival/CarnivalFeatures.kt @@ -1,17 +1,16 @@ package moe.nea.firmament.features.events.carnival -import moe.nea.firmament.features.FirmamentFeature -import moe.nea.firmament.gui.config.ManagedConfig +import moe.nea.firmament.util.data.Config +import moe.nea.firmament.util.data.ManagedConfig -object CarnivalFeatures : FirmamentFeature { - object TConfig : ManagedConfig(identifier, Category.EVENTS) { +object CarnivalFeatures { + @Config + object TConfig : ManagedConfig(identifier, Category.EVENTS) { val enableBombSolver by toggle("bombs-solver") { true } val displayTutorials by toggle("tutorials") { true } } - override val config: ManagedConfig? - get() = TConfig - override val identifier: String + val identifier: String get() = "carnival" } diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt index cfc05cc..64b3814 100644 --- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt +++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt @@ -2,17 +2,17 @@ package moe.nea.firmament.features.events.carnival import io.github.notenoughupdates.moulconfig.observer.ObservableList -import io.github.notenoughupdates.moulconfig.platform.ModernItemStack +import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform import io.github.notenoughupdates.moulconfig.xml.Bind import java.util.UUID -import net.minecraft.block.Blocks -import net.minecraft.item.Item -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.text.ClickEvent -import net.minecraft.text.Text -import net.minecraft.util.math.BlockPos -import net.minecraft.world.WorldAccess +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraft.network.chat.ClickEvent +import net.minecraft.network.chat.Component +import net.minecraft.core.BlockPos +import net.minecraft.world.level.LevelAccessor import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.thenExecute import moe.nea.firmament.events.AttackBlockEvent @@ -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 = Component.literal(fruitName) @Bind - fun getIcon() = ModernItemStack.of(itemStack) + fun getIcon() = MoulConfigPlatform.wrap(itemStack) - @Bind - fun pieceLabel() = fruitColor.formattingCode + fruitName + @get:Bind("pieceLabel") + val pieceLabel = Component.literal(fruitColor.formattingCode + fruitName) - @Bind - fun boardLabel() = "§a$totalPerBoard§7/§rboard" + @get:Bind("boardLabel") + val boardLabel = Component.literal("§a$totalPerBoard§7/§rboard") - @Bind("description") - fun getDescription() = buildString { + @get:Bind("description") + val getDescription = Component.literal(buildString { append(specialAbility) if (points >= 0) { append(" Default points: $points.") } } - } +) } object TutorialScreen { @get:Bind("pieces") @@ -158,7 +159,7 @@ object MinesweeperHelper { ; @Bind("itemType") - fun getItemStack() = ModernItemStack.of(ItemStack(itemType)) + fun getItemStack() = MoulConfigPlatform.wrap(ItemStack(itemType)) companion object { val id = SkyblockId("CARNIVAL_SHOVEL") @@ -175,10 +176,10 @@ object MinesweeperHelper { ) { fun toBlockPos() = BlockPos(sandBoxLow.x + x, sandBoxLow.y, sandBoxLow.z + y) - fun getBlock(world: WorldAccess) = world.getBlockState(toBlockPos()).block - fun isUnopened(world: WorldAccess) = getBlock(world) == Blocks.SAND - fun isOpened(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE - fun isScorched(world: WorldAccess) = getBlock(world) == Blocks.SANDSTONE_STAIRS + fun getBlock(world: LevelAccessor) = world.getBlockState(toBlockPos()).block + fun isUnopened(world: LevelAccessor) = getBlock(world) == Blocks.SAND + fun isOpened(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE + fun isScorched(world: LevelAccessor) = getBlock(world) == Blocks.SANDSTONE_STAIRS companion object { fun fromBlockPos(blockPos: BlockPos): BoardPosition? { @@ -221,7 +222,7 @@ object MinesweeperHelper { @Subscribe fun onChat(event: ProcessChatEvent) { if (CarnivalFeatures.TConfig.displayTutorials && event.unformattedString == startGameQuestion) { - MC.sendChat(Text.translatable("firmament.carnival.tutorial.minesweeper").styled { + MC.sendChat(Component.translatable("firmament.carnival.tutorial.minesweeper").withStyle { it.withClickEvent(ClickEvent.RunCommand("/firm minesweepertutorial")) }) } @@ -259,7 +260,7 @@ object MinesweeperHelper { val boardPosition = BoardPosition.fromBlockPos(event.blockPos) log.log { "Breaking block at ${event.blockPos} ($boardPosition)" } gs.lastClickedPosition = boardPosition - gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandStack) + gs.lastDowsingMode = DowsingMode.fromItem(event.player.mainHandItem) } @Subscribe @@ -267,7 +268,7 @@ object MinesweeperHelper { val gs = gameState ?: return RenderInWorldContext.renderInWorld(event) { for ((pos, bombCount) in gs.nearbyBombs) { - this.text(pos.toBlockPos().up().toCenterPos(), Text.literal("§a$bombCount \uD83D\uDCA3")) + this.text(pos.toBlockPos().above().center, Component.literal("§a$bombCount \uD83D\uDCA3")) } } } |
