diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java index aa2ee65fb..0f068fc6d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java @@ -64,6 +64,14 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); @@ -118,16 +126,32 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol(this).register(ClientboundPackets1_18.STATISTICS); - final PacketHandler titleHandler = wrapper -> { - final JsonElement component = wrapper.read(Type.COMPONENT); - if (!isTextComponentNull(component)) { - wrapper.write(Type.COMPONENT, component); - } else { - wrapper.write(Type.COMPONENT, ChatRewriter.emptyComponent()); - } + final PacketHandler singleNullTextComponentMapper = wrapper -> { + wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); }; - registerClientbound(ClientboundPackets1_18.TITLE_TEXT, titleHandler); - registerClientbound(ClientboundPackets1_18.TITLE_SUBTITLE, titleHandler); + registerClientbound(ClientboundPackets1_18.TITLE_TEXT, singleNullTextComponentMapper); + registerClientbound(ClientboundPackets1_18.TITLE_SUBTITLE, singleNullTextComponentMapper); + registerClientbound(ClientboundPackets1_18.ACTIONBAR, singleNullTextComponentMapper); + registerClientbound(ClientboundPackets1_18.SCOREBOARD_OBJECTIVE, wrapper -> { + wrapper.passthrough(Type.STRING); // Objective Name + byte action = wrapper.passthrough(Type.BYTE); // Mode + if (action == 0 || action == 2) { + wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Display Name + } + }); + registerClientbound(ClientboundPackets1_18.TEAMS, wrapper -> { + wrapper.passthrough(Type.STRING); // Team Name + byte action = wrapper.passthrough(Type.BYTE); // Mode + if (action == 0 || action == 2) { + wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Display Name + wrapper.passthrough(Type.BYTE); // Flags + wrapper.passthrough(Type.STRING); // Name Tag Visibility + wrapper.passthrough(Type.STRING); // Collision rule + wrapper.passthrough(Type.VAR_INT); // Color + wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Prefix + wrapper.write(Type.COMPONENT, mapTextComponentIfNull(wrapper.read(Type.COMPONENT))); // Suffix + } + }); final CommandRewriter commandRewriter = new CommandRewriter<>(this); registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, wrapper -> {