diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index 944fb5446..d1dfc1280 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -152,10 +152,8 @@ public class CPUOptimizedClipboard extends LinearClipboard { @Override public Collection getTileEntities() { convertTilesToIndex(); - for (Map.Entry entry : nbtMapIndex.entrySet()) { - int index = entry.getKey(); - CompoundTag tag = entry.getValue(); - Map values = tag.getValue(); + nbtMapIndex.replaceAll((index, tag) -> { + Map values = new HashMap<>(tag.getValue()); if (!values.containsKey("x")) { int y = index / getArea(); index -= y * getArea(); @@ -164,23 +162,26 @@ public class CPUOptimizedClipboard extends LinearClipboard { values.put("x", new IntTag(x)); values.put("y", new IntTag(y)); values.put("z", new IntTag(z)); + return new CompoundTag(values); + } else { + return tag; } - } + }); return nbtMapIndex.values(); } @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - nbtMapLoc.put(new IntTriple(x, y, z), tag); + nbtMapLoc.put(new IntTriple(x, y, z), new CompoundTag(tag.getValue())); return true; } public boolean setTile(int index, CompoundTag tag) { - nbtMapIndex.put(index, tag); - Map values = tag.getValue(); + final Map values = new HashMap<>(tag.getValue()); values.remove("x"); values.remove("y"); values.remove("z"); + nbtMapIndex.put(index, new CompoundTag(values)); return true; }