SerenityJS
    Preparing search index...

    Class BlockType<T>

    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"

    Type Parameters

    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: T

    The identifier of the block type.

    liquid: boolean

    Whether the block type is liquid.

    loggable: boolean

    Whether the block type is loggable.

    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.

    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

    Methods

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

    • Gets the network definition of the block type, which is used to send the block type to the client.

      Returns NetworkBlockTypeDefinition

      The network block type definition.

    • Check if the block type has a tag.

      Parameters

      • tag: string

        The tag to check.

      Returns boolean

      True if the block type has the tag, false otherwise.

    • Checks if the block type requires an axe to be mined.

      Returns boolean

      True if the block type requires an axe, false otherwise.

      This method evaluates if the block type has the "*_axe_diggable" tag.

    • Checks if the block type requires a hoe to be mined.

      Returns boolean

      True if the block type requires a hoe, false otherwise.

      This method evaluates if the block type has the "*_hoe_diggable" tag.

    • Checks if the block type requires a pickaxe to be mined.

      Returns boolean

      True if the block type requires a pickaxe, false otherwise.

      This method evaluates if the block type has the "*_pick_diggable" tag.

    • Checks if the block type requires a shovel to be mined.

      Returns boolean

      True if the block type requires a shovel, false otherwise.

      This method evaluates if the block type has the "*_shovel_diggable" tag.

    • Checks if the block type requires a sword to be mined.

      Returns boolean

      True if the block type requires a sword, false otherwise.

      This method evaluates if the block type has the "*_sword_diggable" tag.