Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts

    Class in @minecraft/server

    A block at a place in the world.

    import { Block } from '@minecraft/server';
    import { world, type Block } from '@minecraft/server';
    function describe(block: Block): string {
    const { x, y, z } = block.location;
    return `${block.typeId} at ${x}, ${y}, ${z}`;
    }
    world.afterEvents.playerBreakBlock.subscribe((event) => {
    event.player.sendMessage(`You broke the block where ${describe(event.block)} now is.`);
    });
    import { world } from '@minecraft/server';
    function describe(block) {
    const { x, y, z } = block.location;
    return `${block.typeId} at ${x}, ${y}, ${z}`;
    }
    world.afterEvents.playerBreakBlock.subscribe((event) => {
    event.player.sendMessage(`You broke the block where ${describe(event.block)} now is.`);
    });

    read-only

    readonly typeId: string;

    Its identifier, as minecraft:stone.

    read-only

    readonly type: { readonly id: string };

    read-only

    readonly permutation: BlockPermutation;

    Its type and states, read from the world when first wanted.

    read-only

    readonly location: Vector3;
    Types

    read-only

    readonly x: number;

    read-only

    readonly y: number;

    read-only

    readonly z: number;

    read-only

    readonly dimension: Dimension;

    read-only

    readonly isAir: boolean;

    read-only

    readonly isLiquid: boolean;

    Whether it’s water or lava.

    read-only

    readonly localizationKey: string;

    The block’s name key in the language files, as tile.stone.name.

    read-only

    readonly isValid: boolean;

    False once its chunk isn’t loaded.

    read-only

    readonly isWaterlogged: boolean;

    Whether it’s waterlogged.

    setType(blockType: string | { id: string }): void;

    Sets the block to a type’s default state.

    Parameters
    blockType
    string | { id: string }
    setPermutation(permutation: BlockPermutation): void;
    Parameters
    permutation
    BlockPermutation
    matches(blockName: string, states?: Record<string, boolean | number | string>): boolean;

    Whether it’s this block, with these states if given.

    Parameters
    blockName
    string
    statesoptional
    Record<string, boolean | number | string>
    Returns
    boolean
    offset(offset: Vector3): Block | undefined;

    The block this far away, or undefined if its chunk isn’t loaded.

    Parameters
    offset
    Vector3
    Returns
    Block | undefined
    Types
    above(steps?: number): Block | undefined;

    The block steps up, 1 by default.

    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    below(steps?: number): Block | undefined;
    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    north(steps?: number): Block | undefined;

    Towards -z.

    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    south(steps?: number): Block | undefined;

    Towards +z.

    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    east(steps?: number): Block | undefined;

    Towards +x.

    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    west(steps?: number): Block | undefined;

    Towards -x.

    Parameters
    stepsoptional
    number
    Returns
    Block | undefined
    center(): Vector3;

    The middle of the block.

    Returns
    Vector3
    Types
    bottomCenter(): Vector3;

    The middle of the block’s bottom face.

    Returns
    Vector3
    Types
    setWaterlogged(isWaterlogged: boolean): void;

    Waterlogs the block, or drains it.

    Parameters
    isWaterlogged
    boolean
    getComponent<T extends string>(componentId: T): BlockComponentReturnType<T> | undefined;

    A block component by name; undefined if absent (Basalt backs none yet).

    Parameters
    componentId
    T
    Returns
    BlockComponentReturnType<T> | undefined
    getComponents(): BlockComponent[];

    Every component on the block.

    Returns
    BlockComponent[]
    hasComponent(componentId: string): boolean;

    Whether it has the component.

    Parameters
    componentId
    string
    Returns
    boolean
    getTags(): string[];

    The block type’s tags, as minecraft:dirt.

    Returns
    string[]
    hasTag(tag: string): boolean;

    Whether it has this block tag.

    Parameters
    tag
    string
    Returns
    boolean
    getItemStack(amount?: number, withData?: boolean): ItemStack | undefined;

    An item stack of the block, if it has one.

    Parameters
    amountoptional
    number
    withDataoptional
    boolean
    Returns
    ItemStack | undefined
    getRedstonePower(): number | undefined;

    Its redstone power, or undefined if it isn’t a redstone component.

    Returns
    number | undefined
    getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;

    A dynamic property kept in the block’s NBT. It’s saved with the world, moves with a piston, and goes when the block is broken or replaced. Air keeps nothing.

    Parameters
    identifier
    string
    Returns
    boolean | number | string | Vector3 | undefined
    Types
    setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;

    Sets a property on the block, or removes it with undefined.

    Parameters
    identifier
    string
    valueoptional
    boolean | number | string | Vector3
    Types
    setDynamicProperties(values: Record<string, boolean | number | string | Vector3>): void;
    Parameters
    values
    Record<string, boolean | number | string | Vector3>
    Types
    getDynamicPropertyIds(): string[];
    Returns
    string[]
    getDynamicPropertyTotalByteCount(): number;
    Returns
    number
    clearDynamicProperties(): void;
    getLightLevel(): number;

    The light reaching it.

    Returns
    number
    getSkyLightLevel(): number;

    The skylight reaching it.

    Returns
    number
    getParts(): Block[] | undefined;

    The sub-blocks of a multi-block, or undefined.

    Returns
    Block[] | undefined
    canContainLiquid(liquidType: LiquidType): boolean;

    Whether the block can hold this liquid.

    Parameters
    liquidType
    LiquidType
    Returns
    boolean
    canBeDestroyedByLiquidSpread(liquidType: LiquidType): boolean;

    Whether spreading liquid would break it.

    Parameters
    liquidType
    LiquidType
    Returns
    boolean
    isLiquidBlocking(liquidType: LiquidType): boolean;

    Whether it stops this liquid.

    Parameters
    liquidType
    LiquidType
    Returns
    boolean
    liquidCanFlowFromDirection(liquidType: LiquidType, flowDirection: Direction): boolean;

    Whether liquid may flow in from a direction.

    Parameters
    liquidType
    LiquidType
    flowDirection
    Direction
    Returns
    boolean
    liquidSpreadCausesSpawn(liquidType: LiquidType): boolean;

    Whether liquid spreading onto it spawns the block’s drop.

    Parameters
    liquidType
    LiquidType
    Returns
    boolean

    Entity.getBlockStandingOn, Entity.getAllBlocksStandingOn, Dimension.getBlock, Dimension.getBlockAbove, Dimension.getBlockBelow, Dimension.getTopmostBlock, PlayerBreakBlockBeforeEvent.block, PlayerBreakBlockAfterEvent.block, PlayerPlaceBlockBeforeEvent.block, PlayerPlaceBlockAfterEvent.block, PlayerInteractWithBlockAfterEvent.block, BlockExplodeAfterEvent.block, ExplosionBeforeEvent.getImpactedBlocks, ExplosionBeforeEvent.setImpactedBlocks, ExplosionAfterEvent.getImpactedBlocks, BlockHitInformation.block, ButtonPushAfterEvent.block, LeverActionAfterEvent.block, PistonActivateAfterEvent.block, PressurePlatePushAfterEvent.block, PressurePlatePopAfterEvent.block, TargetBlockHitAfterEvent.block, TripWireTripAfterEvent.block, BlockComponent.block and 9 more