From c2cb463dae604a782d86291a77e43b3e38b37ff1 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 1 Nov 2019 23:48:52 +0100 Subject: [PATCH] Fix schem load --- .../java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java | 4 ++-- .../src/main/java/com/sk89q/jnbt/NBTInputStream.java | 7 +++++++ .../com/sk89q/worldedit/command/SchematicCommands.java | 1 - .../extent/clipboard/io/SpongeSchematicReader.java | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java index 1c9330b4c..db889de85 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java @@ -156,11 +156,11 @@ public class StreamDelegate { } public StreamDelegate withLong(LongValueReader valueReader) { - return withValue(valueReader); + return withElem(valueReader); } public StreamDelegate withInt(IntValueReader valueReader) { - return withValue(valueReader); + return withElem(valueReader); } public StreamDelegate withValue(ValueReader valueReader) { diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java index 629ece96a..e74ca6c7d 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -183,6 +183,7 @@ public final class NBTInputStream implements Closeable { return; case NBTConstants.TYPE_BYTE: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyInt(0, is.readByte()); } else { @@ -192,6 +193,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_SHORT: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyInt(0, is.readShort()); } else { @@ -201,6 +203,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_INT: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyInt(0, is.readInt()); } else { @@ -210,6 +213,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_LONG: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyLong(0, is.readLong()); } else { @@ -219,6 +223,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_FLOAT: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyFloat(0, is.readFloat()); } else { @@ -228,6 +233,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_DOUBLE: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); if (value != null) { value.applyDouble(0, is.readDouble()); } else { @@ -237,6 +243,7 @@ public final class NBTInputStream implements Closeable { } case NBTConstants.TYPE_STRING: { ValueReader value = scope.getValueReader(); + if (value == null) value = scope.getElemReader(); int length = is.readShort() & 0xFFFF; if (value != null) { byte[] bytes = new byte[length]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 9a0edeeed..04afe5765 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -591,7 +591,6 @@ public class SchematicCommands { String filter, Arguments arguments ) throws WorldEditException { - if (formatName.isEmpty()) formatName = null; if (oldFirst && newFirst) { throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest.")); } 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 f80aea697..abc2a70a2 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 @@ -251,7 +251,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) { origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ)); } - if (blocksOut.getSize() != 0) { + if (blocksOut != null && blocksOut.getSize() != 0) { try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) { if (clipboard instanceof LinearClipboard) { LinearClipboard linear = (LinearClipboard) clipboard; @@ -286,7 +286,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } } - if (biomesOut.getSize() != 0) { + if (biomesOut != null && biomesOut.getSize() != 0) { try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) { if (clipboard instanceof LinearClipboard) { LinearClipboard linear = (LinearClipboard) clipboard;