mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Re-enable chunk unloading, corrected packet order
This commit is contained in:
parent
d360904f77
commit
de7241ef6c
@ -1547,27 +1547,25 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
final int[] oldChunks = ArrayUtils.getDifferencesBetweenArray(lastVisibleChunks, updatedVisibleChunks);
|
||||
final int[] newChunks = ArrayUtils.getDifferencesBetweenArray(updatedVisibleChunks, lastVisibleChunks);
|
||||
|
||||
// Update client render distance
|
||||
updateViewPosition(newChunk.getChunkX(), newChunk.getChunkZ());
|
||||
|
||||
// Unload old chunks
|
||||
for (int index : oldChunks) {
|
||||
final long chunkIndex = lastVisibleChunks[index];
|
||||
final int chunkX = ChunkUtils.getChunkCoordX(chunkIndex);
|
||||
final int chunkZ = ChunkUtils.getChunkCoordZ(chunkIndex);
|
||||
|
||||
// TODO prevent the client from getting lag spikes when re-loading large chunks
|
||||
// Probably by having a distinction between visible and loaded (cache) chunks
|
||||
/*UnloadChunkPacket unloadChunkPacket = new UnloadChunkPacket();
|
||||
final UnloadChunkPacket unloadChunkPacket = new UnloadChunkPacket();
|
||||
unloadChunkPacket.chunkX = chunkX;
|
||||
unloadChunkPacket.chunkZ = chunkZ;
|
||||
playerConnection.sendPacket(unloadChunkPacket);*/
|
||||
playerConnection.sendPacket(unloadChunkPacket);
|
||||
|
||||
final Chunk chunk = instance.getChunk(chunkX, chunkZ);
|
||||
if (chunk != null)
|
||||
chunk.removeViewer(this);
|
||||
}
|
||||
|
||||
// Update client render distance
|
||||
updateViewPosition(newChunk.getChunkX(), newChunk.getChunkZ());
|
||||
|
||||
// Load new chunks
|
||||
for (int index : newChunks) {
|
||||
final long chunkIndex = updatedVisibleChunks[index];
|
||||
|
Loading…
Reference in New Issue
Block a user