Repairable Items

Durability is set with vanilla components too, so any EcoItem can wear out, be repaired at an anvil with the materials you choose, be enchanted, or never break at all. This page covers giving an item durability and making it repairable, on top of a standard item.

Quick start

  1. Open your item's config in /plugins/EcoItems/items/.

  2. Add minecraft:max_damage to give it durability, plus minecraft:max_stack_size: 1.

  3. Add minecraft:repairable with the items that repair it.

  4. Run /ecoitems reload.

  5. Damage the item (or set its durability with /ecoitems durability <remaining>), then combine it with a repair item in an anvil to confirm it repairs.

The structure of a repairable item

PartWhat it controls
ItemThe base item, display, and recipe, identical to any EcoItem
minecraft:max_damageTotal durability
minecraft:repairableThe items that repair it in an anvil
minecraft:enchantableHow well it enchants at an enchanting table
minecraft:repair_costThe starting anvil cost
minecraft:unbreakableWhether it never loses durability
# === Item: a normal EcoItem ===
item:
  item: iron_pickaxe
  name: "&bMithril Pickaxe"

  # === Durability and repair, as vanilla components ===
  components:
    "minecraft:max_stack_size": 1 # Items with durability can't stack
    "minecraft:max_damage": 1200 # Total durability

    # Read here: https://minecraft.wiki/w/Data_component_format#repairable
    "minecraft:repairable":
      items: "#minecraft:diamond_tool_materials" # An item, a list of items, or a #tag

    # Read here: https://minecraft.wiki/w/Data_component_format#enchantable
    "minecraft:enchantable":
      value: 10 # Enchantability; iron is 14, diamond is 10, gold is 22

    "minecraft:repair_cost": 0 # Optional; extra anvil levels, grows with each use

Item

The item: section is the same as any other EcoItem; see How to Make an Item. Basing the item on a vanilla tool, weapon, or armor piece means it already has durability, repair materials, and enchantability, so you only override what changes.

Durability

minecraft:max_damage is the item's total durability. It needs minecraft:max_stack_size: 1, since an item can't be both damageable and stackable. minecraft:damage sets how much durability a fresh copy has already lost.

To make an item that never wears out, add minecraft:unbreakable instead:

components:
  "minecraft:unbreakable": {}

Repairing

minecraft:repairable lists the items that repair it in an anvil. items takes a single item ID, a list of IDs, or an item tag starting with #, such as #minecraft:iron_tool_materials. Each repair item restores a quarter of the durability, like vanilla.

Players can also repair an item by combining two copies in an anvil, like vanilla tools. /ecoitems repair fully repairs the held item for operators.

Enchanting

minecraft:enchantable sets the item's enchantability, which affects how good the enchantments from an enchanting table are. Which enchantments apply is decided by the base item's type and tags. minecraft:repair_cost is the extra level cost added in an anvil, which vanilla increases every time the item is worked on.


Where to go next

  • Tools and weapons: Custom Tools and Custom Weapons for items that wear out as they're used.

  • Commands: Commands and Permissions for /ecoitems repair and /ecoitems durability.

  • The base item: How to Make an Item for the shared item, display, and recipe fields.