Enchantments
Enchantments are data-driven definitions that modify item behavior, apply effects, change damage calculations, and alter various game mechanics. In Minecraft Java Edition 1.21+, enchantments are fully customizable through data packs, allowing you to create entirely new enchantments with unique effects.
Overview
Custom enchantments have several key characteristics:
- Data-driven: Defined as JSON files in data packs, not hardcoded
- Effect components: Modular system of 30+ effect types
- Level-based scaling: Values can scale with enchantment level
- Slot-aware: Effects apply based on equipment slot configuration
- Conditional: Effects can have predicate requirements
Enchantment Properties
Every enchantment defines these core properties:
| Property | Description |
|---|---|
description |
Text component displayed on items |
supported_items |
Items or item tags that can receive the enchantment |
primary_items |
Items or item tags offered by the enchanting table |
exclusive_set |
Incompatible enchantments |
weight |
Probability weight (1-1024) |
max_level |
Maximum level (1-255) |
min_cost / max_cost |
Enchanting power window, as base + per_level_above_first |
anvil_cost |
Base cost for anvil application |
slots |
Equipment slots where effects apply |
effects |
Effect components that define behavior |
File Structure
Enchantments are stored as JSON files in data packs at:
For complete JSON specification, see the Minecraft Wiki - Enchantment definition.
Creating Enchantments
Use the enchantment builder function to create enchantments in Kore:
This generates data/my_datapack/enchantment/fire_aspect_plus.json.
In game: a diamond sword enchanted with fire_aspect_plus, pick a level up to maxLevel
Basic Properties
Description
The text shown on enchanted items:
Supported and Primary Items
Both accept items and item tags, mixed freely:
Exclusive Set
Enchantments that cannot coexist:
Cost and Weight
Equipment Slots
Where the enchantment's effects apply:
Available slots: ANY, HAND, MAINHAND, OFFHAND, ARMOR, FEET, LEGS, CHEST, HEAD, BODY, SADDLE.
Effect Components
Effects define what the enchantment actually does. Kore supports all vanilla effect components.
Value Effect Components
These components change a number the game computes, and share the add, multiply, set, removeBinomial and allOf builders:
| Component | Description |
|---|---|
ammoUse |
Ammunition consumption |
armorEffectiveness |
Armor effectiveness multiplier |
blockExperience |
XP from breaking blocks |
crossbowChargeTime |
Crossbow charge time |
damage |
Bonus attack damage |
damageProtection |
Damage reduction (max 80% total) |
equipmentDrops |
Equipment drop chance |
fishingLuckBonus |
Fishing luck bonus |
fishingTimeReduction |
Fishing speed bonus |
itemDamage |
Durability loss multiplier |
knockback |
Knockback strength |
mobExperience |
XP from killing mobs |
projectileCount |
Projectiles fired |
projectilePiercing |
Targets pierced |
projectileSpread |
Accuracy spread in degrees |
repairWithXp |
Durability repaired per XP |
smashDamagePerFallenBlock |
Mace bonus damage per block fallen |
tridentReturnAcceleration |
Trident return speed |
tridentSpinAttackStrength |
Riptide attack strength |
equipmentDrops names which side of the fight has to carry the enchantment, so its effects go inside an on block:
crossbowChargeTime and tridentSpinAttackStrength hold a single effect instead of a list, so they take no requirements. Use an allOf block to apply several operations:
Entity Effect Components
These components run actions on an entity, and share the entity effect builders listed below:
| Component | Description |
|---|---|
hitBlock |
After hitting a block with the enchanted item |
locationChanged |
When the holder moves, equips the item or loads |
postAttack |
After damaging an entity |
postPiercingAttack |
After a piercing projectile goes through it |
projectileSpawned |
When a projectile is created |
tick |
Every game tick while equipped |
postAttack names both the side carrying the enchantment and the side taking the effect, so its effects go inside an on block:
Special Effect Components
| Component | Description |
|---|---|
attributes |
Applies attribute modifiers |
crossbowChargingSounds |
Custom crossbow sounds |
damageImmunity |
Grants immunity to matching hits |
preventArmorChange |
Prevents removing from armor slot |
preventEquipmentDrop |
Prevents item from dropping on death |
tridentSound |
Custom trident sounds |
Entity Effects
The builders below are available in every entity effect component, in allOf blocks and inside a postAttack on block.
All Of
Apply Exhaustion
Apply Impulse
Apply Mob Effect
Damage Entity
Damage Item
Explode
smallParticle, largeParticle and sound are required; everything else has a vanilla default. Both particles are particle options, simpleParticle(...) for a particle without options:
Ignite
Play Sound
Replace Block / Disk
Set Block Properties
Spawn Particles
spawnParticles takes particle options: simpleParticle(...) for a particle without options, and a factory such as dustParticle, blockParticle or geyserParticle for one that has some. The same factories work in explode and in the ambient particles of environment attributes.
A red dust particle, colors being written as packed ints:
Run Function
Summon Entity
Level-Based Values
Level-based values allow effects to scale with enchantment level. Every one of them is a float, so fractional results are expressible, and every builder is scoped to the block that accepts a value.
| Type | Description | Example |
|---|---|---|
clampedLevelBased(value, min, max) |
Clamped range | clampedLevelBased(linear, 1f, 10f) |
constantLevelBased(value) |
Fixed value | constantLevelBased(5) |
exponentLevelBased(base, power) |
Exponential | exponentLevelBased(1, 5) |
fractionLevelBased(num, denom) |
Fractional | fractionLevelBased(1, 2) |
levelsSquaredLevelBased(added) |
Quadratic scaling | levelsSquaredLevelBased(1) → 1, 4, 9... |
linearLevelBased(base, perLevel) |
Linear scaling | linearLevelBased(2f, 0.5f) → 2, 2.5, 3... |
lookupLevelBased(values, fallback) |
Lookup table | lookupLevelBased(1, 3, 7, fallback = 10) |
Outside a DSL block, LevelBased is a scope of its own, so LevelBased.linearLevelBased(1, 1) builds a value anywhere.
Requirements (Conditions)
Every effect accepts a requirements block holding predicate conditions, lifted next to the effect in the generated JSON. The requirements field holds one condition: a block with several conditions is written as one minecraft:all_of. The game validates enchantments without access to other files and refuses to load one holding a predicate ID, so Kore copies the condition of each referenced predicate of the pack in its place (in the requirements, and in the terms and term of the conditions nested in them), and throws for a predicate or a tag defined outside the pack:
Full Example
Enchantment Providers
Enchantment providers pick the enchantments an item receives outside the enchanting table, such as the gear mobs spawn with or the crossbow of a raid pillager. They generate data/<namespace>/enchantment_provider/<name>.json, and a name holding slashes lands in subfolders. Every vanilla provider is listed as an EnchantmentProviders constant, such as EnchantmentProviders.Raid.VINDICATOR, whose asId() is the name to reuse to override it.
Best Practices
- Balance carefully - Test enchantment power at all levels; use appropriate weights
- Use exclusive sets - Prevent overpowered combinations with incompatible enchantments
- Scale appropriately - Use level-based values that provide meaningful progression
- Add requirements - Use conditions to create situational bonuses
- Consider slots - Ensure effects only apply in appropriate equipment slots
- Test thoroughly - Verify effects work correctly in all contexts (PvP, PvE, etc.)
See Also
- Predicates - Conditions for enchantment effect requirements
- Components - Item components and matchers
- Tags - Use enchantment and item tags
- Villager Trades -
doubleTradePriceEnchantmentsand enchanting villager trade outputs
External Resources
- Minecraft Wiki: Enchantment definition - Official JSON format reference
- Minecraft Wiki: Enchantment provider - Provider JSON format reference
- Minecraft Wiki: Enchanting - Enchanting mechanics overview
