SerenityJS
    Preparing search index...

    Block is a class the represents an instance of a block in a dimension of a world. The Block instance contains its position, dimension, type, permutation, components, traits, and nbt data. Blocks can be interacted with, destroyed, and have additional behavior added to them through traits.

     // Fetching a block from a dimension.
    const query = dimension.getBlock({ x: 0, y: 0, z: 0 });
    Index

    Constructors

    Properties

    dimension: Dimension

    The dimension the block is in.

    isTicking: boolean = false

    Whether the block is currently ticking or not. If true, this means the behaviors of the block are being processed. If false, this means the block currently isn't within the simulation distance from a player.

    position: BlockPosition

    The position of the block. (x, y, z)

    serenity: Serenity

    The serenity instance of the server.

    Accessors

    • get isLoggable(): boolean

      Whether or not the block is loggable. Depening on the value, this will determine if the block can be logged with a fluid type block.

      Returns boolean

    • get isSolid(): boolean

      Whether or not the block is solid. Depening on the value, this will determine if entities can pass through the block.

      Returns boolean

    • get permutation(): BlockPermutation

      The current permutation of the block. The permutation contains the specific state of the block, which determines the block's appearance and behavior. The permutation is a combination of the block type and the block state.

      Returns BlockPermutation

    • set permutation(permutation: BlockPermutation): void

      The current permutation of the block. The permutation contains the specific state of the block, which determines the block's appearance and behavior. The permutation is a combination of the block type and the block state.

      Parameters

      Returns void

    Methods

    • Adds a tag entry to the level storage.

      Type Parameters

      • T extends BaseTag

      Parameters

      • tag: T

        The tag entry to add.

      Returns T

      The tag entry that was added.

    • Adds a trait to the block.

      Type Parameters

      Parameters

      • trait: T

        The trait to add to the block.

      • Optionaloptions: ConstructorParameters<T>[1]

        The additional options to pass to the trait.

      Returns InstanceType<T>

      The trait instance that was added to the block.

    • Deletes a tag entry from the level storage.

      Parameters

      • name: string

        The name of the tag entry to delete.

      Returns boolean

      Whether the tag entry was deleted or not.

    • Get the time it takes to break the block.

      Parameters

      • OptionalitemStack: null | ItemStack

        The item stack used to break the block.

      Returns number

      The time it takes to break the block.

    • Gets the specified dynamic property from the block.

      Type Parameters

      Parameters

      • key: string

        The key of the dynamic property to get from the block.

      Returns null | T

      The dynamic property if it exists, otherwise null.

    • Get the a specific state of the block.

      Type Parameters

      • T

      Parameters

      • key: string

        The key of the state to get.

      Returns T

      The value of the state.

    • Get a specific tag entry from the level storage.

      Type Parameters

      • T extends BaseTag

      Parameters

      • name: string

        The name of the tag entry to get.

      Returns null | T

      The tag entry if it exists, otherwise null.

    • Whether the block has the specified dynamic property.

      Parameters

      • key: string

        The key of the dynamic property to check for.

      Returns boolean

      Whether the block has the dynamic property.

    • Check if the block has a specific state.

      Parameters

      • key: string

        The key of the state to check for.

      Returns boolean

      Whether the block has the state or not.

    • Check if the level storage has a specific tag entry.

      Parameters

      • name: string

        The name of the tag entry to check for.

      Returns boolean

      Whether the tag entry exists or not.

    • Pushes multiple tag entries to the level storage.

      Parameters

      • ...tags: BaseTag[]

        The tag entries to push.

      Returns void

    • Removes the specified dynamic from the block.

      Parameters

      • key: string

        The key of the dynamic to remove.

      Returns void

    • Sends the current level storage to all players in the dimension.

      Parameters

      • dirty: boolean = true

      Returns void

    • Sets the state of the block.

      Type Parameters

      • T

      Parameters

      • key: string

        The key of the state to set.

      • value: T

        The value of the state to set.

      Returns void

    • Set a specific tag entry in the level storage.

      Type Parameters

      • T extends BaseTag

      Parameters

      • name: string

        The name of the tag entry to set.

      • tag: T

        The tag entry to set.

      Returns void

    • Updates the block and surrounding blocks.

      Parameters

      • surrounding: boolean = false

        Whether to update the surrounding blocks.

      • source: Block = ...

        The source of the update.

      Returns void