The data mapping system allows you to dynamically display an item's custom data in its name and description. For example, you can show a weapon's damage value, level, durability, and other attributes, letting players intuitively see the item's properties.
The data mapping system operates through three steps:
Item Configuration - Define data and mapping rules
Display Template - Define display format
System Processing - Automatically apply mappings and generate the final display
item/weapons/swords.yml
my_sword: display: weapon_display # Must specify a display template data: damage: 100 level: 5 meta: native: CustomStats: power: 150 data-mapper: damage: it # Map data from the data node level: it # Map data from the data node power: "&CustomStats.power" # Map data from native NBT # Item's name and lore provide basic variable values name: item_name: '&6Divine Sword' lore: item_type: '&9Weapon'
Use both data and meta.native data simultaneously:
item/weapons/hybrid_sword.yml
hybrid_sword: display: hybrid_display data: base_damage: 100 level: 15 data-mapper: base_damage: it # Data from data node level: it # Data from data node bonus_damage: "&Enchantments.sharpness" # Data from native NBT total_damage: |- # Hybrid calculation math + [ &base_damage &Enchantments.sharpness ] meta: native: Enchantments: sharpness: 25 unbreaking: 3 name: item_name: '&cHybrid Sword'