Enchant Data
EnchantData
EnchantData: is an optional section inside any enchantment YAML that lets you declaratively define vanilla Minecraft datapack effect components — the same JSON that lives in data/<namespace>/enchantment/<key>.json. Instead of writing raw JSON you write YAML; MythicEnchants validates it and generates the correct datapack file at startup.
Any parse error (typo in a key, missing required field, etc.) is printed to the server log and blocks that enchantment from being written to the datapack entirely until fixed. Other enchantments are unaffected.
Minecraft wiki references
Table of Contents
- Version compatibility
- How it fits together
- Value providers — how numbers are expressed
- Requirements / predicates — conditional gating
- Value effect components — scalar boosts
- Bare value components — crossbow & trident timing
- Entity effect components — on-hit, on-tick, etc.
- Entity effect types — what happens
- Attribute effects — stat modifiers
- Flag components — boolean toggles
- Special components — sounds
- Full examples
Version compatibility
MythicEnchants detects the running server version at startup and generates datapacks at the correct pack format automatically.
| Server version | Pack format | Notes |
|---|---|---|
| 1.21.11 | 94 | Supported. post_piercing_attack and damage_immunity skipped with a warning. |
| 26.1.x | 101 | Supported. Same component restrictions as 94. |
| 26.2+ | 107 | Full support for all components. |
Predicate key format
Minecraft changed how sub-keys inside entity_properties predicates are named in pack format 107:
| Key purpose | Pre-107 (1.21.11, 26.1) | 107+ (26.2) |
|---|---|---|
| Entity flags | flags |
minecraft:flags |
| Location check | location |
minecraft:location |
| Entity type | type |
minecraft:entity_type |
| Type-specific data | type_specific |
minecraft:type_specific |
Always write predicates in the 26.2 namespaced form. MythicEnchants automatically rewrites them to the correct bare-key form when generating datapacks for servers on format < 107. You never need to maintain two versions of a predicate.
# Write this on any server version — MythicEnchants handles the rest
requirements:
condition: minecraft:entity_properties
entity: this
predicate:
minecraft:flags:
is_on_fire: true
Components not available before 26.2
These are skipped with a server log warning on format < 107. The enchantment still loads normally — only the datapack component is omitted.
| Component | Minimum version |
|---|---|
post_piercing_attack |
26.2 (pack format 107) — added for Lunge |
damage_immunity |
26.2 (pack format 107) |
How it fits together
my_enchant:
Display: '&6My Enchant'
MaxLevel: 3
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/sword'
EnchantData:
# Everything under here is datapack generation
damage:
value:
type: linear
base: 0.5
perLevel: 0.5
Skills:
- ... # normal MythicEnchants skill lines still work alongside EnchantData
EnchantData: and Skills: are independent — you can use both, either, or neither.
Value providers
A value provider describes how a number is calculated, usually based on enchantment level. Used anywhere a numeric field appears (value effects, attribute amounts, entity effect parameters, etc.).
linear
Grows linearly with level. base is the value at level 1; perLevel is added for each level above 1.
value:
type: linear
base: 1.0
perLevel: 0.5
# level 1 = 1.0, level 2 = 1.5, level 3 = 2.0
Shorthand (same thing, no type: needed):
base: 1.0
perLevel: 0.5
constant
Fixed value regardless of level.
value:
type: constant
value: 2.5
Bare number shorthand (only on top-level effect keys, not inside nested sections):
fishing_luck_bonus: 1.0
levels_squared
Value = (level - 1)² + added. Vanilla uses this for Protection.
value:
type: levels_squared
added: 1.0
# level 1 = 1, level 2 = 2, level 3 = 5, level 4 = 10
lookup
Returns a fixed value per level from a list. If the level exceeds the list length, fallback is used.
value:
type: lookup
values: [1.0, 2.5, 4.5, 7.0]
fallback: 7.0 # also accepts a nested value provider
clamped
Clamps another value provider to a [min, max] range.
value:
type: clamped
value:
type: linear
base: 0.0
perLevel: 2.0
min: 0.0
max: 6.0
fraction
Divides one value provider by another. Vanilla uses this for Sweeping Edge.
value:
type: fraction
numerator:
type: linear
base: 1.0
perLevel: 1.0
denominator:
type: linear
base: 2.0
perLevel: 1.0
# level 1 = 1/2, level 2 = 2/3, level 3 = 3/4
Bare numbers work for numerator/denominator too:
value:
type: fraction
numerator: 1.0
denominator: 3.0
exponent
Raises base to the power of power. Both accept nested value providers or bare numbers.
value:
type: exponent
base: 2.0
power:
type: linear
base: 1.0
perLevel: 1.0
formula (math)
Evaluates a math expression once per level (1 through MaxLevel) and bakes the results into a
minecraft:lookup table — vanilla's JSON format has no arbitrary-formula value type, so
MythicEnchants resolves the expression ahead of time at datapack generation rather than at
runtime. Uses the same expression engine (exp4j) and function set as <math:...> skill-line
tokens — see the class doc on MenchMathParser for the full operator/function list
(min, max, clamp, sqrt, sin, round, lerp, etc.).
Available variables: level (current enchantment level), max_level (the enchant's MaxLevel).
value:
type: formula
expression: "1 + sqrt(level) * 2"
# level 1 = 3, level 2 = 3.83, level 3 = 4.46, ...
math is accepted as an alias for type: formula. A parse/eval error at any level is logged
and that level falls back to 0.
Requirements / predicates
Any effect entry can include an optional requirements: block. This is a standard Minecraft Predicate written as YAML — it is serialised directly to JSON without any schema validation, so you can use the full condition vocabulary from the wiki.
See: Predicate
damage:
value:
base: 2.0
perLevel: 1.0
requirements:
condition: minecraft:entity_properties
entity: this
predicate:
minecraft:flags:
is_on_fire: true
Multiple conditions — wrap them in minecraft:all_of:
requirements:
condition: minecraft:all_of
terms:
- condition: minecraft:random_chance
chance: 0.25
- condition: minecraft:weather_check
thundering: true
Always write predicates in the 26.2 namespaced form (minecraft:flags, minecraft:location, minecraft:entity_type, etc.). MythicEnchants automatically rewrites them to the correct bare-key form for servers running pre-107 pack formats. See Version compatibility for details.
Value effect components
These are conditional arrays — each entry has an effect (the number) and an optional requirements predicate. Multiple entries are evaluated in order; all matching entries are summed.
| Key | What it affects |
|---|---|
damage |
Extra damage dealt |
damage_protection |
Damage reduction (Protection family) |
armor_effectiveness |
How much armor helps against this damage source |
knockback |
Knockback strength on hit |
smash_damage_per_fallen_block |
Bonus damage per block fallen before impact (Density) |
equipment_drops |
Chance modifier for mob equipment drops |
ammo_use |
Ammo consumption modifier (Infinity uses 0) |
projectile_piercing |
How many entities a projectile can pierce (Piercing) |
projectile_count |
Number of projectiles fired (Multishot) |
projectile_spread |
Spread angle of projectiles in degrees |
block_experience |
XP dropped from breaking blocks (Fortune) |
mob_experience |
XP dropped from killing mobs (Looting) |
repair_with_xp |
Item repair rate from XP (Mending) |
item_damage |
Durability damage dealt to the item |
trident_return_acceleration |
Loyalty return speed |
fishing_time_reduction |
Reduction in fishing wait time (Lure) |
fishing_luck_bonus |
Luck bonus for fishing loot table (Luck of the Sea) |
location_changed |
Fires when the player moves to a new block (Frost Walker) |
Single entry (most common)
damage:
value:
type: linear
base: 0.5
perLevel: 0.5
With requirements
damage_protection:
value:
type: levels_squared
added: 1.0
requirements:
condition: minecraft:entity_properties
entity: this
predicate:
minecraft:flags:
is_on_fire: true
Multiple gated entries
damage:
entries:
- value:
type: constant
value: 2.0
requirements:
condition: minecraft:random_chance
chance: 0.5
- value:
base: 0.5
perLevel: 0.25
Bare number shorthand
Expands to a constant value with no requirements:
fishing_luck_bonus: 2.0
Bare value components
These two components take a single bare value object in the datapack JSON — not an array of conditional entries. You cannot add multiple gated entries; use them for a simple scalar override.
crossbow_charge_time
Changes crossbow charge time. Negative values make it faster (vanilla Quick Charge: −0.25 per level).
crossbow_charge_time:
value:
type: linear
base: -0.25
perLevel: -0.25
Shorthand:
crossbow_charge_time: -0.75
trident_spin_attack_strength
Strength of the trident spin attack (Riptide).
trident_spin_attack_strength:
value:
type: linear
base: 1.5
perLevel: 0.75
Entity effect components
These fire in response to game events. Each entry specifies who carries the enchantment (enchanted), who is affected (affected), the effect type, and an optional requirements predicate.
| Component | When it fires |
|---|---|
post_attack |
After a melee attack connects |
tick |
Every game tick while equipped in a valid slot |
hit_block |
When a projectile hits a block |
projectile_spawned |
When a projectile is fired |
post_piercing_attack |
After a piercing projectile passes through an entity |
enchanted / affected values
| Value | Meaning |
|---|---|
attacker |
The entity holding the enchanted item |
victim |
The entity being attacked |
damaging_entity |
The direct source of damage (e.g. the arrow itself) |
Not all combinations are valid for every component — hit_block has no affected, for example.
Single entry
post_attack:
enchanted: attacker
affected: victim
effect:
type: apply_mob_effect
to_apply: minecraft:poison
min_duration: 3.0
max_duration: 3.0
min_amplifier: 0.0
max_amplifier: 0.0
requirements:
condition: minecraft:random_chance
chance: 0.15
Multiple entries
post_attack:
entries:
- enchanted: attacker
affected: victim
effect:
type: ignite
duration: 4.0
- enchanted: attacker
affected: victim
effect:
type: apply_mob_effect
to_apply: minecraft:slowness
min_duration: 2.0
max_duration: 2.0
min_amplifier: 1.0
max_amplifier: 1.0
requirements:
condition: minecraft:random_chance
chance: 0.3
Entity effect types
These go inside the effect: block of an entity effect entry.
See: Entity effects
apply_mob_effect
Applies a potion effect to the target.
See: Effect IDs
effect:
type: apply_mob_effect
to_apply: minecraft:poison # required — effect ID or list of IDs
min_duration: 3.0 # seconds (default 5.0)
max_duration: 3.0
min_amplifier: 0.0 # 0 = level I (default 0.0)
max_amplifier: 0.0
to_apply can be a list for random selection:
to_apply:
- minecraft:poison
- minecraft:wither
Duration and amplifier accept value providers:
min_duration:
type: linear
base: 2.0
perLevel: 1.0
max_duration:
type: linear
base: 3.0
perLevel: 1.5
ignite
Sets the target on fire.
effect:
type: ignite
duration: 8.0 # seconds — accepts a value provider
damage_entity
Deals direct damage.
See: Damage types
effect:
type: damage_entity
damage_type: minecraft:generic # required
min_damage: 1.0 # accepts value providers
max_damage: 4.0
change_item_damage
Damages the enchanted item's durability.
effect:
type: change_item_damage
amount: 1.0 # accepts a value provider
apply_exhaustion
Drains the player's food exhaustion meter.
effect:
type: apply_exhaustion
amount: 0.1 # accepts a value provider
apply_impulse
Applies a velocity impulse to the target.
effect:
type: apply_impulse
direction: [0.0, 1.0, 0.0] # [x, y, z] unit vector
coordinate_scale: [1.0, 0.0, 1.0] # optional — scales each axis by a factor
magnitude: 2.0 # accepts a value provider
summon_entity
Spawns an entity at the target's location.
See: Entity IDs
effect:
type: summon_entity
entity: minecraft:lightning_bolt # required — entity ID or list
join_team: false # optional
run_function
Runs a datapack function.
effect:
type: run_function
function: mynamespace:my_function # required — function ID
play_sound
Plays a sound at the target's location.
See: Sound events
effect:
type: play_sound
sound: minecraft:entity.lightning_bolt.thunder # string or list for random pick
volume: 5.0 # accepts value providers
pitch: 1.0
Random sound pick:
sound:
- minecraft:entity.lightning_bolt.thunder
- minecraft:entity.generic.explode
spawn_particles
Spawns particles at the target.
See: Particle types
effect:
type: spawn_particles
particle: # required — particle definition (pass raw YAML)
type: minecraft:flame
horizontal_position: # optional position/velocity sections
type: entity_position
offset: 0.5
vertical_position:
type: entity_position
offset: 0.5
speed: 0.1
explode
Creates an explosion at the target.
effect:
type: explode
radius: 3.0 # accepts value provider
attribute_to_user: true # optional
damage_type: minecraft:explosion # optional
block_interaction: destroy # optional: destroy | block | none | trigger_block
create_fire: false # optional
offset: [0.0, 0.0, 0.0] # optional [x, y, z]
immune_blocks: '#minecraft:dragon_immune' # optional — block tag or list
knockback_multiplier: 1.0 # optional — value provider
sound: minecraft:entity.generic.explode # optional
replace_block
Replaces the block at the target location with another block state.
effect:
type: replace_block
block_state: # the replacement block state as raw YAML
Name: minecraft:ice
offset: [0.0, -1.0, 0.0] # optional [x, y, z]
predicate: # optional block predicate
blocks: '#minecraft:water'
trigger_game_event: minecraft:block_change # optional
replace_disk
Same as replace_block but fills a disk area.
effect:
type: replace_disk
block_state:
Name: minecraft:frosted_ice
Properties:
age: '0'
radius: 2.0 # accepts value provider
height: 1.0 # accepts value provider
offset: [0.0, -1.0, 0.0]
set_block_properties
Changes properties of an existing block without replacing it.
effect:
type: set_block_properties
properties:
waterlogged: 'true'
offset: [0.0, 0.0, 0.0]
trigger_game_event: minecraft:block_change
all_of
Runs multiple effects together. Effects inside are all applied unconditionally (use outer requirements to gate the group).
effect:
type: all_of
effects:
- type: ignite
duration: 4.0
- type: apply_mob_effect
to_apply: minecraft:poison
min_duration: 2.0
max_duration: 2.0
min_amplifier: 0.0
max_amplifier: 0.0
Attribute effects
Attribute modifiers change entity stat values while the enchanted item is equipped. Multiple modifiers are supported.
attributes:
- attribute: generic.attack_damage # short alias or full minecraft:... ID
operation: add # add | add_multiplied_base | add_multiplied_total
value:
type: linear
base: 1.0
perLevel: 0.5
id: my_namespace:my_enchant/damage # optional — auto-generated if omitted
requirements: # optional
condition: minecraft:random_chance
chance: 1.0
Attribute operations
| YAML value | Datapack value | Effect |
|---|---|---|
add |
add_value |
Adds a flat amount to the base value |
add_multiplied_base |
add_multiplied_base |
Adds base × amount |
add_multiplied_total |
add_multiplied_total |
Multiplies the running total |
See: Modifier operations
Attribute short aliases
You can use short names instead of the full minecraft: ID:
| Short alias | Full ID |
|---|---|
damage, attack_damage |
minecraft:generic.attack_damage |
attack_speed |
minecraft:generic.attack_speed |
armor, armor_points |
minecraft:generic.armor |
armor_toughness |
minecraft:generic.armor_toughness |
knockback_resistance |
minecraft:generic.knockback_resistance |
max_health, health |
minecraft:generic.max_health |
movement_speed, speed |
minecraft:generic.movement_speed |
luck |
minecraft:generic.luck |
reach, block_reach, block_interaction_range |
minecraft:player.block_interaction_range |
entity_reach, entity_interaction_range |
minecraft:player.entity_interaction_range |
mining_efficiency |
minecraft:player.mining_efficiency |
sneaking_speed |
minecraft:player.sneaking_speed |
submerged_mining_speed |
minecraft:player.submerged_mining_speed |
sweeping_damage_ratio, sweeping |
minecraft:generic.sweeping_damage_ratio |
armor_effectiveness |
minecraft:generic.armor_effectiveness |
gravity |
minecraft:generic.gravity |
jump_strength |
minecraft:generic.jump_strength |
safe_fall_distance |
minecraft:generic.safe_fall_distance |
fall_damage_multiplier |
minecraft:generic.fall_damage_multiplier |
burning_time |
minecraft:generic.burning_time |
explosion_knockback_resistance |
minecraft:generic.explosion_knockback_resistance |
water_movement_efficiency |
minecraft:generic.water_movement_efficiency |
oxygen_bonus |
minecraft:generic.oxygen_bonus |
Any unrecognised alias is expanded to minecraft:generic.<alias> — so any future attributes added by Mojang will work automatically.
Flag components
Boolean toggles. Set to true to enable; false or omitting the key entirely disables (same result).
See: Flag components
| Key | Effect |
|---|---|
damage_immunity |
The enchanted item's holder takes no damage from the effect's damage type (e.g. Fire Protection vs fire) |
prevent_equipment_drop |
Mobs with this enchantment do not drop their equipment on death |
prevent_armor_change |
Players cannot equip or unequip armor while wearing this item |
damage_immunity: true
prevent_equipment_drop: true
prevent_armor_change: true
Special components
crossbow_charging_sounds
Defines the sounds played per Quick Charge level while charging a crossbow. One entry per charge level (vanilla has 3).
Full form (control both start and end sounds):
crossbow_charging_sounds:
- start: minecraft:item.crossbow.quick_charge_1
end: minecraft:item.crossbow.loading_end
- start: minecraft:item.crossbow.quick_charge_2
end: minecraft:item.crossbow.loading_end
- start: minecraft:item.crossbow.quick_charge_3
end: minecraft:item.crossbow.loading_end
Shorthand (only specify start sounds; end always defaults to minecraft:item.crossbow.loading_end):
crossbow_charging_sounds:
- minecraft:item.crossbow.quick_charge_1
- minecraft:item.crossbow.quick_charge_2
- minecraft:item.crossbow.quick_charge_3
trident_sound
Sounds played per Riptide level when spinning (one per level, vanilla has 3).
See: trident_sound
trident_sound:
- minecraft:item.trident.riptide_1
- minecraft:item.trident.riptide_2
- minecraft:item.trident.riptide_3
Full examples
Sharpness clone
Flat extra damage, grows with level.
sharp_echo:
Display: '&7Sharp Echo'
MaxLevel: 5
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/sharp_weapon'
EnchantData:
damage:
value:
type: linear
base: 1.0
perLevel: 0.5
Fire-conditional damage boost
Extra damage only when the wielder is on fire.
inferno_strike:
Display: '&cInferno Strike'
MaxLevel: 3
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/sharp_weapon'
EnchantData:
damage:
value:
type: linear
base: 2.0
perLevel: 1.0
requirements:
condition: minecraft:entity_properties
entity: this
predicate:
minecraft:flags:
is_on_fire: true
Stat-boosting ring (attribute modifiers)
Hypothetical ring item that boosts health and speed.
vitality_ring:
Display: '&aVitality Ring'
MaxLevel: 3
ValidSlots: [OFFHAND]
SupportedItems: '#mythicenchants:enchantable/ring'
EnchantData:
attributes:
- attribute: max_health
operation: add
value:
type: linear
base: 2.0
perLevel: 2.0
- attribute: movement_speed
operation: add_multiplied_total
value:
type: constant
value: 0.05
Poisoning strikes (entity effect)
Random chance to poison on hit.
venom_touch:
Display: '&2Venom Touch'
MaxLevel: 3
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/sharp_weapon'
EnchantData:
post_attack:
enchanted: attacker
affected: victim
effect:
type: apply_mob_effect
to_apply: minecraft:poison
min_duration:
type: linear
base: 1.0
perLevel: 1.0
max_duration:
type: linear
base: 2.0
perLevel: 1.0
min_amplifier: 0.0
max_amplifier: 0.0
requirements:
condition: minecraft:random_chance
chance: 0.25
Multi-effect on hit (all_of)
Ignite and slow on hit, with a random chance gate.
glacial_flare:
Display: '&bGlacial Flare'
MaxLevel: 2
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/sharp_weapon'
EnchantData:
post_attack:
enchanted: attacker
affected: victim
effect:
type: all_of
effects:
- type: ignite
duration: 3.0
- type: apply_mob_effect
to_apply: minecraft:slowness
min_duration: 2.0
max_duration: 2.0
min_amplifier: 1.0
max_amplifier: 1.0
requirements:
condition: minecraft:random_chance
chance: 0.20
Custom Quick Charge with sounds
swift_draw:
Display: '&eSwift Draw'
MaxLevel: 3
ValidSlots: [MAINHAND]
SupportedItems: '#minecraft:enchantable/crossbow'
EnchantData:
crossbow_charge_time:
value:
type: linear
base: -0.25
perLevel: -0.25
crossbow_charging_sounds:
- minecraft:item.crossbow.quick_charge_1
- minecraft:item.crossbow.quick_charge_2
- minecraft:item.crossbow.quick_charge_3
Protection with level-scaled damage reduction
Mimics vanilla Protection using levels_squared.
arcane_guard:
Display: '&9Arcane Guard'
MaxLevel: 4
ValidSlots: [HEAD, CHEST, LEGS, FEET]
SupportedItems: '#minecraft:enchantable/armor'
EnchantData:
damage_protection:
value:
type: levels_squared
added: 1.0
Multiple value effect entries (gated stacking)
Base reduction always applies; bonus kicks in only underwater.
tide_ward:
Display: '&3Tide Ward'
MaxLevel: 3
ValidSlots: [CHEST]
SupportedItems: '#minecraft:enchantable/armor'
EnchantData:
damage_protection:
entries:
- value:
type: linear
base: 1.0
perLevel: 1.0
- value:
type: constant
value: 3.0
requirements:
condition: minecraft:entity_properties
entity: this
predicate:
minecraft:flags:
is_in_water: true