From 934680dac22934251e584557a1204931b4a26c84 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Tue, 4 Sep 2018 14:26:50 +0200 Subject: [PATCH] fix sponge schematic offset --- .../extent/clipboard/io/SpongeSchematicReader.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 f0e8f1f25..e1541bc63 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 @@ -119,7 +119,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue(); Vector offset = new Vector(offsetX, offsetY, offsetZ); origin = min.subtract(offset); - region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE)); + region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE)); } else { origin = min; region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE)); @@ -160,7 +160,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { for (Map tileEntity : tileEntityTags) { int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); - tileEntitiesMap.put(origin.add(new BlockVector(pos[0], pos[1], pos[2])).toBlockVector(), tileEntity); + tileEntitiesMap.put(new BlockVector(pos[0], pos[1], pos[2]).toBlockVector(), tileEntity); } } catch (Exception e) { throw new IOException("Failed to load Tile Entities: " + e.getMessage()); @@ -189,9 +189,9 @@ public class SpongeSchematicReader extends NBTSchematicReader { i++; } // index = (y * length + z) * width + x - int y = origin.getBlockY() + index / (width * length); - int z = origin.getBlockZ() + (index % (width * length)) / width; - int x = origin.getBlockX() + (index % (width * length)) % width; + int y = index / (width * length); + int z = (index % (width * length)) / width; + int x = (index % (width * length)) % width; BlockState state = palette.get(value); BlockVector pt = new BlockVector(x, y, z); try { @@ -208,9 +208,9 @@ public class SpongeSchematicReader extends NBTSchematicReader { values.put("id", values.get("Id")); values.remove("Id"); values.remove("Pos"); - clipboard.setBlock(pt, state.toBaseBlock(new CompoundTag(values))); + clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(values))); } else { - clipboard.setBlock(pt, state); + clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state); } } catch (WorldEditException e) { throw new IOException("Failed to load a block in the schematic");