Skip to content

Block

endstone.block

Classes relating to the blocks in a world, including special states.

Classes:

Name Description
Block

Represents a block.

BlockData

Represents the data related to a live block.

BlockFace
BlockState

Represents a captured state of a block, which will not update automatically.

BlockType

Represents a block type.

Block

Represents a block.

Methods:

Name Description
capture_state

Captures the current state of this block.

get_relative
set_data

Sets the complete data for this block.

set_type

Sets the type of this block.

Attributes:

Name Type Description
data BlockData

The complete block data for this block.

dimension Dimension

The dimension which contains this Block.

location Location

The location of this block.

type BlockType

The type of the block.

x int

X-coordinate of this block.

y int

Y-coordinate of this block.

z int

Z-coordinate of this block.

data property

data: BlockData

The complete block data for this block.

dimension property

dimension: Dimension

The dimension which contains this Block.

location property

location: Location

The location of this block.

type property

type: BlockType

The type of the block.

x property

x: int

X-coordinate of this block.

y property

y: int

Y-coordinate of this block.

z property

z: int

Z-coordinate of this block.

capture_state

capture_state() -> BlockState

Captures the current state of this block.

The returned object will never be updated, and you are not guaranteed that (for example) a sign is still a sign after you capture its state.

Returns:

Type Description
BlockState

A BlockState snapshot of the current state of this block.

get_relative

get_relative(
    offset_x: int, offset_y: int, offset_z: int
) -> Block
get_relative(face: BlockFace, distance: int = 1) -> Block

set_data

set_data(
    data: BlockData, apply_physics: bool = True
) -> None

Sets the complete data for this block.

Parameters:

Name Type Description Default
data BlockData

New block-specific data.

required
apply_physics bool

False to cancel physics on the changed block.

True

set_type

set_type(
    type: Identifier[BlockType] | str,
    apply_physics: bool = True,
) -> None

Sets the type of this block.

Parameters:

Name Type Description Default
type Identifier[BlockType] | str

New type for this block (e.g. minecraft:stone).

required
apply_physics bool

False to cancel physics on the changed block.

True

BlockData

Represents the data related to a live block.

Attributes:

Name Type Description
block_states dict[str, bool | str | int]

The block states for this block.

runtime_id int

The runtime id for this block.

translation_key str

The translation key for this block.

type BlockType

The block type represented by this block data.

block_states property

block_states: dict[str, bool | str | int]

The block states for this block.

When passed into Server.create_block_data(type, block_states) these will unambiguously recreate this instance.

runtime_id property

runtime_id: int

The runtime id for this block.

translation_key property

translation_key: str

The translation key for this block.

type property

type: BlockType

The block type represented by this block data.

BlockFace

Bases: Enum

Attributes:

Name Type Description
DOWN
EAST
NORTH
SOUTH
UP
WEST

DOWN class-attribute instance-attribute

DOWN = 0

EAST class-attribute instance-attribute

EAST = 5

NORTH class-attribute instance-attribute

NORTH = 2

SOUTH class-attribute instance-attribute

SOUTH = 3

UP class-attribute instance-attribute

UP = 1

WEST class-attribute instance-attribute

WEST = 4

BlockState

Represents a captured state of a block, which will not update automatically.

Unlike Block, which only one object can exist per coordinate, BlockState can exist multiple times for any given Block. Note that another plugin may change the state of the block, and you will not know, or they may change the block to another type entirely, causing your BlockState to become invalid.

Methods:

Name Description
update

Attempts to update the block represented by this state, setting it to the new values defined by this state.

Attributes:

Name Type Description
block Block

The block represented by this block state.

data BlockData

The data for this block state.

dimension Dimension

The dimension which contains the block represented by this block state.

location Location

The location of this block state.

type BlockType

The type of this block state.

x int

X-coordinate of this block state.

y int

Y-coordinate of this block state.

z int

Z-coordinate of this block state.

block property

block: Block

The block represented by this block state.

data property writable

data: BlockData

The data for this block state.

dimension property

dimension: Dimension

The dimension which contains the block represented by this block state.

location property

location: Location

The location of this block state.

type property writable

type: BlockType

The type of this block state.

x property

x: int

X-coordinate of this block state.

y property

y: int

Y-coordinate of this block state.

z property

z: int

Z-coordinate of this block state.

update

update(
    force: bool = False, apply_physics: bool = True
) -> bool

Attempts to update the block represented by this state, setting it to the new values defined by this state.

Unless force is True, this will not modify the state of a block if it is no longer the same type as it was when this state was taken; in that case it returns False.

If force is True, the block type is set to match the new state, the state data is applied, and True is returned.

If apply_physics is True, a physics update is triggered on surrounding blocks, which could cause them to update or disappear.

Parameters:

Name Type Description Default
force bool

True to forcefully set the state.

False
apply_physics bool

False to cancel updating physics on surrounding blocks.

True

Returns:

Type Description
bool

True if the update was successful, False otherwise.

BlockType

Represents a block type.

Methods:

Name Description
create_block_data

Creates a new BlockData instance for this block type, with all properties initialized to defaults.

get

Attempts to get the BlockType with the given name.

Attributes:

Name Type Description
has_item_type bool

True if this BlockType has a corresponding ItemType.

id Identifier[BlockType]

The identifier of this block type.

translation_key str

The translation key, suitable for use in a translation component.

has_item_type property

has_item_type: bool

True if this BlockType has a corresponding ItemType.

id property

id: Identifier[BlockType]

The identifier of this block type.

translation_key property

translation_key: str

The translation key, suitable for use in a translation component.

create_block_data

create_block_data() -> BlockData

Creates a new BlockData instance for this block type, with all properties initialized to defaults.

Returns:

Type Description
BlockData

A new BlockData instance.

get staticmethod

get(name: Identifier[BlockType] | str) -> BlockType

Attempts to get the BlockType with the given name.

Parameters:

Name Type Description Default
name Identifier[BlockType] | str

The identifier of the block type (e.g. minecraft:stone).

required

Returns:

Type Description
BlockType

The BlockType, or None if no block type with that name exists.