Remove now-obsolete sign workaround. Yay.

This commit is contained in:
Camotoy 2022-05-29 20:31:54 -04:00
parent f79a3ef2f7
commit 7a0a6795d0
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
2 changed files with 2 additions and 23 deletions

View File

@ -492,15 +492,6 @@ public class GeyserSession implements GeyserConnection, CommandSender {
@Setter
private boolean thunder = false;
/**
* Stores the last text inputted into a sign.
* <p>
* Bedrock sends packets every time you update the sign, Java only wants the final packet.
* Until we determine that the user has finished editing, we save the sign's current status.
*/
@Setter
private String lastSignMessage;
/**
* Stores a map of all statistics sent from the server.
* The server only sends new statistics back to us, so in order to show all statistics we need to cache existing ones.

View File

@ -30,7 +30,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.Serverb
import com.nukkitx.math.vector.Vector3i;
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;
@ -45,16 +44,8 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
String id = tag.getString("id");
if (id.equals("Sign")) {
String text = tag.getString("Text");
// 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
// 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;
}
// Otherwise the two messages are identical and we can get to work deconstructing
// Note: as of 1.18.30, only one packet is sent from Bedrock when the sign is finished.
// Previous versions did not have this behavior.
StringBuilder newMessage = new StringBuilder();
// While Bedrock's sign lines are one string, Java's is an array of each line
// (Initialized all with empty strings because it complains about null)
@ -113,9 +104,6 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
ServerboundSignUpdatePacket signUpdatePacket = new ServerboundSignUpdatePacket(pos, lines);
session.sendDownstreamPacket(signUpdatePacket);
// We set the sign text cached in the session to null to indicate there is no work-in-progress sign
session.setLastSignMessage(null);
} else if (id.equals("JigsawBlock")) {
// Client has just sent a jigsaw block update
Vector3i pos = Vector3i.from(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));