aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/events')
-rw-r--r--src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt30
-rw-r--r--src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt28
-rw-r--r--src/main/kotlin/features/events/carnival/MinesweeperHelper.kt38
3 files changed, 48 insertions, 48 deletions
diff --git a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
index ded5e13..955d23b 100644
--- a/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/AnniversaryFeatures.kt
@@ -4,9 +4,9 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
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 net.minecraft.world.entity.animal.Pig
+import net.minecraft.network.chat.Component
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityInteractionEvent
import moe.nea.firmament.events.ProcessChatEvent
@@ -36,16 +36,16 @@ object AnniversaryFeatures {
}
data class ClickedPig(
- val clickedAt: TimeMark,
- val startLocation: BlockPos,
- val pigEntity: PigEntity
+ val clickedAt: TimeMark,
+ val startLocation: BlockPos,
+ val pigEntity: Pig
) {
@Bind("timeLeft")
fun getTimeLeft(): Double = 1 - clickedAt.passedTime() / pigDuration
}
val clickedPigs = ObservableList<ClickedPig>(mutableListOf())
- var lastClickedPig: PigEntity? = null
+ var lastClickedPig: Pig? = null
val pigDuration = 90.seconds
@@ -62,14 +62,14 @@ object AnniversaryFeatures {
if (event.unformattedString == "Oink! Bring the pig back to the Shiny Orb!") {
val pig = lastClickedPig ?: return
// TODO: store proper location based on the orb location, maybe
- val startLocation = pig.blockPos ?: return
+ val startLocation = pig.blockPosition() ?: return
clickedPigs.add(ClickedPig(TimeMark.now(), startLocation, pig))
lastClickedPig = null
}
if (event.unformattedString == "SHINY! The orb is charged! Click on it for loot!") {
val player = MC.player ?: return
val lowest =
- clickedPigs.minByOrNull { it.startLocation.getSquaredDistance(player.pos) } ?: return
+ clickedPigs.minByOrNull { it.startLocation.distToCenterSqr(player.position) } ?: return
clickedPigs.remove(lowest)
}
pattern.useMatch(event.unformattedString) {
@@ -166,7 +166,7 @@ object AnniversaryFeatures {
@Subscribe
fun onEntityClick(event: EntityInteractionEvent) {
- if (event.entity is PigEntity) {
+ if (event.entity is Pig) {
lastClickedPig = event.entity
}
}
@@ -203,12 +203,12 @@ object AnniversaryFeatures {
@OptIn(ExpensiveItemCacheApi::class)
@Bind
- fun name(): Text {
+ fun name(): Component {
return when (backedBy) {
- 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)
+ is Reward.Coins -> Component.literal("Coins")
+ is Reward.EXP -> Component.literal(backedBy.skill)
+ is Reward.Items -> itemStack.asImmutableItemStack().hoverName
+ is Reward.Unknown -> Component.literal(backedBy.text)
}
}
diff --git a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
index 13ecd7b..9b87cc6 100644
--- a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
@@ -3,9 +3,9 @@ package moe.nea.firmament.features.events.anniversity
import java.util.Optional
import me.shedaniel.math.Color
import kotlin.jvm.optionals.getOrNull
-import net.minecraft.entity.player.PlayerEntity
-import net.minecraft.text.Style
-import net.minecraft.util.Formatting
+import net.minecraft.world.entity.player.Player
+import net.minecraft.network.chat.Style
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.EntityRenderTintEvent
import moe.nea.firmament.util.MC
@@ -26,18 +26,18 @@ object CenturyRaffleFeatures {
val cakeIcon = "⛃"
val cakeColors = listOf(
- CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, Formatting.BLUE),
- CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, Formatting.YELLOW),
- CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, Formatting.GREEN),
- CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, Formatting.RED),
- CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, Formatting.LIGHT_PURPLE),
+ CakeTeam(SkyBlockItems.SLICE_OF_BLUEBERRY_CAKE, ChatFormatting.BLUE),
+ CakeTeam(SkyBlockItems.SLICE_OF_CHEESECAKE, ChatFormatting.YELLOW),
+ CakeTeam(SkyBlockItems.SLICE_OF_GREEN_VELVET_CAKE, ChatFormatting.GREEN),
+ CakeTeam(SkyBlockItems.SLICE_OF_RED_VELVET_CAKE, ChatFormatting.RED),
+ CakeTeam(SkyBlockItems.SLICE_OF_STRAWBERRY_SHORTCAKE, ChatFormatting.LIGHT_PURPLE),
)
data class CakeTeam(
- val id: SkyblockId,
- val formatting: Formatting,
+ val id: SkyblockId,
+ val formatting: ChatFormatting,
) {
- val searchedTextRgb = formatting.colorValue!!
+ val searchedTextRgb = formatting.color!!
val brightenedRgb = Color.ofOpaque(searchedTextRgb)//.brighter(2.0)
val tintOverlay by lazy {
TintedOverlayTexture().setColor(brightenedRgb)
@@ -51,13 +51,13 @@ object CenturyRaffleFeatures {
if (!TConfig.highlightPlayersForSlice) return
val requestedCakeTeam = sliceToColor[MC.stackInHand?.skyBlockId] ?: return
// TODO: cache the requested color
- val player = event.entity as? PlayerEntity ?: return
- val cakeColor: Style = player.styledDisplayName.visit(
+ val player = event.entity as? Player ?: return
+ val cakeColor: Style = player.feedbackDisplayName.visit(
{ style, text ->
if (text == cakeIcon) Optional.of(style)
else Optional.empty()
}, Style.EMPTY).getOrNull() ?: return
- if (cakeColor.color?.rgb == requestedCakeTeam.searchedTextRgb) {
+ if (cakeColor.color?.value == requestedCakeTeam.searchedTextRgb) {
event.renderState.overlayTexture_firmament = requestedCakeTeam.tintOverlay
}
}
diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
index e675cc9..64b3814 100644
--- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
+++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
@@ -5,14 +5,14 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
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
@@ -118,19 +118,19 @@ object MinesweeperHelper {
val itemStack = createSkullItem(UUID.randomUUID(), textureUrl)
.setSkyBlockFirmamentUiId("MINESWEEPER_$name")
@get:Bind("fruitName")
- val textFruitName = Text.literal(fruitName)
+ val textFruitName = Component.literal(fruitName)
@Bind
fun getIcon() = MoulConfigPlatform.wrap(itemStack)
@get:Bind("pieceLabel")
- val pieceLabel = Text.literal(fruitColor.formattingCode + fruitName)
+ val pieceLabel = Component.literal(fruitColor.formattingCode + fruitName)
@get:Bind("boardLabel")
- val boardLabel = Text.literal("§a$totalPerBoard§7/§rboard")
+ val boardLabel = Component.literal("§a$totalPerBoard§7/§rboard")
@get:Bind("description")
- val getDescription = Text.literal(buildString {
+ val getDescription = Component.literal(buildString {
append(specialAbility)
if (points >= 0) {
append(" Default points: $points.")
@@ -176,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? {
@@ -222,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"))
})
}
@@ -260,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
@@ -268,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"))
}
}
}