From a44be1d5ec05fdb558ab97fdb76837abcf466484 Mon Sep 17 00:00:00 2001 From: Allmoz Date: Thu, 23 Oct 2025 14:37:58 -0300 Subject: [PATCH] contraption blocks remove from world inversion --- .../create/content/contraptions/Contraption.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 181f74fc95..e3bfffbe96 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; @@ -182,7 +184,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<>(); @@ -1005,6 +1007,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))