aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch
diff options
context:
space:
mode:
Diffstat (limited to 'Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch')
-rw-r--r--Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch b/Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch
new file mode 100644
index 0000000000..ee9073137c
--- /dev/null
+++ b/Spigot-Server-Patches-Unmapped/0330-Handle-Oversized-Tile-Entities-in-chunks.patch
@@ -0,0 +1,54 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Wed, 6 May 2020 05:00:57 -0400
+Subject: [PATCH] Handle Oversized Tile Entities in chunks
+
+Splits out Extra Packets if too many TE's are encountered to prevent
+creating too large of a packet to sed.
+
+Co authored by Spottedleaf
+
+diff --git a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
+index 0059ede4ba3ff271d47dd38ea87fddc2399aa008..a7d10d124021f3427f23fcd533f885367b64515c 100644
+--- a/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
++++ b/src/main/java/net/minecraft/network/protocol/game/PacketPlayOutMapChunk.java
+@@ -34,7 +34,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
+ private boolean h;
+
+ public PacketPlayOutMapChunk() {}
++ // Paper start
++ private final java.util.List<Packet> extraPackets = new java.util.ArrayList<>();
++ private static final int TE_LIMIT = Integer.getInteger("Paper.excessiveTELimit", 750);
+
++ @Override
++ public java.util.List<Packet> getExtraPackets() {
++ return extraPackets;
++ }
++ // Paper end
+ public PacketPlayOutMapChunk(Chunk chunk, int i) {
+ ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
+
+@@ -61,6 +69,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
+ this.c = this.a(new PacketDataSerializer(this.j()), chunk, i);
+ this.g = Lists.newArrayList();
+ iterator = chunk.getTileEntities().entrySet().iterator();
++ int totalTileEntities = 0; // Paper
+
+ while (iterator.hasNext()) {
+ entry = (Entry) iterator.next();
+@@ -69,6 +78,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
+ int j = blockposition.getY() >> 4;
+
+ if (this.f() || (i & 1 << j) != 0) {
++ // Paper start - improve oversized chunk data packet handling
++ if (++totalTileEntities > TE_LIMIT) {
++ PacketPlayOutTileEntityData updatePacket = tileentity.getUpdatePacket();
++ if (updatePacket != null) {
++ this.extraPackets.add(updatePacket);
++ continue;
++ }
++ }
++ // Paper end
+ NBTTagCompound nbttagcompound = tileentity.b();
+ if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
+