mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
JavaUpdateTileEntityTranslator improvements
- Remove the use of deprecated functions - Check for empty NBT (fixes errors on CubeCraft)
This commit is contained in:
parent
82c6276794
commit
545dfa38f0
1 changed files with 8 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue