2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-05-06 11:22:03 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 34e92e544f37167317d58af4242acde49e588673..5fae0ec8933cef2b87d2f465c8019af0af2e130d 100644
|
2020-05-06 11:22:03 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -22,7 +22,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
|
|
private boolean h;
|
2020-05-06 11:22:03 +02:00
|
|
|
|
|
|
|
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);
|
2020-08-25 04:22:08 +02:00
|
|
|
|
2020-05-06 11:22:03 +02:00
|
|
|
+ @Override
|
|
|
|
+ public java.util.List<Packet> getExtraPackets() {
|
|
|
|
+ return extraPackets;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2020-08-25 04:22:08 +02:00
|
|
|
public PacketPlayOutMapChunk(Chunk chunk, int i) {
|
2020-05-06 11:22:03 +02:00
|
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -49,6 +57,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
|
|
this.c = this.a(new PacketDataSerializer(this.j()), chunk, i);
|
2020-05-06 11:22:03 +02:00
|
|
|
this.g = Lists.newArrayList();
|
|
|
|
iterator = chunk.getTileEntities().entrySet().iterator();
|
|
|
|
+ int totalTileEntities = 0; // Paper
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
entry = (Entry) iterator.next();
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -57,6 +66,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
2020-05-06 11:22:03 +02:00
|
|
|
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
|
|
|
|
|