# World

`com.jsmacrosce.jsmacros.client.api.library.impl.FWorld`

Functions for getting and using world data.  

An instance of this class is passed to scripts as the `World` variable.  


The client-side `World` library exposes the currently loaded world. Results reflect
client state, and methods document their own null or sentinel behavior. Block-search methods
inspect loaded chunks; overloads distinguish chunk coordinates from block positions.  
```js
// the world has to be loaded before anything here says anything useful
if (World.isWorldLoaded()) {
  // what is the time and where are we
  Chat.log(`${World.getDimension()} at ${World.getTime()}, biome ${World.getBiome()}`);  

  // what is under the player
  const player = Player.getPlayer();  
  if (player !== null) {
    const block = World.getBlock(player.getBlockPos().down());  
    if (block !== null) {
      Chat.log(`standing on ${block.getName()}`);  
    }
  }

  // find diamond ore in the loaded chunks around the player
  const found = World.findBlocksMatching("diamond_ore", 4);  
  if (found !== null) {
    for (const pos of found) {
      Chat.log(`diamond ore at ${pos.getX()}, ${pos.getY()}, ${pos.getZ()}`);  
    }
  }
}
```

Accessible in scripts via the global `World` variable.

## Fields

### server15MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_server15MAverageTPS}

```js
static server15MAverageTPS: double
```

The server's estimated TPS averaged over the last fifteen minutes, using five-minute averages.

**Since:** 1.2.7

### server1MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_server1MAverageTPS}

```js
static server1MAverageTPS: double
```

The server's estimated TPS averaged over the last minute.

**Since:** 1.2.7

### server5MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_server5MAverageTPS}

```js
static server5MAverageTPS: double
```

The server's estimated TPS averaged over the last five minutes, using one-minute averages.

**Since:** 1.2.7

### serverInstantTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_serverInstantTPS}

```js
static serverInstantTPS: double
```

The latest server TPS estimate, calculated from server time updates.  
Initialized to 20; retains the last estimate until another update is measured.

**Since:** 1.2.7

## Methods

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-int-int-String-int-}

```js
findBlocksMatching(int centerX, int centerZ, String id, int chunkrange): List<Pos3D>
```

Finds positions of a block ID in the square chunk range centered at `centerX, centerZ`.  
These are chunk coordinates; a range of `1` covers a 3-by-3 chunk square. Only
loaded chunks are scanned, examining their block positions; large ranges can be expensive.  
IDs may omit the `minecraft:` namespace. A negative range throws
[IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `centerX`: the x coordinate of the centre chunk, not the block position
- `centerZ`: the z coordinate of the centre chunk, not the block position
- `id`: the block id to look for, with or without the minecraft namespace
- `chunkrange`: how many chunks out from the centre to search, so one is a three by three

**Returns:** the positions of every matching block, or `null` if no world is loaded

**Since:** 1.6.4

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-String-int-}

```js
findBlocksMatching(String id, int chunkrange): List<Pos3D>
```

Finds positions of a block ID in the square chunk range centered on the player. Returns
`null` if there is no world or player. IDs may omit the `minecraft:` namespace;  
only loaded chunks are scanned. A negative range throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `id`: the block id to look for, with or without the minecraft namespace
- `chunkrange`: how many chunks out from the player's chunk to search

**Returns:** the positions of every matching block, or `null` if there is no world or player

**Since:** 1.6.4

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-String[]-int-}

```js
findBlocksMatching(String[] ids, int chunkrange): List<Pos3D>
```

Finds positions whose block ID matches any ID in `ids`, centered on the player.  
IDs may omit the `minecraft:` namespace; duplicates do not duplicate results.  
Returns `null` if there is no world or player. Only loaded chunks are scanned; a
negative range throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `ids`: the block ids to look for, with or without the minecraft namespace
- `chunkrange`: how many chunks out from the player's chunk to search

**Returns:** matching positions, or `null` if there is no world or player

**Since:** 1.6.4

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-int-int-String[]-int-}

```js
findBlocksMatching(int centerX, int centerZ, String[] ids, int chunkrange): List<Pos3D>
```

Finds positions whose block ID matches any ID in `ids`, centered at chunk
coordinates `centerX, centerZ`. IDs may omit the namespace; duplicates do not
duplicate results. Only loaded chunks are scanned; a negative range throws
[IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `centerX`: the x coordinate of the centre chunk, not the block position
- `centerZ`: the z coordinate of the centre chunk, not the block position
- `ids`: the block ids to look for, with or without the minecraft namespace
- `chunkrange`: how many chunks out from the centre to search

**Returns:** the positions of every matching block, or `null` if no world is loaded

**Since:** 1.6.4

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-MethodWrapper-MethodWrapper-int-}

```js
findBlocksMatching(MethodWrapper<BlockHelper, Object, Boolean, ?> blockFilter, MethodWrapper<BlockStateHelper, Object, Boolean, ?> stateFilter, int chunkrange): List<Pos3D>
```

