endstone/block

Classes

NameDescription
BlockRepresents a block.
BlockDataRepresents the data related to a live block.
BlockStateRepresents a captured state of a block, which will not update automatically.
BlockType

Enums

NameDescription
BlockFaceRepresents the face of a block.

Type Aliases

NameDescription
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

NameDescription
~Block
getTypeGet the type of the block.
setTypeSets the type of this block.
setTypeSets the type of this block.
getDataGets the complete block data for this block.
setDataSets the complete data for this block.
setDataSets the complete data for this block.
getRelativeGets the block at the given offsets.
getRelativeGets the block at the given face.
getRelativeGets the block at the given distance of the given face.
getDimensionGets the dimension which contains this Block.
getXGets the x-coordinate of this block.
getYGets the y-coordinate of this block.
getZGets the z-coordinate of this block.
getLocationGets the Location of the block.
captureStateCaptures the current state of this block.
cloneCreates a copy of the current block.

meth~Blockvirtual

~Block() =default

methgetTypeabstractconst

std::string getType() const =0

Get the type of the block.

This method returns the type of the block as a string, for example, minecraft:acacia_stairs.

Returns

TypeDescription
std::stringThe type of the block.

methsetTypeabstract

void setType(std::string type) =0

Sets the type of this block.

Parameters

NameTypeDescription
typestd::stringMaterial to change this block to

methsetTypeabstract

void setType(std::string type, bool apply_physics) =0

Sets the type of this block.

Parameters

NameTypeDescription
typestd::stringMaterial to change this block to
apply_physicsboolFalse to cancel physics on the changed block.

methgetDataabstractconst

std::unique_ptr<BlockData> getData() const =0

Gets the complete block data for this block.

Returns

TypeDescription
std::unique_ptr<BlockData>block specific data

methsetDataabstract

void setData(const BlockData& data) =0

Sets the complete data for this block.

Parameters

NameTypeDescription
dataconst BlockData&new block specific data

methsetDataabstract

void setData(const BlockData& data, bool apply_physics) =0

Sets the complete data for this block.

Parameters

NameTypeDescription
dataconst BlockData&new block specific data
apply_physicsboolFalse to cancel physics on the changed block.

methgetRelativeabstract

std::unique_ptr<Block> getRelative(int offset_x, int offset_y, int offset_z) =0

Gets the block at the given offsets.

Parameters

NameTypeDescription
offset_xintX-coordinate offset
offset_yintY-coordinate offset
offset_zintZ-coordinate offset

Returns

TypeDescription
std::unique_ptr<Block>Block at the given offsets

methgetRelativeabstract

std::unique_ptr<Block> getRelative(BlockFace face) =0

Gets the block at the given face.

This method is equal to getRelative(face, 1)

Parameters

NameTypeDescription
faceBlockFaceFace of this block to return

Returns

TypeDescription
std::unique_ptr<Block>Block at the given face

methgetRelativeabstract

std::unique_ptr<Block> getRelative(BlockFace face, int distance) =0

Gets the block at the given distance of the given face.

Parameters

NameTypeDescription
faceBlockFaceFace of this block to return
distanceintDistance to get the block at

Returns

TypeDescription
std::unique_ptr<Block>Block at the given face

methgetDimensionabstractconst

Dimension& getDimension() const =0

Gets the dimension which contains this Block.

Returns

TypeDescription
Dimension&Dimension containing this block

methgetXabstractconst

int getX() const =0

Gets the x-coordinate of this block.

Returns

TypeDescription
intx-coordinate

methgetYabstractconst

int getY() const =0

Gets the y-coordinate of this block.

Returns

TypeDescription
intx-coordinate

methgetZabstractconst

int getZ() const =0

Gets the z-coordinate of this block.

Returns

TypeDescription
intx-coordinate

methgetLocationabstractconst

Location getLocation() const =0

Gets the Location of the block.

Returns

TypeDescription
LocationLocation of block

methcaptureStateabstractconst

std::unique_ptr<BlockState> captureState() const =0

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

TypeDescription
std::unique_ptr<BlockState>BlockState with the current state of this block.

methcloneabstractconst

std::unique_ptr<Block> clone() const =0

Creates a copy of the current block.

Returns

TypeDescription
std::unique_ptr<Block>Block

classBlockData

Defined in <endstone/block/block_data.h>

Represents the data related to a live block.

Methods

NameDescription
~BlockData
getTypeGet the block type represented by this block data.
getBlockStatesGets the block states, which when passed into a method such as Server::createBlockData(type, block_states) will unambiguously recreate this instance.
getRuntimeIdGet the runtime ID for this block.

