Tutorial:Adding custom enchantments

Jump to navigation Jump to search
This tutorial page is a work in progress.
 
Please help expand and improve it. The talk page may contain suggestions.
This feature is exclusive to Java Edition.
 

This tutorial explains how to create a data pack that adds custom enchantments.

The ability to add custom enchantments was added in 1.21, meaning this tutorial does not work in versions prior to it.

This tutorial assumes you know how to create a data pack.

Refer to Enchantment definition to learn about enchantment's JSON format used in this tutorial.

Custom enchantments[edit | edit source]

Let's start with the central file in the enchantment folder in the data pack.

data/example/enchantment/reach.json

{
  "description": "Reach",
  "supported_items": "#minecraft:enchantable/mining",
  "weight": 5,
  "max_level": 3,
  "min_cost": {
    "base": 1,
    "per_level_above_first": 1
  },
  "max_cost": {
    "base": 51,
    "per_level_above_first": 10
  },
  "anvil_cost": 4,
  "slots": [
    "hand"
  ],
  "effects": {
    "minecraft:attributes": [
      {
        "id": "block_interaction_range",
        "attribute": "minecraft:block_interaction_range",
        "amount": {
          "type": "minecraft:linear",
          "base": 1,
          "per_level_above_first": 1
        },
        "operation": "add_value",
        "uuid": "3a4f09dc-231d-41ac-8c6b-ba5adb86ac0c"
      }
    ]
  }
}


Navigation[edit | edit source]