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

ToolAPI.ToolParams

Object containing additional parameters and functions used by Core Engine to work with the tool.

Hierarchy

Index

Properties

optionalblockMaterials

blockMaterials?: {}

List of block material names that can be broken by this instrument. Defined by ToolAPI.registerTool,


Type declaration

  • [key string]: boolean

optionalbrokenId

brokenId?: number = 0

Numeric ID of the item that replaces tool item when it's broken. By default the tool disappears.

optionalcalcDestroyTime

calcDestroyTime?: (tool: ItemInstance, coords: ItemUseCoordinates, block: Tile, timeData: { base: number; devider: number; modifier: number }, defaultTime: number, enchantData?: EnchantData) => number

Function used to recalculate block destroy time based on some custom logic.


Type declaration

    • Parameters

      • tool: ItemInstance

        Tool item.

      • coords: ItemUseCoordinates

        Coordinates where the block is being broken.

      • block: Tile

        Block that is being broken.

      • timeData: { base: number; devider: number; modifier: number }

        Some time properties that can be used to calculate destroy time for the tool and block.

        • base: number

          Base destroy time of the block.

        • devider: number

          Tool material devider.

        • modifier: number

          Divider applied due to efficiency enchantment.

      • defaultTime: number

        Default block destroy time, calculated as base / divider / modifier.

      • optionalenchantData: EnchantData

        Tool's enchant data.

      Returns number

optionaldamage

damage?: number = 0 // 4 in case of sword starting with 2.4.0b122o1

Base damage of the instrument, is added to the material damage to calculate the tool's final damage.

optionalisNative
internal

isNative?: boolean

If true, the tool is vanilla Minecraft tool. Generally used within Core Engine code and should not be used within mods until you really know what you're doing.

optionalisWeapon

isWeapon?: boolean

If true, breaking blocks with this tool makes it break 2x faster, otherwise attacking mobs breaks tool 2x faster.

optionalmodifyEnchant

modifyEnchant?: (enchantData: EnchantData, item: ItemInstance, coords?: ItemUseCoordinates, block?: Tile) => void

Function that is used to change enchant data object before all the calculations. Can be used to add some enchantment properties, such as silk touch, efficiency, unbreaking or fortune.


Type declaration

optionalonAttack

onAttack?: (item: ItemInstance, victim: number, attacker: number) => boolean

Function that is called when players attacks some entity with the tool.

@returns

true if default damage should not be applied to the instrument, false otherwise.


Type declaration

    • (item: ItemInstance, victim: number, attacker: number): boolean
    • Parameters

      • item: ItemInstance

        Tool item.

      • victim: number

        Unique numeric ID of the entity that is attacked.

      • attacker: number

        Entity UID of the player that attacked victim.

      Returns boolean

optionalonBroke

onBroke?: (item: ItemInstance) => boolean

Function that is called when the instrument is broken.

@returns

true if default breaking behavior (replacing by brokenId item) should not be applied.


Type declaration

optionalonDestroy

onDestroy?: (item: ItemInstance, coords: ItemUseCoordinates, block: Tile, player: number) => boolean

Function that is called when the block is destroyed.

@returns

true if default damage should not be applied to the instrument, false otherwise.


Type declaration

optionalonMineBlock

onMineBlock?: (coords: ItemUseCoordinates, carried: ItemInstance, fullTile: Tile, blockSource: BlockSource, player: number) => void

Function that is called when the block that has a destroy function is destroyed.


Type declaration

optionaltoolMaterial

toolMaterial?: ToolMaterial

Properties of the tool material. Defined by ToolAPI.registerTool,