endstone/block
Classes
| Name | Description |
|---|---|
Block | Represents a block. |
BlockData | Represents the data related to a live block. |
BlockState | Represents a captured state of a block, which will not update automatically. |
BlockType |
Enums
| Name | Description |
|---|---|
BlockFace | Represents the face of a block. |
Type Aliases
| Name | Description |
|---|---|
BlockStates | |
BlockTypeId |
classBlock
Defined in <endstone/block/block.h>
Represents a block.
This is a live object, and only one Block may exist for any given location in a dimension.
Methods
| Name | Description |
|---|---|
~Block | |
getType | Get the type of the block. |
setType | Sets the type of this block. |
setType | Sets the type of this block. |
getData | Gets the complete block data for this block. |
setData | Sets the complete data for this block. |
setData | Sets the complete data for this block. |
getRelative | Gets the block at the given offsets. |
getRelative | Gets the block at the given face. |
getRelative | Gets the block at the given distance of the given face. |
getDimension | Gets the dimension which contains this Block. |
getX | Gets the x-coordinate of this block. |
getY | Gets the y-coordinate of this block. |
getZ | Gets the z-coordinate of this block. |
getLocation | Gets the Location of the block. |
captureState | Captures the current state of this block. |
clone | Creates a copy of the current block. |
meth~Blockvirtual
~Block() =defaultmethgetTypeabstractconst
std::string getType() const =0Get the type of the block.
This method returns the type of the block as a string, for example, minecraft:acacia_stairs.
Returns
| Type | Description |
|---|---|
std::string | The type of the block. |
methsetTypeabstract
void setType(std::string type) =0Sets the type of this block.
Parameters
| Name | Type | Description |
|---|---|---|
type | std::string | Material to change this block to |
methsetTypeabstract
void setType(std::string type, bool apply_physics) =0Sets the type of this block.
Parameters
| Name | Type | Description |
|---|---|---|
type | std::string | Material to change this block to |
apply_physics | bool | False to cancel physics on the changed block. |
methgetDataabstractconst
std::unique_ptr<BlockData> getData() const =0Gets the complete block data for this block.
Returns
| Type | Description |
|---|---|
std::unique_ptr<BlockData> | block specific data |
methsetDataabstract
void setData(const BlockData& data) =0Sets the complete data for this block.
Parameters
| Name | Type | Description |
|---|---|---|
data | const BlockData& | new block specific data |
methsetDataabstract
void setData(const BlockData& data, bool apply_physics) =0Sets the complete data for this block.
Parameters
| Name | Type | Description |
|---|---|---|
data | const BlockData& | new block specific data |
apply_physics | bool | False to cancel physics on the changed block. |
methgetRelativeabstract
std::unique_ptr<Block> getRelative(int offset_x, int offset_y, int offset_z) =0Gets the block at the given offsets.
Parameters
| Name | Type | Description |
|---|---|---|
offset_x | int | X-coordinate offset |
offset_y | int | Y-coordinate offset |
offset_z | int | Z-coordinate offset |
Returns
| Type | Description |
|---|---|
std::unique_ptr<Block> | Block at the given offsets |
methgetRelativeabstract
std::unique_ptr<Block> getRelative(BlockFace face) =0Gets the block at the given face.
This method is equal to getRelative(face, 1)
Parameters
| Name | Type | Description |
|---|---|---|
face | BlockFace | Face of this block to return |
Returns
| Type | Description |
|---|---|
std::unique_ptr<Block> | Block at the given face |
methgetRelativeabstract
std::unique_ptr<Block> getRelative(BlockFace face, int distance) =0Gets the block at the given distance of the given face.
Parameters
| Name | Type | Description |
|---|---|---|
face | BlockFace | Face of this block to return |
distance | int | Distance to get the block at |
Returns
| Type | Description |
|---|---|
std::unique_ptr<Block> | Block at the given face |
methgetDimensionabstractconst
Dimension& getDimension() const =0Gets the dimension which contains this Block.
methgetXabstractconst
int getX() const =0Gets the x-coordinate of this block.
Returns
| Type | Description |
|---|---|
int | x-coordinate |
methgetYabstractconst
int getY() const =0Gets the y-coordinate of this block.
Returns
| Type | Description |
|---|---|
int | x-coordinate |
methgetZabstractconst
int getZ() const =0Gets the z-coordinate of this block.
Returns
| Type | Description |
|---|---|
int | x-coordinate |
methgetLocationabstractconst
Location getLocation() const =0Gets the Location of the block.
methcaptureStateabstractconst
std::unique_ptr<BlockState> captureState() const =0Captures 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 |
|---|---|
std::unique_ptr<BlockState> | BlockState with the current state of this block. |
methcloneabstractconst
std::unique_ptr<Block> clone() const =0Creates a copy of the current block.
Returns
| Type | Description |
|---|---|
std::unique_ptr<Block> | Block |
classBlockData
Defined in <endstone/block/block_data.h>
Represents the data related to a live block.
Methods
| Name | Description |
|---|---|
~BlockData | |
getType | Get the block type represented by this block data. |
getBlockStates | Gets the block states, which when passed into a method such as Server::createBlockData(type, block_states) will unambiguously recreate this instance. |
getRuntimeId | Get the runtime ID for this block. |
meth~BlockDatavirtual
~BlockData() =defaultmethgetTypeabstractconst
std::string getType() const =0Get the block type represented by this block data.
Returns
| Type | Description |
|---|---|
std::string | the block type |
methgetBlockStatesabstractconst
BlockStates getBlockStates() const =0Gets the block states, which when passed into a method such as Server::createBlockData(type, block_states) will unambiguously recreate this instance.
Returns
| Type | Description |
|---|---|
BlockStates | the block states for this block |
methgetRuntimeIdabstractconst
std::uint32_t getRuntimeId() const =0Get the runtime ID for this block.
Returns
| Type | Description |
|---|---|
std::uint32_t | the runtime id for this block |
classBlockState
Defined in <endstone/block/block_state.h>
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 |
|---|---|
~BlockState | |
getBlock | Gets the block represented by this block state. |
getType | Gets the type of this block state. |
setType | Sets the type of this block state. |
getData | Gets the data for this block state. |
setData | Sets the data for this block state. |
getDimension | Gets the dimension which contains the block represented by this block state. |
getX | Gets the x-coordinate of this block state. |
getY | Gets the y-coordinate of this block state. |
getZ | Gets the z-coordinate of this block state. |
getLocation | Gets the location of this block state. |
update | Attempts to update the block represented by this state, setting it to yhe new values as defined by this state. |
update | Attempts to update the block represented by this state, setting it to the new values as defined by this state. |
update | Attempts to update the block represented by this state, setting it to the new values as defined by this state. |
meth~BlockStatevirtual
~BlockState() =defaultmethgetBlockabstractconst
std::unique_ptr<Block> getBlock() const =0Gets the block represented by this block state.
Returns
| Type | Description |
|---|---|
std::unique_ptr<Block> | the block represented by this block state |
methgetTypeabstractconst
std::string getType() const =0Gets the type of this block state.
Returns
| Type | Description |
|---|---|
std::string | block type |
methsetTypeabstract
void setType(std::string type) =0Sets the type of this block state.
Parameters
| Name | Type | Description |
|---|---|---|
type | std::string | Block type to change this block state to |
methgetDataabstractconst
std::unique_ptr<BlockData> getData() const =0Gets the data for this block state.
Returns
| Type | Description |
|---|---|
std::unique_ptr<BlockData> | block specific data |
methsetDataabstract
void setData(const BlockData& data) =0Sets the data for this block state.
Parameters
| Name | Type | Description |
|---|---|---|
data | const BlockData& | New block specific data |
methgetDimensionabstractconst
Dimension& getDimension() const =0Gets the dimension which contains the block represented by this block state.
Returns
| Type | Description |
|---|---|
Dimension& | the dimension containing the block represented by this block state |
methgetXabstractconst
int getX() const =0Gets the x-coordinate of this block state.
Returns
| Type | Description |
|---|---|
int | x-coordinate |
methgetYabstractconst
int getY() const =0Gets the y-coordinate of this block state.
Returns
| Type | Description |
|---|---|
int | y-coordinate |
methgetZabstractconst
int getZ() const =0Gets the z-coordinate of this block state.
Returns
| Type | Description |
|---|---|
int | z-coordinate |
methgetLocationabstractconst
Location getLocation() const =0Gets the location of this block state.
Returns
| Type | Description |
|---|---|
Location | the location |
methupdateabstract
bool update() =0Attempts to update the block represented by this state, setting it to yhe new values as defined by this state.
This has the same effect as calling update(false). That is to say, 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. It will return false in this eventuality.
Returns
| Type | Description |
|---|---|
bool | true if the update was successful, otherwise false |
methupdateabstract
bool update(bool force) =0Attempts to update the block represented by this state, setting it to the new values as defined by this state.
This has the same effect as calling update(force, true). That is to say, this will trigger a physics update to surrounding blocks.
Parameters
| Name | Type | Description |
|---|---|---|
force | bool | true to forcefully set the state |
Returns
| Type | Description |
|---|---|
bool | true if the update was successful, otherwise false |
methupdateabstract
bool update(bool force, bool apply_physics) =0Attempts to update the block represented by this state, setting it to the new values as 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. It will return false in this eventuality.
If force is true, it will set the type of the block to match the new state, set the state data and then return true.
If apply_physics is true, it will trigger a physics update on surrounding blocks which could cause them to update or disappear.
Parameters
| Name | Type | Description |
|---|---|---|
force | bool | true to forcefully set the state |
apply_physics | bool | false to cancel updating physics on surrounding blocks |
Returns
| Type | Description |
|---|---|
bool | true if the update was successful, otherwise false |
classBlockType
Defined in <endstone/block/block_type.h>
Variables
| Name | Description |
|---|---|
Air |
Methods
| Name | Description |
|---|---|
hasItemType | Returns true if this BlockType has a corresponding ItemType. |
createBlockData | Creates a new BlockData instance for this block type, with all properties initialized to unspecified defaults. |
varAirstaticconstexpr
auto AirmethhasItemTypeabstractconst
bool hasItemType() const =0Returns true if this BlockType has a corresponding ItemType.
Returns
| Type | Description |
|---|---|
bool | true if there is a corresponding ItemType, otherwise false |
methcreateBlockDataabstractconst
std::unique_ptr<BlockData> createBlockData() const =0Creates a new BlockData instance for this block type, with all properties initialized to unspecified defaults.
Returns
| Type | Description |
|---|---|
std::unique_ptr<BlockData> | new data instance |
enumBlockFace
BlockFaceRepresents the face of a block.
Values
| Name | Value | Description |
|---|---|---|
Down | ||
Up | ||
North | ||
South | ||
West | ||
East |
typeBlockStates
std::unordered_map<std::string, std::variant<bool, std::string, int>> BlockStatestypeBlockTypeId
Identifier<BlockType> BlockTypeId