Skip to content

Commit

Permalink
Move logic in anyPlayerCloseEnoughForSpawning overwrite to correct place
Browse files Browse the repository at this point in the history
The internal function is responsible for the actual player iteration.
  • Loading branch information
Spottedleaf committed Oct 24, 2024
1 parent a3f2328 commit f22335f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ private void removePlayerFromSpawnTracker(final ServerPlayer player, final boole
}

/**
* @reason Use nearby players to avoid iterating over all online players
* @reason Avoid checking first if there are nearby players, as we make internal perform this implicitly.
* @author Spottedleaf
*/
@Overwrite
public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) {
return this.anyPlayerCloseEnoughForSpawningInternal(pos);
}

/**
* @reason Use nearby players to avoid iterating over all online players
* @author Spottedleaf
*/
@Overwrite
public boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) {
final ReferenceList<ServerPlayer> players = ((ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers(
pos, NearbyPlayers.NearbyMapType.SPAWN_RANGE
);
Expand Down

0 comments on commit f22335f

Please sign in to comment.