Перейти к основному содержанию

BlockBehavior

Block functions

Hierarchy

Implemented by

Index

Methods

optionalgetDrop

optionalonAnimateTick

  • onAnimateTick(x: number, y: number, z: number, id: number, data: number): void
  • Method which enables animation update callback for the block and called on it. Occurs more often then random tick callback and only if the block is not far away from player.


    Parameters

    • x: number

      x coord of the block

    • y: number

      y coord of the block

    • z: number

      z coord of the block

    • id: number

      block id

    • data: number

      block data

    Returns void

optionalonBreak

  • Method called when the block is destroyed by explosion or environment.


    Parameters

    Returns void

optionalonClick

  • Method called when player clicks on the block.


    Parameters

    Returns void

optionalonDestroy

  • Method called when block is destroyed by player


    Parameters

    • coords: Vector

      block coords

    • block: Tile

      block id and data

    • region: BlockSource

      BlockSource object

    • player: number

      player uid

    Returns void

optionalonDispense

  • Method called when the item was dispensed.


    Parameters

    • coords: ItemUseCoordinates

      full coords object, where the main coords are the position of the dispenser block, relative ones are the position of the block to which the dispenser is pointed, and vec are the coords for the item to be dropped at

    • item: ItemStack

      item that was dispensed

    • region: WorldRegion

      BlockSource object

    • slot: number

      numeric id of the slot from which the item was dispensed

    Returns void

optionalonEntityInside

  • onEntityInside(coords: Vector, block: Tile, entity: number): void
  • Method called on entity being inside the block. Can be used to create portals.


    Parameters

    • coords: Vector

      coords of the block

    • block: Tile

      block id and data

    • entity: number

      entity uid

    Returns void

optionalonEntityStepOn

  • onEntityStepOn(coords: Vector, block: Tile, entity: number): void
  • Method called on entity step on the block.


    Parameters

    • coords: Vector

      coords of the block

    • block: Tile

      block id and data

    • entity: number

      entity uid

    Returns void

optionalonItemUse

  • Method called when player clicks on block with the item.


    Parameters

    • coords: ItemUseCoordinates

      object of touch coordinates with side information and relative coordinates set.

    • item: ItemStack

      item that was in the player's hand when he touched the block

    • block: Tile

      block that was touched

    • player: number

      player entity uID

    Returns void

optionalonNameOverride

  • onNameOverride(item: ItemInstance, translation: string, name: string): string
  • Method to get displayed item name.


    Parameters

    • item: ItemInstance

      item stack information

    • translation: string

      translated item name

    • name: string

      original item name

    Returns string

    new name that will be displayed

optionalonNeighbourChange

  • Method called on neighbour blocks updates


    Parameters

    Returns void

optionalonPlace

  • Method used to determine where block is placed in the world


    Parameters

    Returns void | Vector

    coordinates where to actually place the block, or void for default placement

optionalonRandomTick

  • onRandomTick(x: number, y: number, z: number, block: Tile, region: BlockSource): void
  • Method which enables random tick callback for the block and called on it.


    Parameters

    • x: number

      x coord of the block

    • y: number

      y coord of the block

    • z: number

      z coord of the block

    • block: Tile

      block id and data

    • region: BlockSource

      BlockSource object

    Returns void