{
	"format_version": "1.16.100",
	"minecraft:item": {
		"description": {
			"identifier": "bridge:usp",
			"category": "Equipment"
		},
		"components": {
			"minecraft:icon": {
				"texture": "usp"
			},
			"minecraft:display_name": {
				"value": "USP \n§7Bullets: 12 \n§7Damage: 9 \nAmmo: 9mm Bullet"
			},
			"minecraft:durability": {
				"max_durability": 12
			},
			"minecraft:max_stack_size": 1,
			"minecraft:hand_equipped": true,
			"minecraft:creative_category": {
				"parent": "Gun"
			},
			"minecraft:on_use": {
				"on_use": {
					"event": "fire",
					"target": "self"
				}
			},
			"minecraft:explodable": false,
			"minecraft:cooldown": {
				"category": "pistol",
				"duration": 0.20
			},
			"minecraft:weapon": {
				"on_hurt_entity": {
					"event": "no_damage",
					"target": "self"
				},
				"on_not_hurt_entity": {
					"event": "no_damage",
					"target": "self"
				},
				"on_hit_block": {
					"event": "no_damage",
					"target": "self"
				}
			},
			"tag:is_gun": {},
			"tag:is_pistol": {}
		},
		"events": {
			"fire": {
				"sequence": [
					{
						"sequence": [
							{
								"condition": "query.remaining_durability >= 1",
								"sequence": [
									{
										"run_command": {
											"command": [
												"playsound item.gun.usp.fire @a ~ ~ ~ 1 1",
												"camerashake add @s 0.02 0.1 rotational"
											],
											"target": "holder"
										}
									},
									{
										"shoot": {
											"projectile": "bullet:usp",
											"launch_power": 1,
											"angle_offset": "query.cardinal_facing"
										}
									},
									{
										"damage": {
											"type": "magic",
											"amount": 1,
											"target": "self"
										}
									}
								]
							},
							{
								"sequence": [
									{
										"condition": "query.remaining_durability == 12",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l11§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 11",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l10§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 10",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l9§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 9",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l8§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 8",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l7§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 7",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l6§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 6",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l5§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 5",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l4§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 4",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l3§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 3",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l2§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 2",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l1§r/12"
											],
											"target": "holder"
										}
									},
									{
										"condition": "query.remaining_durability == 1",
										"run_command": {
											"command": [
												"title @s actionbar \uE105 §l0§r/12"
											],
											"target": "holder"
										}
									}
								]
							}
						]
					},
					{
						"condition": "query.remaining_durability == 0 && query.equipped_item_any_tag('slot.weapon.offhand', '9mm')",
						"run_command": {
							"command": [
								"replaceitem entity @s slot.weapon.mainhand 0 bridge:usp 1 0",
								"clear @s bridge:ammo_9mm 0 1",
								"title @s actionbar §aReloaded",
								"playsound item.gun.reload @a ~ ~ ~ 1 1"
							],
							"target": "holder"
						}
					},
					{
						"condition": "query.remaining_durability == 0 && !query.equipped_item_any_tag('slot.weapon.offhand', '9mm')",
						"run_command": {
							"command": [
								"title @s actionbar \uE105 §l0§r/12",
								"playsound item.gun.dry_fire @a ~ ~ ~ 1 1"
							],
							"target": "holder"
						}
					}
				]
			},
			"no_damage": {
				"damage": {
					"type": "magic",
					"amount": 0,
					"target": "self"
				}
			}
		}
	}
}