From f69b1bfb2102d2aaf5f8bf6a44c168dcd08edde4 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 13 Jan 2021 17:09:18 +0000 Subject: [PATCH] properly load nms chunk for lighting operations --- .../adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java | 14 +++++++------- .../adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java | 14 +++++++------- .../adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java | 14 +++++++------- .../adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) 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 55080de5f..6a23beeee 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 @@ -150,7 +150,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl public void setHeightmapToGet(HeightMapType type, int[] data) { BitArray bitArray = new BitArray(9, 256); bitArray.fromRaw(data); - nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); + getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); } public int getChunkZ() { @@ -176,7 +176,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl @Override public void removeSectionLighting(int layer, boolean sky) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); if (nibble != null) { lightUpdate = true; @@ -188,7 +188,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl } } if (sky) { - SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky); if (nibble != null) { lightUpdate = true; @@ -225,7 +225,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl public int getSkyLight(int x, int y, int z) { int layer = y >> 4; if (skyLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -245,7 +245,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl public int getEmmittedLight(int x, int y, int z) { int layer = y >> 4; if (blockLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -352,7 +352,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl private void updateGet(BukkitGetBlocks_1_15_2 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { synchronized (get) { - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = sections.clone(); this.reset(); @@ -451,7 +451,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl synchronized (this) { synchronized (lock) { lock.untilFree(); - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = null; this.reset(); 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 acef040e3..5baadd20a 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 @@ -151,7 +151,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl public void setHeightmapToGet(HeightMapType type, int[] data) { BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); bitArray.fromRaw(data); - nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); + getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); } public int getChunkZ() { @@ -177,7 +177,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl @Override public void removeSectionLighting(int layer, boolean sky) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); if (nibble != null) { lightUpdate = true; @@ -189,7 +189,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl } } if (sky) { - SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky); if (nibble != null) { lightUpdate = true; @@ -226,7 +226,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl @Override public int getSkyLight(int x, int y, int z) { int layer = y >> 4; if (skyLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -245,7 +245,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl @Override public int getEmmittedLight(int x, int y, int z) { int layer = y >> 4; if (blockLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -352,7 +352,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl private void updateGet(BukkitGetBlocks_1_16_1 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { synchronized (get) { - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = sections.clone(); this.reset(); @@ -451,7 +451,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl synchronized (this) { synchronized (lock) { lock.untilFree(); - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = null; this.reset(); 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 94d8e2b15..8e62d54db 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 @@ -151,7 +151,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl public void setHeightmapToGet(HeightMapType type, int[] data) { BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); bitArray.fromRaw(data); - nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); + getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); } public int getChunkZ() { @@ -177,7 +177,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl @Override public void removeSectionLighting(int layer, boolean sky) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); if (nibble != null) { lightUpdate = true; @@ -189,7 +189,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl } } if (sky) { - SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky); if (nibble != null) { lightUpdate = true; @@ -227,7 +227,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl public int getSkyLight(int x, int y, int z) { int layer = y >> 4; if (skyLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -247,7 +247,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl public int getEmmittedLight(int x, int y, int z) { int layer = y >> 4; if (blockLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -355,7 +355,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl private void updateGet(BukkitGetBlocks_1_16_2 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { synchronized (get) { - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = sections.clone(); this.reset(); @@ -454,7 +454,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl synchronized (this) { synchronized (lock) { lock.untilFree(); - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = null; this.reset(); 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 37a26a089..c78063452 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 @@ -151,7 +151,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl public void setHeightmapToGet(HeightMapType type, int[] data) { BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); bitArray.fromRaw(data); - nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); + getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData()); } public int getChunkZ() { @@ -177,7 +177,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl @Override public void removeSectionLighting(int layer, boolean sky) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); if (nibble != null) { lightUpdate = true; @@ -189,7 +189,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl } } if (sky) { - SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky); if (nibble != null) { lightUpdate = true; @@ -227,7 +227,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl public int getSkyLight(int x, int y, int z) { int layer = y >> 4; if (skyLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -247,7 +247,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl public int getEmmittedLight(int x, int y, int z) { int layer = y >> 4; if (blockLight[layer] == null) { - SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); + SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { @@ -355,7 +355,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl private void updateGet(BukkitGetBlocks_1_16_4 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { synchronized (get) { - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = sections.clone(); this.reset(); @@ -454,7 +454,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl synchronized (this) { synchronized (lock) { lock.untilFree(); - if (this.nmsChunk != nmsChunk) { + if (this.getChunk() != nmsChunk) { this.nmsChunk = nmsChunk; this.sections = null; this.reset();