Fix glitchy chunk loading when you first login and don't send chunks to a player that are out of the player's render distance.

This commit is contained in:
Eoghanmc22 2020-08-13 17:23:35 -04:00
parent 542d603d60
commit 74c99e8886

View File

@ -558,7 +558,8 @@ public class Player extends LivingEntity implements CommandSender {
viewableChunks.add(chunk);
chunk.addViewer(this);
instance.sendChunk(this, chunk);
updateViewPosition(chunk);
if (chunk.getChunkX() == Math.floorDiv((int) getPosition().getX(), 16) && chunk.getChunkZ() == Math.floorDiv((int) getPosition().getZ(), 16))
updateViewPosition(chunk);
}
final boolean isLast = counter.get() == length - 1;
if (isLast) {
@ -1170,8 +1171,8 @@ public class Player extends LivingEntity implements CommandSender {
* @param newChunk the current/new player chunk
*/
protected void onChunkChange(Chunk lastChunk, Chunk newChunk) {
final long[] lastVisibleChunks = ChunkUtils.getChunksInRange(new Position(16 * lastChunk.getChunkX(), 0, 16 * lastChunk.getChunkZ()), MinecraftServer.CHUNK_VIEW_DISTANCE);
final long[] updatedVisibleChunks = ChunkUtils.getChunksInRange(new Position(16 * newChunk.getChunkX(), 0, 16 * newChunk.getChunkZ()), MinecraftServer.CHUNK_VIEW_DISTANCE);
final long[] lastVisibleChunks = ChunkUtils.getChunksInRange(new Position(16 * lastChunk.getChunkX(), 0, 16 * lastChunk.getChunkZ()), getChunkRange());
final long[] updatedVisibleChunks = ChunkUtils.getChunksInRange(new Position(16 * newChunk.getChunkX(), 0, 16 * newChunk.getChunkZ()), getChunkRange());
final int[] oldChunks = ArrayUtils.getDifferencesBetweenArray(lastVisibleChunks, updatedVisibleChunks);
final int[] newChunks = ArrayUtils.getDifferencesBetweenArray(updatedVisibleChunks, lastVisibleChunks);