Fix CME in minecart capability

This commit is contained in:
simibubi 2024-07-24 14:24:59 +02:00
parent eaa4688a3f
commit 283998711d

View File

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.minecart.capability; package com.simibubi.create.content.contraptions.minecart.capability;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -128,6 +129,8 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
queuedRemovals.clear(); queuedRemovals.clear();
queued.clear(); queued.clear();
List<UUID> toRemove = new ArrayList<>();
for (Entry<UUID, MinecartController> entry : carts.entrySet()) { for (Entry<UUID, MinecartController> entry : carts.entrySet()) {
MinecartController controller = entry.getValue(); MinecartController controller = entry.getValue();
if (controller != null) { if (controller != null) {
@ -136,8 +139,12 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
continue; continue;
} }
} }
cartsWithCoupling.remove(entry.getKey()); toRemove.add(entry.getKey());
keySet.remove(entry.getKey()); }
for (UUID uuid : toRemove) {
keySet.remove(uuid);
cartsWithCoupling.remove(uuid);
} }
} }