diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java index 2e80c802..5cd3c156 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java @@ -267,8 +267,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]); @@ -278,6 +282,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/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java index ef6153f6..14c23cd9 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java @@ -233,20 +233,33 @@ public class ForgeChunk_All extends CharFaweChunk { } // Efficiently merge sections 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); ExtendedBlockStorage section = sections[j]; - if ((section == null) || (this.getCount(j) >= 4096)) { + if ((section == null)) { + if (count == countAir) { + continue; + } sections[j] = section = new ExtendedBlockStorage(j << 4, !getParent().getWorld().provider.hasNoSky); section.setBlockLSBArray(newIdArray); section.setBlockMetadataArray(newDataArray); continue; + } else if (count >= 4096) { + if (count == countAir) { + sections[j] = null; + continue; + } + section.setBlockLSBArray(newIdArray); + section.setBlockMetadataArray(newDataArray); + continue; } byte[] currentIdArray = section.getBlockLSBArray(); NibbleArray currentDataArray = section.getMetadataArray(); diff --git a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java index c5b23335..4520c3d1 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java @@ -184,14 +184,21 @@ public class ForgeChunk_All extends CharFaweChunk { if (newArray == null) { continue; } + int countAir = this.getAir(j); ExtendedBlockStorage section = sections[j]; - if ((section == null)) { + if (count == countAir) { + continue; + } section = new ExtendedBlockStorage(j << 4, flag); section.setData(newArray); sections[j] = section; continue; } else if (count >= 4096){ + if (count == countAir) { + sections[j] = null; + continue; + } section.setData(newArray); getParent().setCount(0, count - this.getAir(j), section); continue; diff --git a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java index c409671a..04d0c3dd 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java @@ -265,8 +265,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]); @@ -276,6 +280,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);