sendChunks(entityPlayerMP);
nsh.handleFlying(this);
}
private static void sendChunks(EntityPlayerMP entityPlayerMP) {
NetServerHandler netServerHandler = entityPlayerMP.playerNetServerHandler;
if (!entityPlayerMP.loadedChunks.isEmpty()) {
ArrayList<ChunkCoordIntPair> unpopulatedChunks = new ArrayList<ChunkCoordIntPair>();
ArrayList<Chunk> chunks = new ArrayList<Chunk>(5);
ArrayList<TileEntity> tileEntities = new ArrayList<TileEntity>();
synchronized (entityPlayerMP.loadedChunks) {
ChunkCoordIntPair chunkCoordIntPair;
while (chunks.size() < 5 && (chunkCoordIntPair = (ChunkCoordIntPair) entityPlayerMP.loadedChunks.remove(0)) != null) {
int x = chunkCoordIntPair.chunkXPos;
int z = chunkCoordIntPair.chunkZPos;
Chunk chunk = entityPlayerMP.worldObj.getChunkIfExists(x, z);
if (chunk == null) {
continue;
}
synchronized (chunk) {
if (!chunk.isTerrainPopulated) {
unpopulatedChunks.add(chunkCoordIntPair);
continue;
}
}
chunks.add(chunk);
tileEntities.addAll(chunk.chunkTileEntityMap.values());
}
}
entityPlayerMP.loadedChunks.addAll(unpopulatedChunks);
if (!chunks.isEmpty()) {
netServerHandler.sendPacketToPlayer(new Packet56MapChunks(chunks));
Iterator iterator = tileEntities.iterator();
while (iterator.hasNext()) {
Packet descriptionPacket;
try {
descriptionPacket = ((TileEntity) iterator.next()).getDescriptionPacket();
} catch (Throwable t) {
Log.warning("A TileEntity failed to provide a description packet", t);
continue;
}
if (descriptionPacket != null) {
netServerHandler.sendPacketToPlayer(descriptionPacket);
}
}
iterator = chunks.iterator();