From 477ae2a76dd81cf706de306973134f22635e5b54 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 7 Sep 2017 18:39:26 +1000 Subject: [PATCH] Fixes #726 --- .../boydti/fawe/jnbt/SchematicStreamer.java | 8 +++++ .../extent/clipboard/io/SchematicWriter.java | 30 +++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java b/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java index 7f21ce8a..0bd7a2ee 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java @@ -72,6 +72,14 @@ public class SchematicStreamer extends NBTStreamer { fc.setBiome(index, value); } }; + NBTStreamReader initializer23 = new NBTStreamReader() { + @Override + public void run(Integer value1, Integer value2) { + if (fc == null) setupClipboard(length * width * height); + } + }; + addReader("Schematic.AWEBiomes.?", initializer23); + addReader("Schematic.Biomes.?", initializer23); addReader("Schematic.AWEBiomes.#", biomeReader); // AWE stores as an int[] addReader("Schematic.Biomes.#", biomeReader); // FAWE stores as a byte[] (4x smaller) diff --git a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java index 6347e00b..0f175283 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java @@ -155,21 +155,6 @@ public class SchematicWriter implements ClipboardWriter { out.writeNamedTag("WEOffsetZ", (offset.getBlockZ())); out.writeNamedTag("Platform", Fawe.imp().getPlatform()); - if (clipboard.IMP.hasBiomes()) { - out.writeNamedTagName("Biomes", NBTConstants.TYPE_BYTE_ARRAY); - out.getOutputStream().writeInt(width * length); // area - clipboard.IMP.streamBiomes(new NBTStreamer.ByteReader() { - @Override - public void run(int index, int byteValue) { - try { - rawStream.writeByte(byteValue); - } catch (IOException e) { - e.printStackTrace(); - } - } - }); - } - out.writeNamedTagName("Blocks", NBTConstants.TYPE_BYTE_ARRAY); out.getOutputStream().writeInt(volume); clipboard.IMP.streamIds(new NBTStreamer.ByteReader() { @@ -239,6 +224,21 @@ public class SchematicWriter implements ClipboardWriter { } } + if (clipboard.IMP.hasBiomes()) { + out.writeNamedTagName("Biomes", NBTConstants.TYPE_BYTE_ARRAY); + out.getOutputStream().writeInt(width * length); // area + clipboard.IMP.streamBiomes(new NBTStreamer.ByteReader() { + @Override + public void run(int index, int byteValue) { + try { + rawStream.writeByte(byteValue); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + } + if (hasTile) { final List tileEntities = clipboard.IMP.getTileEntities(); out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class, tileEntities));