From 61f20217a918ad167cafbed668f35fa4d7c88bcf Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 14 Nov 2021 13:52:48 -0500 Subject: [PATCH] Fix some block entity inconsistencies --- .../level/JavaBlockEntityDataTranslator.java | 2 +- .../JavaLevelChunkWithLightTranslator.java | 17 +++++++++-------- .../entity/SkullBlockEntityTranslator.java | 5 +---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/level/JavaBlockEntityDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/level/JavaBlockEntityDataTranslator.java index 8f33742c6..d68823d1a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/level/JavaBlockEntityDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/level/JavaBlockEntityDataTranslator.java @@ -61,7 +61,7 @@ public class JavaBlockEntityDataTranslator extends PacketTranslator> 4) - yOffset]; - int blockState = section.get(x & 0xF, y & 0xF, z & 0xF); + int blockState = section.get(x, y & 0xF, z); if (type == BlockEntityType.LECTERN && BlockStateValues.getLecternBookStates().get(blockState)) { // If getLecternBookStates is false, let's just treat it like a normal block entity - bedrockBlockEntities[blockEntityCount] = session.getConnector().getWorldManager().getLecternDataAt( - session, blockEntity.getX(), blockEntity.getY(), blockEntity.getZ(), true); - blockEntityCount++; + bedrockBlockEntities[blockEntityCount++] = session.getConnector().getWorldManager().getLecternDataAt( + session, x + chunkBlockX, y, z + chunkBlockZ, true); continue; } BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(type); - bedrockBlockEntities[blockEntityCount] = blockEntityTranslator.getBlockEntityTag(type, x, y, z, tag, blockState); + bedrockBlockEntities[blockEntityCount] = blockEntityTranslator.getBlockEntityTag(type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState); // Check for custom skulls if (session.getPreferencesCache().showCustomSkulls() && tag != null && tag.contains("SkullOwner")) { - SkullBlockEntityTranslator.spawnPlayer(session, tag, blockState); + SkullBlockEntityTranslator.spawnPlayer(session, tag, x + chunkBlockX, y, z + chunkBlockZ, blockState); } blockEntityCount++; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java index 0acc01a7d..0dc92bbfe 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/SkullBlockEntityTranslator.java @@ -85,10 +85,7 @@ public class SkullBlockEntityTranslator extends BlockEntityTranslator implements return CompletableFuture.completedFuture(null); } - public static void spawnPlayer(GeyserSession session, CompoundTag tag, int blockState) { - int posX = (int) tag.get("x").getValue(); - int posY = (int) tag.get("y").getValue(); - int posZ = (int) tag.get("z").getValue(); + public static void spawnPlayer(GeyserSession session, CompoundTag tag, int posX, int posY, int posZ, int blockState) { float x = posX + .5f; float y = posY - .01f; float z = posZ + .5f;