Represents a block in a dimension. A block represents a unique X, Y, and Z within a dimension and get/sets the state of the block at that location. This type was significantly updated in version 1.17.10.21.

Hierarchy

  • Block

Constructors

  • Returns Block

Properties

dimension: Dimension

Returns the dimension that the block is within.

isWaterlogged: boolean

Returns or sets whether this block has a liquid on it.

location: BlockLocation

Coordinates of the specified block.

permutation: BlockPermutation

Additional block configuration data that describes the block.

Throws

This property can throw when used.

type: BlockType

Gets the type of block.

Throws

This property can throw when used.

typeId: string
x: number

X coordinate of the block.

y: number

Y coordinate of the block.

z: number

Z coordinate of the block.

Methods

  • Parameters

    • componentName: string

      Identifier of the component. If a namespace is not specified, minecraft: is assumed.

    Returns any

    Returns the component object if it is present on the particular block.

    Remarks

    Gets additional configuration properties (a component) for specific capabilities of particular blocks - for example, an inventory component of a chest block.

    Throws

    This function can throw errors.

  • Returns string[]

    The list of tags that the block has.

    Throws

    This function can throw errors.

  • Parameters

    • tag: string

      Tag to check for.

    Returns boolean

    Returns true if the permutation of this block has the tag, else false.

    Remarks

    Checks to see if the permutation of this block has a specific tag.

    Throws

    This function can throw errors.

    Example

    check_block_tags.js

           import { world, BlockLocation } from "mojang-minecraft";

    // Fetch the block
    const block = world.getDimension("overworld").getBlock(new BlockLocation(1, 2, 3));

    console.log(`Block is dirt: ${block.hasTag("dirt")}`);
    console.log(`Block is wood: ${block.hasTag("wood")}`);
    console.log(`Block is stone: ${block.hasTag("stone")}`);
  • Parameters

    • permutation: BlockPermutation

      Permutation that contains a set of property states for the Block.

    Returns void

    Remarks

    Sets the block in the dimension to the state of the permutation.

    Throws

    This function can throw errors.

  • Parameters

    • blockType: BlockType

      Identifier of the type of block to apply - for example, minecraft:powered_repeater.

    Returns void

    Remarks

    Sets the type of block.

    Throws

    This function can throw errors.