Searches around the player using a required block predicate and an optional state
predicate. The callbacks receive [BlockHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/BlockHelper.md) and [BlockStateHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/BlockStateHelper.md),  
respectively; the state predicate runs only after the block predicate accepts a block.  
Pass `null` to omit the state stage. Results are cached by block state, so callbacks
need not run once per position. A negative range throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html);  
returns `null` if there is no world or player.  
```js
const found = World.findBlocksMatching(
  JavaWrapper.methodToJava(function (block) {
    return block.getId() === "minecraft:chest";  
  }),  
  null,  
  1
);  
```

**Parameters:**
- `blockFilter`: required predicate selecting blocks; results may be reused for matching states
- `stateFilter`: optional predicate selecting states accepted by the block filter, or `null`
- `chunkrange`: how many chunks out from the player's chunk to search

**Returns:** the positions of every matching block, or `null` if there is no player or world

**Since:** 1.6.4

### findBlocksMatching {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_findBlocksMatching-int-int-MethodWrapper-MethodWrapper-int-}

```js
findBlocksMatching(int chunkX, int chunkZ, MethodWrapper<BlockHelper, Object, Boolean, ?> blockFilter, MethodWrapper<BlockStateHelper, Object, Boolean, ?> stateFilter, int chunkrange): List<Pos3D>
```

Searches around chunk coordinates `chunkX, chunkZ` using a required block predicate
and an optional state predicate. The callbacks receive [BlockHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/BlockHelper.md) and
[BlockStateHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/BlockStateHelper.md); the state predicate runs only after the block predicate accepts
a block. Pass `null` to omit that stage. Results are cached by block state. Returns
`null` if no world is loaded; a negative range throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `chunkX`: the x coordinate of the centre chunk, not the block position
- `chunkZ`: the z coordinate of the centre chunk, not the block position
- `blockFilter`: required predicate selecting blocks; results may be reused for matching states
- `stateFilter`: optional predicate selecting states accepted by the block filter, or `null`
- `chunkrange`: how many chunks out from the centre to search

**Returns:** the positions of every matching block, or `null` if no world is loaded

**Since:** 1.6.4

### getBiome {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBiome-}

```js
getBiome(): String
```

Returns the registry ID of the biome at the player's block position, or `null` if
there is no world, player, or registry ID.

**Returns:** the current biome, or `null` if no world is loaded

**Since:** 1.1.5

### getBiomeAt {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBiomeAt-int-int-}

```js
getBiomeAt(int x, int z): String
```

Looks up the biome at `(x, 10, z)`; use [getBiomeAt(int, int, int)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBiomeAt-int-int-int-) when the
vertical coordinate matters. The lookup does not require a loaded chunk, but the result
can be `null` if no world is loaded or the biome has no registered key.  
```js
// what biome is this column in
const player = Player.getPlayer();  
if (player !== null) {
  Chat.log(`column biome is ${World.getBiomeAt(Math.floor(player.getX()), Math.floor(player.getZ()))}`);  
}
```

**Parameters:**
- `x`: the x block coordinate
- `z`: the z block coordinate

**Returns:** the biome ID at the sampled position, or `null` if unavailable

**Since:** 1.2.3

### getBiomeAt {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBiomeAt-int-int-int-}

```js
getBiomeAt(int x, int y, int z): String
```

Looks up the biome at the given block coordinates, including the supplied vertical
coordinate (unlike [getBiomeAt(int, int)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBiomeAt-int-int-)). The lookup does not require a loaded
chunk, but the result can be `null` if no world is loaded or the biome has no
registered key.

**Parameters:**
- `x`: the x block coordinate
- `y`: the y block coordinate
- `z`: the z block coordinate

**Returns:** the biome ID at the sampled position, or `null` if unavailable

**Since:** 1.8.4

### getBlock {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlock-int-int-int-}

```js
getBlock(int x, int y, int z): BlockDataHelper
```

Returns the block data at block coordinates. A `null` result means the position
resolves to void air or no world is loaded; ordinary air still returns a helper.

**Parameters:**
- `x`: the x block coordinate
- `y`: the y block coordinate
- `z`: the z block coordinate

**Returns:** the block data, or `null` for void air or no loaded world

### getBlock {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlock-Pos3D-}

```js
getBlock(Pos3D pos): BlockDataHelper
```

Returns the block containing `pos`, flooring each coordinate before lookup.  
A `null` result has the same meaning as in [getBlock(int, int, int)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlock-int-int-int-).

**Parameters:**
- `pos`: the point in the world, whose coordinates are rounded down to a block

**Returns:** The block that point falls inside, or `null` if the client has no data for it

**Since:** 1.8.4

### getBlock {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlock-BlockPosHelper-}

```js
getBlock(BlockPosHelper pos): BlockDataHelper
```

Returns the block data at `pos`; a `null` result has the same meaning as in
[getBlock(int, int, int)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlock-int-int-int-).

**Parameters:**
- `pos`: the block position to look up

**Returns:** The block at that position, or `null` if the client has no data for it

**Since:** 1.8.4

### getBlockLight {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBlockLight-int-int-int-}

```js
getBlockLight(int x, int y, int z): int
```

Returns block-emitted light at the block coordinates, independently of sky light. This
value alone does not determine the game's lighting or spawning rules.

**Parameters:**
- `x`: the x block coordinate
- `y`: the y block coordinate
- `z`: the z block coordinate

**Returns:** the block-light level from `0` to `15`, or `-1` if no world is loaded

**Since:** 1.1.2

