Skip to content

Commit 5563e58

Browse files
Optimize waypoint distance check (#13857)
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
1 parent 013d163 commit 5563e58

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

paper-server/patches/features/0001-Moonrise-optimisation-patches.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36909,7 +36909,7 @@ index cec7442a5401b2886f5ce7c473386c15f64fe0a3..88eb48034d8022600dc08b4dcf6162bb
3690936909

3691036910
for (SavedTick<T> pendingTick : this.pendingTicks) {
3691136911
diff --git a/net/minecraft/world/waypoints/WaypointTransmitter.java b/net/minecraft/world/waypoints/WaypointTransmitter.java
36912-
index e822b8429e8ea2b113ef83310223bc7edb12aad9..2866b750a28cc32c2913d3c1afee95f05956982c 100644
36912+
index 01fd20a4a452de5201f4e6141d6fb7563e2597b4..07af92310ee5c8bba04e6175b6faac629632e4de 100644
3691336913
--- a/net/minecraft/world/waypoints/WaypointTransmitter.java
3691436914
+++ b/net/minecraft/world/waypoints/WaypointTransmitter.java
3691536915
@@ -34,7 +34,10 @@ public interface WaypointTransmitter extends Waypoint {
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
--- a/net/minecraft/world/waypoints/WaypointTransmitter.java
22
+++ b/net/minecraft/world/waypoints/WaypointTransmitter.java
3-
@@ -20,6 +_,7 @@
3+
@@ -20,13 +_,14 @@
44
Waypoint.Icon waypointIcon();
55

66
static boolean doesSourceIgnoreReceiver(final LivingEntity source, final ServerPlayer receiver) {
77
+ if (!receiver.getBukkitEntity().canSee(source.getBukkitEntity())) return true; // Paper - ignore if entity is hidden from player
88
if (receiver.isSpectator()) {
99
return false;
1010
} else if (!source.isSpectator() && !source.hasIndirectPassenger(receiver)) {
11+
double broadcastRange = Math.min(
12+
source.getAttributeValue(Attributes.WAYPOINT_TRANSMIT_RANGE), receiver.getAttributeValue(Attributes.WAYPOINT_RECEIVE_RANGE)
13+
);
14+
- return source.distanceTo(receiver) >= broadcastRange;
15+
+ return source.distanceToSqr(receiver) >= Mth.square(broadcastRange); // Paper - optimize waypoint distance check by using squared distance
16+
} else {
17+
return true;
18+
}

0 commit comments

Comments
 (0)