aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1027-Optimise-nearby-player-retrieval.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-04-08 16:03:41 -0700
committerJake Potrebic <[email protected]>2024-04-10 14:04:48 -0700
commit83903c75cf9a027b0d8e8c01843b51a427361f3a (patch)
tree63be93b40a9863c1f5ce1450684fe630264f1f20 /patches/server/1027-Optimise-nearby-player-retrieval.patch
parentc1166f5d0d73723d8e7bad1a158a96a21835c5c2 (diff)
downloadPaper-83903c75cf9a027b0d8e8c01843b51a427361f3a.tar.gz
Paper-83903c75cf9a027b0d8e8c01843b51a427361f3a.zip
update patches again to handle inlined simple lambdas
Diffstat (limited to 'patches/server/1027-Optimise-nearby-player-retrieval.patch')
-rw-r--r--patches/server/1027-Optimise-nearby-player-retrieval.patch25
1 files changed, 12 insertions, 13 deletions
diff --git a/patches/server/1027-Optimise-nearby-player-retrieval.patch b/patches/server/1027-Optimise-nearby-player-retrieval.patch
index 5607141705..06b8d42fec 100644
--- a/patches/server/1027-Optimise-nearby-player-retrieval.patch
+++ b/patches/server/1027-Optimise-nearby-player-retrieval.patch
@@ -128,16 +128,19 @@ index 8a5abc320137d045acba0c87cef9f2912d78b6fb..6907d1be36fbdf0856c0e11983218d2f
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
-index 3e24da56fc57afa5d8fdcb3c32c60299272fa43e..65cd42ce9f553e0aa5bf248bdbf902f9d1f55460 100644
+index 2e887e426dcd79e2dda401f127d0e01ca537e80e..65cd42ce9f553e0aa5bf248bdbf902f9d1f55460 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
-@@ -21,18 +21,50 @@ public class PlayerSensor extends Sensor<LivingEntity> {
+@@ -21,17 +21,50 @@ public class PlayerSensor extends Sensor<LivingEntity> {
@Override
protected void doTick(ServerLevel world, LivingEntity entity) {
-- List<Player> list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter(player -> {
-- return entity.closerThan(player, 16.0);
-- }).sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList());
+- List<Player> list = world.players()
+- .stream()
+- .filter(EntitySelector.NO_SPECTATORS)
+- .filter(player -> entity.closerThan(player, 16.0))
+- .sorted(Comparator.comparingDouble(entity::distanceToSqr))
+- .collect(Collectors.toList());
+ // Paper start - Perf: optimise nearby player retrieval & remove streams from hot code
+ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = world.chunkSource.chunkMap.getNearbyPlayers();
+ net.minecraft.world.phys.Vec3 entityPos = entity.position();
@@ -164,13 +167,9 @@ index 3e24da56fc57afa5d8fdcb3c32c60299272fa43e..65cd42ce9f553e0aa5bf248bdbf902f9
+ players.sort(Comparator.comparingDouble(entity::distanceToSqr));
Brain<?> brain = entity.getBrain();
- brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list);
-- List<Player> list2 = list.stream().filter(player -> {
-- return isEntityTargetable(entity, player);
-- }).collect(Collectors.toList());
+- List<Player> list2 = list.stream().filter(player -> isEntityTargetable(entity, player)).collect(Collectors.toList());
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list2.isEmpty() ? null : list2.get(0));
-- Optional<Player> optional = list2.stream().filter(player -> {
-- return isEntityAttackable(entity, player);
-- }).findFirst();
+- Optional<Player> optional = list2.stream().filter(player -> isEntityAttackable(entity, player)).findFirst();
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, optional);
+
+ brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players);
@@ -208,10 +207,10 @@ index aecb0ad814586bfc5e56755ee14379a69388b38c..d2f0c3b26d4beedb49d86e0242d84359
private boolean testInvisible = true;
@Nullable
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
-index 44cfa3821774f22ac05aa679fdee34d8d68b7d60..e6f7081450e129a72ac0b5031b474d14328a6d42 100644
+index 21843501355a0c0c8d594e3e5312e97861c9a777..ea0aee88c7d901034427db201c1b2430f8a1d522 100644
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
-@@ -235,9 +235,13 @@ public interface EntityGetter {
+@@ -233,9 +233,13 @@ public interface EntityGetter {
T livingEntity = null;
for (T livingEntity2 : entityList) {