World API with region utilities, particle shapes, and spawn helpers

World

The World class provides access to world properties, blocks, entities, weather, time, and advanced utilities for working with regions, particles, and entity spawning.


Constructor

World(name: str | None = None)

Resolve a world by name. You can also get worlds from server.worlds or server.world("name").


Attributes

name

The world name.

uuid

The world's unique identifier.

environment

The world environment (NORMAL, NETHER, THE_END).

entities

All entities currently in the world, including players, mobs, dropped items, etc.

players

All players currently in this world.

time

Current world time (0–24000). 0 = dawn, 6000 = noon, 12000 = dusk, 18000 = midnight.

world_time

Current world time as a WorldTime object with helper properties.

full_time

Absolute world time that is not reset by sleeping.

difficulty

World difficulty level.

spawn_location

The world's spawn location.

has_storm

Whether it is currently raining/snowing.

is_thundering

Whether there is a thunderstorm.

weather_duration

Remaining weather duration in ticks.

thunder_duration

Remaining thunder duration in ticks.

seed

The world seed.

pvp

Whether PvP is enabled in this world.

game_rules

All game rules as a dictionary.

world_border

The world border settings as a dictionary.

contains

Supports entity in world operator:

if player in world:
    await player.send_message("You're in this world!")

Methods

block_at

block = await world.block_at(x, y, z)

Get the block at specific coordinates.

block = await world.block_at(0, 64, 0)
print(block.type)  # Material.GRASS_BLOCK

chunk_at

chunk = await world.chunk_at(x, z)

Get the chunk at chunk coordinates.

spawn

entity = await world.spawn(location, entity_cls, **kwargs)

Spawn an entity at a location.

zombie = await world.spawn(Location(0, 64, 0), EntityType.ZOMBIE)

spawn_entity

entity = await world.spawn_entity(location, entity_type, **kwargs)

Spawn an entity by type name.

spawn_particle

await world.spawn_particle(particle, location, count=1, offset_x=0, offset_y=0, offset_z=0, extra=0, data=None, force=False)

Spawn particles visible to all players in the world.

await world.spawn_particle(Particle.FLAME, player.location, count=50, offset_x=0.5, offset_y=1, offset_z=0.5)
# Force particles visible at long range
await world.spawn_particle(Particle.END_ROD, loc, count=10, force=True)

play_sound

await world.play_sound(location, sound, volume=1.0, pitch=1.0)

Play a sound at a location, audible to nearby players.

strike_lightning

entity = await world.strike_lightning(location)

Strike lightning at a location. This deals damage and starts fires.

strike_lightning_effect

await world.strike_lightning_effect(location)

Strike visual-only lightning (no damage, no fire).


Time & Weather

All time and weather values are settable via property syntax (see Attributes above). For example:

world.time = 6000               # Set to noon
world.difficulty = Difficulty.HARD
world.has_storm = False          # Clear weather

at_time

@world.at_time(time)
async def handler(world):
    ...

Register a handler that runs every time this world crosses the specified time of day. Useful for day/night cycle events.

world = World(name="world")

@world.at_time(WorldTime.NOON)
async def high_noon(w):
    await server.broadcast("It's high noon!")

@world.at_time(WorldTime.DUSK)
async def sunset(w):
    await server.broadcast("Night is falling...")

@world.at_time(0)
async def dawn(w):
    await server.broadcast("A new day begins!")

set_full_time

Deprecated setter method. Use property syntax instead: world.full_time = 100000

set_difficulty

Deprecated setter method. Use property syntax instead: world.difficulty = Difficulty.HARD

set_spawn_location

Deprecated setter method. Use property syntax instead: world.spawn_location = location

set_storm

Deprecated setter method. Use property syntax instead: world.has_storm = True

set_thundering

Deprecated setter method. Use property syntax instead: world.is_thundering = True

set_weather_duration

Deprecated setter method. Use property syntax instead: world.weather_duration = 6000

set_thunder_duration

Deprecated setter method. Use property syntax instead: world.thunder_duration = 6000


Game Rules

get_game_rule

value = await world.get_game_rule(rule)

Get a game rule value.

set_game_rule

await world.set_game_rule(rule, value)

Set a game rule value.

await world.set_game_rule("doDaylightCycle", False)
await world.set_game_rule("randomTickSpeed", 10)

Terrain & Block Queries

get_highest_block_at

block = await world.get_highest_block_at(x, z)

Get the highest non-air block at the given X/Z coordinates.

generate_tree

result = await world.generate_tree(location, tree_type)

Generate a tree at the given location.

get_chunk_at_async

chunk = await world.get_chunk_at_async(x, z)

Asynchronously load a chunk at chunk coordinates.


Advanced Entity Queries

get_nearby_entities

entities = await world.get_nearby_entities(location, dx, dy, dz)

Get entities within a bounding box centered on a location.

find_entities

entities = await world.find_entities(location, radius, predicate=None, entity_type=None)

Find entities within a radius, optionally filtered by type.

batch_spawn

entities = await world.batch_spawn(specs)

Spawn multiple entities in a single call.

ray_trace

result = await world.ray_trace(start, direction, max_distance)

Perform a ray trace from a start location in a direction.


Async Bulk Operations

async_fill

