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 549526f9f..f078eb9a0 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 @@ -90,6 +90,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { public NibbleArray[] skyLight = new NibbleArray[16]; private boolean createCopy = false; private BukkitGetBlocks_1_15_2_Copy copy = null; + private boolean forceLoadSections = true; public BukkitGetBlocks_1_15_2(World world, int chunkX, int chunkZ) { this(((CraftWorld) world).getHandle(), chunkX, chunkZ); @@ -316,6 +317,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { @Override public > T call(IChunkSet set, Runnable finalizer) { + forceLoadSections = false; copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getChunkX(), getChunkZ()) : null; try { WorldServer nmsWorld = world; @@ -364,7 +366,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { // If we're creating a copy, it's because we're delaying history so we do not want to write to // the chunkSet yet. if (createCopy) { - setArr = setArr.clone(); copy.storeSection(layer); copy.storeSetBlocks(layer, setArr); } @@ -408,7 +409,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode); if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) { log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); - continue; } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -475,9 +475,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { Set entityRemoves = set.getEntityRemoves(); if (entityRemoves != null && !entityRemoves.isEmpty()) { - if (syncTasks == null) { - syncTasks = new Runnable[3]; - } + syncTasks = new Runnable[3]; syncTasks[2] = () -> { final List[] entities = nmsChunk.getEntitySlices(); @@ -637,6 +635,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { } catch (Throwable e) { e.printStackTrace(); return null; + } finally { + forceLoadSections = true; } } @@ -758,7 +758,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { } public ChunkSection[] getSections(boolean force) { - if (force) { + if (force && forceLoadSections) { return sections = getChunk().getSections().clone(); } ChunkSection[] tmp = sections; @@ -828,7 +828,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { continue; } - ChunkSection existing = getSections(false)[i]; + ChunkSection existing = getSections(true)[i]; try { final DataPaletteBlock blocksExisting = existing.getBlocks(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2_Copy.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2_Copy.java index 19fb70d5d..837676daa 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2_Copy.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2_Copy.java @@ -108,7 +108,7 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen } protected void storeSection(int layer) { - blocks[layer] = update(layer, null).clone(); + blocks[layer] = load(layer).clone(); } @Override @@ -130,7 +130,7 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen } protected void storeSetBlocks(int layer, char[] blocks) { - newSetBlocks[layer] = blocks; + newSetBlocks[layer] = blocks.clone(); } @Override 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 458ae27a5..63ad1dada 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 @@ -90,6 +90,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { public NibbleArray[] skyLight = new NibbleArray[16]; private boolean createCopy = false; private BukkitGetBlocks_1_16_1_Copy copy = null; + private boolean forceLoadSections = true; public BukkitGetBlocks_1_16_1(World world, int chunkX, int chunkZ) { this(((CraftWorld) world).getHandle(), chunkX, chunkZ); @@ -316,6 +317,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { @Override public > T call(IChunkSet set, Runnable finalizer) { + forceLoadSections = false; copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getChunkX(), getChunkZ()) : null; try { WorldServer nmsWorld = world; @@ -364,7 +366,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { // If we're creating a copy, it's because we're delaying history so we do not want to write to // the chunkSet yet. if (createCopy) { - setArr = setArr.clone(); copy.storeSection(layer); copy.storeSetBlocks(layer, setArr); } @@ -410,7 +411,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { if (!BukkitAdapter_1_16_1 .setSectionAtomic(sections, existingSection, newSection, layer)) { log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); - continue; } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -477,9 +477,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { Set entityRemoves = set.getEntityRemoves(); if (entityRemoves != null && !entityRemoves.isEmpty()) { - if (syncTasks == null) { - syncTasks = new Runnable[3]; - } + syncTasks = new Runnable[3]; syncTasks[2] = () -> { final List[] entities = nmsChunk.getEntitySlices(); @@ -639,6 +637,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { } catch (Throwable e) { e.printStackTrace(); return null; + } finally { + forceLoadSections = true; } } @@ -760,7 +760,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { } public ChunkSection[] getSections(boolean force) { - if (force) { + if (force && forceLoadSections) { return sections = getChunk().getSections().clone(); } ChunkSection[] tmp = sections; @@ -830,7 +830,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { continue; } - ChunkSection existing = getSections(false)[i]; + ChunkSection existing = getSections(true)[i]; try { final DataPaletteBlock blocksExisting = existing.getBlocks(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1_Copy.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1_Copy.java index 5deaaa901..2cd174af9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1_Copy.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1_Copy.java @@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen } protected void storeSection(int layer) { - blocks[layer] = update(layer, null).clone(); + blocks[layer] = load(layer).clone(); } @Override @@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen } protected void storeSetBlocks(int layer, char[] blocks) { - newSetBlocks[layer] = blocks; + newSetBlocks[layer] = blocks.clone(); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java index 44c885305..f22000616 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java @@ -91,6 +91,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { public NibbleArray[] skyLight = new NibbleArray[16]; private boolean createCopy = false; private BukkitGetBlocks_1_16_2_Copy copy = null; + private boolean forceLoadSections = true; public BukkitGetBlocks_1_16_2(World world, int chunkX, int chunkZ) { this(((CraftWorld) world).getHandle(), chunkX, chunkZ); @@ -319,6 +320,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { @Override public > T call(IChunkSet set, Runnable finalizer) { + forceLoadSections = false; copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getChunkX(), getChunkZ()) : null; try { WorldServer nmsWorld = world; @@ -367,7 +369,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { // If we're creating a copy, it's because we're delaying history so we do not want to write to // the chunkSet yet. if (createCopy) { - setArr = setArr.clone(); copy.storeSection(layer); copy.storeSetBlocks(layer, setArr); } @@ -413,7 +414,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { if (!BukkitAdapter_1_16_2 .setSectionAtomic(sections, existingSection, newSection, layer)) { log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); - continue; } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -480,9 +480,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { Set entityRemoves = set.getEntityRemoves(); if (entityRemoves != null && !entityRemoves.isEmpty()) { - if (syncTasks == null) { - syncTasks = new Runnable[3]; - } + syncTasks = new Runnable[3]; syncTasks[2] = () -> { final List[] entities = nmsChunk.getEntitySlices(); @@ -642,6 +640,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { } catch (Throwable e) { e.printStackTrace(); return null; + } finally { + forceLoadSections = true; } } @@ -763,7 +763,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { } public ChunkSection[] getSections(boolean force) { - if (force) { + if (force && forceLoadSections) { return sections = getChunk().getSections().clone(); } ChunkSection[] tmp = sections; @@ -833,7 +833,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { continue; } - ChunkSection existing = getSections(false)[i]; + ChunkSection existing = getSections(true)[i]; try { final DataPaletteBlock blocksExisting = existing.getBlocks(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2_Copy.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2_Copy.java index dccf17358..c0086e180 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2_Copy.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2_Copy.java @@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen } protected void storeSection(int layer) { - blocks[layer] = update(layer, null).clone(); + blocks[layer] = load(layer).clone(); } @Override @@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen } protected void storeSetBlocks(int layer, char[] blocks) { - newSetBlocks[layer] = blocks; + newSetBlocks[layer] = blocks.clone(); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java index e43987767..1282a8d45 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java @@ -1,7 +1,6 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_4; import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; @@ -28,10 +27,8 @@ import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.block.BlockTypesCache; import net.minecraft.server.v1_16_R3.BiomeBase; import net.minecraft.server.v1_16_R3.BiomeStorage; -import net.minecraft.server.v1_16_R3.Block; import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.Chunk; import net.minecraft.server.v1_16_R3.ChunkSection; @@ -94,6 +91,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { public NibbleArray[] skyLight = new NibbleArray[16]; private boolean createCopy = false; private BukkitGetBlocks_1_16_4_Copy copy = null; + private boolean forceLoadSections = true; public BukkitGetBlocks_1_16_4(World world, int chunkX, int chunkZ) { this(((CraftWorld) world).getHandle(), chunkX, chunkZ); @@ -322,6 +320,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { @Override public > T call(IChunkSet set, Runnable finalizer) { + forceLoadSections = false; copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world, getChunkX(), getChunkZ()) : null; try { WorldServer nmsWorld = world; @@ -370,7 +369,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { // If we're creating a copy, it's because we're delaying history so we do not want to write to // the chunkSet yet. if (createCopy) { - setArr = setArr.clone(); copy.storeSection(layer); copy.storeSetBlocks(layer, setArr); } @@ -416,7 +414,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { if (!BukkitAdapter_1_16_4 .setSectionAtomic(sections, existingSection, newSection, layer)) { log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); - continue; } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -483,9 +480,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { Set entityRemoves = set.getEntityRemoves(); if (entityRemoves != null && !entityRemoves.isEmpty()) { - if (syncTasks == null) { - syncTasks = new Runnable[3]; - } + syncTasks = new Runnable[3]; syncTasks[2] = () -> { final List[] entities = nmsChunk.getEntitySlices(); @@ -645,6 +640,8 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { } catch (Throwable e) { e.printStackTrace(); return null; + } finally { + forceLoadSections = true; } } @@ -766,7 +763,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { } public ChunkSection[] getSections(boolean force) { - if (force) { + if (force && forceLoadSections) { return sections = getChunk().getSections().clone(); } ChunkSection[] tmp = sections; @@ -836,7 +833,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { continue; } - ChunkSection existing = getSections(false)[i]; + ChunkSection existing = getSections(true)[i]; try { final DataPaletteBlock blocksExisting = existing.getBlocks(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4_Copy.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4_Copy.java index 3a2ebe25f..da2980d1e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4_Copy.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4_Copy.java @@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen } protected void storeSection(int layer) { - blocks[layer] = update(layer, null).clone(); + blocks[layer] = load(layer).clone(); } @Override @@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen } protected void storeSetBlocks(int layer, char[] blocks) { - newSetBlocks[layer] = blocks; + newSetBlocks[layer] = blocks.clone(); } @Override