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 |
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. |
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 |
set_data
¶
set_type
¶
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
¶
The block states for this block.
When passed into Server.create_block_data(type, block_states) these
will unambiguously recreate this instance.
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. |
dimension
property
¶
dimension: Dimension
The dimension which contains the block represented by this block state.
update
¶
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
|
|
False
|
apply_physics
|
bool
|
|
True
|
Returns:
| Type | Description |
|---|---|
bool
|
|
BlockType
¶
Represents a block type.
Methods:
| Name | Description |
|---|---|
create_block_data |
Creates a new |
get |
Attempts to get the |
Attributes:
| Name | Type | Description |
|---|---|---|
has_item_type |
bool
|
|
id |
Identifier[BlockType]
|
The identifier of this block type. |
translation_key |
str
|
The translation key, suitable for use in a translation component. |
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 |