Add DISPLAY tracking range type (#9668)

This commit is contained in:
Warrior 2023-09-17 01:02:58 +03:00 committed by GitHub
parent ede9c06814
commit e312ebb1bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 29 deletions

View file

@ -1485,10 +1485,10 @@ index 0000000000000000000000000000000000000000..f0d4ec73bc8872a85e34f5c6b4d342e7
+}
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..da7c899fbab162ee197a0593f455ebd9c5286d3c
index 0000000000000000000000000000000000000000..f45afb7e2607617d1239abeca13a9002dd9a3a18
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -0,0 +1,530 @@
@@ -0,0 +1,531 @@
+package io.papermc.paper.configuration;
+
+import com.google.common.collect.HashBasedTable;
@ -1800,8 +1800,6 @@ index 0000000000000000000000000000000000000000..da7c899fbab162ee197a0593f455ebd9
+ public IntOr.Default other = IntOr.Default.USE_DEFAULT;
+
+ public int get(Entity entity, int def) {
+ if (entity instanceof Display) return display.or(def);
+
+ switch (TrackingRange.getTrackingRangeType(entity)) {
+ case PLAYER -> {
+ return player.or(def);
@ -1818,6 +1816,9 @@ index 0000000000000000000000000000000000000000..da7c899fbab162ee197a0593f455ebd9
+ case ENDERDRAGON -> {
+ return -1; // Ender dragon is exempt
+ }
+ case DISPLAY -> {
+ return display.or(def);
+ }
+ }
+
+ return other.or(def);

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026a91406cd 100644
index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43bc2900b23 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -157,6 +157,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -75,7 +75,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
}
// Paper end
// Paper start
@@ -276,6 +314,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -276,6 +314,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager);
// Paper end
this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
@ -107,6 +107,9 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
+ case ENDERDRAGON:
+ configuredSpigotValue = EntityType.ENDER_DRAGON.clientTrackingRange() * 16;
+ break;
+ case DISPLAY:
+ configuredSpigotValue = spigotWorldConfig.displayTrackingRange;
+ break;
+ default:
+ throw new IllegalStateException("Missing case for enum " + trackingRangeType);
+ }
@ -121,7 +124,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
}
protected ChunkGenerator generator() {
@@ -960,17 +1037,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -960,17 +1040,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
public void move(ServerPlayer player) {
@ -140,7 +143,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
int i = SectionPos.blockToSectionCoord(player.getBlockX());
int j = SectionPos.blockToSectionCoord(player.getBlockZ());
@@ -1054,7 +1121,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1054,7 +1124,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
@ -149,7 +152,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1098,7 +1165,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1098,7 +1168,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
entity.tracker = null; // Paper - We're no longer tracked
}
@ -187,7 +190,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players();
ObjectIterator objectiterator = this.entityMap.values().iterator();
@@ -1205,46 +1302,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1205,46 +1305,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}));
// Paper end
DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos());
@ -235,7 +238,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..93dea79180ebaef3ffb6abffd47f0026
}
@@ -1299,6 +1357,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1299,6 +1360,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lastSectionPos = SectionPos.of((EntityAccess) entity);
}
@ -330,10 +333,10 @@ index ce4b2ec2ad6138b754ced976521d1c73eb4193a8..c99d24008792b07d5e2984261215de94
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
index 172d231adecf043f9f06b7f5e0365ae82327998d..8fca15099952626ee537f5ce3eefdfaa6518dc1b 100644
index 172d231adecf043f9f06b7f5e0365ae82327998d..ed8378ad022c375b0d18172aeccf65cb026d9d68 100644
--- a/src/main/java/org/spigotmc/TrackingRange.java
+++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -55,4 +55,45 @@ public class TrackingRange
@@ -55,4 +55,48 @@ public class TrackingRange
return config.otherTrackingRange;
}
}
@ -363,6 +366,8 @@ index 172d231adecf043f9f06b7f5e0365ae82327998d..8fca15099952626ee537f5ce3eefdfaa
+ // Paper end
+ {
+ return TrackingRangeType.MISC;
+ } else if (entity instanceof Display) {
+ return TrackingRangeType.DISPLAY;
+ } else
+ {
+ return TrackingRangeType.OTHER;
@ -375,7 +380,8 @@ index 172d231adecf043f9f06b7f5e0365ae82327998d..8fca15099952626ee537f5ce3eefdfaa
+ MONSTER,
+ MISC,
+ OTHER,
+ ENDERDRAGON;
+ ENDERDRAGON,
+ DISPLAY;
+ }
+ // Paper end - optimise entity tracking
}

