From e661652c12d1d82dfb31e24a502f68f44a2fa057 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 17 Nov 2019 19:30:28 +0000 Subject: [PATCH] Fix setting blocks in null sections --- .../adapter/mc1_14/BukkitAdapter_1_14.java | 9 ++++++--- .../adapter/mc1_14/BukkitGetBlocks_1_14.java | 20 +++++++++++-------- .../src/main/java/com/boydti/fawe/Fawe.java | 2 +- .../java/com/boydti/fawe/beta/IBlocks.java | 2 -- .../implementation/blocks/CharBlocks.java | 3 +++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java index cc9847e45..a58068458 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java @@ -227,7 +227,7 @@ public final class BukkitAdapter_1_14 { for (; i < 4096; i++) { char ordinal = set[i]; switch (ordinal) { - case 0: + case BlockID.__RESERVED__: break outer; case BlockID.AIR: case BlockID.CAVE_AIR: @@ -247,14 +247,17 @@ public final class BukkitAdapter_1_14 { for (; i < 4096; i++) { char ordinal = set[i]; switch (ordinal) { - case 0: + case BlockID.__RESERVED__: ordinal = getArr[i]; - set[i] = ordinal; switch (ordinal) { + case BlockID.__RESERVED__: + ordinal = BlockID.AIR; case BlockID.AIR: case BlockID.CAVE_AIR: case BlockID.VOID_AIR: air++; + default: + set[i] = ordinal; } break; case BlockID.AIR: diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index 412e3dfca..3de8bc89b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -38,6 +38,7 @@ import java.util.concurrent.Future; import java.util.function.Function; import javax.annotation.Nullable; import net.minecraft.server.v1_14_R1.BiomeBase; +import net.minecraft.server.v1_14_R1.Block; import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.ChunkSection; @@ -564,17 +565,20 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { return data; } - char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); + char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); try { - final int size = num_palette; - if (size != 1) { - for (int i = 0; i < size; i++) { + if (num_palette != 1) { + for (int i = 0; i < num_palette; i++) { char ordinal = ordinal(palette.a(i), adapter); - paletteToBlockChars[i] = ordinal; + paletteToOrdinal[i] = ordinal; } for (int i = 0; i < 4096; i++) { char paletteVal = data[i]; - char val = paletteToBlockChars[paletteVal]; + char val = paletteToOrdinal[paletteVal]; + if (val == Character.MAX_VALUE) { + val = ordinal(palette.a(i), adapter); + paletteToOrdinal[i] = val; + } data[i] = val; } } else { @@ -583,14 +587,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { } } finally { for (int i = 0; i < num_palette; i++) { - paletteToBlockChars[i] = Character.MAX_VALUE; + paletteToOrdinal[i] = Character.MAX_VALUE; } } + return data; } catch (IllegalAccessException e) { e.printStackTrace(); throw new RuntimeException(e); } - return data; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 7f5697e6c..69754c103 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -304,7 +304,7 @@ public class Fawe { br.close(); this.version = FaweVersion.tryParse(versionString, commitString, dateString); Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString(); - Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/" + version.build; + Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-commanding-pipeline/" + version.build; Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/commit/" + Integer.toHexString(version.hash); } catch (Throwable ignore) {} try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java index 575ee1178..2aa9bd34a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java @@ -64,8 +64,6 @@ public interface IBlocks extends Trimable { for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue; - System.out.println("Write section " + layer); - char[] ids = this.load(layer); int nonEmpty = 0; // TODO optimize into same loop as toPalette diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java index 900b265d3..5cd894008 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java @@ -20,6 +20,9 @@ public abstract class CharBlocks implements IBlocks { char[] arr = blocks.blocks[layer]; if (arr == null) { arr = blocks.blocks[layer] = blocks.update(layer, null); + if (arr == null) { + throw new IllegalStateException("Array cannot be null: " + blocks.getClass()); + } } else { blocks.blocks[layer] = blocks.update(layer, arr); }