Skip to content

Commit 32a8800

Browse files
committed
Premultiply chunk offset for incredibly small performance gain
1 parent 1c78911 commit 32a8800

File tree

1 file changed

+4
-4
lines changed
  • common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/missing_block_entities

1 file changed

+4
-4
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/missing_block_entities/LevelChunkMixin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ private void validateBlockEntitiesInChunk(CallbackInfo ci) {
6262

6363
@Unique
6464
private void scanSectionForBlockEntities(LevelChunkSection section, int i) {
65-
int chunkX = this.chunkPos.x;
66-
int chunkZ = this.chunkPos.z;
65+
int chunkXOff = this.chunkPos.x * 16;
66+
int chunkZOff = this.chunkPos.z * 16;
6767
BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
68-
int sectionY = this.getSectionYFromSectionIndex(i);
68+
int sectionYOff = this.getSectionYFromSectionIndex(i) * 16;
6969
for (int y = 0; y < 16; y++) {
7070
for (int z = 0; z < 16; z++) {
7171
for (int x = 0; x < 16; x++) {
7272
var state = section.getBlockState(x, y, z);
7373
if (state.hasBlockEntity()) {
74-
cursor.set(chunkX * 16 + x, sectionY * 16 + y, chunkZ * 16 + z);
74+
cursor.set(chunkXOff + x, sectionYOff + y, chunkZOff + z);
7575
makeBlockEntityIfNotExists(state, cursor);
7676
}
7777
}

0 commit comments

Comments
 (0)