### getBossBars {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getBossBars-}

```js
getBossBars(): Map<String, BossBarHelper>
```

Copies the client boss overlay's bars into a map keyed by UUID strings.  
Bars are not restricted to boss fights. The map is a fresh snapshot, but its helpers
wrap the existing bar objects rather than frozen copies of their state.

**Returns:** a non-null map of boss-bar helpers, empty when the overlay has no bars

**Since:** 1.2.1

### getChunk {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getChunk-int-int-}

```js
getChunk(int x, int z): ChunkHelper
```

Returns the chunk at chunk coordinates `x`, `z`; these are not block coordinates.  
Block coordinates map to chunks by shifting right four bits: `100 >> 4` is chunk
`6` (blocks `96`–`111`), while `-1 >> 4` is chunk `-1`.  
The result is `null` if no world is loaded. A missing client chunk produces a
helper wrapping the client's empty-chunk placeholder, not generated terrain; check
[isChunkLoaded(int, int)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isChunkLoaded-int-int-) first when you need an already-loaded chunk.  
```js
// Convert block coordinates to chunk coordinates, including for negative positions.  
const x = -1 >> 4;  
const z = 100 >> 4;  
if (World.isChunkLoaded(x, z)) {
  const chunk = World.getChunk(x, z);  
  if (chunk !== null) Chat.log(`chunk ${x}, ${z} is available`);  
}
```

**Parameters:**
- `x`: the x coordinate of the chunk, not the absolute position
- `z`: the z coordinate of the chunk, not the absolute position

**Returns:** the chunk helper, or `null` if no world is loaded

**Since:** 1.8.4

### getClockManager {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getClockManager-}

```js
getClockManager(): ClockManager
```

Returns the current world's Mojang `ClockManager`.  

Use this with the raw timelines returned by `World.getTimelines()` to read
their current, total, and period-count tick values. It is `null` when no world
is loaded.

**Returns:** the active Mojang clock manager, or `null` when unavailable.

**Since:** 2.1.0

### getCurrentServerAddress {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getCurrentServerAddress-}

```js
getCurrentServerAddress(): String
```

Returns the remote address recorded by the current network connection; its string format
depends on that address and is not necessarily the hostname entered by the player.  
```js
const address = World.getCurrentServerAddress();  
if (address !== null) {
  Chat.log(`connected to ${address}`);  
}
```

**Returns:** the connection's remote address string, or `null` if no connection exists

**Since:** 1.2.2

### getDifficulty {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getDifficulty-}

```js
getDifficulty(): int
```

Returns the client world's difficulty ID.

**Returns:** 0 for peaceful, 1 for easy, 2 for normal, 3 for hard, or `-1` if no world is loaded

**Since:** 1.2.6

### getDimension {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getDimension-}

```js
getDimension(): String
```

Returns the current dimension identifier as a string, or `null` if no world is loaded.

**Returns:** the current dimension, or `null` if no world is loaded

**Since:** 1.1.2

### getEntities {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-}

```js
getEntities(): List<EntityHelper<?>>
```

Returns a snapshot of entities currently available to the client; it is `null` when
no world is loaded. Use [getEntities(String...)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-String[]-) to filter by type,  
[getEntities(double)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-double-) to filter by player distance, or
[getEntities(MethodWrapper)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-MethodWrapper-) for a custom filter.  
```js
const entities = World.getEntities();  
if (entities !== null) {
  Chat.log(`${entities.size()} entities available to the client`);  
}
```

**Returns:** a snapshot of available entities, or `null` if no world is loaded

### getEntities {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-String[]-}

```js
getEntities(String... types): List<EntityHelper<?>>
```

Returns entities from the client's rendering collection whose type matches any supplied
ID. IDs may omit the `minecraft:` namespace; returns `null` without a world.

**Parameters:**
- `types`: the entity types to consider, with or without the minecraft namespace

**Returns:** matching entities in the client's rendering collection, or `null` if no world is loaded

**Since:** 1.8.4

### getEntities {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-double-}

```js
getEntities(double distance): List<EntityHelper<?>>
```

Returns entities from the client's rendering collection whose distance from the player
is at most `distance`; negative values match none. Returns `null` if no player
or world is available.

**Parameters:**
- `distance`: the maximum distance to search for entities

**Returns:** matching entities in the client's rendering collection, or `null` if no player or world is available

**Since:** 1.8.4

### getEntities {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-double-String[]-}

```js
getEntities(double distance, String... types): List<EntityHelper<?>>
```

Returns rendering-collection entities that match any supplied type ID and whose distance
from the player is at most `distance`. IDs may omit the namespace. Returns
`null` if no player or world is available.

**Parameters:**
- `distance`: the maximum distance to search for entities
- `types`: the entity types to consider, with or without the minecraft namespace

**Returns:** matching entities in the client's rendering collection, or `null` if no player or world is available

**Since:** 1.8.4

### getEntities {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getEntities-MethodWrapper-}

```js
getEntities(MethodWrapper<EntityHelper<?>, ?, ?, ?> filter): List<EntityHelper<?>>
```

Applies `filter` to wrappers for entities in the client's rendering collection and
returns those accepted. Returns `null` without a world. The result list is newly
assembled, but its helpers wrap live entities.

