From 27a47b77c754e178184058b771e36fbeb694dc15 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Sat, 14 Dec 2024 19:31:59 +0100 Subject: [PATCH] net/minecraft/network/protocol/login --- .../ClientboundCustomQueryPacket.java.patch | 7 +++---- ...lientboundLoginDisconnectPacket.java.patch | 21 +++++++++++++++++++ ...verboundCustomQueryAnswerPacket.java.patch | 20 ++++++++---------- ...lientboundLoginDisconnectPacket.java.patch | 21 ------------------- 4 files changed, 33 insertions(+), 36 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch (81%) create mode 100644 paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch (70%) delete mode 100644 paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch similarity index 81% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index 60ed80c610..e1eb0709fe 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java +++ b/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java -@@ -47,4 +47,14 @@ - public void handle(ClientLoginPacketListener listener) { - listener.handleCustomQuery(this); +@@ -47,4 +_,13 @@ + public void handle(ClientLoginPacketListener handler) { + handler.handleCustomQuery(this); } + + // Paper start - MC Utils - default query payloads + public static record PlayerInfoChannelPayload(ResourceLocation id, FriendlyByteBuf buffer) implements CustomQueryPayload { -+ + @Override + public void write(final FriendlyByteBuf buf) { + buf.writeBytes(this.buffer.copy()); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch new file mode 100644 index 0000000000..3bc9092eb9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java ++++ b/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java +@@ -18,11 +_,16 @@ + } + + private ClientboundLoginDisconnectPacket(FriendlyByteBuf buffer) { +- this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(262144), RegistryAccess.EMPTY); ++ this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH), RegistryAccess.EMPTY); // Paper - diff on change + } + + private void write(FriendlyByteBuf buffer) { +- buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); ++ // Paper start - Adventure ++ // buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); ++ // In the login phase, buffer.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute ++ java.util.Locale bufLocale = buffer.adventure$locale; ++ buffer.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH); ++ // Paper end - Adventure + } + + @Override diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch similarity index 70% rename from paper-server/patches/unapplied/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch rename to paper-server/patches/sources/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch index 663ca9ede2..9596254f44 100644 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java +++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java -@@ -20,7 +20,17 @@ +@@ -20,7 +_,17 @@ } - private static CustomQueryAnswerPayload readPayload(int queryId, FriendlyByteBuf buf) { -- return readUnknownPayload(buf); + private static CustomQueryAnswerPayload readPayload(int transactionId, FriendlyByteBuf buffer) { +- return readUnknownPayload(buffer); + // Paper start - MC Utils - default query payloads -+ FriendlyByteBuf buffer = buf.readNullable((buf2) -> { ++ FriendlyByteBuf buf = buffer.readNullable((buf2) -> { + int i = buf2.readableBytes(); + if (i >= 0 && i <= MAX_PAYLOAD_SIZE) { + return new FriendlyByteBuf(buf2.readBytes(i)); @@ -14,19 +14,18 @@ + throw new IllegalArgumentException("Payload may not be larger than " + MAX_PAYLOAD_SIZE + " bytes"); + } + }); -+ return buffer == null ? null : new net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket.QueryAnswerPayload(buffer); ++ return buf == null ? null : new net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket.QueryAnswerPayload(buf); + // Paper end - MC Utils - default query payloads } - private static CustomQueryAnswerPayload readUnknownPayload(FriendlyByteBuf buf) { -@@ -47,4 +57,21 @@ - public void handle(ServerLoginPacketListener listener) { - listener.handleCustomQueryPacket(this); + private static CustomQueryAnswerPayload readUnknownPayload(FriendlyByteBuf buffer) { +@@ -47,4 +_,19 @@ + public void handle(ServerLoginPacketListener handler) { + handler.handleCustomQueryPacket(this); } + + // Paper start - MC Utils - default query payloads + public static final class QueryAnswerPayload implements CustomQueryAnswerPayload { -+ + public final FriendlyByteBuf buffer; + + public QueryAnswerPayload(final net.minecraft.network.FriendlyByteBuf buffer) { @@ -39,5 +38,4 @@ + } + } + // Paper end - MC Utils - default query payloads -+ } diff --git a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch b/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch deleted file mode 100644 index 7ad1ef4a1c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java -+++ b/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java -@@ -18,11 +18,16 @@ - } - - private ClientboundLoginDisconnectPacket(FriendlyByteBuf buf) { -- this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(262144), RegistryAccess.EMPTY); -+ this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH), RegistryAccess.EMPTY); // Paper - diff on change - } - - private void write(FriendlyByteBuf buf) { -- buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); -+ // Paper start - Adventure -+ // buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); -+ // In the login phase, buf.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute -+ java.util.Locale bufLocale = buf.adventure$locale; -+ buf.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH); -+ // Paper end - Adventure - } - - @Override