I am trying to make a sword that gives you absorbtion if you hold it but I don't know how I tries using on player's held item change, but that only works when you held the sword previously before swapping. Any Ideasa how to do this?
Code:
on player's held item change:
if player is not holding an iron sword named "<purple>Protector Worlds" with nbt "{Unbreakable:1,AttributeModifiers:[{AttributeName:""generic.attack_damage"",Amount:17,Slot:mainhand,Name:""generic.attack_damage"",UUID:[I;-121912,29295,214724,-58590]}],HideFlags:6}":
remove absorption from player
if player is holding an iron sword named "<purple>Protector Worlds" with nbt "{Unbreakable:1,AttributeModifiers:[{AttributeName:""generic.attack_damage"",Amount:17,Slot:mainhand,Name:""generic.attack_damage"",UUID:[I;-121912,29295,214724,-58590]}],HideFlags:6}":
apply absorption to player for 100000 seconds