Advanced Items: Item Settings
The ItemSettings
class gives you fine-grained control over how your item behaves and looks, using Paper's DataComponent system under the hood.
You get an ItemSettings
instance via new ItemSettings(item)
, and you can chain methods to configure everything from durability to rarity, food, tools, and beyond.
Example: Unbreakable Fire-Resistant Tool
Common Settings
durability(int)
— sets max damage, stack size to 1, and damage to 0stackSize(int)
— overrides max stack sizefireResistant()
— makes the item immune to fire damageunbreakable()
— prevents the item from taking durability damagerarity(ItemRarity)
— applies rarity tag (COMMON, UNCOMMON, RARE, EPIC)useCooldown(float)
— sets use cooldown in ticksusingConvertsTo(ItemStack)
— like a milk bucket turning into an empty bucket
Food Items
FoodProperties
- the property component of a Food, defines Nutrition and Saturation.ConsumeSeconds
- the time it takes to eat the item, in seconds. (can pass in Consumable.consumable() as well).
Attributes
Or per-slot:
Weapon Items
itemDamagePerAttack
: how much damage it dealsdisableBlockingForSeconds
: disables shields for this many seconds
You can chain as many settings as you want.