mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 23:52:11 -07:00
More changes to view distance API implementation
Should fix GH-381
This commit is contained in:
@@ -85,6 +85,93 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
// this.c(l1, i2).a(entityplayer);
|
// this.c(l1, i2).a(entityplayer);
|
||||||
chunksToLoad.add(new ChunkCoordIntPair(l1, i2)); // CraftBukkit
|
chunksToLoad.add(new ChunkCoordIntPair(l1, i2)); // CraftBukkit
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +0,0 @@ public class PlayerChunkMap {
|
||||||
|
return playerchunk != null && playerchunk.d(entityplayer) && playerchunk.e();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public final void setViewDistanceForAll(int viewDistance) { this.a(viewDistance); } // Paper - OBFHELPER
|
||||||
|
+ // Paper start - Separate into two methods
|
||||||
|
public void a(int i) {
|
||||||
|
i = MathHelper.clamp(i, 3, 32);
|
||||||
|
if (i != this.j) {
|
||||||
|
@@ -0,0 +0,0 @@ public class PlayerChunkMap {
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||||
|
- int k = (int) entityplayer.locX >> 4;
|
||||||
|
- int l = (int) entityplayer.locZ >> 4;
|
||||||
|
- int i1;
|
||||||
|
- int j1;
|
||||||
|
-
|
||||||
|
- if (j > 0) {
|
||||||
|
- for (i1 = k - i; i1 <= k + i; ++i1) {
|
||||||
|
- for (j1 = l - i; j1 <= l + i; ++j1) {
|
||||||
|
- PlayerChunk playerchunk = this.c(i1, j1);
|
||||||
|
-
|
||||||
|
- if (!playerchunk.d(entityplayer)) {
|
||||||
|
- playerchunk.a(entityplayer);
|
||||||
|
- }
|
||||||
|
+ this.setViewDistance(entityplayer, i, false); // Paper - Split, don't mark sort pending, we'll handle it after
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ this.j = i;
|
||||||
|
+ this.e();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setViewDistance(EntityPlayer entityplayer, int i) {
|
||||||
|
+ this.setViewDistance(entityplayer, i, true); // Mark sort pending by default so we don't have to remember to do so all the time
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Copied from above with minor changes
|
||||||
|
+ public void setViewDistance(EntityPlayer entityplayer, int i, boolean markSort) {
|
||||||
|
+ i = MathHelper.clamp(i, 3, 32);
|
||||||
|
+ int oldViewDistance = entityplayer.getViewDistance();
|
||||||
|
+ if (i != oldViewDistance) {
|
||||||
|
+ int j = i - oldViewDistance;
|
||||||
|
+
|
||||||
|
+ int k = (int) entityplayer.locX >> 4;
|
||||||
|
+ int l = (int) entityplayer.locZ >> 4;
|
||||||
|
+ int i1;
|
||||||
|
+ int j1;
|
||||||
|
+
|
||||||
|
+ if (j > 0) {
|
||||||
|
+ for (i1 = k - i; i1 <= k + i; ++i1) {
|
||||||
|
+ for (j1 = l - i; j1 <= l + i; ++j1) {
|
||||||
|
+ PlayerChunk playerchunk = this.c(i1, j1);
|
||||||
|
+
|
||||||
|
+ if (!playerchunk.d(entityplayer)) {
|
||||||
|
+ playerchunk.a(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- } else {
|
||||||
|
- for (i1 = k - this.j; i1 <= k + this.j; ++i1) {
|
||||||
|
- for (j1 = l - this.j; j1 <= l + this.j; ++j1) {
|
||||||
|
- if (!this.a(i1, j1, k, l, i)) {
|
||||||
|
- this.c(i1, j1).b(entityplayer);
|
||||||
|
- }
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ for (i1 = k - oldViewDistance; i1 <= k + oldViewDistance; ++i1) {
|
||||||
|
+ for (j1 = l - oldViewDistance; j1 <= l + oldViewDistance; ++j1) {
|
||||||
|
+ if (!this.a(i1, j1, k, l, i)) {
|
||||||
|
+ this.c(i1, j1).b(entityplayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ if (markSort) {
|
||||||
|
+ this.e();
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- this.j = i;
|
||||||
|
- this.e();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
|
private void e() {
|
||||||
|
this.l = true;
|
||||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap {
|
@@ -0,0 +0,0 @@ public class PlayerChunkMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,9 +186,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ viewDistance = -1;
|
+ viewDistance = -1;
|
||||||
+ }
|
+ }
|
||||||
+ if (viewDistance != oldViewDistance) {
|
+ if (viewDistance != oldViewDistance) {
|
||||||
+ removePlayer(player);
|
+ // Order matters
|
||||||
|
+ this.setViewDistance(player, viewDistance);
|
||||||
+ player.setViewDistance(viewDistance);
|
+ player.setViewDistance(viewDistance);
|
||||||
+ addPlayer(player);
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
Reference in New Issue
Block a user