diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer')
9 files changed, 162 insertions, 102 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt deleted file mode 100644 index 8c6399dde..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HighlightSlayerMiniBoss.kt +++ /dev/null @@ -1,52 +0,0 @@ -package at.hannibal2.skyhanni.features.slayer - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper -import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.entity.EntityCreature -import net.minecraft.entity.monster.EntityBlaze -import net.minecraft.entity.monster.EntityEnderman -import net.minecraft.entity.monster.EntitySpider -import net.minecraft.entity.monster.EntityZombie -import net.minecraft.entity.passive.EntityWolf -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class HighlightSlayerMiniBoss { - - @SubscribeEvent - fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { - if (!isEnabled()) return - - val entity = event.entity - if (DamageIndicatorManager.isBoss(entity)) return - - val maxHealth = event.maxHealth - for (bossType in SlayerMiniBossType.entries) { - if (!bossType.clazz.isInstance(entity)) continue - - if (bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) { - RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127)) - { SkyHanniMod.feature.slayer.slayerMinibossHighlight } - RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.slayer.slayerMinibossHighlight } - } - } - } - - private fun isEnabled() = LorenzUtils.inSkyBlock && - SkyHanniMod.feature.slayer.slayerMinibossHighlight && - !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight - - enum class SlayerMiniBossType(val clazz: Class<out EntityCreature>, vararg val health: Int) { - REVENANT(EntityZombie::class.java, 24_000, 90_000, 360_000, 600_000, 2_400_000), - TARANTULA(EntitySpider::class.java, 54_000, 144_000, 576_000), - SVEN(EntityWolf::class.java, 45_000, 120_000, 480_000), - VOIDLING(EntityEnderman::class.java, 8_400_000, 17_500_000, 52_500_000), - INFERNAL(EntityBlaze::class.java, 12_000_000, 25_000_000), - ; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt index 0ab6eb997..1d8dd0698 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class SlayerBossSpawnSoon { @@ -28,7 +29,7 @@ class SlayerBossSpawnSoon { if (completion > config.percent / 100.0) { if (!warned || (config.repeat && completion != lastCompletion)) { SoundUtils.playBeepSound() - TitleUtils.sendTitle("§cSlayer boss soon!", 2_000) + TitleUtils.sendTitle("§cSlayer boss soon!", 2.seconds) warned = true } } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index c402becdb..8130526f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -29,6 +29,7 @@ import net.minecraft.network.play.server.S0DPacketCollectItem import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.seconds object SlayerItemProfitTracker { private val config get() = SkyHanniMod.feature.slayer.itemProfitTracker @@ -148,7 +149,7 @@ object SlayerItemProfitTracker { } if (config.titleWarning) { if (price > config.minimumPriceWarning) { - TitleUtils.sendTitle("§a+ $itemName", 5_000) + TitleUtils.sendTitle("§a+ $itemName", 5.seconds) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt new file mode 100644 index 000000000..c03e47146 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt @@ -0,0 +1,81 @@ +package at.hannibal2.skyhanni.features.slayer + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.EntityCreature +import net.minecraft.entity.monster.EntityBlaze +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.entity.monster.EntitySpider +import net.minecraft.entity.monster.EntityZombie +import net.minecraft.entity.passive.EntityWolf +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class SlayerMiniBossFeatures { + private val config get() = SkyHanniMod.feature.slayer + private var miniBosses = listOf<EntityCreature>() + + @SubscribeEvent + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!isEnabled()) return + val entity = event.entity as? EntityCreature ?: return + if (DamageIndicatorManager.isBoss(entity)) return + + val maxHealth = event.maxHealth + for (bossType in SlayerMiniBossType.entries) { + if (!bossType.health.any { entity.hasMaxHealth(it, false, maxHealth) }) continue + if (!bossType.clazz.isInstance(entity)) continue + + miniBosses = miniBosses.editCopy { add(entity) } + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.AQUA.toColor().withAlpha(127)) + { config.slayerMinibossHighlight } + RenderLivingEntityHelper.setNoHurtTime(entity) { config.slayerMinibossHighlight } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + miniBosses = emptyList() + } + + @SubscribeEvent + fun onWorldRender(event: RenderWorldLastEvent) { + if (!config.slayerMinibossLine) return + for (mob in miniBosses) { + if (mob.health <= 0) continue + if (mob.isDead) continue + if (mob.distanceToPlayer() > 10) continue + + event.draw3DLine( + event.exactPlayerEyeLocation(), + mob.getLorenzVec().add(0, 1, 0), + LorenzColor.AQUA.toColor(), + 3, + true + ) + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight + + enum class SlayerMiniBossType(val clazz: Class<out EntityCreature>, vararg val health: Int) { + REVENANT(EntityZombie::class.java, 24_000, 90_000, 360_000, 600_000, 2_400_000), + TARANTULA(EntitySpider::class.java, 54_000, 144_000, 576_000), + SVEN(EntityWolf::class.java, 45_000, 120_000, 480_000), + VOIDLING(EntityEnderman::class.java, 8_400_000, 17_500_000, 52_500_000), + INFERNAL(EntityBlaze::class.java, 12_000_000, 25_000_000), + ; + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 9fc4b9c6e..6c3648bcc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class SlayerQuestWarning { private val config get() = SkyHanniMod.feature.slayer @@ -134,7 +135,7 @@ class SlayerQuestWarning { LorenzUtils.chat("§e[SkyHanni] $chatMessage") if (config.questWarningTitle) { - TitleUtils.sendTitle("§e$titleMessage", 2_000) + TitleUtils.sendTitle("§e$titleMessage", 2.seconds) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 371aa5337..7f785cf10 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd import io.github.moulberry.notenoughupdates.util.Constants import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.ceil +import kotlin.time.Duration.Companion.seconds class SlayerRngMeterDisplay { private val config get() = SkyHanniMod.feature.slayer.rngMeterDisplay @@ -74,7 +75,7 @@ class SlayerRngMeterDisplay { if (!hasItemSelected) { if (config.warnEmpty) { LorenzUtils.warning("§c[Skyhanni] No Slayer RNG Meter Item selected!") - TitleUtils.sendTitle("§cNo RNG Meter Item!", 3_000) + TitleUtils.sendTitle("§cNo RNG Meter Item!", 3.seconds) } } var blockChat = config.hideChat && hasItemSelected diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index 9948695bb..6d93816b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation import at.hannibal2.skyhanni.utils.SoundUtils.playSound import kotlinx.coroutines.* import net.minecraft.client.Minecraft @@ -127,8 +128,12 @@ object VampireSlayerFeatures { if (shouldSendSound) playTwinclawsSound() if (shouldSendTitle) - TitleUtils.sendTitle("§6§lTWINCLAWS", (1750 - config.twinclawsDelay), 2.6) - nextClawSend = System.currentTimeMillis() + 5000 + TitleUtils.sendTitle( + "§6§lTWINCLAWS", + (1750 - config.twinclawsDelay).milliseconds, + 2.6 + ) + nextClawSend = System.currentTimeMillis() + 5_000 } } } @@ -178,7 +183,7 @@ object VampireSlayerFeatures { else canUseSteak && configCoopBoss.steakAlert && containCoop if (shouldSendSteakTitle) - TitleUtils.sendTitle("§c§lSTEAK!", 300, 2.6) + TitleUtils.sendTitle("§c§lSTEAK!", 300.milliseconds, 2.6) if (shouldRender) { RenderLivingEntityHelper.setEntityColor(this, color) { isEnabled() } @@ -278,10 +283,8 @@ object VampireSlayerFeatures { val vec = event.exactLocation(it) val distance = start.distance(vec) if (distance <= 15) { - val player = Minecraft.getMinecraft().thePlayer - val add = if (player.isSneaking) LorenzVec(0.0, 1.54, 0.0) else LorenzVec(0.0, 1.62, 0.0) event.draw3DLine( - event.exactLocation(player).add(add), + event.exactPlayerEyeLocation(), vec.add(0.0, 1.54, 0.0), config.lineColor.toChromaColor(), config.lineWidth, diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt index c518d1317..723432b9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.SoundUtils.playSound import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class BlazeSlayerFirePitsWarning { private val config get() = SkyHanniMod.feature.slayer @@ -18,7 +19,7 @@ class BlazeSlayerFirePitsWarning { private var lastFirePitsWarning = 0L fun fireFirePits() { - TitleUtils.sendTitle("§cFire Pits!", 2_000) + TitleUtils.sendTitle("§cFire Pits!", 2.seconds) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index be9debe90..776545a6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor @@ -16,13 +17,12 @@ import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation import at.hannibal2.skyhanni.utils.TimeUtils.format -import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityEnderman import net.minecraft.init.Blocks import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -30,7 +30,7 @@ class EndermanSlayerFeatures { private val config get() = SkyHanniMod.feature.slayer private val beaconConfig get() = config.endermanBeaconConfig private val endermenWithBeacons = mutableListOf<EntityEnderman>() - private val flyingBeacons = mutableListOf<EntityArmorStand>() + private var flyingBeacons = listOf<EntityArmorStand>() private val nukekubiSkulls = mutableListOf<EntityArmorStand>() private var sittingBeacon = mapOf<LorenzVec, SimpleTimeMark>() private val logger = LorenzLogger("slayer/enderman") @@ -44,7 +44,7 @@ class EndermanSlayerFeatures { if (entity in endermenWithBeacons || entity in flyingBeacons) return if (entity is EntityEnderman) { - if (beaconConfig.enabled) { + if (showBeacon()) { if (hasBeaconInHand(entity) && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { endermenWithBeacons.add(entity) logger.log("Added enderman with beacon at ${entity.getLorenzVec()}") @@ -53,12 +53,14 @@ class EndermanSlayerFeatures { } if (entity is EntityArmorStand) { - if (beaconConfig.showLine) { + if (showBeacon()) { val stack = entity.inventory[4] ?: return if (stack.name == "Beacon" && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { - flyingBeacons.add(entity) + flyingBeacons = flyingBeacons.editCopy { + add(entity) + } if (beaconConfig.showWarning) - TitleUtils.sendTitle("§4Beacon", 2_00) + TitleUtils.sendTitle("§4Beacon", 2.seconds) logger.log("Added flying beacons at ${entity.getLorenzVec()}") } } @@ -78,12 +80,14 @@ class EndermanSlayerFeatures { private fun canSee(a: LorenzVec, b: LorenzVec) = LocationUtils.canSee(a, b) || a.distance(b) < 15 + private fun showBeacon() = beaconConfig.highlightBeacon || beaconConfig.showWarning || beaconConfig.showLine + @SubscribeEvent fun onRenderMobColored(event: RenderMobColoredEvent) { if (!IslandType.THE_END.isInIsland()) return - if (beaconConfig.enabled && event.entity in flyingBeacons) { - event.color = LorenzColor.DARK_RED.toColor().withAlpha(1) + if (beaconConfig.highlightBeacon && event.entity in flyingBeacons) { + event.color = beaconConfig.beaconColor.toChromaColor().withAlpha(1) } if (config.endermanHighlightNukekebi && event.entity in nukekubiSkulls) { @@ -91,45 +95,58 @@ class EndermanSlayerFeatures { } } - @SubscribeEvent(priority = EventPriority.HIGH) + @SubscribeEvent fun onWorldRender(event: RenderWorldLastEvent) { if (!IslandType.THE_END.isInIsland()) return - if (!beaconConfig.enabled) return - endermenWithBeacons.removeIf { it.isDead || !hasBeaconInHand(it) } - endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) } - .forEach { event.drawColor(it, LorenzColor.DARK_RED, alpha = 1f) } + if (beaconConfig.highlightBeacon) { + endermenWithBeacons.removeIf { it.isDead || !hasBeaconInHand(it) } + + endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) } + .forEach { event.drawColor(it, beaconConfig.beaconColor.toChromaColor(), alpha = 0.5f) } + } for ((location, time) in sittingBeacon) { + if (location.distanceToPlayer() > 20) continue if (beaconConfig.showLine) { - val distance = location.distance(location) - if (distance <= 15) { - val player = Minecraft.getMinecraft().thePlayer - val add = if (player.isSneaking) LorenzVec(0.0, 1.54, 0.0) else LorenzVec(0.0, 1.62, 0.0) - event.draw3DLine( - event.exactLocation(player).add(add), - location.add(0.5, 1.0, 0.5), - beaconConfig.lneColor.toChromaColor(), - beaconConfig.lineWidth, - true - ) - } + event.draw3DLine( + event.exactPlayerEyeLocation(), + location.add(0.5, 1.0, 0.5), + beaconConfig.lneColor.toChromaColor(), + beaconConfig.lineWidth, + true + ) } - val duration = 5.seconds - time.passedSince() - val durationFormat = duration.format(showMilliSeconds = true) - event.drawColor(location, LorenzColor.DARK_RED, alpha = 1f) - event.drawWaypointFilled(location, LorenzColor.RED.toColor(), true, true) - event.drawDynamicText(location.add(0, 1, 0), "§4Beacon §b$durationFormat", 1.8) + if (beaconConfig.highlightBeacon) { + val duration = 5.seconds - time.passedSince() + val durationFormat = duration.format(showMilliSeconds = true) + event.drawColor(location, beaconConfig.beaconColor.toChromaColor(), alpha = 1f) + event.drawWaypointFilled(location, beaconConfig.beaconColor.toChromaColor(), true, true) + event.drawDynamicText(location.add(0, 1, 0), "§4Beacon §b$durationFormat", 1.8) + } } for (beacon in flyingBeacons) { - if (!beacon.isDead) { - val location = event.exactLocation(beacon) - event.drawDynamicText(location.add(0, 1, 0), "§4Beacon", 1.8) + if (beacon.isDead) continue + if (beaconConfig.highlightBeacon) { + val beaconLocation = event.exactLocation(beacon) + event.drawDynamicText(beaconLocation.add(0, 1, 0), "§4Beacon", 1.8) + } + + if (beaconConfig.showLine) { + val beaconLocation = event.exactLocation(beacon) + event.draw3DLine( + event.exactPlayerEyeLocation(), + beaconLocation.add(0.5, 1.0, 0.5), + beaconConfig.lneColor.toChromaColor(), + beaconConfig.lineWidth, + true + ) } } + config.endermanHighlightNukekebi for (skull in nukekubiSkulls) { if (!skull.isDead) { event.drawDynamicText( @@ -147,8 +164,12 @@ class EndermanSlayerFeatures { if (!IslandType.THE_END.isInIsland()) return if (!event.repeatSeconds(1)) return - nukekubiSkulls.also { it.removeAll { it.isDead } } - flyingBeacons.also { it.removeAll { it.isDead } } + nukekubiSkulls.also { skulls -> skulls.removeAll { it.isDead } } + if (flyingBeacons.any { it.isDead }) { + flyingBeacons = flyingBeacons.editCopy { + removeAll { it.isDead } + } + } // Removing the beacon if It's still there after 7 sesconds. // This is just a workaround for the cases where the ServerBlockChangeEvent don't detect the beacon despawn info. @@ -163,13 +184,15 @@ class EndermanSlayerFeatures { @SubscribeEvent fun onBlockChange(event: ServerBlockChangeEvent) { if (!IslandType.THE_END.isInIsland()) return - if (!beaconConfig.enabled) return + if (!showBeacon()) return val location = event.location if (event.new == "beacon") { val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 } if (armorStand != null) { - flyingBeacons.remove(armorStand) + flyingBeacons = flyingBeacons.editCopy { + remove(armorStand) + } sittingBeacon = sittingBeacon.editCopy { this[location] = SimpleTimeMark.now() } logger.log("Replaced flying beacon with sitting beacon at $location") } @@ -184,7 +207,7 @@ class EndermanSlayerFeatures { @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { endermenWithBeacons.clear() - flyingBeacons.clear() + flyingBeacons = emptyList() nukekubiSkulls.clear() sittingBeacon = emptyMap() logger.log("Reset everything (world change)") |
