@minecraft/server
    Preparing search index...

    Class BlockEntityStorageComponentBeta

    Represents storage for entities associated with a block entity. This component is available on blocks whose behavior pack definition enables entity storage with the minecraft:block_entity component. Stored entities are serialized and removed from the world until they are released or transferred. A block can store up to four entities. Entity storage is scoped to the content pack accessing it.

    Hierarchy (View Summary)

    Index

    Properties

    block: Block

    Block instance that this component pertains to.

    isValid: boolean

    Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.

    typeId: string

    Identifier of the component.

    componentId: "minecraft:entity_storage" = 'minecraft:entity_storage'

    Methods

    • Beta

      Parameters

      Returns Entity

      The released Entity. The released entity receives a new runtime ID.

      Releases a stored entity from this block's entity storage and spawns it back into the world, at the same location it was when stored.

      no-restricted-execution - This function can't be called in restricted-execution mode.

      Throws if the entity ID is invalid or does not identify an entity stored by the current content pack, if the stored entity cannot be loaded or spawned, or if the block entity is invalid.

      Error

      InvalidBlockComponentError

      LocationInUnloadedChunkError

      LocationOutOfWorldBoundariesError

    • Beta

      Returns number

      The number of entities stored by the current content pack.

      Returns the number of entities stored in this block's entity storage by the current content pack.

      Throws if the block entity is invalid or the block's location is not loaded or is outside the world boundaries.

      Error

      InvalidBlockComponentError

      LocationInUnloadedChunkError

      LocationOutOfWorldBoundariesError

    • Beta

      Parameters

      Returns string

      The unique ID assigned to the stored entity. Keep this ID to release, transfer, or inspect the stored entity later.

      Serializes and stores an entity in this block's entity storage. The entity is removed from the world after it is stored. Only non-player mob entities can be stored. Entities with passengers or that are passengers cannot be stored.

      no-restricted-execution - This function can't be called in restricted-execution mode.

      Throws if the storage is full, the entity is already stored, the entity cannot be serialized, or the block entity is invalid.

      Error

      InvalidBlockComponentError

      LocationInUnloadedChunkError

      LocationOutOfWorldBoundariesError

    • Beta

      Parameters

      Returns void

      Moves a stored entity from this block's entity storage to the target block's entity storage without releasing it into the world.

      no-restricted-execution - This function can't be called in restricted-execution mode.

      Throws if the entity ID is invalid or not stored by the current content pack, if the target block is invalid, in another dimension, lacks entity storage, or is full, or if the source and target blocks are the same.

      Error

      InvalidBlockComponentError

      LocationInUnloadedChunkError

      LocationOutOfWorldBoundariesError