Fix signs for Bedrock 1.18.30

Fixes #2944
This commit is contained in:
Camotoy 2022-04-21 22:23:00 -04:00
parent 3108ea726c
commit 05d74ebd3e
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.Ser
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundSignUpdatePacket;
import com.nukkitx.nbt.NbtMap;
import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
import com.nukkitx.protocol.bedrock.v503.Bedrock_v503;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -40,6 +41,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
@Override
public void translate(GeyserSession session, BlockEntityDataPacket packet) {
System.out.println(packet);
NbtMap tag = packet.getData();
String id = tag.getString("id");
if (id.equals("Sign")) {
@ -47,7 +49,9 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
// This is the reason why this all works - Bedrock sends packets every time you update the sign, Java only wants the final packet
// But Bedrock sends one final packet when you're done editing the sign, which should be equal to the last message since there's no edits
// So if the latest update does not match the last cached update then it's still being edited
if (!text.equals(session.getLastSignMessage())) {
// TODO check 1.19:
// Bedrock only sends one packet as of 1.18.30. I (Camotoy) am suspicious this is a bug, but if it's permanent then we don't need the lastSignMessage variable.
if (session.getUpstream().getProtocolVersion() < Bedrock_v503.V503_CODEC.getProtocolVersion() && !text.equals(session.getLastSignMessage())) {
session.setLastSignMessage(text);
return;
}