# WorldAnchor
> A HUD marker pinned to a point in the world, tracking it as the player looks around.
`gg.lode.lecternapi.api.ui.WorldAnchor`
---
## Signature
```java
public class WorldAnchor
```
---
## Notes
The client draws the marker itself, a pin while the target is in view, an arrow pinned to the
screen edge along the bearing to it when it is not, and an optional pair of labels that appear
only while the player is actually looking at it. That last part is why the marker is described
here rather than assembled from HUD elements: it reacts to where the crosshair is, which
changes every frame and no packet could keep up with.
The two group prefixes are optional and independent of the marker. Naming them lets a server
compose its own elements for the on-screen and off-screen states, which are then positioned by
the anchor; leaving them empty gives just the marker.
```java
api.getHUDManager().setAnchor(player, new WorldAnchor("objective", location)
.icon("lectern:textures/gui/anchor_pin.png", 11f) // or .item("minecraft:iron_ingot")
.arrowColor(0xFFFFC83C)
.labels("Objective", "%distance%m")
.maxDistance(200f));
```
---
## Methods
### groups
```java
public WorldAnchor groups(String visibleGroup, String offscreenGroup)
```
Reference prefixes for server-composed groups: one drawn while the point is on screen, the
other while it is not. Empty for a marker with no groups of its own.
| Parameter | Type |
|---|---|
| `visibleGroup` | `String` |
| `offscreenGroup` | `String` |
---
### edgeMargin
```java
public WorldAnchor edgeMargin(float pixels)
```
How far in from the screen edge an off-screen marker sits, in scaled GUI pixels.
| Parameter | Type |
|---|---|
| `pixels` | `float` |
---
### maxDistance
```java
public WorldAnchor maxDistance(float blocks)
```
Hide the marker past this many blocks; 0 for no limit.
| Parameter | Type |
|---|---|
| `blocks` | `float` |
---
### icon
```java
public WorldAnchor icon(String icon, float size)
```
The texture drawn while the target is on screen, and its size in scaled GUI pixels.
| Parameter | Type |
|---|---|
| `icon` | `String` |
| `size` | `float` |
---
### item
```java
public WorldAnchor item(String itemId)
public WorldAnchor item(String itemId, String itemModel)
```
Draw an item at the marker instead of a texture, the client renders the stack itself, the
way an inventory slot does.
Marking a dropped sword is the case this exists for: a texture path has to be guessed from
the item and the guess is wrong wherever a pack's art doesn't sit where the name implies,
while an item id is something the client can look up and always render. Set when the marker
stands for an item; leave it and use `float)` for anything else.
As above, for an item a resource pack re-skins.
---
### head
```java
public WorldAnchor head(String uuidOrName)
```
Draw a player's head at the marker, for a marker that stands for a person, which reads
faster than any icon a server could pick.
| Parameter | Type | Description |
|---|---|---|
| `uuidOrName` | `String` | the player's UUID, or their name. A name is resolved against the players the client can see; a UUID always works, so prefer it when you have one |
---
### showOffscreen
```java
public WorldAnchor showOffscreen(boolean showOffscreen)
```
Whether the marker shows an arrow at the screen edge while the target is behind the player.
On by default: a marker worth placing is usually worth finding. Turning it off keeps the
marker to what is actually in view, which is what you want when several are up at once and
a ring of arrows would say less than the world does.
| Parameter | Type |
|---|---|
| `showOffscreen` | `boolean` |
---
### iconColor
```java
public WorldAnchor iconColor(int argb)
```
ARGB tint for the icon.
| Parameter | Type |
|---|---|
| `argb` | `int` |
---
### arrowColor
```java
public WorldAnchor arrowColor(int argb)
```
ARGB tint for the off-screen arrow.
| Parameter | Type |
|---|---|
| `argb` | `int` |
---
### labels
```java
public WorldAnchor labels(String top, String bottom)
```
Lines shown above and below the icon while the player looks at the marker, animating in
and out as their attention moves. Either may be empty.
Styled like any other Lectern text, and `%distance%` expands to the whole number of
blocks to the target, a value that changes as the player walks, so the client fills it in
rather than the server re-sending the anchor.
| Parameter | Type |
|---|---|
| `top` | `String` |
| `bottom` | `String` |
---
### getId
```java
public String getId()
```
---
### getLocation
```java
public Location getLocation()
```
---
### getVisibleGroup
```java
public String getVisibleGroup()
```
---
### getOffscreenGroup
```java
public String getOffscreenGroup()
```
---
### getEdgeMargin
```java
public float getEdgeMargin()
```
---
### getMaxDistance
```java
public float getMaxDistance()
```
---
### getIcon
```java
public String getIcon()
```
---
### getIconSize
```java
public float getIconSize()
```
---
### getIconColor
```java
public int getIconColor()
```
---
### getArrowColor
```java
public int getArrowColor()
```
---
### getTopText
```java
public String getTopText()
```
---
### getBottomText
```java
public String getBottomText()
```
---
### getItem
```java
public String getItem()
```
---
### getItemModel
```java
public String getItemModel()
```
---
### getHead
```java
public String getHead()
```
---
### isShowOffscreen
```java
public boolean isShowOffscreen()
```
---