Level
endstone.level
¶
Classes:
| Name | Description |
|---|---|
Chunk |
Represents a chunk of blocks. |
Dimension |
Represents a dimension within a |
DimensionCreator |
Represents the options that may be used to create a custom dimension. |
Level |
Represents a level, which may contain actors, chunks and blocks. |
Location |
Represents a 3-dimensional location in a dimension within a level. |
Chunk
¶
Represents a chunk of blocks.
Methods:
| Name | Description |
|---|---|
add_plugin_chunk_ticket |
Adds a plugin ticket for this chunk, loading it if it is not already loaded. |
load |
Requests this chunk to be loaded, and keeps it resident until it is released again. |
remove_plugin_chunk_ticket |
Removes the given plugin's ticket for this chunk. |
unload |
Releases the hold that |
Attributes:
| Name | Type | Description |
|---|---|---|
block_actors |
list[BlockState]
|
The state of every block actor in this chunk, or an empty list if this chunk is not loaded. |
dimension |
Dimension
|
The dimension containing this chunk. |
is_loaded |
bool
|
Whether this chunk is loaded. |
level |
Level
|
The level containing this chunk. |
plugin_chunk_tickets |
list[Plugin]
|
The |
x |
int
|
X-coordinate of this chunk. |
z |
int
|
Z-coordinate of this chunk. |
block_actors
property
¶
block_actors: list[BlockState]
The state of every block actor in this chunk, or an empty list if this chunk is not loaded.
plugin_chunk_tickets
property
¶
The Plugins holding a ticket for this chunk.
add_plugin_chunk_ticket
¶
load
¶
Requests this chunk to be loaded, and keeps it resident until it is released again.
See Dimension.load_chunk for how the hold behaves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generate
|
bool
|
Whether to generate the chunk if it does not exist yet. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
|
remove_plugin_chunk_ticket
¶
Dimension
¶
Represents a dimension within a Level.
Methods:
| Name | Description |
|---|---|
add_plugin_chunk_ticket |
Adds a plugin ticket for the |
drop_item |
Drops an item at the specified |
get_block_at |
|
get_highest_block_at |
|
get_highest_block_y_at |
Gets the highest non-empty (impassable) coordinate at the given coordinates. |
get_plugin_chunk_tickets |
Gets which plugins hold a ticket for the |
is_chunk_generated |
Checks if the |
is_chunk_loaded |
Checks if the |
load_chunk |
Requests the |
remove_plugin_chunk_ticket |
Removes the given plugin's ticket for the |
remove_plugin_chunk_tickets |
Removes every ticket the given plugin holds in this dimension. |
spawn_actor |
Creates an actor at the given |
unload_chunk |
Releases the hold that |
unload_chunk_request |
Releases the hold that |
Attributes:
| Name | Type | Description |
|---|---|---|
NETHER |
Identifier[Dimension]
|
|
OVERWORLD |
Identifier[Dimension]
|
|
THE_END |
Identifier[Dimension]
|
|
actors |
list[Actor]
|
A list of all actors currently residing in this dimension. |
id |
Identifier[Dimension]
|
The identifier of this dimension. |
is_valid |
bool
|
Whether this dimension is still valid (loaded). |
level |
Level
|
The level to which this dimension belongs. |
loaded_chunks |
list[Chunk]
|
A list of all loaded |
mobs |
list[Mob]
|
A list of all mobs currently residing in this dimension. |
players |
list[Player]
|
A list of all players currently residing in this dimension. |
plugin_chunk_tickets |
dict[Plugin, list[Chunk]]
|
The |
translation_key |
str
|
The translation key, suitable for use in a translation component. |
OVERWORLD
class-attribute
instance-attribute
¶
OVERWORLD: Identifier[Dimension] = 'minecraft:overworld'
players
property
¶
A list of all players currently residing in this dimension.
plugin_chunk_tickets
property
¶
The Chunks each Plugin holds a ticket for, as a snapshot.
translation_key
property
¶
translation_key: str
The translation key, suitable for use in a translation component.
add_plugin_chunk_ticket
¶
Adds a plugin ticket for the Chunk at the given coordinates, loading it if it is not already loaded.
A plugin ticket keeps the chunk resident until it is explicitly removed or the owning plugin is disabled. A plugin
may only have one ticket per chunk, but each chunk can have multiple plugin tickets. unload_chunk does not
remove plugin tickets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
plugin
|
Plugin
|
|
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the plugin is not enabled, or if called from a thread other than the server thread. |
drop_item
¶
get_block_at
¶
get_highest_block_at
¶
get_highest_block_y_at
¶
get_plugin_chunk_tickets
¶
Gets which plugins hold a ticket for the Chunk at the given coordinates.
The returned list is a snapshot; it does not track tickets added or removed afterwards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
Returns:
| Type | Description |
|---|---|
list[Plugin]
|
The |
is_chunk_generated
¶
Checks if the Chunk at the given coordinates has been generated.
A chunk counts as generated once it is loaded or has been written to the level's chunk storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
is_chunk_loaded
¶
load_chunk
¶
Requests the Chunk at the given coordinates to be loaded, and keeps it resident until it is released again.
The chunk is held from the moment this returns until unload_chunk or unload_chunk_request releases it, or
the server restarts. Unlike Java Edition, Bedrock has no synchronous chunk load: unless the chunk was already
resident, the load finishes on a later tick, so is_chunk_loaded may still report False right afterwards. A
chunk held this way stays in memory but is not ticked, and the hold never expires on its own. Intended for keeping
a handful of chunks resident, not for loading large regions.
The hold is not attributed to any plugin and survives that plugin being disabled. Use add_plugin_chunk_ticket
for a hold that is released automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
generate
|
bool
|
Whether to generate the chunk if it does not exist yet. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
the world limit, otherwise |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called from a thread other than the server thread. |
remove_plugin_chunk_ticket
¶
Removes the given plugin's ticket for the Chunk at the given coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
plugin
|
Plugin
|
|
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
remove_plugin_chunk_tickets
¶
remove_plugin_chunk_tickets(plugin: Plugin) -> None
Removes every ticket the given plugin holds in this dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
Plugin
|
|
required |
spawn_actor
¶
unload_chunk
¶
Releases the hold that load_chunk placed on the Chunk at the given coordinates, and unloads it if nothing
else keeps it resident.
A chunk kept alive by a nearby player, the spawn area, a /tickingarea or a plugin chunk ticket stays loaded,
and this reports False. Unloading a chunk saves it and fires a ChunkUnloadEvent, which handlers observe
before this returns. It also completes any chunk unloads the dimension had pending, so calling it once per chunk
over a large area is expensive; use unload_chunk_request when releasing many chunks at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called from a thread other than the server thread. |
unload_chunk_request
¶
Releases the hold that load_chunk placed on the Chunk at the given coordinates, without unloading it now.
The chunk is unloaded on a later tick once nothing else keeps it resident.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X-coordinate of the chunk. |
required |
z
|
int
|
Z-coordinate of the chunk. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called from a thread other than the server thread. |
DimensionCreator
¶
Represents the options that may be used to create a custom dimension.
Creates an instance of a DimensionCreator for the given dimension id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
Identifier[Dimension] | str
|
The identifier of the dimension to create, e.g. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Identifier[Dimension]
|
The identifier of the dimension that is being created. |
Level
¶
Represents a level, which may contain actors, chunks and blocks.
Methods:
| Name | Description |
|---|---|
create_dimension |
Creates a new custom dimension within this level. |
get_dimension |
Gets the dimension with the given id. |
get_game_rule |
|
has_game_rule |
Checks if a game rule exists. |
set_game_rule |
|
Attributes:
| Name | Type | Description |
|---|---|---|
actors |
list[Actor]
|
A list of all actors currently residing in this level. |
dimensions |
list[Dimension]
|
A list of all dimensions within this level. |
name |
str
|
The unique name of this level. |
recipes |
list[Recipe]
|
The list of crafting recipes. |
seed |
int
|
The Seed for this level. |
time |
int
|
The relative in-game time of this level. |
create_dimension
¶
create_dimension(
creator: DimensionCreator,
) -> Dimension | None
Creates a new custom dimension within this level.
Custom dimensions are empty (void) dimensions identified by a namespaced id, e.g. myplugin:void_realm;
populate them with blocks, structures or actors afterward.
The level remembers which id belongs to which name, so a dimension's terrain and actors survive a restart. The registration itself does not: call this again on every startup to get the same dimension back.
If a dimension with the requested name already exists, that existing dimension is returned instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
creator
|
DimensionCreator
|
The options to use when creating the dimension. An identifier or plain string is also accepted as the name. |
required |
Returns:
| Type | Description |
|---|---|
Dimension | None
|
The newly created (or existing) |
get_dimension
¶
get_game_rule
¶
has_game_rule
¶
Location
¶
Location(
dimension: Dimension | None,
x: float,
y: float,
z: float,
pitch: float = 0.0,
yaw: float = 0.0,
)
Represents a 3-dimensional location in a dimension within a level.
Methods:
| Name | Description |
|---|---|
distance |
Get the distance between this location and another. |
distance_squared |
Get the squared distance between this location and another. |
normalize_pitch |
Normalizes the given pitch angle to a value between |
normalize_yaw |
Normalizes the given yaw angle to a value between |
zero |
Zero this location's components. Not world-aware. |
Attributes:
| Name | Type | Description |
|---|---|---|
block |
Block
|
The block at the represented location. |
block_x |
int
|
The floored value of the X component, indicating the block that this location is contained with. |
block_y |
int
|
The floored value of the Y component, indicating the block that this location is contained with. |
block_z |
int
|
The floored value of the Z component, indicating the block that this location is contained with. |
dimension |
Dimension | None
|
The |
direction |
Vector
|
A unit-vector pointing in the direction that this |
is_dimension_loaded |
bool
|
Whether the dimension of this location is present and still loaded. |
length |
float
|
The magnitude of the location, defined as |
length_squared |
float
|
The magnitude of the location squared. |
pitch |
float
|
The pitch of this location, measured in degrees. |
x |
float
|
The x-coordinate of this location. |
y |
float
|
The y-coordinate of this location. |
yaw |
float
|
The yaw of this location, measured in degrees. |
z |
float
|
The z-coordinate of this location. |
block_x
property
¶
block_x: int
The floored value of the X component, indicating the block that this location is contained with.
block_y
property
¶
block_y: int
The floored value of the Y component, indicating the block that this location is contained with.
block_z
property
¶
block_z: int
The floored value of the Z component, indicating the block that this location is contained with.
dimension
property
writable
¶
dimension: Dimension | None
The Dimension that contains this position, or None if it is not set.
direction
property
writable
¶
direction: Vector
A unit-vector pointing in the direction that this Location is facing.
is_dimension_loaded
property
¶
is_dimension_loaded: bool
Whether the dimension of this location is present and still loaded.
length
property
¶
length: float
The magnitude of the location, defined as sqrt(x^2+y^2+z^2).
Not world-aware and orientation independent.
length_squared
property
¶
length_squared: float
The magnitude of the location squared.
Not world-aware and orientation independent.