Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace ToolAPI

Module used to manage block and tools material and create tools with all required properties

Index

Functions

addBlockMaterial

  • addBlockMaterial(name: string, breakingMultiplier: number): void
  • Creates new material with specified breaking speed multiplier. Some of the materials are already registered:

    stone - used for pickaxes

    wood - used for axes

    dirt - used for shovels

    plant - used for all plants (no vanilla tool supports this material)

    fibre - used for swords (to break web)

    cobweb - currently not used

    unbreaking - used for unbreaking blocks, liquids, end portal, etc.

    Parameters

    • name: string

      new (or existing) material name

    • breakingMultiplier: number

      multiplier used to calculate block breaking speed. 1 is a default value for dirt and 3 is a default value for stone

    Returns void

addToolMaterial

  • addToolMaterial(name: string, material: ToolMaterial): void
  • Creates new tool material with specified parameters. Some of the tool materials are already registered:

    wood - used for wooden instruments

    stone - used for stone instruments

    iron - used for iron instruments

    golden - used for golden instruments

    diamond - used for diamond instruments

    Parameters

    • name: string

      new (or existing) material name

    • material: ToolMaterial

      parameters describing material properties

    Returns void

dropExpOrbs

  • dropExpOrbs(x: number, y: number, z: number, value: number): void
  • Spawns experience orbs on the specified coordinate

    Parameters

    • x: number
    • y: number
    • z: number
    • value: number

      amount of experience to spawn

    Returns void

dropOreExp

  • dropOreExp(coords: Vector, minVal: any, maxVal: any, modifier: any): void
  • Spawns random amount of experience on the specified block coordinates

    Parameters

    • coords: Vector

      block coordinates

    • minVal: any

      minimum amount of orbs to be spawned

    • maxVal: any

      maximum amount of orbs to be spawned

    • modifier: any

      additional experiences, usually passed from ToolAPI.EnchantData.experience field

    Returns void

fortuneDropModifier

getBlockData

  • getBlockData(blockID: number): BlockData | undefined
  • Parameters

    • blockID: number

      numeric tile id

    Returns BlockData | undefined

    object containing ToolAPI block data or undefined if no block data was specified for this block

getBlockDestroyLevel

  • getBlockDestroyLevel(blockID: any): number
  • Parameters

    • blockID: any

      numeric tile id

    Returns number

    destroy level of the block with specified id or 0, if no block data was specified for this block

getBlockMaterial

  • Parameters

    • blockID: any

      numeric tile id

    Returns BlockMaterial | null

    object containing block material information or null, if no block data was specified for this block

getBlockMaterialName

  • getBlockMaterialName(blockID: number): string | null

getCarriedToolData

  • getCarriedToolData(): void

getCarriedToolLevel

  • getCarriedToolLevel(): void
  • Returns void

    carried tool's breaking level or 0 if no tool data was provided

getDestroyTimeViaTool

  • Calculates destroy time for the block that is being broken with specefied tool at the specified coords. Used mostly by Core Engine to apply break time

    Parameters

    • fullBlock: Tile
    • toolItem: ItemInstance
    • coords: ItemUseCoordinates
    • Optional ignoreNative: boolean

      if block and item are native items, and this parameter is set to true, all the calculations will still be performed

    Returns void

getEnchantExtraData

  • Parameters

    • Optional extra: ItemExtraData

      item extra instance, if not specified, method uses carried item's extra

    Returns EnchantData

    enchant data object, containing enchants used for blocks destroy speeed calculations

getToolData

getToolLevel

  • getToolLevel(itemID: number): number
  • Parameters

    • itemID: number

      numeric item id

    Returns number

    tool's breaking level or 0 if no tool data was provided

getToolLevelViaBlock

  • getToolLevelViaBlock(itemID: number, blockID: number): void
  • Parameters

    • itemID: number

      numeric item id

    • blockID: number

      numeric tile id

    Returns void

    digging level if specified tool can mine specified block, 0 if data for the tool or for the block was not specified or if specified tool cannot mine specified block

refresh

  • refresh(): void

registerBlockDiggingLevel

  • registerBlockDiggingLevel(uid: number, level: number): void
  • Sets digging level for block. If digging level of tool is higher then block's one, the block is dropped

    Parameters

    • uid: number

      numeric tile id

    • level: number

      block's digging level

    Returns void

registerBlockMaterial

  • registerBlockMaterial(uid: number, materialName: string, level?: number, isNative?: boolean): void
  • Registers material and digging level for the specified block

    Parameters

    • uid: number

      numeric tile id

    • materialName: string

      material name

    • Optional level: number

      block's digging level

    • Optional isNative: boolean

      used to mark vanilla blocks data. Generally used within Core Engine code and should not be used within mods until you really know what you're doing

    Returns void

registerBlockMaterialAsArray

  • registerBlockMaterialAsArray(materialName: string, UIDs: number[], isNative: boolean): void
  • Registers material and digging level for the specified blocks

    Parameters

    • materialName: string

      material name

    • UIDs: number[]

      an array of numeric tiles ids

    • isNative: boolean

      used to mark vanilla blocks data. Generally used within Core Engine code and should not be used within mods until you really know what you're doing

    Returns void

registerSword

  • Registers item as a sword

    Parameters

    • id: number

      numeric item id

    • toolMaterial: string | ToolMaterial

      registered tool material name or tool material object used to register the sword

    • Optional params: ToolParams

      additional tool parameters

    Returns void

registerTool

  • registerTool(id: number, toolMaterial: string | ToolMaterial, blockMaterials: string[], params?: ToolParams): void
  • Registers item as a tool

    Parameters

    • id: number

      numeric item id

    • toolMaterial: string | ToolMaterial

      registered tool material name or tool material object used to register the tool

    • blockMaterials: string[]

      block material names that can be broken with this instrument. For example, you can use ["stone"] for the pickaxes

    • Optional params: ToolParams

      additional tool parameters

    Returns void

resetEngine

  • resetEngine(): void

Generated using TypeDoc