From 18c9da372c8e3ab3f27e1fd053c80592a5dc2753 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 2 Jul 2020 18:16:15 +0100 Subject: [PATCH] GetBlocks should default to air not reserved --- .../bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java | 5 ++++- .../adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java | 5 ++++- .../adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java | 5 ++++- .../beta/implementation/blocks/CharGetBlocks.java | 12 ++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) 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 ae871b419..c2c4395d1 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 @@ -563,10 +563,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { - return FaweCache.IMP.EMPTY_CHAR_4096; + data = new char[4096]; + Arrays.fill(data, (char) 1); + return data; } if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; + Arrays.fill(data, (char) 1); } DelegateLock lock = BukkitAdapter_1_14.applyLock(section); synchronized (lock) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index e0cbf7266..e77c06f85 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -581,10 +581,13 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { - return FaweCache.IMP.EMPTY_CHAR_4096; + data = new char[4096]; + Arrays.fill(data, (char) 1); + return data; } if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; + Arrays.fill(data, (char) 1); } DelegateLock lock = BukkitAdapter_1_15_2.applyLock(section); synchronized (lock) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index d6dada109..d09240f6c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -552,10 +552,13 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { - return FaweCache.IMP.EMPTY_CHAR_4096; + data = new char[4096]; + Arrays.fill(data, (char) 1); + return data; } if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; + Arrays.fill(data, (char) 1); } DelegateLock lock = BukkitAdapter_1_16_1.applyLock(section); synchronized (lock) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java index f38d1bae4..fc2b72b96 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java @@ -2,12 +2,12 @@ package com.boydti.fawe.beta.implementation.blocks; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; +import java.util.Arrays; + public abstract class CharGetBlocks extends CharBlocks implements IChunkGet { @Override @@ -25,6 +25,14 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet { return true; } + public char[] update(int layer, char[] data) { + if (data == null) { + return new char[4096]; + } + Arrays.fill(data, (char) 1); + return data; + } + @Override public boolean trim(boolean aggressive, int layer) { sections[layer] = EMPTY;