Fix some block entity inconsistencies

This commit is contained in:
Camotoy 2021-11-14 13:52:48 -05:00
parent 6249292903
commit 61f20217a9
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
3 changed files with 11 additions and 13 deletions

View file

@ -61,7 +61,7 @@ public class JavaBlockEntityDataTranslator extends PacketTranslator<ClientboundB
packet.getNbt(), blockState), packet.getPosition());
// Check for custom skulls.
if (session.getPreferencesCache().showCustomSkulls() && packet.getNbt() != null && packet.getNbt().contains("SkullOwner")) {
SkullBlockEntityTranslator.spawnPlayer(session, packet.getNbt(), blockState);
SkullBlockEntityTranslator.spawnPlayer(session, packet.getNbt(), position.getX(), position.getY(), position.getZ(), blockState);
}
// If block entity is command block, OP permission level is appropriate, player is in creative mode and the NBT is not empty

View file

@ -222,32 +222,33 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
BlockEntityInfo[] blockEntities = packet.getBlockEntities();
NbtMap[] bedrockBlockEntities = new NbtMap[blockEntities.length + bedrockOnlyBlockEntities.size()];
int blockEntityCount = 0;
final int chunkBlockX = packet.getX() << 4;
final int chunkBlockZ = packet.getZ() << 4;
while (blockEntityCount < blockEntities.length) {
BlockEntityInfo blockEntity = blockEntities[blockEntityCount];
CompoundTag tag = blockEntity.getNbt();
BlockEntityType type = blockEntity.getType();
int x = blockEntity.getX();
int x = blockEntity.getX(); // Relative to chunk
int y = blockEntity.getY();
int z = blockEntity.getZ();
int z = blockEntity.getZ(); // Relative to chunk
// Get the Java block state ID from block entity position
DataPalette section = javaChunks[(y >> 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++;
}

View file

@ -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;