await world.async_fill(x1, y1, z1, x2, y2, z2, material, blocks_per_tick=256)

Fill a region asynchronously over multiple ticks to avoid lag spikes.

async_replace

await world.async_replace(x1, y1, z1, x2, y2, z2, from_material, to_material, blocks_per_tick=256)

Replace blocks asynchronously over multiple ticks.


Region Utilities

These methods operate on regions of blocks in the world. Position arguments accept Location, tuple[int,int,int], or Vector.

set_block

count = await world.set_block(x, y, z, material, apply_physics=False)

Set a single block.

fill

count = await world.fill(pos1, pos2, material, apply_physics=False)

Fill a cuboid region with a material.

await world.fill((0, 60, 0), (10, 70, 10), Material.STONE)

replace

count = await world.replace(pos1, pos2, from_material, to_material)

Replace all blocks of one material with another in a region.

await world.replace((0, 60, 0), (10, 70, 10), "DIRT", "GRASS_BLOCK")

fill_sphere

count = await world.fill_sphere(center, radius, material, hollow=False)

Fill a sphere with a material.

await world.fill_sphere(player.location, 5, Material.GLASS, hollow=True)

fill_cylinder

count = await world.fill_cylinder(center, radius, height, material, hollow=False)

Fill a vertical cylinder.

fill_line

count = await world.fill_line(start, end, material)

Place blocks along a line between two points.


Particle Shape Utilities

All particle shape methods accept optional offset_x, offset_y, offset_z, extra parameters for per-particle randomization.

particle_line

count = await world.particle_line(start, end, particle, density=4.0)

Draw a line of particles between two points.

particle_sphere

count = await world.particle_sphere(center, radius, particle, density=4.0, hollow=True)

Draw a sphere of particles.

particle_cube

count = await world.particle_cube(pos1, pos2, particle, density=4.0, hollow=True)

Draw a cuboid of particles.

particle_ring

count = await world.particle_ring(center, radius, particle, density=4.0)

Draw a horizontal ring of particles.


Entity Spawn Helpers

spawn_at_player

entity = await world.spawn_at_player(player, entity_type, offset=None, **kwargs)

Spawn an entity at a player's current position with an optional offset.

zombie = await world.spawn_at_player(player, "ZOMBIE", offset=(2, 0, 0))

spawn_projectile

entity = await world.spawn_projectile(shooter, entity_type, velocity=None, **kwargs)

Spawn a projectile from an entity with an optional initial velocity.

spawn_with_nbt

entity = await world.spawn_with_nbt(location, entity_type, nbt, **kwargs)

Spawn an entity with custom SNBT (Stringified NBT) data.

await world.spawn_with_nbt(loc, "ZOMBIE", '{{IsBaby:1b,CustomName:\'{{"text":"Baby Zombie"}}\'}}')

World Utilities

create_explosion

await world.create_explosion(location, power=4.0, fire=False)

Create an explosion at the given location.

await world.create_explosion(player.location, power=2.0, fire=True)

entities_near

entities = await world.entities_near(location, radius)

Get all entities within a radius of the location.

nearby = await world.entities_near(player.location, 10)
for e in nearby:
    await e.set_fire_ticks(100)

blocks_near

blocks = world.blocks_near(location, radius)

Get all blocks within a cubic radius of the location. Synchronous — returns a pre-built list of Block proxies.

for block in world.blocks_near(player.location, 3):
    if block.type.name == "DIAMOND_ORE":
        await player.send_message("Diamond nearby!")

Dimension

The Dimension type represents a world's dimension. It's available as a property on World objects.

Properties

name

The dimension name (e.g. "OVERWORLD", "THE_NETHER", "THE_END").

world = player.world
dim = world.dimension
print(dim.name)  # "OVERWORLD"

WorldTime Class

The WorldTime class represents a Minecraft time of day (0–24000 ticks) with utilities for conversion and comparison.

Constructor

WorldTime(ticks: int)

Create a WorldTime from a tick value. Automatically wraps to 0–24000.

Class Methods

from_hours

WorldTime.from_hours(hours: float) -> WorldTime

Create from a 24-hour clock value. 6.0 = dawn (tick 0), 12.0 = noon (tick 6000).

noon = WorldTime.from_hours(12.0)   # WorldTime(ticks=6000)
midnight = WorldTime.from_hours(0)  # WorldTime(ticks=18000)

Constants

ConstantTicksReal-world equivalent
WorldTime.DAWN06:00 AM
WorldTime.NOON600012:00 PM
WorldTime.DUSK120006:00 PM
WorldTime.MIDNIGHT1800012:00 AM

Properties

ticks

The raw tick value (0–24000).

hours

The time as a 24-hour clock value (0.0–24.0).

is_day

True when ticks are in the 0–12000 range (daytime).

is_night

True when ticks are 12000+ (nighttime).

Example

from bridge import WorldTime, World, server

world = World(name="world")

# Check time of day
t = world.world_time
if t.is_night:
    await server.broadcast("It's dark outside!")

# Schedule events at specific times
@world.at_time(WorldTime.NOON)
async def noon_event(w):
    await server.broadcast("The sun is at its peak!")

@world.at_time(WorldTime.MIDNIGHT)
async def midnight_event(w):
    await server.broadcast("Beware the creatures of the night!")