**Parameters:**
- `filter`: the entity filter

**Returns:** matching entities, or `null` if no world is loaded

**Since:** 1.8.4

### getLoadedPlayers {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getLoadedPlayers-}

```js
getLoadedPlayers(): List<PlayerEntityHelper<Player>>
```

Returns wrappers for player entities currently present in the client world. Unlike
[getPlayers()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getPlayers-), this does not include tab-list entries for players without a
client-side entity.

**Returns:** current client-world player entities, or `null` if no world is loaded

### getMoonPhase {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getMoonPhase-}

```js
getMoonPhase(): int
```

Returns the moon phase index from `0` through `7`; `0` is full and
`4` is new. The phase advances once per 24,000 clock ticks.

**Returns:** the moon phase index, or `-1` if no world is loaded

**Since:** 1.2.6

### getPlayerEntry {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getPlayerEntry-String-}

```js
getPlayerEntry(String name): PlayerListEntryHelper
```

Returns the matching online-player entry, or `null` when there is no connection
or no matching name. See [getPlayers()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getPlayers-) for the entry list.

**Parameters:**
- `name`: the name of the player to get the entry for

**Returns:** player entry for the given player's name or `null` if not found.

**Since:** 1.8.4

### getPlayers {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getPlayers-}

```js
getPlayers(): List<PlayerListEntryHelper>
```

Returns a snapshot of the connection's online-player entries. Unlike
[getLoadedPlayers()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getLoadedPlayers-), entries need not have a client-side entity; returns
`null` when there is no connection.

**Returns:** online-player entries, or `null` if no connection is available

### getRaw {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getRaw-}

```js
getRaw(): ClientLevel
```

