Skip to content

Optimize waypoint distance check#13857

Open
Foorcee wants to merge 2 commits into
PaperMC:mainfrom
Foorcee:feat/optimize-waypoint-distance
Open

Optimize waypoint distance check#13857
Foorcee wants to merge 2 commits into
PaperMC:mainfrom
Foorcee:feat/optimize-waypoint-distance

Conversation

@Foorcee
Copy link
Copy Markdown
Contributor

@Foorcee Foorcee commented May 3, 2026

The method doesSourceIgnoreReceiver is called frequently, so using squared distance instead of calculating the actual distance is a straightforward improvement. Additionally, the distance check can be skipped when the broadcast range is set to zero.

@Foorcee Foorcee requested a review from a team as a code owner May 3, 2026 12:09
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue May 3, 2026
);
- return source.distanceTo(receiver) >= broadcastRange;
+ // Paper start - optimize waypoint distance check by using squared distance
+ if (broadcastRange <= 0) return true;
Copy link
Copy Markdown
Contributor

@Lulu13022002 Lulu13022002 May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check does anything, players are not added to the tracked list if their attribute is zero or less, same for the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

5 participants