Skip to content

Latest commit

 

History

History
96 lines (53 loc) · 2.84 KB

File metadata and controls

96 lines (53 loc) · 2.84 KB

📮 Block Entity Object API

In LLSE, "block entity objects" are used to manipulate and obtain additional data associated with a particular block. Note: Block Entity Object is not a Entity! There is no special relationship between them.

Get a Block Entity Object

Obtained From Blocks

For an existing block object bl, there are:

bl.getBlockEntity()

  • Return type: The block's block entity object.
  • Return value type: BlockEntity
    • If the return value is Null, it means that obtaining the block entity object failed, or this block doesn't have a corresponding entity object.

Note: Do not save a block entity object. When the block corresponding to the block object is destroyed, the corresponding block entity object will become invalid. Therefore, if there is a need to operate a certain block entity for a long time, please obtain the real-time block entity object through the above method.

Block Entity Object - Properties

Each block entity object contains some fixed object properties. For a particular block entity object be, there are the following properties:

Attributes Meaning Data Type
be.name The block entity name (example: container.chest) String
be.pos The coordinates where the block entity is located. IntPos
be.type The Type ID of the block entity object. Integer

These object properties are read-only and cannot be modified.

Block Entity Object - Function

Each block entity object contains some member functions (member methods) that can be executed. For a specific block entity object be, you can perform some operations on this block entity through the following functions:

Get the Block Entity's NBT Object

be.getNbt()

  • Return type: NBT object of the block entity.
  • Return value type: NbtCompound

Write to the Block Entity's NBT object

be.setNbt(nbt)

  • Parameters:
    • nbt : NbtCompound
      NBT objects.
  • Return type: Whether the write was successful or not.
  • Return value type: Boolean

For more usage of NBT objects, please refer to NBT Interface Documentation

Get the Block Entity's Block Object

be.getBlock()

  • Return type: The block entity's block object.
  • Return value type: Block

Set Block Entity Custom Name

!!! warning This function is only available in 0.19.1 and later.

be.setCustomName(name)

  • Parameters:
    • name : String New block entity custom name.
  • Return type: Whether setting was successful.
  • Return value type: Boolean

Get Block Entity Custom Name

!!! warning This function is only available in 0.19.1 and later.

be.getCustomName()

  • Return type: The block entity's custom name.
  • Return value type: String