You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -174,6 +174,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -36,7 +36,7 @@ index 6f851c24a67d1b3a349790b0d60f45b23ff93bc6..4566af37c76cb3a2fe6441451a444a5a
36
36
// Paper start - distance maps
37
37
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
38
38
39
-
@@ -954,7 +955,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
39
+
@@ -975,7 +976,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
40
40
return Either.left(chunk);
41
41
});
42
42
}, (runnable) -> {
@@ -46,10 +46,10 @@ index 6f851c24a67d1b3a349790b0d60f45b23ff93bc6..4566af37c76cb3a2fe6441451a444a5a
@@ -177,21 +177,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
43
+
@@ -177,11 +177,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
44
44
final CallbackExecutor chunkLoadConversionCallbackExecutor = new CallbackExecutor(); // Paper
45
45
// Paper start - distance maps
46
46
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@@ -61,28 +61,32 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..87b612c25f865af4c8da72c761b70094
61
61
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
62
62
// Note: players need to be explicitly added to distance maps before they can be updated
63
63
+ this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@@ -281,6 +298,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
83
87
this.regionManagers.add(this.dataRegionManager);
84
88
// Paper end
85
-
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
89
+
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
86
90
+ // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
87
91
+ this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
88
92
+ (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
@@ -118,15 +122,15 @@ index 62a8482b73796f2c6b76c0e039cb21e799bc9416..87b612c25f865af4c8da72c761b70094
118
122
}
119
123
120
124
protected ChunkGenerator generator() {
121
-
@@ -466,6 +514,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
125
+
@@ -487,6 +536,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
122
126
} else {
123
127
if (holder != null) {
124
128
holder.setTicketLevel(level);
125
129
+ holder.updateRanges(); // Paper - optimise anyPlayerCloseEnoughForSpawning
126
130
}
127
131
128
132
if (holder != null) {
129
-
@@ -1310,43 +1359,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
133
+
@@ -1331,43 +1381,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -188,15 +189,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
20
+
@@ -188,10 +189,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
21
21
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap; // this map is absent from updateMaps since it's controlled at the start of the chunkproviderserver tick
22
22
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
23
23
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@@ -52,9 +52,11 @@ index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc8
52
52
+ // Paper end - use distance map to optimise entity tracker
53
53
// Note: players need to be explicitly added to distance maps before they can be updated
54
54
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
55
-
}
55
+
// Paper start - per player mob spawning
56
+
@@ -203,6 +229,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -63,7 +65,7 @@ index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc8
63
65
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
64
66
this.playerMobSpawnMap.remove(player);
65
67
this.playerChunkTickRangeMap.remove(player);
66
-
@@ -207,6 +238,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
68
+
@@ -218,6 +249,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
67
69
int chunkX = MCUtil.getChunkCoordinate(player.getX());
68
70
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
69
71
// Note: players need to be explicitly added to distance maps before they can be updated
@@ -76,12 +78,12 @@ index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc8
76
78
+ }
77
79
+ // Paper end - use distance map to optimise entity tracker
78
80
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
79
-
}
80
-
// Paper end
81
-
@@ -282,6 +321,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
81
+
// Paper start - per player mob spawning
82
+
if (this.playerMobDistanceMap != null) {
83
+
@@ -298,6 +337,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
82
84
this.regionManagers.add(this.dataRegionManager);
83
85
// Paper end
84
-
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
86
+
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
85
87
+ // Paper start - use distance map to optimise entity tracker
86
88
+ this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length];
87
89
+ this.entityTrackerTrackRanges = new int[TRACKING_RANGE_TYPES.length];
@@ -124,7 +126,7 @@ index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc8
124
126
// Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
125
127
this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
126
128
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
127
-
@@ -1482,17 +1560,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
129
+
@@ -1504,17 +1582,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
128
130
}
129
131
130
132
public void move(ServerPlayer player) {
@@ -143,7 +145,7 @@ index 87b612c25f865af4c8da72c761b70094fb89c4cb..2534cae6f1b369843808aac91931bdc8
143
145
144
146
int i = SectionPos.blockToSectionCoord(player.getBlockX());
145
147
int j = SectionPos.blockToSectionCoord(player.getBlockZ());
146
-
@@ -1619,7 +1687,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
148
+
@@ -1641,7 +1709,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
147
149
148
150
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
0 commit comments