From d10a5cc5fa4d4aac454f7414d56380d0f4720d38 Mon Sep 17 00:00:00 2001 From: weaondara Date: Wed, 7 Oct 2020 21:11:57 +0200 Subject: [PATCH] Fix schem loading of sponge schems with dataversion == 1 (#690) * fix sponge schem loading with schem version 1 --- .../extent/clipboard/io/FastSchematicReader.java | 11 ++++++++++- .../extent/clipboard/io/SchematicReader.java | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java index 6433ce318..c0c413689 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java @@ -32,10 +32,13 @@ import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.DataFixer; @@ -99,6 +102,7 @@ public class FastSchematicReader extends NBTSchematicReader { public FastSchematicReader(NBTInputStream inputStream) { checkNotNull(inputStream); this.inputStream = inputStream; + this.fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer(); } private String fix(String palettePart) { @@ -133,7 +137,12 @@ public class FastSchematicReader extends NBTSchematicReader { StreamDelegate root = new StreamDelegate(); StreamDelegate schematic = root.add("Schematic"); schematic.add("DataVersion").withInt((i, v) -> dataVersion = v); - schematic.add("Version").withInt((i, v) -> version = v); + schematic.add("Version").withInt((i, v) -> { + version = v; + if (v == 1 && dataVersion == -1) { // DataVersion might not be present, assume 1.13.2 + dataVersion = Constants.DATA_VERSION_MC_1_13_2; + } + }); schematic.add("Width").withInt((i, v) -> width = v); schematic.add("Height").withInt((i, v) -> height = v); schematic.add("Length").withInt((i, v) -> length = v); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index 44ac3c8bf..14f363009 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -33,6 +33,8 @@ import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.legacycompat.BannerBlockCompatibilityHandler; +import com.sk89q.worldedit.extent.clipboard.io.legacycompat.BedBlockCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.EntityNBTCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.FlowerPotCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler; @@ -86,7 +88,9 @@ public class SchematicReader implements ClipboardReader { new SignCompatibilityHandler(), new FlowerPotCompatibilityHandler(), new NoteBlockCompatibilityHandler(), - new SkullBlockCompatibilityHandler() + new SkullBlockCompatibilityHandler(), + new BannerBlockCompatibilityHandler(), + new BedBlockCompatibilityHandler() }; private static final EntityNBTCompatibilityHandler[] ENTITY_COMPATIBILITY_HANDLERS = { new Pre13HangingCompatibilityHandler()