Fix the coordinate-packing for block entity-loading

This commit fixes the incorrect shifting of bits when
packing the chunk-local coordinates of a block entity
into a 64-bit long for lookups.
This commit is contained in:
Gerber Lóránt Viktor 2024-03-19 17:09:39 +01:00
parent b10d15657a
commit 574bc6f9e8
3 changed files with 6 additions and 6 deletions

View File

@ -121,7 +121,7 @@ public Chunk_1_13(MCAWorld world, Data data) {
}
this.blockEntities = level.blockEntities.stream().collect(Collectors.toMap(
it -> (long) it.getY() << 40 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
it -> (long) it.getY() << 8 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
));
}
@ -207,7 +207,7 @@ public int getOceanFloorY(int x, int z) {
@Override
public @Nullable BlockEntity getBlockEntity(int x, int y, int z) {
return blockEntities.get((long) y << 40 | (x & 0xF) << 4 | z & 0xF);
return blockEntities.get((long) y << 8 | (x & 0xF) << 4 | z & 0xF);
}
private @Nullable Section getSection(int y) {

View File

@ -120,7 +120,7 @@ public Chunk_1_16(MCAWorld world, Data data) {
}
this.blockEntities = level.blockEntities.stream().collect(Collectors.toMap(
it -> (long) it.getY() << 40 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
it -> (long) it.getY() << 8 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
));
}
@ -203,7 +203,7 @@ public int getOceanFloorY(int x, int z) {
@Override
public @Nullable BlockEntity getBlockEntity(int x, int y, int z) {
return blockEntities.get((long) y << 40 | (x & 0xF) << 4 | z & 0xF);
return blockEntities.get((long) y << 8 | (x & 0xF) << 4 | z & 0xF);
}
private @Nullable Section getSection(int y) {

View File

@ -117,7 +117,7 @@ public Chunk_1_18(MCAWorld world, Data data) {
}
this.blockEntities = data.blockEntities.stream().collect(Collectors.toMap(
it -> (long) it.getY() << 40 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
it -> (long) it.getY() << 8 | (it.getX() & 0xF) << 4 | it.getZ() & 0xF, it -> it
));
}
@ -195,7 +195,7 @@ public int getOceanFloorY(int x, int z) {
@Override
public @Nullable BlockEntity getBlockEntity(int x, int y, int z) {
return blockEntities.get((long) y << 40 | (x & 0xF) << 4 | z & 0xF);
return blockEntities.get((long) y << 8 | (x & 0xF) << 4 | z & 0xF);
}
private @Nullable Section getSection(int y) {