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

ItemRegistry

Module for advanced item definition.

Index

Functions

addArmorMaterial

  • Creates new armor material with specified parameters.


    Parameters

    • name: string

      new (or existing) material name

    • material: ArmorMaterial

      material properties

    Returns void

addToolMaterial

  • Registers new tool material in ToolAPI. Some of the tool materials are already registered: wood, stone, iron, golden and diamond


    Parameters

    • name: string

      new (or existing) material name

    • material: ToolMaterial

      material properties

    Returns void

createArmor

  • createArmor(stringID: string, params: ArmorDescription): ItemArmor
  • Creates armor item from given description. Automatically generates item id from given string id.


    Parameters

    • stringID: string

      item string id

    • params: ArmorDescription

      item and armor parameters

    Returns ItemArmor

    item class instance

createFood

  • createFood(stringID: string, params: FoodDescription): ItemFood
  • Parameters

    • stringID: string
    • params: FoodDescription

    Returns ItemFood

createItem

  • createItem(stringID: string, params: ItemDescription): ItemBase
  • Creates item from given description. Automatically generates item id from given string id.


    Parameters

    • stringID: string

      item string id.

    • params: ItemDescription

      item description

    Returns ItemBase

    item class instance

createTool

  • Creates tool item and registers it in ToolAPI. Automatically generates item id from given string id.


    Parameters

    • stringID: string

      item string id

    • params: ToolDescription

      object with item parameters and tool material

    • optionaltoolData: ToolParams

      tool parameters and functions

    Returns ItemTool

    item class instance

getArmorMaterial


  • Parameters

    • name: string

    Returns ArmorMaterial

    armor material by name.

getInstanceOf

  • getInstanceOf(itemID: string | number): Nullable<ItemBase>

  • Parameters

    • itemID: string | number

    Returns Nullable<ItemBase>

    instance of item class if the item was added by BlockEngine, null otherwise.

getItemRarityColor

  • getItemRarityColor(itemID: number): string

  • Parameters

    • itemID: number

    Returns string

    chat color for rare items.

getRarity

  • getRarity(itemID: number): number

  • Parameters

    • itemID: number

    Returns number

    EnumRarity value for the item.

getRarityColor

  • getRarityColor(rarity: number): string

  • Parameters

    • rarity: number

      one of EnumRarity values

    Returns string

    chat color for rarity.

getToolMaterial


  • Parameters

    • name: string

    Returns ToolMaterial

    tool material by name registered in ToolAPI.

getType

  • getType(id: number): block | item

  • Parameters

    • id: number

    Returns block | item

    item type

getVanillaStringID

  • getVanillaStringID(id: number): string

  • Parameters

    • id: number

    Returns string

    item string id in the game (in snake_case format).

isBlock

  • isBlock(id: number): boolean

  • Parameters

    • id: number

      block id

    Returns boolean

    true if a block identifier was given, false otherwise.

isItem

  • isItem(id: number): boolean

  • Parameters

    • id: number

      item id

    Returns boolean

    true if an item identifier was given, false otherwise.

isVanilla

  • isVanilla(id: number): boolean

  • Parameters

    • id: number

    Returns boolean

    whether the item is an item from the original game.

registerItem

  • Registers item instance and it's functions.


    Parameters

    • itemInstance: ItemBase

      item class instance

    Returns ItemBase

    item instance back

registerItemFuncs

  • registerItemFuncs(itemID: string | number, itemFuncs: ItemBehavior): void
  • Registers all item functions from given object.


    Parameters

    • itemID: string | number
    • itemFuncs: ItemBehavior

      object which implements ItemBehavior interface

    Returns void

setRarity

  • setRarity(id: string | number, rarity: number, preventNameOverride?: boolean): void
  • Sets item rarity.


    Parameters

    • id: string | number

      item id

    • rarity: number

      one of EnumRarity values

    • optionalpreventNameOverride: boolean

      prevent registration of name override function

    Returns void