Returns the raw Minecraft client level rather than a JsMacros wrapper. Its member names
depend on the loader and Minecraft target, and shipped typings do not model those game
members; see [FClient.getMinecraft()](FClient.md#com.jsmacrosce.jsmacros.client.api.library.impl.FClient_getMinecraft-) for the related raw Minecraft access point.

**Returns:** the raw client level, or `null` if no world is loaded

**Since:** 1.9.1

### getRespawnPos {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getRespawnPos-}

```js
getRespawnPos(): BlockPosHelper
```

Returns respawn-related position data from the client level; it does not predict the
eventual respawn outcome. Before 1.21.9 this is the level's shared spawn position; on
1.21.9 and later it is the position in the level's respawn data, not a personal bed lookup. The result is
`null` if no world is loaded.

**Returns:** the client-level spawn or respawn-data position, or `null` if no world is loaded

**Since:** 1.2.6

### getScoreboards {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getScoreboards-}

```js
getScoreboards(): ScoreboardsHelper
```

Returns the current client world's scoreboard, including its objectives, display slots,  
and teams. The client state reflects scoreboard updates it has received; the result is
`null` when no world is loaded.  
```js
const boards = World.getScoreboards();  
if (boards !== null) {
  const current = boards.getCurrentScoreboard();  
  if (current !== null) {
    Chat.log(`sidebar objective is ${current.getName()}`);  
  }
}
```

**Returns:** the current scoreboard, or `null` if no world is loaded

**Since:** 1.2.9

### getServer15MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getServer15MAverageTPS-}

```js
getServer15MAverageTPS(): double
```

Returns the server's estimated TPS averaged over the last fifteen minutes.

**Returns:** the fifteen-minute average of five-minute TPS averages

**Since:** 1.2.7

### getServer1MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getServer1MAverageTPS-}

```js
getServer1MAverageTPS(): double
```

Returns the server's estimated TPS averaged over the last minute.

**Returns:** the one-minute average of instant TPS estimates

**Since:** 1.2.7

### getServer5MAverageTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getServer5MAverageTPS-}

```js
getServer5MAverageTPS(): double
```

Returns the server's estimated TPS averaged over the last five minutes.

**Returns:** the five-minute average of one-minute TPS averages

**Since:** 1.2.7

### getServerInstantTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getServerInstantTPS-}

```js
getServerInstantTPS(): double
```

Returns the latest server TPS estimate, calculated from server time updates.  
Initialized to 20 and not reset on world changes.

**Returns:** the latest server TPS estimate

**Since:** 1.2.7

### getServerTPS {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getServerTPS-}

```js
getServerTPS(): String
```

Formats the latest server TPS estimate and the one-, five- and fifteen-minute averages.  
Estimates use server time updates, not a server-reported TPS measurement. The one-minute
value averages retained instant estimates; the five-minute value averages one-minute
averages sampled at intervals exceeding one minute, and the fifteen-minute value averages
five-minute averages sampled at intervals exceeding five minutes. Each update removes at
most one expired sample from each window, so older samples can remain after a long gap.  
Values start at 20 and retain their last reading across world changes. Login clears the
sample windows but does not reset the published values; a later time update recalculates
them using only samples accumulated since login. Longer averages represent their full
periods only after enough new samples accumulate.  

```js
Chat.log(`server tps: ${World.getServerTPS()}`);  
```

**Returns:** the instant, one-, five- and fifteen-minute estimates in one string

**Since:** 1.2.7

### getSkyLight {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getSkyLight-int-int-int-}

```js
getSkyLight(int x, int y, int z): int
```

Returns sky light at the block coordinates. This layer is independent of block light and
does not account for sky-darkening effects of time or weather; a position in an unloaded
chunk may still return a level.  
```js
const player = Player.getPlayer();  
if (player !== null) {
  const pos = player.getBlockPos();  
  const sky = World.getSkyLight(pos.getX(), pos.getY(), pos.getZ());  
  const block = World.getBlockLight(pos.getX(), pos.getY(), pos.getZ());  
  Chat.log(`sky light ${sky}, block light ${block}`);  
}
```

**Parameters:**
- `x`: the x block coordinate
- `y`: the y block coordinate
- `z`: the z block coordinate

**Returns:** the sky-light level from `0` to `15`, or `-1` if no world is loaded

**Since:** 1.1.2

### getTabListFooter {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTabListFooter-}

```js
getTabListFooter(): TextHelper
```

Returns the current tab-list footer, normally supplied by the server, as a [TextHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/TextHelper.md).  
Retains its rich formatting and hover/click data, without guaranteeing those actions run.  
Use [getTabListHeader()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTabListHeader-) for the corresponding header.

**Returns:** the footer, or `null` if absent

**Since:** 1.3.1

### getTabListHeader {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTabListHeader-}

```js
getTabListHeader(): TextHelper
```

Returns the current tab-list header, normally supplied by the server, as a [TextHelper](../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/TextHelper.md).  
Retains its rich formatting and hover/click data, without guaranteeing those actions run.  
```js
const header = World.getTabListHeader();  
if (header !== null) {
  Chat.log(`tab-list header: ${header}`);  
}
```

**Returns:** the header, or `null` if absent

**Since:** 1.3.1

### getTime {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTime-}

```js
getTime(): long
```

Returns the client world's game-time counter, distinct from the day-time clock returned
by [getTimeOfDay()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTimeOfDay-). Returns `-1` when no world is loaded.

**Returns:** the current world time. `-1` if world is not loaded.

**Since:** 1.1.5

### getTimelines {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTimelines-}

```js
getTimelines(): List<Holder<Timeline>>
```

Returns the data-driven timelines active in the current dimension.  

These are Mojang `Holder<Timeline>` objects. Each timeline supplies
`getCurrentTicks`, `getTotalTicks`, and `getPeriodCount`; pass
`World.getClockManager()` to those methods. The returned holders retain their
registered timeline IDs.  
```js
const clockManager = World.getClockManager();  
for (const timelineHolder of World.getTimelines()) {
    const timeline = timelineHolder.value();  
    Chat.log(`${timelineHolder.getRegisteredName()}: ${timeline.getCurrentTicks(clockManager)}`);  
}
```

**Returns:** a snapshot of the current dimension's active timeline holders, or an empty list when no world is loaded.

**Since:** 2.1.0

### getTimeOfDay {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTimeOfDay-}

```js
getTimeOfDay(): long
```

Returns the current dimension's time-of-day ticks, including time skipped by sleeping.  
On 26.1+, dimensions with a default clock use it; dimensions without one use the overworld clock.  
Unlike [getTime()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getTime-), this value follows the day-time clock rather than elapsed game ticks.

**Returns:** time-of-day ticks, or `-1` if no world is loaded

**Since:** 1.1.5

### getWorldIdentifier {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getWorldIdentifier-}

```js
getWorldIdentifier(): String
```

Builds a name-based identifier for the current world; it is not guaranteed unique or stable.  
Singleplayer uses `LOCAL_` followed by the save folder name; realms and LAN games
use `REALM_` or `LAN_` followed by the server entry's name. Other servers use
their address with every `:25565` substring removed and remaining colons replaced
by underscores.

**Returns:** the derived identifier, or `"UNKNOWN_NAME"` if no world or server was found

**Since:** 1.8.4

### getWorldScanner {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getWorldScanner-}

```js
getWorldScanner(): WorldScannerBuilder
```

Returns a builder for a world scanner. The example builds a scanner matching blocks
facing south that do not require a tool, have hardness at most `10`, and whose
string representation contains `chest` or `barrel`; building does not scan.  
```js
World.getWorldScanner()
    .withBlockFilter("getHardness").is("\x3C=", 10)
    .andStringBlockFilter().contains("chest", "barrel")
    .withStringStateFilter().contains("facing=south")
    .andStateFilter("isToolRequired").is(false)
    .build()
```

**Returns:** a builder to create a WorldScanner.

**Since:** 1.6.5

### getWorldScanner {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getWorldScanner-MethodWrapper-MethodWrapper-}

```js
getWorldScanner(MethodWrapper<BlockHelper, Object, Boolean, ?> blockFilter, MethodWrapper<BlockStateHelper, Object, Boolean, ?> stateFilter): WorldScanner
```

Returns a scanner over the current world from two filter functions.  

This is the free form of the scanner [getWorldScanner()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_getWorldScanner-) builds, and it is the one
to reach for when a filter is a real computation rather than a chain of
`equals` and `contains` checks. The filters are stages: a block is kept when
the block filter accepts it, and its state must then pass the state filter. Either may be
`null` to skip that stage.  

Results are cached per block state for the life of the scanner and reused rather than
evaluated for every block. Concurrent first encounters of a state may evaluate the filters
more than once before an answer is cached. Build a new scanner when a filter reads script
state that can change. The scanner uses parallel streams only when both filters support
parallel execution; those filters must not access the world unsafely.  
```ts
// every loaded block that is solid and is not dirt. naming the parameter type
// is what tells the wrapper what it is being handed
const scanner = World.getWorldScanner(
  JavaWrapper.methodToJava(function (block: BlockHelper) {
    return block.getId() !== "minecraft:dirt";  
  }),  
  JavaWrapper.methodToJava(function (state: BlockStateHelper) {
    return state.isSolid();  
  })
);  
if (scanner !== null) {
  const found = scanner.scanAroundPlayer(2);  
  Chat.log(`${found.size()} blocks matched`);  
}
```

**Parameters:**
- `blockFilter`: tests block states, keeping the ones it returns
                   `true` for, or `null` to keep all of them
- `stateFilter`: tests states the block filter kept, keeping the ones
                   it returns `true` for, or `null` to keep all of those

**Returns:** a scanner for the current world, or `null` if no world is loaded

**Since:** 1.6.5

### isChunkLoaded {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isChunkLoaded-int-int-}

```js
isChunkLoaded(int chunkX, int chunkZ): boolean
```

Checks whether the client chunk source currently has the given chunk.

**Parameters:**
- `chunkX`: the x coordinate of the chunk, not the absolute position
- `chunkZ`: the z coordinate of the chunk, not the absolute position

**Returns:** `true` if the client chunk source has the chunk; `false` if no world is loaded

**Since:** 1.2.2

### isDay {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isDay-}

```js
isDay(): boolean
```

Tests the world's outside brightness, based on world time and weather rather than block
light or whether the player is underwater. With no world loaded it returns `false`.  
In fixed-time dimensions both this and [isNight()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isNight-) return `false`.

**Returns:** `true` when the world's outside-brightness test passes; `false` otherwise

**Since:** 1.8.4

### isNight {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isNight-}

```js
isNight(): boolean
```

Uses the world's outside-darkness test, which considers time and weather rather than
block light or whether the player is underwater. In fixed-time dimensions both
[isDay()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isDay-) and this method return `false`; with no world loaded this also returns `false`.

**Returns:** `true` when the world's outside-darkness test passes; `false` otherwise, including with no world loaded

**Since:** 1.8.4

### isRaining {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isRaining-}

```js
isRaining(): boolean
```

Returns whether the client world's global rain state is active; this is not a local
player-position or sky-visibility test.

**Returns:** `true` if global rain is active, `false` otherwise, including with no world loaded

**Since:** 1.8.4

### isThundering {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isThundering-}

```js
isThundering(): boolean
```

Returns whether the client world's global thunder state is active, not whether there is
thunder at the player's position. The global thunder level is derived from the rain level,  
so `true` implies [isRaining()](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isRaining-) is also `true`.

**Returns:** `true` if global thunder is active, `false` otherwise, including with no world loaded

**Since:** 1.8.4

### isWorldLoaded {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_isWorldLoaded-}

```js
isWorldLoaded(): boolean
```

Returns whether the client currently has a world loaded.

**Returns:** `true` if a world is currently loaded, `false` otherwise

**Since:** 1.3.0

### iterateBox {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_iterateBox-BlockPosHelper-BlockPosHelper-MethodWrapper-}

```js
iterateBox(BlockPosHelper pos1, BlockPosHelper pos2, MethodWrapper<BlockDataHelper, ?, ?, ?> callback): void
```

walk a cuboid of block positions, ignoring air.  

This is the box shaped counterpart to [iterateSphere(BlockPosHelper, int,  
MethodWrapper)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_iterateSphere-BlockPosHelper-int-MethodWrapper-), and it includes both corners, so a box from one position to the next
covers every position between them as well. The two corners are given in either order
and the walk covers the space between them, so it does not matter which is which.  

The callback is called synchronously on the calling thread for each non-air position.  
```js
// what is in the six blocks directly above the player
const player = Player.getPlayer();  
if (player !== null) {
  const base = player.getBlockPos();  
  World.iterateBox(base.up(), base.up(6), JavaWrapper.methodToJava(function (block) {
    Chat.log(block.getName());  
  }));  
}
```

**Parameters:**
- `pos1`: the first position
- `pos2`: the second position
- `callback`: the callback to call for each block

**Since:** 1.8.4

### iterateBox {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_iterateBox-BlockPosHelper-BlockPosHelper-boolean-MethodWrapper-}

```js
iterateBox(BlockPosHelper pos1, BlockPosHelper pos2, boolean ignoreAir, MethodWrapper<BlockDataHelper, ?, ?, ?> callback): void
```

Visits positions between the corners, including air only when `ignoreAir` is false.  
The callback runs synchronously on the calling thread; with no world loaded there are no
calls. Each corner's y is computed as `clamp(minY, cornerY, height)` in the current
implementation, not as a clamp of `cornerY` to the build-height range; visited
positions are not guaranteed to lie within that range.

**Parameters:**
- `pos1`: the first position
- `pos2`: the second position
- `ignoreAir`: whether to ignore air blocks
- `callback`: the callback to call for each block

**Since:** 1.8.4

### iterateSphere {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_iterateSphere-BlockPosHelper-int-MethodWrapper-}

```js
iterateSphere(BlockPosHelper pos, int radius, MethodWrapper<BlockDataHelper, ?, ?, ?> callback): void
```

By default, air blocks are ignored and the callback is only called for real blocks.  

This walks a sphere of block positions around a centre and calls back for each one that
is not air. The shape is a sphere measured in whole blocks, so the callback is made for
every position inside the radius rather than for a sphere surface, and the vertical
extent is clamped to the world's own build limits so the walk does not run off the top or
the bottom.  

This is the form for "everything solid near here" where the answer is short and a list
would be wasteful. The callback is called once per block position, so it is the
per-block work that costs. Callbacks run synchronously on the calling thread.  
```js
// count the solid blocks in a five block bubble around the player
const player = Player.getPlayer();  
if (player !== null) {
  let count = 0;  
  World.iterateSphere(player.getBlockPos(), 5, JavaWrapper.methodToJava(function (block) {
    if (block.getBlockStateHelper().isSolid()) count++;  
  }));  
  Chat.log(`${count} solid blocks within five blocks`);  
}
```

**Parameters:**
- `pos`: the center position
- `radius`: the radius to scan
- `callback`: the callback to call for each block

**Since:** 1.8.4

### iterateSphere {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_iterateSphere-BlockPosHelper-int-boolean-MethodWrapper-}

```js
iterateSphere(BlockPosHelper pos, int radius, boolean ignoreAir, MethodWrapper<BlockDataHelper, ?, ?, ?> callback): void
```

Visits positions accepted by a squared-distance test around `pos`. Bounds and the
distance test use integer arithmetic, which can overflow for large radii or coordinates.  
The current y bounds use `clamp(minY, centerY - radius, height)` and
`clamp(minY, centerY + radius, height)`; they do not guarantee positions within the
world's build-height limits. With `ignoreAir` true, air positions are skipped.  
The callback runs synchronously on the calling thread; with no world loaded there are
no calls. A negative radius throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html).

