Item Modifiers
Item modifiers (also called loot functions) transform item stacks by adjusting counts, adding enchantments, copying data, setting components, and more. They can be defined as standalone JSON files referenced by commands, or used inline within loot tables.
Overview
Item modifiers have several key characteristics:
- Composable: Chain multiple functions together for complex transformations
- Conditional: Each function can have predicate conditions
- Context-aware: Access loot context for killer, tool, block entity, etc.
- Reusable: Define once as a file, reference anywhere
Common Use Cases
| Use Case | Functions |
|---|---|
| Set stack count | setCount |
| Add enchantments | enchantRandomly, enchantWithLevels, setEnchantments |
| Modify durability | setDamage |
| Copy NBT/components | copyComponents, copyCustomData, copyName |
| Set name/lore | setName, setLore |
| Create explorer maps | explorationMap |
| Fill containers | setContents, setLootTable |
| Apply formulas | applyBonus, enchantedCountIncrease |
File Structure
Item modifiers are stored as JSON files in data packs at:
For complete JSON specification, see the Minecraft Wiki - Item modifier.
Creating Item Modifiers
Use the itemModifier builder function to create item modifiers in Kore:
This generates data/my_datapack/item_modifier/fortune_bonus.json.
Using Item Modifiers
With Commands
Apply modifiers to items using the /item modify command:
In Loot Tables
Use functions directly in loot tables at table, pool, or entry level:
Function Reference
Count and Damage
setCount
Sets or modifies the stack count:
setDamage
Sets item durability (1.0 = full, 0.0 = broken):
limitCount
Clamps stack count to a range:
Enchantments
enchantRandomly
Adds a random enchantment:
enchantWithLevels
Enchants as if using an enchanting table:
setEnchantments
Sets specific enchantments and levels:
enchantedCountIncrease
Increases count based on enchantment level (like Looting):
Names and Lore
setName
Sets the item's display name:
setLore
Sets or modifies item lore:
Components
setComponents
Directly set item components:
copyComponents
Copy components from a source:
copyName
Copy entity/block name to item:
copyCustomData
Copy NBT data to custom_data component:
Container Contents
setContents
Fill container items (bundles, shulker boxes):
setLootTable
Set a container's loot table:
modifyContents
Apply modifiers to items inside a container:
Maps and Exploration
explorationMap
Convert empty map to explorer map:
Special Items
setInstrument
Set goat horn instrument:
setPotion
Set potion type:
setStewEffect
Set suspicious stew effects:
setFireworks
Configure firework rocket:
setBookCover
Set written book cover:
Attributes
setAttributes
Add attribute modifiers:
Banners and Patterns
setBannerPattern
Add banner patterns:
Block State
copyState
Copy block state to item:
Bonus Formulas
applyBonus
Apply enchantment-based bonus formulas:
Smelting and Decay
furnaceSmelt
Smelt the item as if in a furnace:
explosionDecay
Random chance to destroy items based on explosion:
Player Heads
fillPlayerHead
Set player head skin:
Tooltips
toggleTooltips
Show/hide tooltip sections:
Composition
sequence
Run multiple functions in sequence:
filtered
Apply functions only to matching items:
reference
Reference another item modifier:
Conditions
Every function can have conditions that must pass:
See Predicates for all available conditions.
Full Example
Generated JSON
Best Practices
- Keep modifiers focused - Create small, reusable modifiers and compose with
reference() - Use conditions wisely - Guard expensive operations with appropriate conditions
- Prefer components - Use
setComponentsfor direct component manipulation when possible - Consider context - Some functions require specific loot contexts (killer, tool, etc.)
- Test thoroughly - Verify modifiers work in all intended contexts (loot, commands, etc.)
See Also
- Predicates - Conditions for item functions
- Components - Understanding item components
- Loot Tables - Use item modifiers in loot tables
- Commands - Using the
/itemcommand
External Resources
- Minecraft Wiki: Item modifier - Official JSON format reference
