Skip to content

Enchantments, damage types, effects and attributes

Status: Partly implemented. Enchantments, damage types, paintings, jukebox songs, trims and banner patterns work as data from the mod’s datapack/ folder (they are data-pack registries in 26.3), and entity.damage can change or cancel damage. Enchantment effect components from code, mob effects, potions and attributes from code, and damage sources from code are Planned.

Enchantments (data)

datapack/<ns>/enchantment/<name>.json
datapack/<ns>/tags/enchantment/...               e.g. add it to minecraft:in_enchanting_table
assets/<ns>/lang/en_us.json                      "enchantment.<ns>.<name>"

An enchantment uses vanilla’s effect components (minecraft:damage, minecraft:attributes, minecraft:post_attack, …). Vanilla clients see it too, because the server sends data-pack registries to every client. See A custom enchantment.

Damage

Event Fields Notes
entity.damage entity, level, source (the damage type id), attacker, amount (mut) Cancellable; filter by entity type
entity.death entity, level, source, attacker Cancellable
-- no fall damage for players
cl.on("entity.damage", function(event)
  if event.source == "minecraft:fall" and event.player then event:cancel() end
end)

New damage types are data (datapack/<ns>/damage_type/<name>.json).

Paintings, songs, trims and banner patterns (data)

painting_variant/, jukebox_song/, trim_material/, trim_pattern/, banner_pattern/ in the mod’s data pack, with their textures and sounds in assets/.

Health

cl_living_health(e) and cl_living_set_health(e, h) (Entities).

Planned

Enchantment effect component types from code, mob effects and potions (register, add, remove, query), attributes and modifiers, dealing damage with a damage source from code, and value events for damage and knockback.