From ac6f4ae358652bf4c784ecf5c72811ef60068a07 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 12 Nov 2019 12:41:39 +0000 Subject: [PATCH] Use BlockArrayClipboard for schem load --- .../extent/clipboard/BlockArrayClipboard.java | 7 +++++++ .../extent/clipboard/io/SpongeSchematicReader.java | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 75c90c8b9..5efe2d316 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -60,6 +60,13 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, this(region, UUID.randomUUID()); } + public BlockArrayClipboard(Clipboard clipboard, BlockVector3 offset) { + super(clipboard); + Region shifted = clipboard.getRegion(); + shifted.shift(offset); + setRegion(shifted); + } + /** * Create a new instance. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 167d5e540..1dc22c720 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -218,10 +218,9 @@ public class SpongeSchematicReader extends NBTSchematicReader { biomes = null; BlockVector3 dimensions = BlockVector3.at(width, height, length); - BlockVector3 origin = min; + BlockVector3 origin = BlockVector3.ZERO; if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) { -// origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ)); - origin = BlockVector3.at(offsetX, offsetY, offsetZ); + origin = BlockVector3.at(-offsetX, -offsetY, -offsetZ); } Clipboard clipboard = createOutput.apply(dimensions); @@ -341,6 +340,11 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } clipboard.setOrigin(origin); + + if (!min.equals(BlockVector3.ZERO)) { + new BlockArrayClipboard(clipboard, min); + } + return clipboard; }