diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..ae35fedaf7 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java +@@ -10,27 +10,27 @@ + import net.minecraft.resources.ResourceLocation; + + 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.<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>>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> reader = KNOWN_TYPES.get(resourceLocation); +- return (CustomPacketPayload)(reader != null ? reader.apply(friendlyByteBuf) : readUnknownPayload(resourceLocation, friendlyByteBuf)); ++ private static CustomPacketPayload readPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { ++ FriendlyByteBuf.a<? extends CustomPacketPayload> packetdataserializer_a = (FriendlyByteBuf.a) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(minecraftkey); ++ ++ 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"); + } +@@ -42,8 +42,17 @@ + this.payload.write(buffer); + } + +- @Override + 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 + } |