{ 
  "format_version": "1.16.100", 
  "minecraft:item": {
    "description": {
      "identifier": "add:gold_shield",
      "category": "Equipment"
    },
    "components": { 
      "minecraft:max_stack_size": 1,
      "minecraft:display_name": {
        "value": "item.add:gold_shield.name"
      },
      "minecraft:repairable": {
        "repair_items": [
          {
            "items": [ "minecraft:gold_ingot" ],
            "repair_amount": "Math.random(25,30)"
          },
          {
            "items": [ "minecraft:gold_nugget" ],
            "repair_amount": "Math.random(2,4)"
          }
        ]
      },
      "minecraft:animates_in_toolbar": false,
      "minecraft:ignores_permission": true,
      "minecraft:durability": {
        "max_durability": 100
      },
      "minecraft:on_use": {
        "on_use": {
        "event": "save",
        "condition": "q.health <= 4 && q.player_level >= 2",
        "target": "self"
}
      },
      "minecraft:can_destroy_in_creative": false,
      "minecraft:enchantable": {
        "value": 12,
        "slot": "sword"
      },
      "minecraft:allow_off_hand": true,
      "minecraft:icon": { 
        "texture": "gold_shield"
      }
    },
    "events": {
      "save": {
        "add_mob_effect": {
          "effect": "instant_health",
          "duration": 1,
          "amplifier": 5,
          "target": "holder"
        },
        "run_command": {
          "command": [ "playsound ambient.weather.lightning.impact @s", "playsound ambient.weather.thunder @s", "tellraw @a { \"rawtext\": [ { \"text\": \"§e\" }, { \"selector\": \"@s\" }, { \"translate\": \"gold_shield.use\" } ] }", "replaceitem entity @s slot.weapon.mainhand 0 air 1"
]
        }
      }
    }
  }
}