Item
Index
Interfaces
Variables
Functions
- addCreativeGroup
- addRepairItemIds
- addToCreative
- createArmorItem
- createFoodItem
- createFuelItem
- createItem
- createThrowableItem
- describeItem
- getArmorValue
- getItemById
- getMaxDamage
- getMaxStack
- getName
- getNumericId
- invokeItemUseNoTarget
- invokeItemUseOn
- isNativeItem
- isValid
- registerDispenseFunction
- registerIconOverrideFunction
- registerNameOverrideFunction
- registerNoTargetUseFunction
- registerThrowableFunction
- registerThrowableFunctionForID
- registerUseFunction
- registerUseFunctionForID
- registerUsingCompleteFunction
- registerUsingReleasedFunction
- setAllowedInOffhand
- setArmorDamageable
- setCategory
- setEnchantType
- setExplodable
- setFireResistant
- setGlint
- setLiquidClip
- setMaxDamage
- setMaxUseDuration
- setProperties
- setPrototype
- setShouldDespawn
- setStackedByData
- setToolRender
- setUseAnimation
Interfaces
ArmorParams
Object used in Item.createArmorItem method to specify general armor item parameters.
optionalarmor
Armor protection.
optionaldurability
Armor durability, the more it is, the more hits the armor will resist.
optionalisTech
If true
, the item will not be added to creative.
optionalknockbackResist
Knockback resistance, that the player will have when wearing the following armor. It must be value from 0 (no knockback resistance) to 1 (full knockback resistance).
optionaltexture
Relative path to the armor model texture from the mod assets directory.
type
Armor type, should be one of the helmet
, chestplate
, leggings
or boots
.
FoodParams
Object used in Item.createFoodItem method to specify general food item parameters.
optionalcategory
optionalfood
Amount of hunger restored by this food in halfs.
optionalisTech
If true, the item will not be added to creative.
optionalstack
Maximum item in stack size.
ItemLegacyPrototype
Once upon a time, a new way of registering items, however, in current state, either does not work or is undesirable to use. *
optionalgetArmorFuncs
Type declaration
Parameters
item: null
Returns IArmorJSCallback
optionalgetCategory
Type declaration
Parameters
item: null
Returns number
optionalgetDefineParams
Type declaration
Parameters
item: null
Returns ItemParams | FoodParams | ArmorParams
optionalgetEnchant
Type declaration
Parameters
item: null
Returns number
optionalgetMaxDamage
Type declaration
Parameters
item: null
Returns number
optionalgetMaxUseDuration
Type declaration
Parameters
item: null
Returns number
getName
Type declaration
Parameters
item: null
Returns string
optionalgetProperties
Cannot be used, because of properties should be passed as string, but properties here internally depends on object.
Type declaration
Parameters
item: null
Returns object
getTexture
Type declaration
Parameters
item: null
Returns TextureData
optionalgetToolMaterial
Type declaration
Parameters
item: null
Returns string | ToolMaterial
optionalgetToolPrototype
Type declaration
Parameters
item: null
Returns ToolParams
optionalgetToolTarget
Type declaration
Parameters
item: null
Returns string[]
optionalgetUseAnimation
Type declaration
Parameters
item: null
Returns number
optionalinit
Type declaration
Returns void
optionalisEnchanted
Type declaration
Parameters
item: null
Returns boolean
optionalisStackedByData
Type declaration
Parameters
item: null
Returns boolean
optionalisToolRender
Type declaration
Parameters
item: null
Returns boolean
optionalonThrowableImpact
Type declaration
Parameters
projectile: number
item: ItemInstance
target: ProjectileHitTarget
Returns void
optionalonTick
Unused at all.
Type declaration
Parameters
item: null
Returns void
optionalonUsed
Type declaration
Parameters
coords: Vector
item: ItemInstance
block: Tile
Returns void
type
ItemParams
Object used in Item.createItem and Item.createThrowableItem methods to specify general item parameters.
optionalcategory
optionalisTech
If true, the item will not be added to creative.
optionalstack
Maximum item in stack size.
NativeItem
Class representing item used to set it's properties.
addRepairItem
Parameters
id: number
Returns void
addRepairItems
Parameters
id: number[]
Returns void
setAllowedInOffhand
Parameters
allowed: boolean
Returns void
setArmorDamageable
Parameters
damageable: boolean
Returns void
setCreativeCategory
Parameters
category: number
Returns void
setEnchantType
Parameters
type: number
Returns void
setEnchantability
Parameters
enchant: number
value: number
Returns void
setGlint
Parameters
glint: boolean
Returns void
setHandEquipped
Parameters
equipped: boolean
Returns void
setLiquidClip
Parameters
clip: boolean
Returns void
setMaxDamage
Parameters
maxDamage: number
Returns void
setMaxStackSize
Parameters
maxStack: number
Returns void
setMaxUseDuration
Parameters
duration: number
Returns void
setProperties
Parameters
props: string
Returns void
setStackedByData
Parameters
stacked: boolean
Returns void
setUseAnimation
Parameters
animation: number
Returns void
TextureData
Represents item texture data. For example, if /items-opaque folder
contains file nugget_iron_0.png, you should pass "nugget_iron"
as
texture name and 0
as texture index. _N suffix can be omitted, but it is
generally not recommended.
optionaldata
Texture index defined by _N texture suffix.
optionalmeta
name
Texture name, name of the file stored in the /items-opaque asset folder without extension and _N suffixes.
Variables
consticonOverrideFunctionsinternal
All items icon override functions object.
Type declaration
[key number]: Callback.ItemIconOverrideFunction
constnameOverrideFunctionsinternal
All items name override functions object.
Type declaration
[key number]: Callback.ItemNameOverrideFunction
Functions
addCreativeGroup
Creates group of creative items.
Parameters
name: string
name of group
displayedName: string
name of group in game
ids: number[]
array of items in group
Returns void
addRepairItemIds
Specifies what items can be used to repair this item in the anvil.
Parameters
id: string | number
string or numeric item ID
items: number[]
array of numeric item IDs to be used as repair items
Returns void
addToCreative
Adds item to creative inventory.
Parameters
id: string | number
string or numeric item ID
count: number
amount of the item to be added, generally should be 1
data: number
item data
optionalextra: ItemExtraData
Returns void
createArmorItem
Creates armor item using specified parameters.
Parameters
nameID: 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: ArmorParams
general armor item parameters object, the armor type there is required
Returns NativeItem
createFoodItem
Creates eatable item using specified parameters.
Parameters
nameID: 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
optionalparams: FoodParams
additional item parameters
Returns NativeItem
createFuelItem
Parameters
nameID: string
name: string
texture: TextureData
optionalparams: ItemParams
Returns void
createItem
Creates new item using specified parameters.
Parameters
nameID: 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
optionalparams: ItemParams
additional item parameters
Returns NativeItem
createThrowableItem
Creates throwable item using specified parameters.
Parameters
nameID: 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
optionalparams: ItemParams
additional item parameters
Returns NativeItem
describeItem
Applies several properties via one method call.
Parameters
numericID: number
numeric item ID
description: object
Returns void
getArmorValue
Natural armor points, that also is displayed above hotbar.
Parameters
id: number
numeric item ID
Returns number
Natural armor half points.
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
Parameters
id: number
numeric item ID
Returns number
Maximum damage value for the specified item.
getMaxStack
Parameters
id: number
numeric item ID
Returns number
Maximum stack size for the specified item.
getName
Parameters
id: number
numeric item ID
data: number
item data
Returns string
Current item name.
getNumericId
Parameters
id: string | number
string ID of the item
Returns number
Item numeric ID by it's string ID or just returns it's numeric ID if input was a numeric ID.
invokeItemUseNoTarget
- internal
Invoke click on the block in world without target.
Parameters
item: ItemInstance
item which used on the block
noModCallback: boolean
if
true
, mod ItemUse callback will be not executed
Returns void
invokeItemUseOn
- internal
Invoke click on the block in world.
Parameters
coords: ItemUseCoordinates
coords of click on the block
item: ItemInstance
item which used on the block
noModCallback: boolean
if
true
, mod ItemUse callback will be not executedentity: number
player which clicked on the block
Returns void
isNativeItem
Parameters
id: number
numeric item ID
Returns boolean
true
if given item is vanilla item,false
otherwise.
isValid
Parameters
id: number
numeric item ID
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 occurs
Returns void
registerIconOverrideFunction
Registers item ID as requiring item icon override and registers function to perform such an override.
Parameters
nameID: string | number
string or numeric ID of the item
func: ItemIconOverrideFunction
function that is called to override item icon. Should return Item.TextureData object to be used for the item. See Callback.ItemIconOverrideFunction documentation for details
Returns void
registerNameOverrideFunction
Registers function to perform item name override.
Parameters
nameID: string | number
string or numeric ID of the item
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 occurs
Returns void
registerThrowableFunction
Registers function that is called when throwable item with specified ID hits block or entity.
Parameters
nameID: string | number
string or numeric ID of the item
useFunc: ProjectileHitFunction
function that is called when such an event occurs
Returns void
registerThrowableFunctionForID
Same as Item.registerThrowableFunction, but supports numeric IDs only.
Parameters
numericID: number
useFunc: ProjectileHitFunction
Returns void
registerUseFunction
Registers function that is called when user touches some block in the world with specified item.
Parameters
nameID: string | number
string or numeric ID of the item
useFunc: ItemUseFunction
function that is called when such an event occurs
Returns void
registerUseFunctionForID
Same as Item.registerUseFunction, but supports numeric IDs only.
Parameters
numericID: number
useFunc: ItemUseFunction
Returns void
registerUsingCompleteFunction
Registers function to be called when player completes using item that has maximum use time set with Item.setMaxUseDuration function.
Parameters
nameID: string | number
string or numeric ID of the item
func: ItemUsingCompleteFunction
function that is called when such an event occurs
Returns void
registerUsingReleasedFunction
Registers function to be called when player doesn't complete using item that has maximum use time set with Item.setMaxUseDuration function. 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 occurs
Returns void
setAllowedInOffhand
Allows item to be put in offhand slot.
Parameters
id: string | number
string or numeric item ID
allowed: boolean
Returns void
setArmorDamageable
Parameters
damageable: boolean
Returns void
setCategory
Sets item creative category.
Parameters
id: string | number
string or numeric item ID
category: number
item category, should be one of the EItemCategory values
Returns void
setEnchantType
Specifies how the item can be enchanted.
Parameters
id: string | number
string or numeric item ID
enchant: number
enchant type defining when enchants can or cannot be applied to this item, one of the EEnchantType
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
setExplodable
Parameters
id: string | number
explodable: boolean
Returns void
setFireResistant
Parameters
id: string | number
resistant: boolean
Returns void
setGlint
Sets item as glint (like enchanted tools or golden apple).
Parameters
id: string | number
string or numeric item ID
enabled: boolean
if true, the item will be displayed as glint item
Returns void
setLiquidClip
Allows to click with item on liquid blocks.
Parameters
id: string | number
string or numeric item ID
enabled: boolean
if true, liquid blocks can be selected on click
Returns void
setMaxDamage
Sets item maximum data value.
Parameters
id: string | number
string or numeric item ID
maxdamage: number
maximum data value for the item
Returns void
setMaxUseDuration
Limits maximum use duration. This is useful to create such items as bows.
Parameters
id: string | number
string or numeric item ID
duration: number
maximum use duration in ticks
Returns void
setProperties
Sets additional properties for the item, uses Minecraft mechanisms to set them. Full list of properties is currently unavailable.
Parameters
id: string | number
string or numeric item ID
props: string
JSON string containing some of the properties
Returns void
setPrototype
Parameters
nameID: any
prototype: ItemLegacyPrototype
Returns void
setShouldDespawn
Parameters
id: string | number
should: boolean
Returns void
setStackedByData
Parameters
id: string | number
enabled: boolean
Returns void
setToolRender
Specifies how the player should hold the item.
Parameters
id: string | number
string or numeric item ID
enabled: boolean
if true, player holds the item as a tool, not as a simple item
Returns void
setUseAnimation
Sets animation type for the item.
Parameters
id: string | number
string or numeric item ID
animType: number
use animation type, one of the EItemAnimation values
Returns void
Module used to define items and their properties.