**Parameters:**
- `pos`: the center position
- `radius`: the radius to scan, which must not be negative
- `ignoreAir`: whether to ignore air blocks
- `callback`: the callback to call for each block

**Since:** 1.8.4

### playSound {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-}

```js
playSound(String id): void
```

Plays a local UI sound at volume `1` and pitch `0.25`. The ID is parsed as a
resource location; playback is submitted to the client sound manager. For positional
playback, use [playSound(String, double, double, double, double, double)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-double-double-double-double-).

**Parameters:**
- `id`: the sound event id, with or without the minecraft namespace

**Since:** 1.1.7

### playSound {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-}

```js
playSound(String id, double volume): void
```

Plays a local UI sound at the supplied volume and pitch `0.25`. The ID is parsed as
a resource location; playback is submitted to the client sound manager.  
Use [playSound(String, double, double, double, double, double)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-double-double-double-double-) for positional playback.

**Parameters:**
- `id`: the sound event id, with or without the minecraft namespace
- `volume`: the volume value passed to Minecraft's sound manager

**Since:** 1.1.7

### playSound {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-double-}

```js
playSound(String id, double volume, double pitch): void
```

Plays a local UI sound with volume and pitch converted to `float`. The two-argument
overload defaults pitch to `0.25`; pass a pitch explicitly to choose another value.  
Use [playSound(String, double, double, double, double, double)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-double-double-double-double-) for positional playback.

