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) {
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<Chunk, ForgeQueue_All> {
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);

View File

@ -233,20 +233,33 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
}
// 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();

View File

@ -184,14 +184,21 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
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;

View File

@ -265,8 +265,12 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
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<Chunk, ForgeQueue_All> {
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);