diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-15 11:33:50 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-15 11:33:50 +0200 |
commit | b26814bc3b7559c999dbbb11d0aec11f6ecb2be3 (patch) | |
tree | 7310af8505b742dc92ea336e8ec8a16cc3ae31ea /src/main | |
parent | 8024d7b8ddd5c12df26e2cdd3fcac6f1a2305b78 (diff) | |
download | skyhanni-b26814bc3b7559c999dbbb11d0aec11f6ecb2be3.tar.gz skyhanni-b26814bc3b7559c999dbbb11d0aec11f6ecb2be3.tar.bz2 skyhanni-b26814bc3b7559c999dbbb11d0aec11f6ecb2be3.zip |
Fixed a rare crash while doing enderman slayer.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt | 18 |
1 files changed, 13 insertions, 5 deletions
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 dcdadf84a..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 @@ -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") @@ -56,7 +56,9 @@ class EndermanSlayerFeatures { 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.seconds) logger.log("Added flying beacons at ${entity.getLorenzVec()}") @@ -163,7 +165,11 @@ class EndermanSlayerFeatures { if (!event.repeatSeconds(1)) return nukekubiSkulls.also { skulls -> skulls.removeAll { it.isDead } } - flyingBeacons.also { beacons -> beacons.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. @@ -184,7 +190,9 @@ class EndermanSlayerFeatures { 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") } @@ -199,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)") |