SerenityJS
    Preparing search index...

    Class CustomBlockType

    BlockType represents a block type in the game, which hold all possible permutations the block can have.

    Example Usage

    import { BlockType, BlockIdentifier } from "@serenityjs/block"

    // Get the block type for dirt
    const dirtType = BlockType.get(BlockIdentifier.Dirt)

    // Get the identifier of the type
    dirtType.identifier // Expected to be "minecraft:dirt"

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    air: boolean

    Whether the block type is air.

    drops: ItemDrop[] = []

    The default item drops of the block type.

    identifier: keyof BlockState

    The identifier of the block type.

    liquid: boolean

    Whether the block type is liquid.

    loggable: boolean

    Whether the block type is loggable.

    networkId: number = ++CustomBlockType.networkId

    The network ID of the custom block type.

    permutations: BlockPermutation<keyof BlockState>[] = []

    The default permutations of the block type.

    The nbt properties definition of the block type. This contains the vanilla component definitions.

    solid: boolean

    Whether the block type is solid.

    states: string[] = []

    The state values of the block type.

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

    The traitsthat are bound to the block type. These traits are used to define custom behavior for the block type.

    networkId: number = 10000
    types: Map<string, BlockType<keyof BlockState>> = ...

    A collective registry of all block types.

    Accessors

    • get components(): BlockTypeComponentCollection

      The vanilla components of the block permutation. (hardness, friction, lighting, etc.) These components are active on the client-end when the query condition is met. These components will be used gobally for all permutations, unless a permutation has a definition that overrides it.

      Returns BlockTypeComponentCollection

    • get isComponentBased(): boolean

      Whether the block type is component based. This is determined by the presence of any components in the block type.

      Returns boolean

    Methods

    • Creates a new block permutation for the block type.

      Parameters

      • state: GenericBlockState

        The state of the block. { [key: string]: string | number | boolean }

      • Optionalcomponents: Partial<BlockTypeComponentCollection>

        The components of the block permutation.

      • Optionalquery: string

        The molang query for the block permutation. If not provided, the query will be generated from the state.

      Returns BlockPermutation

      The block permutation that was created using the state definition.

    • Checks if the block type is destructible with an axe. This applies a speed boost to the axe when mining the block.

      Returns boolean

      True if the block type is destructible with an axe, false otherwise.

      This method evaluates if the block type has the "minecraft:is_axe_item_destructible" tag.

    • Checks if the block type is destructible with a hoe. This applies a speed boost to the hoe when mining the block.

      Returns boolean

      True if the block type is destructible with a hoe, false

      This method evaluates if the block type has the "minecraft:is_hoe_item_destructible" tag.

    • Checks if the block type is destructible with a pickaxe. This applies a speed boost to the pickaxe when mining the block.

      Returns boolean

      True if the block type is destructible with a pickaxe, false otherwise.

      This method evaluates if the block type has the "minecraft:is_pickaxe_item_destructible" tag.

    • Checks if the block type is destructible with a shovel. This applies a speed boost to the shovel when mining the block.

      Returns boolean

      True if the block type is destructible with a shovel, false otherwise.

      This method evaluates if the block type has the "minecraft:is_shovel_item_destructible" tag.

    • Checks if the block type is destructible with a sword. This applies a speed boost to the sword when mining the block.

      Returns boolean

      True if the block type is destructible with a sword, false otherwise.

      This method evaluates if the block type has the "minecraft:is_sword_item_destructible" tag.