Skip to content

Class endstone::Block

ClassList > endstone > Block

Represents a block. More...

  • #include <endstone/block/block.h>

Public Functions

Type Name
virtual std::shared_ptr< BlockState > captureState () const = 0
virtual Result< std::shared_ptr< BlockData > > getData () const = 0
Gets the complete block data for this block.
virtual Dimension & getDimension () const = 0
Gets the dimension which contains this Block .
virtual Location getLocation () const = 0
Gets the Location of the block.
virtual Result< std::unique_ptr< Block > > getRelative (int offset_x, int offset_y, int offset_z) = 0
Gets the block at the given offsets.
virtual Result< std::unique_ptr< Block > > getRelative (BlockFace face) = 0
Gets the block at the given face.
virtual Result< std::unique_ptr< Block > > getRelative (BlockFace face, int distance) = 0
Gets the block at the given distance of the given face.
virtual Result< std::string > getType () const = 0
Get the type of the block.
virtual int getX () const = 0
Gets the x-coordinate of this block.
virtual int getY () const = 0
Gets the y-coordinate of this block.
virtual int getZ () const = 0
Gets the z-coordinate of this block.
virtual bool isValid () const = 0
Checks if the block is valid.
virtual Result< void > setData (std::shared_ptr< BlockData > data) = 0
Sets the complete data for this block.
virtual Result< void > setData (std::shared_ptr< BlockData > data, bool apply_physics) = 0
Sets the complete data for this block.
virtual Result< void > setType (std::string type) = 0
Sets the type of this block.
virtual Result< void > setType (std::string type, bool apply_physics) = 0
Sets the type of this block.
virtual ~Block () = default

Detailed Description

This is a live object, and only one Block may exist for any given location in a dimension.

Public Functions Documentation

function captureState

virtual std::shared_ptr< BlockState > endstone::Block::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:

BlockState with the current state of this block.


function getData

Gets the complete block data for this block.

virtual Result< std::shared_ptr< BlockData > > endstone::Block::getData () const = 0

Returns:

block specific data


function getDimension

Gets the dimension which contains this Block .

virtual Dimension & endstone::Block::getDimension () const = 0

Returns:

Dimension containing this block


function getLocation

Gets the Location of the block.

virtual Location endstone::Block::getLocation () const = 0

Returns:

Location of block


function getRelative [⅓]

Gets the block at the given offsets.

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

Parameters:

  • offset_x X-coordinate offset
  • offset_y Y-coordinate offset
  • offset_z Z-coordinate offset

Returns:

Block at the given offsets


function getRelative [⅔]

Gets the block at the given face.

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

This method is equal to getRelative(face, 1)

Parameters:

  • face Face of this block to return

Returns:

Block at the given face


function getRelative [3/3]

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

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

Parameters:

  • face Face of this block to return
  • distance Distance to get the block at

Returns:

Block at the given face


function getType

Get the type of the block.

virtual Result< std::string > endstone::Block::getType () const = 0

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

Returns:

The type of the block.


function getX

Gets the x-coordinate of this block.

virtual int endstone::Block::getX () const = 0

Returns:

x-coordinate


function getY

Gets the y-coordinate of this block.

virtual int endstone::Block::getY () const = 0

Returns:

x-coordinate


function getZ

Gets the z-coordinate of this block.

virtual int endstone::Block::getZ () const = 0

Returns:

x-coordinate


function isValid

Checks if the block is valid.

virtual bool endstone::Block::isValid () const = 0

This method verifies the validity of the block. A block is considered valid if and only if the chunk containing this block is loaded and ticking. If the chunk is not loaded or not in the ticking state, this method will return false.

Returns:

true if the block is valid (i.e., the containing chunk is loaded and ticking), otherwise false.


function setData [½]

Sets the complete data for this block.

virtual Result< void > endstone::Block::setData (
    std::shared_ptr< BlockData > data
) = 0

Parameters:

  • data new block specific data

function setData [2/2]

Sets the complete data for this block.

virtual Result< void > endstone::Block::setData (
    std::shared_ptr< BlockData > data,
    bool apply_physics
) = 0

Parameters:

  • data new block specific data
  • apply_physics False to cancel physics on the changed block.

function setType [½]

Sets the type of this block.

virtual Result< void > endstone::Block::setType (
    std::string type
) = 0

Parameters:

  • type Material to change this block to

function setType [2/2]

Sets the type of this block.

virtual Result< void > endstone::Block::setType (
    std::string type,
    bool apply_physics
) = 0

Parameters:

  • type Material to change this block to
  • apply_physics False to cancel physics on the changed block.

function ~Block

virtual endstone::Block::~Block () = default


The documentation for this class was generated from the following file include/endstone/block/block.h