diff --git a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java index 4a2f109127..5db1824793 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java @@ -5,9 +5,11 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -184,7 +186,7 @@ public abstract class Contraption { protected ContraptionWorld collisionLevel; public Contraption() { - blocks = new HashMap<>(); + blocks = new LinkedHashMap<>(); updateTags = new HashMap<>(); isLegacy = new Object2BooleanArrayMap<>(); seats = new ArrayList<>(); @@ -1020,6 +1022,12 @@ private static StructureBlockInfo legacyReadStructureBlockInfo(CompoundTag block } public void removeBlocksFromWorld(Level world, BlockPos offset) { + // Invert order of the blocks LinkedHashMap, so all posterior iterations are inverted + List> entries = new ArrayList<>(blocks.entrySet()); + Collections.reverse(entries); + blocks.clear(); + entries.forEach(e -> blocks.put(e.getKey(), e.getValue())); + glueToRemove.forEach(glue -> { superglue.add(glue.getBoundingBox() .move(Vec3.atLowerCornerOf(offset.offset(anchor))