mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 18:08:37 +01:00
Fix lag spikes when loading the same chunks multiple times
This commit is contained in:
parent
6514b188fe
commit
8b0ab3d8c3
@ -89,6 +89,7 @@ public class Player extends LivingEntity implements CommandSender {
|
|||||||
|
|
||||||
private DimensionType dimensionType;
|
private DimensionType dimensionType;
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
|
// Chunks that the player can view
|
||||||
protected final Set<Chunk> viewableChunks = new CopyOnWriteArraySet<>();
|
protected final Set<Chunk> viewableChunks = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
private final AtomicInteger teleportId = new AtomicInteger();
|
private final AtomicInteger teleportId = new AtomicInteger();
|
||||||
@ -1507,10 +1508,12 @@ public class Player extends LivingEntity implements CommandSender {
|
|||||||
final int chunkX = ChunkUtils.getChunkCoordX(chunkIndex);
|
final int chunkX = ChunkUtils.getChunkCoordX(chunkIndex);
|
||||||
final int chunkZ = ChunkUtils.getChunkCoordZ(chunkIndex);
|
final int chunkZ = ChunkUtils.getChunkCoordZ(chunkIndex);
|
||||||
|
|
||||||
UnloadChunkPacket unloadChunkPacket = new UnloadChunkPacket();
|
// 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();
|
||||||
unloadChunkPacket.chunkX = chunkX;
|
unloadChunkPacket.chunkX = chunkX;
|
||||||
unloadChunkPacket.chunkZ = chunkZ;
|
unloadChunkPacket.chunkZ = chunkZ;
|
||||||
playerConnection.sendPacket(unloadChunkPacket);
|
playerConnection.sendPacket(unloadChunkPacket);*/
|
||||||
|
|
||||||
final Chunk chunk = instance.getChunk(chunkX, chunkZ);
|
final Chunk chunk = instance.getChunk(chunkX, chunkZ);
|
||||||
if (chunk != null)
|
if (chunk != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user