-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Optimize getNearestPlayer for high player count"
- Loading branch information
1 parent
47979cc
commit cb48e11
Showing
2 changed files
with
46 additions
and
22 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
patches/server/0027-Swap-distanceToSqr-and-EntitySelector.patch
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
patches/server/0027-Swap-distanceToSqr-and-target-test.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Xymb <[email protected]> | ||
Date: Sat, 17 Jun 2023 19:52:29 +0300 | ||
Subject: [PATCH] Swap distanceToSqr and target test | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java | ||
index b1a6a66ed02706c1adc36dcedfa415f5a24a25a0..97a5eca200fd606d6102e40f9b8c32c2e7652cf9 100644 | ||
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java | ||
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java | ||
@@ -99,9 +99,9 @@ public interface EntityGetter { | ||
Player player = null; | ||
|
||
for(Player player2 : this.getLocalPlayers()) { // Folia - region threading | ||
- if (targetPredicate == null || targetPredicate.test(player2)) { | ||
+ if (true || targetPredicate == null || targetPredicate.test(player2)) { // Kaiiju - Move this down | ||
double e = player2.distanceToSqr(x, y, z); | ||
- if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d)) { | ||
+ if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d) && (targetPredicate == null || targetPredicate.test(player2))) { // Kaiiju | ||
d = e; | ||
player = player2; | ||
} | ||
@@ -147,9 +147,10 @@ public interface EntityGetter { | ||
// Paper start | ||
default boolean hasNearbyAlivePlayerThatAffectsSpawning(double x, double y, double z, double range) { | ||
for (Player player : this.getLocalPlayers()) { // Folia - region threading | ||
- if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check | ||
+ if (true || EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check // Kaiiju - Move this down | ||
double distanceSqr = player.distanceToSqr(x, y, z); | ||
if (range < 0.0D || distanceSqr < range * range) { | ||
+ if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) // Kaiiju | ||
return true; | ||
} | ||
} | ||
@@ -199,9 +200,9 @@ public interface EntityGetter { | ||
T livingEntity = null; | ||
|
||
for(T livingEntity2 : entityList) { | ||
- if (targetPredicate.test(entity, livingEntity2)) { | ||
+ if (true || targetPredicate.test(entity, livingEntity2)) { // Kaiiju - Move this down | ||
double e = livingEntity2.distanceToSqr(x, y, z); | ||
- if (d == -1.0D || e < d) { | ||
+ if ((d == -1.0D || e < d) && targetPredicate.test(entity, livingEntity2)) { // Kaiiju | ||
d = e; | ||
livingEntity = livingEntity2; | ||
} |