Remove packet overflow console error (#135)

This commit is contained in:
Luna 2023-08-12 13:45:47 -03:00 committed by GitHub
parent 1111ffabd7
commit 44567fd8b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Block server-side chunkbans
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce5148b800 100644
index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc44995e877b2 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -6,9 +6,17 @@ import io.netty.channel.ChannelHandlerContext;
@ -50,7 +50,7 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get();
if (connectionProtocol == null) {
@@ -33,38 +58,66 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -33,38 +58,59 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw new IOException("Can't serialize unregistered packet");
} else {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
@ -103,8 +103,6 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
+ } else if (packet instanceof ClientboundLevelChunkPacketData chunkPacket) {
+ chunkPacket.clearNBT();
+ } else if (packet instanceof ClientboundSetEntityDataPacket) {
+ return null; // Skip
+ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) {
+ packet = new ClientboundContainerSetContentPacket(containerSetContentPacket.getContainerId(), containerSetContentPacket.getStateId(), NonNullList.create(), ItemStack.EMPTY);
+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) {
@ -113,10 +111,6 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce
+ packet = new ClientboundContainerSetSlotPacket(containerSetSlotPacket.getContainerId(), containerSetSlotPacket.getStateId(), containerSetSlotPacket.getSlot(), ItemStack.EMPTY);
+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) {
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null);
+ } else if (packet instanceof ClientboundSystemChatPacket) {
+ return null;
+ } else if (packet instanceof ClientboundDisguisedChatPacket) {
+ return null;
+ } else if (packet instanceof ClientboundPlayerChatPacket playerChatPacket) {
+ final SignedMessageBody.Packed body = playerChatPacket.body();
+ packet = new ClientboundPlayerChatPacket(playerChatPacket.sender(), // Not sending this packet results in a kick when someone says something.
@ -128,7 +122,6 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce
+ playerChatPacket.chatType()
+ );
+ } else {
+ LOGGER.error("Packet with ID {} was too large and was not caught. Please report this to the Scissors developers.", i);
+ return null;
+ }
+