Premultiply chunk offset for incredibly small performance gain
This commit is contained in:
parent
1c789111e8
commit
32a8800344
|
|
@ -62,16 +62,16 @@ public abstract class LevelChunkMixin extends ChunkAccess {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private void scanSectionForBlockEntities(LevelChunkSection section, int i) {
|
private void scanSectionForBlockEntities(LevelChunkSection section, int i) {
|
||||||
int chunkX = this.chunkPos.x;
|
int chunkXOff = this.chunkPos.x * 16;
|
||||||
int chunkZ = this.chunkPos.z;
|
int chunkZOff = this.chunkPos.z * 16;
|
||||||
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||||
int sectionY = this.getSectionYFromSectionIndex(i);
|
int sectionYOff = this.getSectionYFromSectionIndex(i) * 16;
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
var state = section.getBlockState(x, y, z);
|
var state = section.getBlockState(x, y, z);
|
||||||
if (state.hasBlockEntity()) {
|
if (state.hasBlockEntity()) {
|
||||||
cursor.set(chunkX * 16 + x, sectionY * 16 + y, chunkZ * 16 + z);
|
cursor.set(chunkXOff + x, sectionYOff + y, chunkZOff + z);
|
||||||
makeBlockEntityIfNotExists(state, cursor);
|
makeBlockEntityIfNotExists(state, cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user