aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt')
-rw-r--r--src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
index 9935051..9b87cc6 100644
--- a/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
+++ b/src/main/kotlin/features/events/anniversity/CenturyRaffleFeatures.kt
@@ -3,19 +3,21 @@ 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.gui.config.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SkyblockId
+import moe.nea.firmament.util.data.Config
+import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.render.TintedOverlayTexture
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SkyBlockItems
object CenturyRaffleFeatures {
+ @Config
object TConfig : ManagedConfig("centuryraffle", Category.EVENTS) {
val highlightPlayersForSlice by toggle("highlight-cake-players") { true }
// val highlightAllPlayers by toggle("highlight-all-cake-players") { true }
@@ -24,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)
@@ -49,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
}
}