diff --git a/src/main/java/blusunrize/immersiveengineering/common/wires/WireCollisions.java b/src/main/java/blusunrize/immersiveengineering/common/wires/WireCollisions.java index 5260ba3812..7cf505bb65 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/wires/WireCollisions.java +++ b/src/main/java/blusunrize/immersiveengineering/common/wires/WireCollisions.java @@ -31,6 +31,7 @@ import javax.annotation.Nonnull; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -43,11 +44,13 @@ public static void handleEntityCollision(BlockPos p, Entity e) { GlobalWireNetwork global = GlobalWireNetwork.getNetwork(e.level()); WireCollisionData wireData = global.getCollisionData(); + Iterator infos = wireData.getCollisionInfo(p).iterator(); //noinspection SynchronizationOnLocalVariableOrMethodParameter - synchronized(wireData) + synchronized(infos) { - for(CollisionInfo info : wireData.getCollisionInfo(p)) + while(infos.hasNext()) { + CollisionInfo info = infos.next(); LocalWireNetwork local = info.getLocalNet(global); for(LocalNetworkHandler h : local.getAllHandlers()) if(h instanceof ICollisionHandler collisionHandler)