Item Modification

Modifying existing items


You can change properties of existing items:
ItemEvents.modification(event => {
  event.modify('minecraft:ender_pearl', item => {
    item.maxStackSize = 64
    item.fireResistant = true
    item.rarity = 'UNCOMMON'
  })

  event.modify('minecraft:ancient_debris', item => {
    item.rarity = 'RARE'
    item.burnTime = 16000
  })

  event.modify('minecraft:turtle_helmet', item => {
    item.rarity = 'EPIC'
    item.maxDamage = 481
    item.craftingRemainder = Item.of('minecraft:scute').item
  })
})
You can find full list of MutableItem properties here.

#Tool Defaults

TierlevelmaxDamagedigSpeedattackDamageenchantmentValue
Wood0592015
Stone1131415
Iron22506214
Diamond315618310
Gold03212022
Netherite420319415
attackDamage is a bonus modified by the tool type value, not the final value

#Armor Defaults

All boxes with multiple values are formatted head | chest | legs | feet.
TiermaxDamagearmorProtectionarmorToughnessarmorKnockbackResistance
Leather65758055123100
Chain95225240165145200
Iron195225240165256200
Gold9110511277135200
Diamond429495528363368320
Turtle325---2---00
Netherite481555592407368330.1
Elytra-432---0--00
Turtle only has helmet slot and Elytra only has chestplate slot.

#Tier

Broken at the moment! Use the non tier methods instead.

#Tools

ItemEvents.modification(event => {
  event.modify('minecraft:golden_sword', item => {
    item.tier = tier => {
        tier.speed = 12
        tier.attackDamageBonus = 10
        tier.repairIngredient = '#forge:storage_blocks/gold'
        tier.level = 3
    }
  })

  event.modify('minecraft:wooden_sword', item => {
    item.tier = tier => {
        tier.enchantmentValue = 30
    }
  })
})
You can find full list of MutableToolTier properties here.

#Armor

Doesnt actually exist/work at the moment. Sorry.

#Food

ItemEvents.modification(event => {
  event.modify('minecraft:diamond', item => {
    item.foodProperties = food => {
        food.hunger(2)
        food.saturation(3)
        food.fastToEat()
        // The following method is broken in 1.21.1, use ItemEvents.foodEaten instead.
        // An example is provided below.
        food.eaten(foodData => foodData.player.tell('you ate')) 
    }
  })

  event.modify('minecraft:pumpkin_pie', item => {
    item.foodProperties = null // make pumpkin pies inedible
  })
})
You can find full list of FoodBuilder methods here.

#foodEaten Example

This example exists to address the broken .eaten() method mentioned in the above section.
Note that the ItemEvents.FoodEaten() event is a Server Event, and this example should go in the server_scripts/ folder rather than the startup_scripts/ folder
ItemEvents.foodEaten("minecraft:diamond", (foodEatenEvent) => {
	const { item, level, player } = foodEatenEvent;
	const num_diamonds_eaten =
		(player.persistentData.getInt("diamonds_eaten") ?? 0) + 1;
	player.persistentData.putInt("diamonds_eaten", num_diamonds_eaten);

	player.tell(`You ate a diamond! You've eaten $==={num_diamonds_eaten}=== so far`);
});