diff --git a/src/main/java/noppes/npcs/CommonProxy.java b/src/main/java/noppes/npcs/CommonProxy.java index 08510d08e..bc49db973 100644 --- a/src/main/java/noppes/npcs/CommonProxy.java +++ b/src/main/java/noppes/npcs/CommonProxy.java @@ -23,11 +23,12 @@ import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.MillisTimer; +import java.util.ConcurrentModificationException; import java.util.HashSet; public class CommonProxy implements IGuiHandler { - public static HashSet clientPlayingAnimations = new HashSet<>(); - public static HashSet serverPlayingAnimations = new HashSet<>(); + public final static HashSet clientPlayingAnimations = new HashSet<>(); + public final static HashSet serverPlayingAnimations = new HashSet<>(); protected MillisTimer animationTimer = new MillisTimer(1000); protected long totalTicks; @@ -55,8 +56,11 @@ public class CommonProxy implements IGuiHandler { totalTicks++; } totalTicks %= 60 * 60 * 1000; - clientPlayingAnimations.removeIf(CommonProxy.this::removeAnimation); - serverPlayingAnimations.removeIf(CommonProxy.this::removeAnimation); + + try { + clientPlayingAnimations.removeIf(CommonProxy.this::removeAnimation); + serverPlayingAnimations.removeIf(CommonProxy.this::removeAnimation); + } catch (ConcurrentModificationException ignored) {} } }}); thread.setDaemon(true); diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 3bfb538c5..d89a56ae4 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -167,8 +167,10 @@ public class AnimationData implements IAnimationData { } if (CustomNpcs.proxy.hasClient() && newAnim != null) { - CommonProxy.clientPlayingAnimations.remove(this.animation); - CommonProxy.clientPlayingAnimations.add(newAnim); + synchronized (CommonProxy.clientPlayingAnimations) { + CommonProxy.clientPlayingAnimations.remove(this.animation); + CommonProxy.clientPlayingAnimations.add(newAnim); + } } this.animation = newAnim;