3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Fix some cases of empty tags being needed

Dieser Commit ist enthalten in:
Camotoy 2024-04-23 16:14:18 -04:00
Ursprung abea0131e4
Commit c54624fb26
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 14 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -43,12 +43,16 @@ public abstract class BlockEntityTranslator {
public abstract void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState); public abstract void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState);
public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, CompoundTag tag, int blockState) { public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, CompoundTag tag, int blockState) {
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(type), x, y, z); NbtMapBuilder tagBuilder = getConstantBedrockTag(type, x, y, z);
translateTag(tagBuilder, tag, blockState); translateTag(tagBuilder, tag, blockState);
return tagBuilder.build(); return tagBuilder.build();
} }
protected NbtMapBuilder getConstantBedrockTag(String bedrockId, int x, int y, int z) { public static NbtMapBuilder getConstantBedrockTag(BlockEntityType type, int x, int y, int z) {
return getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(type), x, y, z);
}
public static NbtMapBuilder getConstantBedrockTag(String bedrockId, int x, int y, int z) {
return NbtMap.builder() return NbtMap.builder()
.putInt("x", x) .putInt("x", x)
.putInt("y", y) .putInt("y", y)

Datei anzeigen

@ -393,10 +393,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
for (BlockEntityInfo blockEntity : blockEntities) { for (BlockEntityInfo blockEntity : blockEntities) {
BlockEntityType type = blockEntity.getType(); BlockEntityType type = blockEntity.getType();
CompoundTag tag = blockEntity.getNbt(); CompoundTag tag = blockEntity.getNbt();
if (type == null || tag == null) { if (type == null) {
// As an example: ViaVersion will send -1 if it cannot find the block entity type // As an example: ViaVersion will send -1 if it cannot find the block entity type
// Vanilla Minecraft gracefully handles this // Vanilla Minecraft gracefully handles this
// Since 1.20.5: tags sent here can be null, at which point the block entity is not translated
continue; continue;
} }
int x = blockEntity.getX(); // Relative to chunk int x = blockEntity.getX(); // Relative to chunk
@ -421,8 +420,13 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
continue; continue;
} }
BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(type); if (tag != null) {
bedrockBlockEntities.add(blockEntityTranslator.getBlockEntityTag(session, type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState)); BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(type);
bedrockBlockEntities.add(blockEntityTranslator.getBlockEntityTag(session, type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState));
} else {
// Since 1.20.5, tags can be null, but Bedrock still needs a default tag to render the item
bedrockBlockEntities.add(BlockEntityTranslator.getConstantBedrockTag(type, x + chunkBlockX, y, z + chunkBlockZ).build());
}
// Check for custom skulls // Check for custom skulls
// TODO: The tag layout follows new format (profille, etc...) // TODO: The tag layout follows new format (profille, etc...)