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

JavaUpdateTileEntityTranslator improvements

- Remove the use of deprecated functions
- Check for empty NBT (fixes errors on CubeCraft)
Dieser Commit ist enthalten in:
DoctorMacc 2020-07-06 16:22:07 -04:00
Ursprung 82c6276794
Commit 545dfa38f0

Datei anzeigen

@ -40,12 +40,17 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
@Override
public void translate(ServerUpdateTileEntityPacket packet, GeyserSession session) {
String id = BlockEntityUtils.getBedrockBlockEntityId(packet.getType().name());
if (packet.getNbt().isEmpty()) { // Fixes errors in CubeCraft sending empty NBT
BlockEntityUtils.updateBlockEntity(session, null, packet.getPosition());
return;
}
BlockEntityTranslator translator = BlockEntityUtils.getBlockEntityTranslator(id);
// If not null then the BlockState is used in BlockEntityTranslator.translateTag()
if (ChunkUtils.CACHED_BLOCK_ENTITIES.get(packet.getPosition()) != null) {
if (ChunkUtils.CACHED_BLOCK_ENTITIES.containsKey(packet.getPosition())) {
int blockState = ChunkUtils.CACHED_BLOCK_ENTITIES.getOrDefault(packet.getPosition(), 0);
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(),
ChunkUtils.CACHED_BLOCK_ENTITIES.get(packet.getPosition())), packet.getPosition());
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(packet.getPosition());
blockState), packet.getPosition());
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(packet.getPosition(), blockState);
} else {
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), 0), packet.getPosition());
}