> For the complete documentation index, see [llms.txt](https://docs.nursultan.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nursultan.fun/game-data/world-and-blocks.md).

# World and blocks

`world` is the current world. It only works while you are in a game, so wrap things in `whenInGame` or check `inGame`.

## Which world

```kotlin
world.dimension()        // "minecraft:overworld" and friends
world.timeTicks()        // how long the world has existed
world.dayTimeTicks()     // time of day, 0..24000
world.raining()
world.thundering()
```

## Blocks

A block comes from coordinates or from a point:

```kotlin
val under = world.block(player.x().toInt(), player.y().toInt() - 1, player.z().toInt())
val here = world.block(player.position())
```

What you can ask about it:

```kotlin
under.id()               // "minecraft:stone"
under.name()             // its in-game name
under.x()  under.y()  under.z()
under.position()
under.box()              // its box in the world

under.air()
under.solid()
under.liquid()
under.opaque()
under.blocksMovement()

under.luminance()        // how much light it emits
under.hardness()         // how long it takes to break
under.blastResistance()
under.slipperiness()     // ice is slippery
```

A couple more useful things about space:

```kotlin
world.lightLevel(x, y, z)      // light level
world.topY(x, z)               // height of the topmost block
world.collisionsIn(box)        // every collision inside a box
world.isFree(box)              // is it empty in there
```

## Boxes

A `Box` is a rectangular volume. Entities and blocks have one, and you can build your own:

```kotlin
val around = Box.around(player.position(), 8.0)

around.center()
around.sizeX()
around.expand(1.0)             // grow in every direction
around.contract(0.5)
around.offset(0.0, 1.0, 0.0)
around.contains(point)
around.intersects(other)
```

## Entities around you

```kotlin
world.entities()                                    // everything
world.entities(filters.player())                    // with a filter
world.entitiesIn(Box.around(player.position(), 8.0))
world.entitiesNear(player.position(), 8.0, filters.attackable())
world.players()
world.entityCount()

world.entityById(id)
world.entityByUuid(uuid)
world.entityByName("Notch")
world.nearestEntity(player.position(), 16.0, filters.monster())
```

Anything returning a single entity can return `null` — meaning nothing matched.

Filters and what you can ask an entity are in [Entities and filters](/game-data/entities-and-filters.md).

## Sounds and particles

```kotlin
world.playSound("minecraft:entity.experience_orb.pickup", 1f, 1f)
world.playSound("minecraft:block.anvil.land", position, 1f, 0.8f)

world.spawnParticle("minecraft:flame", position, Vec.ZERO)
```

Without a position the sound plays where you are. Volume and pitch are ordinary Minecraft values: `1f` is normal, `2f` higher, `0.5f` lower.

All of this is seen and heard **by you only** — the server knows nothing about it.