View file

@ -42,7 +42,7 @@ index c5389e7f3665c06e487dfde3200b7e229694fbd2..4164204ba80f68a768de0ed1721c6447
private final com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersSentChunkTo = new com.destroystokyo.paper.util.maplist.ReferenceList<>();
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 93dea79180ebaef3ffb6abffd47f0026a91406cd..4e65e1d2d1538366f554d94bff31ab74c2e8a225 100644
index 52d9d0f2366f292c56eee9fe241cb43bc2900b23..80b2ff12e48e1aabebd9ebcf5958c1f5d073d55b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -174,12 +174,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -89,7 +89,7 @@ index 93dea79180ebaef3ffb6abffd47f0026a91406cd..4e65e1d2d1538366f554d94bff31ab74
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
@@ -353,6 +370,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -356,6 +373,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerEntityTrackerTrackMaps[ordinal] = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
}
// Paper end - use distance map to optimise entity tracker
@ -128,7 +128,7 @@ index 93dea79180ebaef3ffb6abffd47f0026a91406cd..4e65e1d2d1538366f554d94bff31ab74
}
protected ChunkGenerator generator() {
@@ -927,43 +976,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -930,43 +979,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(pos, false);
}

View file

@ -7,10 +7,10 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ee298a136d95a2759ee77ffc11cf6e43cc54c1bb..d83a4405b68d2417de345849b936d43c17e11392 100644
index bcf0dfe50add8e260a280e45673727f964bac6fd..db40680bd9e026d9e98135355e4844c32e82fd51 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1405,7 +1405,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1408,7 +1408,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity;
private final int range;
SectionPos lastSectionPos;

View file

@ -39,7 +39,7 @@ index 4ae1ba645d9fdc1eb6d5a3e4f8ceed9b4841e003..e2202389a2c4133a183cca59c4e909fc
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d83a4405b68d2417de345849b936d43c17e11392..9209b598d7168b82574e4800056b8b9f84265dd0 100644
index db40680bd9e026d9e98135355e4844c32e82fd51..153b82e4a3134ff0e40f267f1a005bc9184785ef 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -157,6 +157,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -79,7 +79,7 @@ index d83a4405b68d2417de345849b936d43c17e11392..9209b598d7168b82574e4800056b8b9f
}
// Paper end
// Paper start
@@ -405,6 +414,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -408,6 +417,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
});
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning

View file

@ -99,10 +99,10 @@ index 6cd6d69a20e95e344fc18ab67dc300824537a59b..2e2a7c2cf3081187da817479a9da3eb1
}
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 9209b598d7168b82574e4800056b8b9f84265dd0..469083208110d5735e1bbda7a15c55a032d0e8cc 100644
index 153b82e4a3134ff0e40f267f1a005bc9184785ef..1337abd1ad70fb67d1ebba0fc0245470c988f7c5 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1000,7 +1000,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1003,7 +1003,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Player Entity Tracking Events
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 469083208110d5735e1bbda7a15c55a032d0e8cc..a98c134ce2ea51ae6d6f92959e57a4f0e03b0f6c 100644
index 1337abd1ad70fb67d1ebba0fc0245470c988f7c5..3b9fcc33fdd91b02f7f9681329b2f3d523a5cd5a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1543,9 +1543,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1546,9 +1546,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// CraftBukkit end
if (flag) {
if (this.seenBy.add(player.connection)) {

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index a98c134ce2ea51ae6d6f92959e57a4f0e03b0f6c..a4bf4ed615653ce30d2416a62e680d74e87b53fa 100644
index 3b9fcc33fdd91b02f7f9681329b2f3d523a5cd5a..14f6c163c4f3cb5b096db1b9111041b4573bfef6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -476,8 +476,27 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -479,8 +479,27 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Configurable entity tracking range by Y coordinate
Options to configure entity tracking by Y coordinate, also for each entity category.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index a4bf4ed615653ce30d2416a62e680d74e87b53fa..65d947df910d60f478e7a449eb161e5105e2c0c9 100644
index 14f6c163c4f3cb5b096db1b9111041b4573bfef6..fb6cbcc4839aef7dc4bd4a49613f892b07aab353 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1554,6 +1554,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1557,6 +1557,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player);