Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<>();
Expand Down Expand Up @@ -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<Map.Entry<BlockPos, StructureBlockInfo>> 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))
Expand Down