EntityPlayerMP: Faster chunk sending (And this avoids thousands of useless chunk light updates on the client side)

This commit is contained in:
Dereku 2026-02-07 08:29:23 +07:00
parent 10abac72b5
commit bbfc5b9e94

View file

@ -151,16 +151,28 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
} }
if (var1 && !this.loadedChunks.isEmpty()) { if (var1 && !this.loadedChunks.isEmpty()) {
ChunkCoordIntPair var7 = (ChunkCoordIntPair) this.loadedChunks.get(0); // Patch start
HashSet<ChunkCoordIntPair> queue = new HashSet<>();
for (int count = 0; !this.loadedChunks.isEmpty() && count < 9; count++) {
//ChunkCoordIntPair var7 = (ChunkCoordIntPair) this.loadedChunks.get(0);
ChunkCoordIntPair var7 = (ChunkCoordIntPair) this.loadedChunks.remove(0);
if (var7 != null) { if (var7 != null) {
boolean var8 = false; //boolean var8 = false;
if (this.playerNetServerHandler.getNumChunkDataPackets() < 4) { //if (this.playerNetServerHandler.getNumChunkDataPackets() < 4) {
var8 = true; // var8 = true;
//}
//if (var8) {
// WorldServer var9 = this.mcServer.getWorldManager(this.dimension);
// this.loadedChunks.remove(var7);
queue.add(var7);
}
} }
if (var8) { if (!queue.isEmpty()) {
WorldServer var9 = this.mcServer.getWorldManager(this.dimension); WorldServer var9 = this.mcServer.getWorldManager(this.dimension);
this.loadedChunks.remove(var7); for (ChunkCoordIntPair var7 : queue) {
// Patch end
this.playerNetServerHandler.sendPacket(new Packet51MapChunk(var7.chunkXPos * 16, 0, var7.chunkZPos * 16, 16, 128, 16, var9)); this.playerNetServerHandler.sendPacket(new Packet51MapChunk(var7.chunkXPos * 16, 0, var7.chunkZPos * 16, 16, 128, 16, var9));
List var5 = var9.getTileEntityList(var7.chunkXPos * 16, 0, var7.chunkZPos * 16, var7.chunkXPos * 16 + 16, 128, var7.chunkZPos * 16 + 16); List var5 = var9.getTileEntityList(var7.chunkXPos * 16, 0, var7.chunkZPos * 16, var7.chunkXPos * 16 + 16, 128, var7.chunkZPos * 16 + 16);