From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar 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/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java index 96626835fee3c0fdb452acacdc9f737ad90c08de..c28879f32b004f36ff746ea2274f91ddd9501e71 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java @@ -27,6 +27,15 @@ public class ClientboundLevelChunkPacket implements Packet blockEntitiesTags; + // Paper start + private final java.util.List extraPackets = new java.util.ArrayList<>(); + private static final int TE_LIMIT = Integer.getInteger("Paper.excessiveTELimit", 750); + + @Override + public java.util.List getExtraPackets() { + return extraPackets; + } + // Paper end public ClientboundLevelChunkPacket(LevelChunk chunk) { ChunkPos chunkPos = chunk.getPos(); @@ -44,9 +53,19 @@ public class ClientboundLevelChunkPacket implements Packet entry2 : chunk.getBlockEntities().entrySet()) { BlockEntity blockEntity = entry2.getValue(); + // Paper start - improve oversized chunk data packet handling + if (++totalTileEntities > TE_LIMIT) { + ClientboundBlockEntityDataPacket updatePacket = blockEntity.getUpdatePacket(); + if (updatePacket != null) { + this.extraPackets.add(updatePacket); + continue; + } + } + // Paper end CompoundTag compoundTag = blockEntity.getUpdateTag(); if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity) { net.minecraft.world.level.block.entity.SkullBlockEntity.sanitizeTileEntityUUID(compoundTag); } // Paper this.blockEntitiesTags.add(compoundTag);