mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Merge remote-tracking branch 'Kebab11noel/position-cleanup' into position-cleanup
This commit is contained in:
commit
71a6d88338
@ -655,6 +655,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
super.setInstance(instance, spawnPosition);
|
||||
|
||||
refreshVisibleChunks();
|
||||
|
||||
if (differentSpawnPos && !firstSpawn) {
|
||||
// Player changed instance at a different position
|
||||
teleport(spawnPosition);
|
||||
@ -1547,27 +1549,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];
|
||||
@ -2595,6 +2595,10 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
private byte displayedSkinParts;
|
||||
private MainHand mainHand;
|
||||
|
||||
public PlayerSettings() {
|
||||
viewDistance = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player game language.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user