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

ItemBehavior

Item functions

Hierarchy

Implemented by

Index

Methods

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

optionalonIconOverride

  • onIconOverride(item: ItemInstance, isModUi: boolean): TextureData
  • Method to override texture for the item icon.


    Parameters

    • item: ItemInstance

      item stack information.

    • isModUi: boolean

      whether icon override is working in mod ui or in vanilla one

    Returns TextureData

    texture data which will be used for the item icon.

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

optionalonNoTargetUse

  • onNoTargetUse(item: ItemStack, player: number): void
  • Method called when player uses item in the air.


    Parameters

    • item: ItemStack

      item that was in the player's hand when the event occurred

    • player: number

      entity uid of the player that used item

    Returns void

optionalonUsingComplete

  • onUsingComplete(item: ItemStack, player: number): void
  • Method called when player completes using item that has maximum use time.


    Parameters

    • item: ItemStack

      item that was in the player's hand when the event occurred

    • player: number

      entity uid of the player that used item

    Returns void

optionalonUsingReleased

  • onUsingReleased(item: ItemStack, ticks: number, player: number): void
  • Method called when player doesn't complete using item that has maximum use time.


    Parameters

    • item: ItemStack

      item that was in the player's hand when the event occurred

    • ticks: number

      amount of ticks left to the specified max use duration value

    • player: number

      entity uid of the player that used item

    Returns void