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

BlockBehavior

Block functions

Hierarchy

Implemented by

Index

Methods

optionalgetDrop

  • getDrop(coords: ItemUseCoordinates, block: Tile, diggingLevel: number, enchant: EnchantData, item: ItemStack, region: BlockSource): ItemInstanceArray[]
  • Method used to get drop from the block


    Parameters

    • coords: ItemUseCoordinates

      block coords

    • block: Tile

      block id and data

    • diggingLevel: number

      tool mining level

    • enchant: EnchantData

      tool enchant data

    • item: ItemStack

      item instance

    • region: BlockSource

      BlockSource object

    Returns ItemInstanceArray[]

    drop items array

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

  • onBreak(coords: Vector, block: Tile, region: BlockSource): void
  • Method called when the block is destroyed by explosion or environment.


    Parameters

    • coords: Vector

      block coords

    • block: Tile

      block id and data

    • region: BlockSource

      BlockSource object

    Returns void

optionalonClick

  • onClick(coords: ItemUseCoordinates, item: ItemStack, block: Tile, player: number): void
  • Method called when player clicks on the block.


    Parameters

    • coords: ItemUseCoordinates

      coords of the block

    • item: ItemStack

      item in player hand

    • block: Tile

      block id and data

    • player: number

      player uid

    Returns void

optionalonDestroy

  • onDestroy(coords: Vector, block: Tile, region: BlockSource, player: number): void
  • 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

  • onItemUse(coords: ItemUseCoordinates, item: ItemStack, block: Tile, player: number): void
  • 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

  • onNeighbourChange(coords: Vector, block: Tile, changeCoords: Vector, region: BlockSource): void
  • Method called on neighbour blocks updates


    Parameters

    • coords: Vector

      coords of the block

    • block: Tile

      block id and data

    • changeCoords: Vector
    • region: BlockSource

      BlockSource object

    Returns void

optionalonPlace

  • onPlace(coords: ItemUseCoordinates, item: ItemStack, block: Tile, player: number, region: BlockSource): any
  • Method used to determine where block is placed in the world


    Parameters

    • coords: ItemUseCoordinates

      click position in the world

    • item: ItemStack

      item in the player hand

    • block: Tile

      block that was touched

    • player: number

      player uid

    • region: BlockSource

      BlockSource object

    Returns any

    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