aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch
new file mode 100644
index 0000000000..7209c3be34
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch
@@ -0,0 +1,67 @@
+--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
+@@ -12,38 +12,47 @@
+ public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> {
+
+ private static final int MAX_PAYLOAD_SIZE = 32767;
+- private static final Map<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.builder().put(BrandPayload.ID, BrandPayload::new).build();
++ private static final Map<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>>builder().build(); // CraftBukkit - no special handling
+
+- public ServerboundCustomPayloadPacket(FriendlyByteBuf friendlybytebuf) {
+- this(readPayload(friendlybytebuf.readResourceLocation(), friendlybytebuf));
++ public ServerboundCustomPayloadPacket(FriendlyByteBuf packetdataserializer) {
++ this(readPayload(packetdataserializer.readResourceLocation(), packetdataserializer));
+ }
+
+- private static CustomPacketPayload readPayload(ResourceLocation resourcelocation, FriendlyByteBuf friendlybytebuf) {
+- FriendlyByteBuf.Reader<? extends CustomPacketPayload> friendlybytebuf_reader = (FriendlyByteBuf.Reader) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(resourcelocation);
++ private static CustomPacketPayload readPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) {
++ FriendlyByteBuf.a<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.a) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(minecraftkey);
+
+- return (CustomPacketPayload) (friendlybytebuf_reader != null ? (CustomPacketPayload) friendlybytebuf_reader.apply(friendlybytebuf) : readUnknownPayload(resourcelocation, friendlybytebuf));
++ return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(packetdataserializer) : readUnknownPayload(minecraftkey, packetdataserializer));
+ }
+
+- private static DiscardedPayload readUnknownPayload(ResourceLocation resourcelocation, FriendlyByteBuf friendlybytebuf) {
+- int i = friendlybytebuf.readableBytes();
++ private static UnknownPayload readUnknownPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { // CraftBukkit
++ int i = packetdataserializer.readableBytes();
+
+ if (i >= 0 && i <= 32767) {
+- friendlybytebuf.skipBytes(i);
+- return new DiscardedPayload(resourcelocation);
++ // CraftBukkit start
++ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i));
++ // CraftBukkit end
+ } else {
+ throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
+ }
+ }
+
+ @Override
+- @Override
+- public void write(FriendlyByteBuf friendlybytebuf) {
+- friendlybytebuf.writeResourceLocation(this.payload.id());
+- this.payload.write(friendlybytebuf);
++ public void write(FriendlyByteBuf buffer) {
++ buffer.writeResourceLocation(this.payload.id());
++ this.payload.write(buffer);
+ }
+
+- @Override
+- public void handle(ServerCommonPacketListener servercommonpacketlistener) {
+- servercommonpacketlistener.handleCustomPayload(this);
++ public void handle(ServerCommonPacketListener handler) {
++ handler.handleCustomPayload(this);
+ }
++
++ // CraftBukkit start
++ public record UnknownPayload(ResourceLocation id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload {
++
++ @Override
++ public void write(FriendlyByteBuf packetdataserializer) {
++ packetdataserializer.writeBytes(data);
++ }
++ }
++ // CraftBukkit end
+ }