@minecraft/server / LocatorBar
Class: LocatorBar ​
Defined in: @minecraft/server/index.d.ts:15660
Manages the collection of waypoints displayed on a player's locator bar. Allows adding, removing, and querying waypoints with a maximum capacity limit.
Invalid waypoints in the locator bar will be automatically removed in the next tick. This includes waypoints tied to entities that have been removed from the world.
Note: You can control whether vanilla player waypoints are automatically added to the locator bar using the playerWaypoints GameRule. Accepted values are off (players are not shown on the locator bar) and everyone (all players are visible on the locator bar).
Note: You can only modify, remove, or query waypoints that were added by this pack.
Example ​
sharedWaypoint.ts
/\*
import { world, LocationWaypoint, WaypointTextureSelector, WaypointTexture } from "@minecraft/server"
function sharedWaypoint() {
const players = world.getAllPlayers();
if (players.length < 2) {
console.warn("Need at least 2 players for this example.");
return;
}
const playerA = players[0];
const playerB = players[1];
// Create a single waypoint at a specific location
const textureSelector: WaypointTextureSelector = {
textureBoundsList: [
{ lowerBound: 0, texture: WaypointTexture.Circle }
]
};
const waypoint = new LocationWaypoint(
{ dimension: playerA.dimension, x: 100, y: 64, z: 100 },
textureSelector,
{ red: 1, green: 0, blue: 0 } // Initially red
);
// Add the same waypoint to both players' locator bars
playerA.locatorBar.addWaypoint(waypoint);
playerB.locatorBar.addWaypoint(waypoint);
// Change the color - this affects both players
waypoint.color = { red: 0, green: 1, blue: 0 }; // Now green for both players
}
*/Properties ​
count ​
readonlycount:number
Defined in: @minecraft/server/index.d.ts:15667
Remarks ​
The current number of waypoints in the locator bar.
maxCount ​
readonlymaxCount:number
Defined in: @minecraft/server/index.d.ts:15674
Remarks ​
The maximum number of waypoints that can be added to the locator bar.
Methods ​
addWaypoint() ​
addWaypoint(
waypoint):void
Defined in: @minecraft/server/index.d.ts:15693
Parameters ​
waypoint ​
The Waypoint to add to the locator bar.
Returns ​
void
Remarks ​
Adds a waypoint to the locator bar. Throws an error if the waypoint already exists, the maximum waypoint limit has been reached, or the waypoint is invalid.
This function can't be called in restricted-execution mode.
Throws ​
This function can throw errors.
minecraftcommon.EngineError
getAllWaypoints() ​
getAllWaypoints():
Waypoint[]
Defined in: @minecraft/server/index.d.ts:15702
Returns ​
Waypoint[]
Remarks ​
Returns an array of all waypoints currently in the locator bar.
This function can't be called in restricted-execution mode.
hasWaypoint() ​
hasWaypoint(
waypoint):boolean
Defined in: @minecraft/server/index.d.ts:15713
Parameters ​
waypoint ​
The Waypoint to check for.
Returns ​
boolean
Remarks ​
Checks whether the specified waypoint exists in the locator bar.
This function can't be called in restricted-execution mode.
removeAllWaypoints() ​
removeAllWaypoints():
void
Defined in: @minecraft/server/index.d.ts:15725
Returns ​
void
Remarks ​
Removes all waypoints from the locator bar, clearing it completely.
This function can't be called in restricted-execution mode.
Throws ​
This function can throw errors.
minecraftcommon.EngineError
removeWaypoint() ​
removeWaypoint(
waypoint):void
Defined in: @minecraft/server/index.d.ts:15741
Parameters ​
waypoint ​
The Waypoint to remove from the locator bar.
Returns ​
void
Remarks ​
Removes a specific waypoint from the locator bar. Returns an error if the waypoint does not exist in the locator bar.
This function can't be called in restricted-execution mode.
Throws ​
This function can throw errors.
minecraftcommon.EngineError