From 574bc6f9e8b84d8da9b03e3617985b2c506a4e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerber=20L=C3=B3r=C3=A1nt=20Viktor?= <17655680+glorantq@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:09:39 +0100 Subject: [PATCH] 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. --- .../bluecolored/bluemap/core/world/mca/chunk/Chunk_1_13.java | 4 ++-- .../bluecolored/bluemap/core/world/mca/chunk/Chunk_1_16.java | 4 ++-- .../bluecolored/bluemap/core/world/mca/chunk/Chunk_1_18.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_13.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_13.java index fbd927b9..979c1264 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_13.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_13.java @@ -121,7 +121,7 @@ public class Chunk_1_13 extends MCAChunk { } 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 class Chunk_1_13 extends MCAChunk { @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) { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_16.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_16.java index a6afda6e..648c338d 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_16.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_16.java @@ -120,7 +120,7 @@ public class Chunk_1_16 extends MCAChunk { } 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 class Chunk_1_16 extends MCAChunk { @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) { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_18.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_18.java index 47c05e57..9e65f541 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_18.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/chunk/Chunk_1_18.java @@ -117,7 +117,7 @@ public class Chunk_1_18 extends MCAChunk { } 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 class Chunk_1_18 extends MCAChunk { @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) {