Fix forge set air section

This commit is contained in:
Jesse Boyd 2017-01-03 08:13:05 +11:00
parent a8e18b885f
commit 8c94489e91
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 39 additions and 3 deletions

View File

@ -267,8 +267,12 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
if (array == null) { if (array == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ExtendedBlockStorage section = sections[j]; ExtendedBlockStorage section = sections[j];
if (section == null) { if (section == null) {
if (count == countAir) {
continue;
}
if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { if (this.sectionPalettes != null && this.sectionPalettes[j] != null) {
section = sections[j] = new ExtendedBlockStorage(j << 4, flag); section = sections[j] = new ExtendedBlockStorage(j << 4, flag);
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
@ -278,6 +282,10 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
sections[j] = section = new ExtendedBlockStorage(j << 4, flag); sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
} }
} else if (count >= 4096) { } else if (count >= 4096) {
if (count == countAir) {
sections[j] = null;
continue;
}
if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { if (this.sectionPalettes != null && this.sectionPalettes[j] != null) {
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);

View File

@ -233,20 +233,33 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} }
// Efficiently merge sections // Efficiently merge sections
for (int j = 0; j < sections.length; j++) { for (int j = 0; j < sections.length; j++) {
if (this.getCount(j) == 0) { int count = this.getCount(j);
if (count == 0) {
continue; continue;
} }
byte[] newIdArray = this.getByteIdArray(j); byte[] newIdArray = this.getByteIdArray(j);
if (newIdArray == null) { if (newIdArray == null) {
continue; continue;
} }
int countAir = this.getAir(j);
NibbleArray newDataArray = this.getDataArray(j); NibbleArray newDataArray = this.getDataArray(j);
ExtendedBlockStorage section = sections[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); sections[j] = section = new ExtendedBlockStorage(j << 4, !getParent().getWorld().provider.hasNoSky);
section.setBlockLSBArray(newIdArray); section.setBlockLSBArray(newIdArray);
section.setBlockMetadataArray(newDataArray); section.setBlockMetadataArray(newDataArray);
continue; continue;
} else if (count >= 4096) {
if (count == countAir) {
sections[j] = null;
continue;
}
section.setBlockLSBArray(newIdArray);
section.setBlockMetadataArray(newDataArray);
continue;
} }
byte[] currentIdArray = section.getBlockLSBArray(); byte[] currentIdArray = section.getBlockLSBArray();
NibbleArray currentDataArray = section.getMetadataArray(); NibbleArray currentDataArray = section.getMetadataArray();

View File

@ -184,14 +184,21 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
if (newArray == null) { if (newArray == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ExtendedBlockStorage section = sections[j]; ExtendedBlockStorage section = sections[j];
if ((section == null)) { if ((section == null)) {
if (count == countAir) {
continue;
}
section = new ExtendedBlockStorage(j << 4, flag); section = new ExtendedBlockStorage(j << 4, flag);
section.setData(newArray); section.setData(newArray);
sections[j] = section; sections[j] = section;
continue; continue;
} else if (count >= 4096){ } else if (count >= 4096){
if (count == countAir) {
sections[j] = null;
continue;
}
section.setData(newArray); section.setData(newArray);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);
continue; continue;

View File

@ -265,8 +265,12 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
if (array == null) { if (array == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ExtendedBlockStorage section = sections[j]; ExtendedBlockStorage section = sections[j];
if (section == null) { if (section == null) {
if (count == countAir) {
continue;
}
if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { if (this.sectionPalettes != null && this.sectionPalettes[j] != null) {
section = sections[j] = new ExtendedBlockStorage(j << 4, flag); section = sections[j] = new ExtendedBlockStorage(j << 4, flag);
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
@ -276,6 +280,10 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
sections[j] = section = new ExtendedBlockStorage(j << 4, flag); sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
} }
} else if (count >= 4096) { } else if (count >= 4096) {
if (count == countAir) {
sections[j] = null;
continue;
}
if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { if (this.sectionPalettes != null && this.sectionPalettes[j] != null) {
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
getParent().setCount(0, count - this.getAir(j), section); getParent().setCount(0, count - this.getAir(j), section);