Skip to Content
⚠ Under Construction
ReferenceC++ APIBlockState

endstone::BlockState

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

Functions:

NameDescription
getBlockGets the block represented by this block state.
getDataGets the data for this block state.
getDimensionGets the dimension which contains the block represented by this block state.
getLocationGets the location of this block state.
getTypeGets the type of 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.
setDataSets the data for this block state.
setTypeSets the type 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.

getBlock

std::unique_ptr<Block> getBlock() const

Gets the block represented by this block state.

Returns:

the block represented by this block state

getData

std::unique_ptr<BlockData> getData() const

Gets the data for this block state.

Returns:

block specific data

getDimension

Dimension &getDimension() const

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

Returns:

the dimension containing the block represented by this block state

getLocation

Location getLocation() const

Gets the location of this block state.

Returns:

the location

getType

std::string getType() const

Gets the type of this block state.

Returns:

block type

getX

int getX() const

Gets the x-coordinate of this block state.

Returns:

x-coordinate

getY

int getY() const

Gets the y-coordinate of this block state.

Returns:

y-coordinate

getZ

int getZ() const

Gets the z-coordinate of this block state.

Returns:

z-coordinate

setData

Result<void> setData(const BlockData &data)

Sets the data for this block state.

Parameters:

  • data New block specific data

setType

Result<void> setType(std::string type)

Sets the type of this block state.

Parameters:

  • type Block type to change this block state to

update

bool update()

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:

true if the update was successful, otherwise false

bool update(bool force)

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:

  • force true to forcefully set the state

Returns:

true if the update was successful, otherwise false

bool update(bool force, bool apply_physics)

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:

  • force true to forcefully set the state
  • apply_physics false to cancel updating physics on surrounding blocks

Returns:

true if the update was successful, otherwise false

Last updated on