Skip to content

Commit

Permalink
Try fixing concurrent modification with wires again, see #5944
Browse files Browse the repository at this point in the history
  • Loading branch information
BluSunrize committed Jul 24, 2024
1 parent b27b2e8 commit 56d89b0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,11 +44,13 @@ public static void handleEntityCollision(BlockPos p, Entity e)
{
GlobalWireNetwork global = GlobalWireNetwork.getNetwork(e.level());
WireCollisionData wireData = global.getCollisionData();
Iterator<CollisionInfo> 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)
Expand Down

0 comments on commit 56d89b0

Please sign in to comment.