**Parameters:**
- `id`: the sound event id, with or without the minecraft namespace
- `volume`: the volume value passed to Minecraft's sound manager
- `pitch`: the pitch value passed to Minecraft's sound manager

**Since:** 1.1.7

### playSound {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSound-String-double-double-double-double-double-}

```js
playSound(String id, double volume, double pitch, double x, double y, double z): void
```

Plays a local sound at the supplied coordinates using the master category. Volume and
pitch are converted to `float`; with no world loaded, this method does nothing.  
The sound is not sent to the server.

**Parameters:**
- `id`: the sound event id, with or without the minecraft namespace
- `volume`: the volume value passed to Minecraft's local-sound API
- `pitch`: the pitch value passed to Minecraft's local-sound API
- `x`: the x world coordinate in blocks
- `y`: the y world coordinate in blocks
- `z`: the z world coordinate in blocks

**Since:** 1.1.7

### playSoundFile {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_playSoundFile-String-double-}

```js
playSoundFile(String file, double volume): Clip
```

Opens and starts a Java Sound clip from a file relative to the macro folder. `volume`
is mapped to the clip's master-gain range; the returned clip can be stopped by the caller
and is closed on its stop event. File and Java Sound operations may fail with the declared
exceptions; actual audibility depends on the host audio system.

**Parameters:**
- `file`: the file to play, relative to the macro folder
- `volume`: position in the clip's master-gain range: `0` selects its minimum and `1` its maximum

**Returns:** the started clip, which the caller may stop

**Since:** 1.1.7

### rayTraceBlock {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_rayTraceBlock-double-double-double-double-double-double-boolean-}

```js
rayTraceBlock(double x1, double y1, double z1, double x2, double y2, double z2, boolean fluid): BlockDataHelper
```

