Closed 0xE69 closed 1 week ago
The issue in the code is likely occurring in the apply method. If an animation is not alive during the apply method, it's not removed from the queue. If an animation becomes not alive during its apply method (which might be called from another thread), it could cause a ConcurrentModificationException.
GitHub\crafting-dead\crafting-dead-core\src\main\java\com\craftingdead\core\client\animation\AnimationController.java
To fix this, we can use an Iterator in the apply method, similar to how you used it in the tick method. Changes recommended;
for (var animation : this.animations) {
if (animation.isAlive()) {
animation.apply(partialTicks, poseStack);
}
}
}
Change to:
var iterator = this.animations.iterator();
while (iterator.hasNext()) {
var animation = iterator.next();
if (animation.isAlive()) {
animation.apply(partialTicks, poseStack);
} else {
iterator.remove();
}
}
}
This way, if an animation is not alive, it will be safely removed from the queue.
Marked as fixed.
From the crash report, it's clear that the crash occurs within the context of rendering an entity, more specifically, it seems to be related to the AnimationController and GunRenderer classes within the crafting-dead-core mod (crafting-dead-core-1.18.2-1.8.0.429.jar). Here's a simplified path to where the issue occurs:
AnimationController tries to apply animations. GunRenderer attempts to render a gun item. A ConcurrentModificationException is thrown during this process.