Optimize set air for more versions

This commit is contained in:
Jesse Boyd 2016-12-27 05:58:14 +11:00
parent 33548c8d55
commit 9d920a5510
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
7 changed files with 69 additions and 9 deletions

View File

@ -328,8 +328,12 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
if (array == null) { if (array == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ChunkSection section = sections[j]; ChunkSection 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] = getParent().newChunkSection(j << 4, flag, null); section = sections[j] = getParent().newChunkSection(j << 4, flag, null);
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
@ -340,6 +344,10 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
} }
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
if (countAir >= 4096) {
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

@ -338,14 +338,14 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
if (count == 0) { if (count == 0) {
continue; continue;
} }
int air = this.getAir(j); int countAir = this.getAir(j);
final char[] array = this.getIdArray(j); final char[] array = this.getIdArray(j);
if (array == null) { if (array == null) {
continue; continue;
} }
ChunkSection section = sections[j]; ChunkSection section = sections[j];
if (section == null) { if (section == null) {
if (count == air) { if (count == countAir) {
continue; continue;
} }
if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { if (this.sectionPalettes != null && this.sectionPalettes[j] != null) {
@ -358,7 +358,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
} }
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
if (air >= 4096) { if (countAir >= 4096) {
sections[j] = null; sections[j] = null;
continue; continue;
} }

View File

@ -279,16 +279,21 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
} }
// Set blocks // Set blocks
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);
ChunkSection section = sections[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); sections[j] = section = new ChunkSection(j << 4, flag);
section.setIdArray(newIdArray); section.setIdArray(newIdArray);
if (newDataArray != null) { if (newDataArray != null) {
@ -296,6 +301,17 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
} }
continue; 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); byte[] currentIdArray = (byte[]) BukkitQueue17.fieldIds.get(section);
NibbleArray currentDataArray = (NibbleArray) BukkitQueue17.fieldData.get(section); NibbleArray currentDataArray = (NibbleArray) BukkitQueue17.fieldData.get(section);
boolean data = currentDataArray != null && newDataArray != null; boolean data = currentDataArray != null && newDataArray != null;

View File

@ -218,20 +218,32 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
} }
// Set blocks // Set blocks
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;
} }
char[] newArray = this.getIdArray(j); char[] newArray = this.getIdArray(j);
if (newArray == null) { if (newArray == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ChunkSection section = sections[j]; ChunkSection section = sections[j];
if (section != null && BukkitQueue18R3.isDirty != null) { if (section != null && BukkitQueue18R3.isDirty != null) {
BukkitQueue18R3.isDirty.set(section, true); BukkitQueue18R3.isDirty.set(section, true);
} }
if ((section == null) || (this.getCount(j) >= 4096)) { if (section == null) {
section = new ChunkSection(j << 4, flag, newArray); if (count == countAir) {
sections[j] = section; 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; continue;
} }
int by = j << 4; int by = j << 4;

View File

@ -330,8 +330,12 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
if (array == null) { if (array == null) {
continue; continue;
} }
int countAir = this.getAir(j);
ChunkSection section = sections[j]; ChunkSection 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] = getParent().newChunkSection(j << 4, flag, null); section = sections[j] = getParent().newChunkSection(j << 4, flag, null);
getParent().setPalette(section, this.sectionPalettes[j]); getParent().setPalette(section, this.sectionPalettes[j]);
@ -342,6 +346,10 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
} }
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
if (countAir >= 4096) {
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

@ -281,8 +281,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]);
@ -292,6 +296,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

@ -298,8 +298,12 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
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]);
@ -309,6 +313,10 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
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);