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.

    dyanamicProperties: Map<string, JSONLikeValue> = ...

    The dynamic properties that are attached to the block. Dynamic properties is additional data that is attached to the block and will be saved with the world database. These are usaully used by traits to store additional data, but can be used by other systems as well.

    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.

    nbt: NbtMap = ...

    The nbt data that is attached to the block. Nbt data is additional data that is attached to the block and will be saved with the world database. The format of the nbt data is exactly the same as the nbt format of vanilla Minecraft. This data is used to apply additional metadata to the block. (Custom Name, Chest Open/Closed, etc.)

    position: BlockPosition

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

    serenity: Serenity

    The serenity instance of the server.

    traits: Map<string, BlockTrait> = ...

    The traits that are attached to the block. Traits add additional behavior to the block and only the trait identifier will be saved with the world database. Traits generally use components or nbt to store additional data.

    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 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.

    • 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.

    • 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.

    • Loads the block data from a block entry object.

      Parameters

      • world: World

        The world the block is in.

      • entry: BlockEntry

        The block entry object to load the block data from.

      • overwrite: boolean = true

        Whether to overwrite the block data.

      Returns void

    • Removes the specified dynamic from the block.

      Parameters

      • key: string

        The key of the dynamic to remove.

      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

    • 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