Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Item

Module used to define items and their properties

Index

Functions

addRepairItemIds

  • addRepairItemIds(id: number | string, items: number[]): void
  • Specifies what items can be used to repair this item in the envil

    Parameters

    • id: number | string

      string or numeric item id

    • items: number[]

      array of numeric item ids to be used as repair items

    Returns void

addToCreative

  • addToCreative(id: number | string, count: number, data: number): void
  • Adds item to creative inventory

    Parameters

    • id: number | string

      string or numeric item id

    • count: number

      amount of the item to be added, generally should be 1

    • data: number

      item data

    Returns void

createArmorItem

  • createArmorItem(namedID: string, name: string, texture: TextureData, params: { armor: number; durability: number; texture: string; type: string }): void
  • Creates armor item using specified parameters

    Parameters

    • namedID: string

      string id of the item. You should register it via [[IDRegistry.genItemID]] call first

    • name: string

      item name in English. Add translations to the name using Translation module, all translation to the item and block names are applied automatically

    • texture: TextureData

      texture data used to create item

    • params: { armor: number; durability: number; texture: string; type: string }

      additional item parameters

      • armor: number

        armor protection. Default vaule is 0

      • durability: number

        armor durability, the more it is, the longer the armor will last. Default value is 1

      • texture: string

        armor model texture path (in the assets), default value is 'textures/logo.png'

      • type: string

        armor type, should be one of the 'helmet', 'chestplate', 'leggings' or 'boots'

    Returns void

createFoodItem

  • createFoodItem(namedID: string, name: string, texture: TextureData, params?: { food?: number; isTech?: boolean; stack?: number }): NativeItem
  • Creates eatable item using specified parameters

    Parameters

    • namedID: string

      string id of the item. You should register it via [[IDRegistry.genItemID]] call first

    • name: string

      item name in English. Add translations to the name using Translation module, all translation to the item and block names are applied automatically

    • texture: TextureData

      texture data used to create item

    • Optional params: { food?: number; isTech?: boolean; stack?: number }

      additional item parameters

      • Optional food?: number

        amount of hunger restored by this food. Default value is 1

      • Optional isTech?: boolean

        if true, the item will not be added to creative. Default value is false

      • Optional stack?: number

        maximum item stack size. Default value is 64

    Returns NativeItem

createFuelItem

  • createFuelItem(namedID: string, name: string, texture: TextureData, params: object): void

createItem

  • createItem(namedID: string, name: string, texture: TextureData, params?: { isTech?: boolean; stack?: number }): NativeItem
  • Creates new item using specified parameters

    Parameters

    • namedID: string

      string id of the item. You should register it via [[IDRegistry.genItemID]] call first

    • name: string

      item name in English. Add translations to the name using Translation module, all translation to the item and block names are applied automatically

    • texture: TextureData

      texture data used to create item

    • Optional params: { isTech?: boolean; stack?: number }

      additional item parameters

      • Optional isTech?: boolean

        if true, the item will not be added to creative. Default value is false

      • Optional stack?: number

        maximum item stack size. Default value is 64

    Returns NativeItem

createThrowableItem

  • createThrowableItem(namedID: string, name: string, texture: TextureData, params: any): void
  • Creates throwable item using specified parameters

    Parameters

    • namedID: string

      string id of the item. You should register it via [[IDRegistry.genItemID]] call first

    • name: string

      item name in English. Add translations to the name using Translation module, all translation to the item and block names are applied automatically

    • texture: TextureData

      texture data used to create item

    • params: any

      additional item parameters

    Returns void

describeItem

  • describeItem(numericID: number, description: { category?: any }): void
  • Applies several properties via one method call

    deprecated

    Consider using appropiate setters instead

    Parameters

    • numericID: number

      numeric item id

    • description: { category?: any }
      • Optional category?: any

    Returns void

getItemById

  • Gets NativeItem instance that can be used to apply some properties to the item

    Parameters

    • id: string

      string id of the item

    Returns NativeItem

    NativeItem instance associated with this item

getMaxDamage

  • getMaxDamage(id: number): number
  • Parameters

    • id: number

      numeric item id

    Returns number

    maximum damage value for the specified item

getMaxStack

  • getMaxStack(id: number): number
  • Parameters

    • id: number

      numeric item id

    Returns number

    maximum stack size for the specified item

getName

  • getName(id: number, data: number, encode?: any): string
  • Parameters

    • id: number

      numeric item id

    • data: number

      item data

    • Optional encode: any

      no longer supported, do not use this parameter

    Returns string

    current item name

getNumericId

  • getNumericId(id: string | number): number
  • Parameters

    • id: string | number

      string id of the item

    Returns number

    item numeric id by its string id or just returns its numeric id if input was a numeric id

isNativeItem

  • isNativeItem(id: number): boolean
  • Parameters

    • id: number

      numeric item id

    Returns boolean

    true if given item is vanilla item, false otherwise