Clips from the start point to the end point against block collider shapes. `fluid`
selects whether fluids are considered; a miss returns `null`. Returns `null`
if either the world or local player is unavailable (the player supplies the clip context).

**Parameters:**
- `x1`: the x coordinate of the start of the line
- `y1`: the y coordinate of the start of the line
- `z1`: the z coordinate of the start of the line
- `x2`: the x coordinate of the end of the line
- `y2`: the y coordinate of the end of the line
- `z2`: the z coordinate of the end of the line
- `fluid`: whether a liquid in the way counts as the hit

**Returns:** block data at the first collider or selected fluid hit, or `null` on a miss or without a world/player

**Since:** 1.6.5

### rayTraceEntity {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_rayTraceEntity-double-double-double-double-double-double-}

```js
rayTraceEntity(double x1, double y1, double z1, double x2, double y2, double z2): EntityHelper<?>
```

Returns the living entity whose hitbox intersects the segment and is nearest the player;  
this need not be the first entity from the segment's start. Non-living entities are ignored.  
Returns `null` if no world is loaded or no eligible entity intersects the segment.  
Requires a local player for the distance comparison when a world is loaded.  
```js
// is there a mob between the player and a point ten blocks ahead?
const player = Player.getPlayer();  
if (player !== null) {
  const eyes = player.getEyePos();  
  const end = eyes.add(10, 0, 0);  
  const mob = World.rayTraceEntity(
    eyes.getX(), eyes.getY(), eyes.getZ(),  
    end.getX(), end.getY(), end.getZ()
  );  
  Chat.log(mob === null ? "nothing in the way" : `${mob.getName()} is in the way`);  
}
```

**Parameters:**
- `x1`: the x coordinate of the start of the line
- `y1`: the y coordinate of the start of the line
- `z1`: the z coordinate of the start of the line
- `x2`: the x coordinate of the end of the line
- `y2`: the y coordinate of the end of the line
- `z2`: the z coordinate of the end of the line

**Returns:** a living entity whose hitbox the line passes through, or `null` if none does

**Since:** 1.8.3

### spawnParticle {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_spawnParticle-String-double-double-double-int-}

```js
spawnParticle(String id, double x, double y, double z, int count): void
```

Spawns particles locally using deltas of `0.1` on each axis, speed `1`, and
the particle-limiter override enabled. Positive counts use Gaussian position offsets,  
not a bounded tenth-block box. Nothing happens without a player.  
See [spawnParticle(String, double, double, double, double, double, double, double, int, boolean)](#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_spawnParticle-String-double-double-double-double-double-double-double-int-boolean-)
for supported IDs, count semantics, and visibility limitations.  
```js
// a puff of particles at a point in the world
World.spawnParticle("minecraft:flame", 0, 65, 0, 20);  
```

**Parameters:**
- `id`: a simple particle registry ID; the namespace defaults to `minecraft`
- `x`: the x world coordinate in blocks
- `y`: the y world coordinate in blocks
- `z`: the z world coordinate in blocks
- `count`: positive values attempt that many particles; zero attempts one; negative values attempt none

**Since:** 1.8.4

### spawnParticle {#com.jsmacrosce.jsmacros.client.api.library.impl.FWorld_spawnParticle-String-double-double-double-double-double-double-double-int-boolean-}

```js
spawnParticle(String id, double x, double y, double z, double deltaX, double deltaY, double deltaZ, double speed, int count, boolean force): void
```

Schedules particle spawning on the local client; no particles are sent to the server or
other players. Nothing happens without a player.  

For positive counts, each attempt uses Gaussian position offsets scaled by the deltas
and independent Gaussian velocity components scaled by `speed`. Zero deltas keep
the initial positions at the supplied coordinates; they do not eliminate velocity.  
A zero count instead attempts one particle at the exact position with velocity components
`deltaX * speed`, `deltaY * speed`, and `deltaZ * speed`.  

The ID is a registry identifier, not particle-option data. Only simple particle types
are supported; parameterized types such as `minecraft:dust` cause a
[ClassCastException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html). A missing registry value falls back to `CLOUD`.  
The `force` argument overrides the particle limiter, while the packet's
`alwaysShow` flag is always enabled. Neither guarantees visibility at arbitrary
distances or that every attempted particle will render.  
```js
// a tight burst of flame with the particle-limiter override enabled
World.spawnParticle("flame", 0, 65, 0, 0, 0, 0, 1, 10, true);  

// and a wider Gaussian spread, not a bounded four-block box
World.spawnParticle("flame", 0, 65, 0, 2, 2, 2, 0.1, 100, false);  
```

**Parameters:**
- `id`: a simple particle registry ID; the namespace defaults to `minecraft`
- `x`: the x world coordinate in blocks
- `y`: the y world coordinate in blocks
- `z`: the z world coordinate in blocks
- `deltaX`: the x position-offset scale for positive counts, or x velocity factor for zero
- `deltaY`: the y position-offset scale for positive counts, or y velocity factor for zero
- `deltaZ`: the z position-offset scale for positive counts, or z velocity factor for zero
- `speed`: the velocity scale; it does not scale position offsets
- `count`: positive values attempt that many particles; zero attempts one; negative values attempt none
- `force`: whether to set the particle-limiter override flag

**Since:** 1.8.4