meth~BlockDatavirtual

~BlockData() =default

methgetTypeabstractconst

std::string getType() const =0

Get the block type represented by this block data.

Returns

TypeDescription
std::stringthe block type

methgetBlockStatesabstractconst

BlockStates getBlockStates() const =0

Gets the block states, which when passed into a method such as Server::createBlockData(type, block_states) will unambiguously recreate this instance.

Returns

TypeDescription
BlockStatesthe block states for this block

methgetRuntimeIdabstractconst

std::uint32_t getRuntimeId() const =0

Get the runtime ID for this block.

Returns

TypeDescription
std::uint32_tthe 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

NameDescription
~BlockState
getBlockGets the block represented by this block state.
getTypeGets the type of this block state.
setTypeSets the type of this block state.
getDataGets the data for this block state.
setDataSets the data for this block state.
getDimensionGets the dimension which contains the block represented by this block state.
getXGets the x-coordinate of this block state.
getYGets the y-coordinate of this block state.
getZGets the z-coordinate of this block state.
getLocationGets the location of this block state.
updateAttempts to update the block represented by this state, setting it to yhe new values as defined by this state.
updateAttempts to update the block represented by this state, setting it to the new values as defined by this state.
updateAttempts to update the block represented by this state, setting it to the new values as defined by this state.

meth~BlockStatevirtual

~BlockState() =default

methgetBlockabstractconst

std::unique_ptr<Block> getBlock() const =0

Gets the block represented by this block state.

Returns

TypeDescription
std::unique_ptr<Block>the block represented by this block state

methgetTypeabstractconst

std::string getType() const =0

Gets the type of this block state.

Returns

TypeDescription
std::stringblock type

methsetTypeabstract

void setType(std::string type) =0

Sets the type of this block state.

Parameters

NameTypeDescription
typestd::stringBlock type to change this block state to

methgetDataabstractconst

std::unique_ptr<BlockData> getData() const =0

Gets the data for this block state.

Returns

TypeDescription
std::unique_ptr<BlockData>block specific data

methsetDataabstract

void setData(const BlockData& data) =0

Sets the data for this block state.

Parameters

NameTypeDescription
dataconst BlockData&New block specific data

methgetDimensionabstractconst

Dimension& getDimension() const =0

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

Returns

TypeDescription
Dimension&the dimension containing the block represented by this block state

methgetXabstractconst

int getX() const =0

Gets the x-coordinate of this block state.

Returns

TypeDescription
intx-coordinate

methgetYabstractconst

int getY() const =0

Gets the y-coordinate of this block state.

Returns

TypeDescription
inty-coordinate

methgetZabstractconst

int getZ() const =0

Gets the z-coordinate of this block state.

Returns

TypeDescription
intz-coordinate

methgetLocationabstractconst

Location getLocation() const =0

Gets the location of this block state.

Returns

TypeDescription
Locationthe location

methupdateabstract

bool update() =0

Attempts 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

TypeDescription
booltrue if the update was successful, otherwise false

methupdateabstract

bool update(bool force) =0

Attempts 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

NameTypeDescription
forcebooltrue to forcefully set the state

Returns

TypeDescription
booltrue if the update was successful, otherwise false

methupdateabstract

bool update(bool force, bool apply_physics) =0

Attempts 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

NameTypeDescription
forcebooltrue to forcefully set the state
apply_physicsboolfalse to cancel updating physics on surrounding blocks

Returns

TypeDescription
booltrue if the update was successful, otherwise false

classBlockType

Defined in <endstone/block/block_type.h>

Bases: Registry<T>::Type

Variables

NameDescription
Air

Methods

NameDescription
hasItemTypeReturns true if this BlockType has a corresponding ItemType.
createBlockDataCreates a new BlockData instance for this block type, with all properties initialized to unspecified defaults.

varAirstaticconstexpr

auto Air

methhasItemTypeabstractconst

bool hasItemType() const =0

Returns true if this BlockType has a corresponding ItemType.

Returns

TypeDescription
booltrue if there is a corresponding ItemType, otherwise false

methcreateBlockDataabstractconst

std::unique_ptr<BlockData> createBlockData() const =0

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

Returns

TypeDescription
std::unique_ptr<BlockData>new data instance

enumBlockFace

BlockFace

Represents the face of a block.

Values

NameValueDescription
Down
Up
North
South
West
East

typeBlockStates

typeBlockTypeId

Identifier<BlockType> BlockTypeId

On this page