From 8c519afce625cde8ae3136dfcb703a4eb6ee2d79 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Tue, 1 Aug 2017 20:47:16 -0500 Subject: [PATCH 1/2] Fix handling of AddBlocks length, DiskClipboard resize --- .../main/java/com/boydti/fawe/jnbt/SchematicStreamer.java | 8 +++++++- .../fawe/object/clipboard/DiskOptimizedClipboard.java | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 2a1948b3..7f21ce8a 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java @@ -33,9 +33,15 @@ public class SchematicStreamer extends NBTStreamer { setupClipboard(length); } }; + NBTStreamReader initializer2 = new NBTStreamReader() { + @Override + public void run(Integer length, Integer type) { + setupClipboard(length*2); + } + }; addReader("Schematic.Blocks.?", initializer); addReader("Schematic.Data.?", initializer); - addReader("Schematic.AddBlocks.?", initializer); + addReader("Schematic.AddBlocks.?", initializer2); addReader("Schematic.Blocks.#", new ByteReader() { @Override public void run(int index, int value) { diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index 4474dc6c..47a6a995 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -238,6 +238,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { area = width * length; volume = width * length * height; long size = width * height * length * 2l + HEADER_SIZE + (hasBiomes() ? area : 0); + close(); + this.braf = new RandomAccessFile(file, "rw"); braf.setLength(size); init(); mbb.putChar(2, (char) width); From 2411adb6d143ea56a79e4084a199782511e8410b Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Tue, 1 Aug 2017 21:36:01 -0500 Subject: [PATCH 2/2] Finish fixing AddBlock support --- .../fawe/object/clipboard/DiskOptimizedClipboard.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index 47a6a995..e4fbdfb8 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -521,9 +521,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { int index = (HEADER_SIZE) + (i << 1); // 00000000 00000000 // [ id ]data - byte id2 = mbb.get(index + 1); - mbb.put(index, (byte) (id >> 4)); - mbb.put(index + 1, (byte) (((id & 0xFF) << 4) + (id2 & 0xFF))); + char combined = mbb.getChar(index); + mbb.putChar(index, (char) ((combined & 0xF00F) + (id << 4))); } public void setCombined(int i, int combined) { @@ -536,7 +535,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { // 00000000 00000000 // [ id ]data char combined = mbb.getChar(index); - mbb.putChar(index, (char) ((combined & 0xFFFF) + (add << 12))); + mbb.putChar(index, (char) ((combined & 0x0FFF) + (add << 12))); } @Override