isValid

  • isValid(id: number, data: number): boolean
  • Parameters

    • id: number

      numeric item id

    • data: number

      no longer supported, do not use this parameter

    Returns boolean

    true, if an item with such id exists, false otherwise

registerDispenseFunction

  • Registers function to be called when item is dispensed from dispenser.

    Parameters

    • nameID: string | number

      string or numeric id of the item

    • func: ItemDispensedFunction

      function that is called when such an event occures

    Returns void

registerIconOverrideFunction

registerNameOverrideFunction

  • Registers function to perform item name override

    Parameters

    • nameID: string | number
    • func: ItemNameOverrideFunction

      function that is called to override item name. Should return string to be used as new item name

    Returns void

registerNoTargetUseFunction

  • Registers function to be called when player uses item in the air (not on the block)

    Parameters

    • nameID: string | number

      string or numeric id of the item

    • func: ItemUseNoTargetFunction

      function that is called when such an event occures

    Returns void

registerThrowableFunction

  • Registers function that is called when throwable item with specified id hits block or entity

    Parameters

    • namedID: string | number

      string or numeric id of the item

    • useFunc: ProjectileHitFunction

      function that is called when such an event occures

    Returns void

registerThrowableFunctionForID

registerUseFunction

  • registerUseFunction(namedID: string | number, useFunc: ItemUseFunction): void
  • Registers function that is called when user touches some block in the world with specified item

    Parameters

    • namedID: string | number

      string or numeric id of the item

    • useFunc: ItemUseFunction

      function that is called when such an event occures

    Returns void

registerUseFunctionForID

  • registerUseFunctionForID(numericID: number, useFunc: ItemUseFunction): void

registerUsingCompleteFunction

registerUsingReleasedFunction

  • Registers function to be called when player doesn't complete using item that has maximum use time set with Item.setMaxUseDuration funciton. Vanilla bow uses this function with max use duration of 72000 ticks

    Parameters

    • nameID: string | number

      string or numeric id of the item

    • func: ItemUsingReleasedFunction

      function that is called when such an event occures

    Returns void

setCategory

  • setCategory(id: number | string, category: number): void
  • Sets item creative category

    Parameters

    • id: number | string

      string or numeric item id

    • category: number

      item category, should be one of the Native.ItemCategory values

    Returns void

setEnchantType

  • setEnchantType(id: number | string, enchant: number, value: number): void
  • Specifies how the item can be enchanted

    Parameters

    • id: number | string

      string or numeric item id

    • enchant: number

      enchant type defining whan enchants can or cannot be applied to this item, one of the Native.EnchantType

    • value: number

      quality of the enchants that are applied, the higher this value is, the better enchants you get with the same level

    Returns void

setGlint

  • setGlint(id: number | string, enabled: boolean): void
  • Sets item as glint (like enchanted tools or golden apple)

    Parameters

    • id: number | string

      string or numeric item id

    • enabled: boolean

      if true, the item will be displayed as glint item

    Returns void

setLiquidClip

  • setLiquidClip(id: number | string, enabled: boolean): void
  • Parameters

    • id: number | string

      string or numeric item id

    • enabled: boolean

    Returns void

setMaxDamage

  • setMaxDamage(id: number | string, maxdamage: number): void
  • Sets item maximum data value

    Parameters

    • id: number | string

      string or numeric item id

    • maxdamage: number

      maximum data value for the item

    Returns void

setMaxUseDuration

  • setMaxUseDuration(id: number | string, duration: number): void
  • Limits maximum use duration. This is useful to create such items as bows

    Parameters

    • id: number | string

      string or numeric item id

    • duration: number

      maximum use duration in ticks

    Returns void

setProperties

  • setProperties(id: number | string, props: string): void
  • Sets additional properties for the item, uses Minecraft mechanisms to set them. Full list of properties is currently unavailable

    Parameters

    • id: number | string

      string or numeric item id

    • props: string

      JSON string containing some of the properties

    Returns void

setPrototype

  • setPrototype(namedID: any, Prototype: any): void
  • deprecated

    Should not be used in new mods, consider using Item properties setters instead

    Parameters

    • namedID: any
    • Prototype: any

    Returns void

setStackedByData

  • setStackedByData(id: number | string, enabled: boolean): void
  • deprecated

    No longer supported

    Parameters

    • id: number | string
    • enabled: boolean

    Returns void

setToolRender

  • setToolRender(id: number | string, enabled: boolean): void
  • Specifies how the player should hold the item

    Parameters

    • id: number | string

      string or numeric item id

    • enabled: boolean

      if true, player holds the item as a tool, not as a simple item

    Returns void

setUseAnimation

  • setUseAnimation(id: number | string, animType: number): void
  • Sets animation type for the item

    Parameters

    • id: number | string

      string or numeric item id

    • animType: number

      use animation type, one of the Native.ItemAnimation values

    Returns void

Generated using TypeDoc