From a3d23fdcea1f199dc20368f0a021c70e02606162 Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 20 Jun 2019 18:51:29 -0400 Subject: [PATCH] Fix requirements of sponge schematic spec. Fixes WORLDEDIT-3929. --- .../clipboard/io/SpongeSchematicReader.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 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 4a9362b6e..e5d6c2e51 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 @@ -129,21 +129,28 @@ public class SpongeSchematicReader extends NBTSchematicReader { BlockVector3 origin; Region region; Map schematic = schematicTag.getValue(); - Map metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue(); int width = requireTag(schematic, "Width", ShortTag.class).getValue(); int height = requireTag(schematic, "Height", ShortTag.class).getValue(); int length = requireTag(schematic, "Length", ShortTag.class).getValue(); - int[] offsetParts = requireTag(schematic, "Offset", IntArrayTag.class).getValue(); - if (offsetParts.length != 3) { - throw new IOException("Invalid offset specified in schematic."); + IntArrayTag offsetTag = getTag(schematic, "Offset", IntArrayTag.class); + int[] offsetParts; + if (offsetTag != null) { + offsetParts = offsetTag.getValue(); + if (offsetParts.length != 3) { + throw new IOException("Invalid offset specified in schematic."); + } + } else { + offsetParts = new int[] {0, 0, 0}; } BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]); - if (metadata.containsKey("WEOffsetX")) { + CompoundTag metadataTag = getTag(schematic, "Metadata", CompoundTag.class); + if (metadataTag != null && metadataTag.containsKey("WEOffsetX")) { // We appear to have WorldEdit Metadata + Map metadata = metadataTag.getValue(); int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue(); int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue(); int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();