Class: ItemDurabilityComponent
When present on an item, this item can take damage in the process of being used. Note that this component only applies to data-driven items.
Extends
Constructors
new ItemDurabilityComponent()
private
new ItemDurabilityComponent():ItemDurabilityComponent
Returns
Overrides
Properties
damage
damage:
number
Remarks
Returns the current damage level of this particular item.
This property can't be edited in read-only mode.
maxDurability
readonly
maxDurability:number
Remarks
Represents the amount of damage that this item can take before breaking.
Throws
This property can throw when used.
typeId
readonly
typeId:string
Remarks
Identifier of the component.
Inherited from
componentId
static
readonly
componentId:"minecraft:durability"
='minecraft:durability'
Methods
getDamageChance()
getDamageChance(
unbreakingEnchantmentLevel
?):number
Parameters
Parameter | Type | Description |
---|---|---|
unbreakingEnchantmentLevel ? | number | Unbreaking factor to consider in factoring the damage chance. Incoming unbreaking parameter must be within the range [0, 3]. |
Returns
number
Remarks
Returns the maximum chance that this item would be damaged using the damageRange property, given an unbreaking enchantment level.
This function can't be called in read-only mode.
Throws
This function can throw errors.
getDamageChanceRange()
getDamageChanceRange():
NumberRange
Returns
NumberRange
Remarks
A range of numbers that is used to calculate the damage chance for an item. The damage chance will fall within this range.
This function can't be called in read-only mode.
Throws
This function can throw errors.
isValid()
isValid():
boolean
Returns
boolean
Whether the component is valid.
Inherited from
Remarks
Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.