aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-12 10:15:22 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-12 10:15:22 +0100
commit669ea76011e12b8befb853b5e9c9e8070bc504de (patch)
tree14ee2cbafdf9749aec0954f8d454bb96157f4c19 /src/main/java/at/hannibal2/skyhanni/features
parent74a3ac9c70238a7154637c9c2c01690ae9d538ab (diff)
downloadskyhanni-669ea76011e12b8befb853b5e9c9e8070bc504de.tar.gz
skyhanni-669ea76011e12b8befb853b5e9c9e8070bc504de.tar.bz2
skyhanni-669ea76011e12b8befb853b5e9c9e8070bc504de.zip
Fixed ConcurrentModificationException in AshfangBlazes.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
index 28ff6f7df..b5aff0bf4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityBlaze
@@ -25,9 +26,9 @@ class AshfangBlazes {
private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang
private val blazeColor = mutableMapOf<EntityBlaze, LorenzColor>()
- private val blazeArmorStand = mutableMapOf<EntityBlaze, EntityArmorStand>()
+ private var blazeArmorStand = mapOf<EntityBlaze, EntityArmorStand>()
- var nearAshfang = false
+ private var nearAshfang = false
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
@@ -43,19 +44,21 @@ class AshfangBlazes {
val list = entity.getAllNameTagsWith(2, "Ashfang")
if (list.size == 1) {
val armorStand = list[0]
- blazeArmorStand[entity] = armorStand
val color = when {
armorStand.name.contains("Ashfang Follower") -> LorenzColor.DARK_GRAY
armorStand.name.contains("Ashfang Underling") -> LorenzColor.RED
armorStand.name.contains("Ashfang Acolyte") -> LorenzColor.BLUE
else -> {
- blazeArmorStand.remove(entity)
- null
+ blazeArmorStand = blazeArmorStand.editCopy {
+ remove(entity)
+ }
+ continue
}
}
- color?.let {
- blazeColor[entity] = it
+ blazeArmorStand = blazeArmorStand.editCopy {
+ this[entity] = armorStand
}
+ blazeColor[entity] = color
}
}
}
@@ -69,7 +72,9 @@ class AshfangBlazes {
if (entityId !in blazeArmorStand.keys.map { it.entityId }) return
if (event.health % 10_000_000 != 0) {
- blazeArmorStand.keys.removeIf { it.entityId == entityId }
+ blazeArmorStand = blazeArmorStand.editCopy {
+ keys.removeIf { it.entityId == entityId }
+ }
}
}
@@ -112,7 +117,7 @@ class AshfangBlazes {
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
blazeColor.clear()
- blazeArmorStand.clear()
+ blazeArmorStand = emptyMap()
}
@SubscribeEvent
@@ -125,4 +130,4 @@ class AshfangBlazes {
private fun isEnabled(): Boolean {
return LorenzUtils.inSkyBlock && DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG)
}
-} \ No newline at end of file
+}