From 5ebc246afeff794acb1c1920e6e86552fa0c73e3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:07:23 +0100 Subject: Fix: ConcurrentModificationException in PestParticleWaypoint (#1306) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/garden/pests/PestParticleWaypoint.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt index 29fd1a43a..d01d80325 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt @@ -37,7 +37,7 @@ class PestParticleWaypoint { private var secondParticlePoint: LorenzVec? = null private var lastParticlePoint: LorenzVec? = null private var guessPoint: LorenzVec? = null - private var locations = mutableListOf() + private val locations = mutableListOf() private var particles = 0 private var lastParticles = 0 private var isPointingToPest = false @@ -145,7 +145,7 @@ class PestParticleWaypoint { } private fun getWaypoint() = if (lastParticles != particles || guessPoint == null) { - calculateWaypoint(locations)?.also { + calculateWaypoint()?.also { guessPoint = it lastParticles = particles } @@ -166,9 +166,9 @@ class PestParticleWaypoint { if (PestAPI.scoreboardPests == 0) reset() } - private fun calculateWaypoint(list: MutableList): LorenzVec? { + private fun calculateWaypoint(): LorenzVec? { val firstParticle = firstParticlePoint ?: return null - + val list = locations.toMutableSet() var pos = LorenzVec(0.0, 0.0, 0.0) for ((i, particle) in list.withIndex()) { pos = pos.add(particle.subtract(firstParticle).divide(i.toDouble() + 1.0)) -- cgit