diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java index 88589cd1..cdfa5218 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java @@ -328,8 +328,12 @@ public class BukkitChunk_1_10 extends CharFaweChunk { if (array == null) { continue; } + int countAir = this.getAir(j); ChunkSection section = sections[j]; if (section == null) { + if (count == countAir) { + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { section = sections[j] = getParent().newChunkSection(j << 4, flag, null); getParent().setPalette(section, this.sectionPalettes[j]); @@ -340,6 +344,10 @@ public class BukkitChunk_1_10 extends CharFaweChunk { } continue; } else if (count >= 4096) { + if (countAir >= 4096) { + sections[j] = null; + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { getParent().setPalette(section, this.sectionPalettes[j]); getParent().setCount(0, count - this.getAir(j), section); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java index 08b59560..1d359b2b 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java @@ -338,14 +338,14 @@ public class BukkitChunk_1_11 extends CharFaweChunk= 4096) { - if (air >= 4096) { + if (countAir >= 4096) { sections[j] = null; continue; } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java index af116bd8..c8446ba7 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java @@ -279,16 +279,21 @@ public class BukkitChunk_1_7 extends CharFaweChunk { } // Set blocks for (int j = 0; j < sections.length; j++) { - if (this.getCount(j) == 0) { + int count = this.getCount(j); + if (count == 0) { continue; } byte[] newIdArray = this.getByteIdArray(j); if (newIdArray == null) { continue; } + int countAir = this.getAir(j); NibbleArray newDataArray = this.getDataArray(j); ChunkSection section = sections[j]; - if ((section == null) || (this.getCount(j) >= 4096)) { + if (section == null) { + if (count == countAir) { + continue; + } sections[j] = section = new ChunkSection(j << 4, flag); section.setIdArray(newIdArray); if (newDataArray != null) { @@ -296,6 +301,17 @@ public class BukkitChunk_1_7 extends CharFaweChunk { } continue; } + if (count >= 4096) { + if (countAir >= 4096) { + sections[j] = null; + continue; + } + section.setIdArray(newIdArray); + if (newDataArray != null) { + section.setDataArray(newDataArray); + } + continue; + } byte[] currentIdArray = (byte[]) BukkitQueue17.fieldIds.get(section); NibbleArray currentDataArray = (NibbleArray) BukkitQueue17.fieldData.get(section); boolean data = currentDataArray != null && newDataArray != null; diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java index e559e30e..72c273c2 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java @@ -218,20 +218,32 @@ public class BukkitChunk_1_8 extends CharFaweChunk { } // Set blocks for (int j = 0; j < sections.length; j++) { - if (this.getCount(j) == 0) { + int count = this.getCount(j); + if (count == 0) { continue; } char[] newArray = this.getIdArray(j); if (newArray == null) { continue; } + int countAir = this.getAir(j); ChunkSection section = sections[j]; if (section != null && BukkitQueue18R3.isDirty != null) { BukkitQueue18R3.isDirty.set(section, true); } - if ((section == null) || (this.getCount(j) >= 4096)) { - section = new ChunkSection(j << 4, flag, newArray); - sections[j] = section; + if (section == null) { + if (count == countAir) { + continue; + } + sections[j] = section = new ChunkSection(j << 4, flag, newArray); + continue; + } + if (count >= 4096) { + if (count == countAir) { + sections[j] = null; + continue; + } + sections[j] = section = new ChunkSection(j << 4, flag, newArray); continue; } int by = j << 4; diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java index df73e72b..33bec7ae 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java @@ -330,8 +330,12 @@ public class BukkitChunk_1_9 extends CharFaweChunk { if (array == null) { continue; } + int countAir = this.getAir(j); ChunkSection section = sections[j]; if (section == null) { + if (count == countAir) { + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { section = sections[j] = getParent().newChunkSection(j << 4, flag, null); getParent().setPalette(section, this.sectionPalettes[j]); @@ -342,6 +346,10 @@ public class BukkitChunk_1_9 extends CharFaweChunk { } continue; } else if (count >= 4096) { + if (countAir >= 4096) { + sections[j] = null; + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { getParent().setPalette(section, this.sectionPalettes[j]); getParent().setCount(0, count - this.getAir(j), section); diff --git a/forge111/src/main/java/com/boydti/fawe/forge/v0/ForgeChunk_All.java b/forge111/src/main/java/com/boydti/fawe/forge/v0/ForgeChunk_All.java index a74601c2..a23b873c 100644 --- a/forge111/src/main/java/com/boydti/fawe/forge/v0/ForgeChunk_All.java +++ b/forge111/src/main/java/com/boydti/fawe/forge/v0/ForgeChunk_All.java @@ -281,8 +281,12 @@ public class ForgeChunk_All extends CharFaweChunk { if (array == null) { continue; } + int countAir = this.getAir(j); ExtendedBlockStorage section = sections[j]; if (section == null) { + if (count == countAir) { + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { section = sections[j] = new ExtendedBlockStorage(j << 4, flag); getParent().setPalette(section, this.sectionPalettes[j]); @@ -292,6 +296,10 @@ public class ForgeChunk_All extends CharFaweChunk { sections[j] = section = new ExtendedBlockStorage(j << 4, flag); } } else if (count >= 4096) { + if (count == countAir) { + sections[j] = null; + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { getParent().setPalette(section, this.sectionPalettes[j]); getParent().setCount(0, count - this.getAir(j), section); diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java index b20201eb..d064466a 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java @@ -298,8 +298,12 @@ public class SpongeChunk_1_11 extends CharFaweChunk { if (array == null) { continue; } + int countAir = this.getAir(j); ExtendedBlockStorage section = sections[j]; if (section == null) { + if (count == countAir) { + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { section = sections[j] = new ExtendedBlockStorage(j << 4, flag); getParent().setPalette(section, this.sectionPalettes[j]); @@ -309,6 +313,10 @@ public class SpongeChunk_1_11 extends CharFaweChunk { sections[j] = section = new ExtendedBlockStorage(j << 4, flag); } } else if (count >= 4096) { + if (count == countAir) { + sections[j] = null; + continue; + } if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { getParent().setPalette(section, this.sectionPalettes[j]); getParent().setCount(0, count - this.getAir(j), section);