endstone::BlockState
Represents a captured state of a block, which will not update automatically.
Functions:
Name | Description |
---|---|
getBlock | Gets the block represented by this block state. |
getData | Gets the data for this block state. |
getDimension | Gets the dimension which contains the block represented by this block state. |
getLocation | Gets the location of this block state. |
getType | Gets the type of 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. |
setData | Sets the data for this block state. |
setType | Sets the type 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. |
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 stateapply_physics
false to cancel updating physics on surrounding blocks
Returns:
true if the update was successful, otherwise false