From ddaee584577565b40b547a6ff6522aeb6c654fe9 Mon Sep 17 00:00:00 2001 From: Luna <90072930+LunaWasFlaggedAgain@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:16:57 -0300 Subject: [PATCH] Fix tile entity packet spam exploit (#105) Co-authored-by: Telesphoreo --- patches/server/0028-Block-server-side-chunkbans.patch | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/patches/server/0028-Block-server-side-chunkbans.patch b/patches/server/0028-Block-server-side-chunkbans.patch index 3f29dbb..338eb66 100644 --- a/patches/server/0028-Block-server-side-chunkbans.patch +++ b/patches/server/0028-Block-server-side-chunkbans.patch @@ -154,7 +154,7 @@ index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f30 this.type = blockEntityType; this.tag = nbt.isEmpty() ? null : nbt; diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..c5d568ce15879be812207f4cd7819f2f6e7d0f7e 100644 +index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..688287c637a0d4b28d630b7304a3c2cf339bdf54 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData { @@ -171,3 +171,11 @@ index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..c5d568ce15879be812207f4cd7819f2f // Paper start - Anti-Xray - Add chunk packet info @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); } public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo) { +@@ -58,6 +65,7 @@ public class ClientboundLevelChunkPacketData { + int totalTileEntities = 0; // Paper + + for(Map.Entry entry2 : chunk.getBlockEntities().entrySet()) { ++ if (this.extraPackets.size() > 50) break; // Scissors - Limit extraPackets size + // Paper start + if (++totalTileEntities > TE_LIMIT) { + var packet = entry2.getValue().getUpdatePacket();