aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-29 15:07:23 +0100
committerGitHub <noreply@github.com>2024-03-29 15:07:23 +0100
commit5ebc246afeff794acb1c1920e6e86552fa0c73e3 (patch)
treee532139c6e0df27b13c5c956c1147863607dfaf9 /src/main/java/at
parent627ad521b556b79ed1c38bbef0f1ad5806dbb1f6 (diff)
downloadskyhanni-5ebc246afeff794acb1c1920e6e86552fa0c73e3.tar.gz
skyhanni-5ebc246afeff794acb1c1920e6e86552fa0c73e3.tar.bz2
skyhanni-5ebc246afeff794acb1c1920e6e86552fa0c73e3.zip
Fix: ConcurrentModificationException in PestParticleWaypoint (#1306)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt8
1 files changed, 4 insertions, 4 deletions
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<LorenzVec>()
+ private val locations = mutableListOf<LorenzVec>()
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>): 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))