# tag certain items for later use
execute as @s[nbt={Item:{id:"minecraft:golden_apple"}}] run tag @s add ItemSaveGA
execute as @s[nbt={Item:{id:"minecraft:egg"}}] run tag @s add ItemSaveEgg
execute as @s[nbt={Item:{id:"minecraft:enchanted_golden_apple"}}] run tag @s add ItemSaveEGA
execute as @s[nbt={Item:{id:"minecraft:brewing_stand"}}] run tag @s add ItemSaveBS
execute as @s[nbt={Item:{id:"minecraft:enchanting_table"}}] run tag @s add ItemSaveET
execute as @s[nbt={Item:{id:"minecraft:ghast_tear"}}] run tag @s add ItemSaveGT
execute as @s[nbt={Item:{id:"minecraft:blaze_powder"}}] run tag @s add ItemSaveBP
execute as @s[nbt={Item:{id:"minecraft:nether_star"}}] run tag @s add ItemSaveNetherStar
execute as @s[nbt={Item:{id:"minecraft:emerald_block"}}] run tag @s add ItemSaveEmBlock
execute as @s[nbt={Item:{id:"minecraft:diamond_block"}}] run tag @s add ItemSaveDiaBlock
execute as @s[nbt={Item:{id:"minecraft:saddle"}}] run tag @s add ItemSaveSaddle
tag @s[nbt={Item:{tag:{Enchantments:[{}]}}}] add EnchB


#
execute as @s[nbt={Item:{id:"minecraft:golden_apple"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:egg"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:enchanted_golden_apple"}}] run tag @s add ItemSaveEffects
#execute as @s[nbt={Item:{id:"minecraft:brewing_stand"}}] run tag @s add ItemSaveEffects
#execute as @s[nbt={Item:{id:"minecraft:enchanting_table"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:ghast_tear"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:blaze_powder"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:nether_star"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:emerald_block"}}] run tag @s add ItemSaveEffects
execute as @s[nbt={Item:{id:"minecraft:diamond_block"}}] run tag @s add ItemSaveEffects


# the number in each of the below tags represents how many items is used in its crafting recipe, which will determine how many materials it gives back
tag @s[nbt={Item:{id:"minecraft:leather_boots"}}] add LeaG4
tag @s[nbt={Item:{id:"minecraft:leather_helmet"}}] add LeaG5
tag @s[nbt={Item:{id:"minecraft:leather_leggings"}}] add LeaG7
tag @s[nbt={Item:{id:"minecraft:leather_chestplate"}}] add LeaG8

tag @s[nbt={Item:{id:"minecraft:diamond_shovel"}}] add DiaG1
tag @s[nbt={Item:{id:"minecraft:diamond_sword"}}] add DiaG2
tag @s[nbt={Item:{id:"minecraft:diamond_hoe"}}] add DiaG2
tag @s[nbt={Item:{id:"minecraft:diamond_axe"}}] add DiaG3
tag @s[nbt={Item:{id:"minecraft:diamond_pickaxe"}}] add DiaG3
tag @s[nbt={Item:{id:"minecraft:diamond_horse_armor"}}] add DiaG3
tag @s[nbt={Item:{id:"minecraft:diamond_boots"}}] add DiaG4
tag @s[nbt={Item:{id:"minecraft:diamond_helmet"}}] add DiaG5
tag @s[nbt={Item:{id:"minecraft:diamond_leggings"}}] add DiaG7
tag @s[nbt={Item:{id:"minecraft:diamond_chestplate"}}] add DiaG8

tag @s[nbt={Item:{id:"minecraft:golden_shovel"}}] add GoldG1
tag @s[nbt={Item:{id:"minecraft:golden_sword"}}] add GoldG2
tag @s[nbt={Item:{id:"minecraft:golden_hoe"}}] add GoldG2
tag @s[nbt={Item:{id:"minecraft:golden_axe"}}] add GoldG3
tag @s[nbt={Item:{id:"minecraft:golden_horse_armor"}}] add GoldG3
tag @s[nbt={Item:{id:"minecraft:golden_pickaxe"}}] add GoldG3
tag @s[nbt={Item:{id:"minecraft:golden_boots"}}] add GoldG4
tag @s[nbt={Item:{id:"minecraft:golden_helmet"}}] add GoldG5
tag @s[nbt={Item:{id:"minecraft:golden_leggings"}}] add GoldG7
tag @s[nbt={Item:{id:"minecraft:golden_chestplate"}}] add GoldG8

tag @s[nbt={Item:{id:"minecraft:iron_shovel"}}] add IronG1
tag @s[nbt={Item:{id:"minecraft:iron_sword"}}] add IronG2
tag @s[nbt={Item:{id:"minecraft:iron_hoe"}}] add IronG2
tag @s[nbt={Item:{id:"minecraft:iron_axe"}}] add IronG3
tag @s[nbt={Item:{id:"minecraft:iron_pickaxe"}}] add IronG3
tag @s[nbt={Item:{id:"minecraft:iron_horse_armor"}}] add IronG3
tag @s[nbt={Item:{id:"minecraft:iron_boots"}}] add IronG4
tag @s[nbt={Item:{id:"minecraft:iron_helmet"}}] add IronG5
tag @s[nbt={Item:{id:"minecraft:iron_leggings"}}] add IronG7
tag @s[nbt={Item:{id:"minecraft:iron_chestplate"}}] add IronG8

tag @s[nbt={Item:{id:"minecraft:netherite_shovel"}}] add NethG1
tag @s[nbt={Item:{id:"minecraft:netherite_sword"}}] add NethG2
tag @s[nbt={Item:{id:"minecraft:netherite_hoe"}}] add NethG2
tag @s[nbt={Item:{id:"minecraft:netherite_axe"}}] add NethG3
tag @s[nbt={Item:{id:"minecraft:netherite_pickaxe"}}] add NethG3
tag @s[nbt={Item:{id:"minecraft:netherite_boots"}}] add NethG4
tag @s[nbt={Item:{id:"minecraft:netherite_helmet"}}] add NethG5
tag @s[nbt={Item:{id:"minecraft:netherite_leggings"}}] add NethG7
tag @s[nbt={Item:{id:"minecraft:netherite_chestplate"}}] add NethG8

##### TAGGING END







##### GIVING BACK BASE MATERIALS START

## NOTE: separate rolls as detailed below can both succeed, occasionally giving back more materials than is normally used in the item
## or they can both fail and give nothing back other than the guaranteed materials
# items that use 1 material in their recipe do not give back a guaranteed material, and have 2 separate rolls: One roll give back 1 material at a 25% rate, and the other roll gives back 1 material at a 50% rate (Minimum: 0.0, Maximum: 2.0, Average: .75)
# items that use 2 materials in their recipe always give back 1 material minimum, and have 2 additional separate rolls: Two rolls give 1 material back at a 25% rate each (Minimum: 1.0, Maximum: 3.0, Average: 1.5)
# items that use 3 materials in their recipe always give back 1 material minimum, and have 3 additional separate rolls: Two rolls give 1 material back at a 25% rate each and the other roll gives back 3 materials at a 25% rate (Minimum: 1.0, Maximum: 5.0, Average: 2.25)
# items that use 4 materials in their recipe always give back 2 materials minimum, and have 2 additional separate rolls: One roll gives 1 material back at a 25% rate and the other roll gives back 3 materials at a 25% rate (Minimum: 2.0, Maximum: 7.0, Average: 3.0)
# items that use 5 materials in their recipe always give back 2 material minimum, and have 3 additional separate rolls: Two rolls give 2 materials back at a 25% rate each, and the last roll gives back 3 materials at a 25% rate (Minimum: 2.0, Maximum: 9.0, Average: 3.75)
# items that use 7 materials in their recipe always give back 3 material minimum, and have 3 additional separate rolls: One roll gives 2 materials back at a 25% rate, one roll gives 3 materials back at 25% rate, and the last roll gives back 4 materials at a 25% rate (Minimum: 3.0, Maximum: 12.0, Average: 5.25)
# items that use 8 materials in their recipe always give back 4 materials minimum, and have 2 additional separate rolls: One roll gives 2 materials back at a 25% rate and the other roll gives back 6 materials at a 25% rate (Minimum: 4.0, Maximum: 12.0, Average: 6)
## netherite is treated as diamond armor for base material purposes, but has a 50% chance to give back a netherite ingot as well

execute at @s[tag=LeaG4] run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG5] run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG7] run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute at @s[tag=LeaG8] run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:4b}}
execute at @s[tag=LeaG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:1b}}
execute at @s[tag=LeaG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute at @s[tag=LeaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute at @s[tag=LeaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute at @s[tag=LeaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:5b}}
execute at @s[tag=LeaG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute at @s[tag=LeaG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:6b}}

#execute at @s[tag=DiaG1] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG2] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG3] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG4] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG5] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG7] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=DiaG8] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:4b}}
execute at @s[tag=DiaG1] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG1] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=DiaG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=DiaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=DiaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=DiaG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:4b}}
execute at @s[tag=DiaG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=DiaG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:6b}}

execute at @s[tag=GoldG2] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG3] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG4] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG5] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG7] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:3b}}
execute at @s[tag=GoldG8] run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:4b}}
execute at @s[tag=GoldG1] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG1] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:1b}}
execute at @s[tag=GoldG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:3b}}
execute at @s[tag=GoldG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:3b}}
execute at @s[tag=GoldG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:3b}}
execute at @s[tag=GoldG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:4b}}
execute at @s[tag=GoldG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:2b}}
execute at @s[tag=GoldG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:gold_ingot",Count:6b}}

execute at @s[tag=IronG2] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG3] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG4] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG5] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG7] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:3b}}
execute at @s[tag=IronG8] run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:4b}}
execute at @s[tag=IronG1] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG1] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:1b}}
execute at @s[tag=IronG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:3b}}
execute at @s[tag=IronG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:3b}}
execute at @s[tag=IronG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:3b}}
execute at @s[tag=IronG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:4b}}
execute at @s[tag=IronG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:2b}}
execute at @s[tag=IronG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:iron_ingot",Count:6b}}

execute at @s[tag=NethG2] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG3] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG4] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG5] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG7] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=NethG8] run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:4b}}
execute at @s[tag=NethG1] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG2] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG3] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG4] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG5] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG7] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG8] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:netherite_ingot",Count:1b}}
execute at @s[tag=NethG1] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG1] run execute if predicate suhc:50percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG2] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG3] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute at @s[tag=NethG4] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=NethG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG5] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=NethG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:3b}}
execute at @s[tag=NethG7] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:4b}}
execute at @s[tag=NethG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:2b}}
execute at @s[tag=NethG8] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:6b}}

##### GIVING BACK BASE MATERIALS END


##### OTHER ITEMS START

execute as @s[tag=ItemSaveSaddle] run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute as @s[tag=ItemSaveSaddle] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:1b}}
execute as @s[tag=ItemSaveSaddle] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:2b}}
execute as @s[tag=ItemSaveSaddle] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:3b}}
execute as @s[tag=ItemSaveSaddle] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:leather",Count:4b}}

execute at @s[tag=EnchB] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:1b}}
execute as @s[tag=EnchB] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:2b}}
execute as @s[tag=EnchB] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:3b}}
execute as @s[tag=EnchB] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:5b}}
execute as @s[tag=EnchB] run execute if predicate suhc:25percent run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:7b}}



#execute at @s[tag=ItemSaveEgg] run execute at @e[type=marker,tag=ECChestMarker,limit=1,sort=nearest] run summon chicken ~ ~1 ~
#
#execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run tag @e[tag=GA2,tag=ECChestMarker,limit=1,distance=..10] add GA3
#execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run tag @e[tag=GA1,tag=ECChestMarker,limit=1,distance=..10] add GA2
#execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run tag @e[tag=!GA1,tag=ECChestMarker,limit=1,distance=..10] add GA1
#execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run execute at @e[tag=ECChestMarker,limit=1,distance=..30,tag=!GA2] run tellraw @a[distance=..200] ["",{"text":"The cavern chest has gained part of the ","color":"gold"},{"text":"effect","color":"gold","underlined":true,"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Consumed item: Golden Apple.\nEffect: Has a chance to heal players near it at the start of every day.","color":"green"}]}}},{"text":" of an item it has consumed!","color":"gold","underlined":false}]
#execute at @e[type=marker,tag=ECChestMarker,tag=!GA3] positioned ~ 0 ~ run execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run execute at @e[tag=ECChestMarker,limit=1,distance=..30,tag=GA2] run tellraw @a[distance=..200] ["",{"text":"The cavern chest has gained part of the ","color":"gold"},{"text":"effect","color":"gold","underlined":true,"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Consumed item: Golden Apple.\nEffect #2: Has a higher chance to heal players near it at the start of every day.","color":"green"}]}}},{"text":" of an item it has consumed!","color":"gold","underlined":false}]
#execute at @e[type=marker,tag=ECChestMarker,tag=GA3] positioned ~ 0 ~ run execute at @s[tag=ItemSaveGA] positioned ~ 10 ~ run execute at @e[tag=ECChestMarker,limit=1,distance=..30,tag=GA3] run tellraw @a[distance=..200] ["",{"text":"The cavern chest has gained part of the ","color":"gold"},{"text":"effect","color":"gold","underlined":true,"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Consumed item: Golden Apple.\nEffect #3: Will always heal players near it at the start of every day.","color":"green"}]}}},{"text":" of an item it has consumed!","color":"gold","underlined":false}]
#execute at @e[type=marker,tag=ECChestMarker,tag=GA3] run effect give @a[distance=..100] regeneration 5 0
#execute if predicate suhc:50percent run execute at @e[tag=ECChestMarker,tag=GA2] run effect give @a[distance=..100] regeneration 5 0
#execute if predicate suhc:25percent run execute at @e[tag=ECChestMarker,tag=GA1] run effect give @a[distance=..100] regeneration 5 0
#execute at @s[tag=ItemSaveNA] positioned ~ 10 ~ run tag @e[tag=ECChestMarker,limit=1,distance=..10] add NA1
#execute at @s[tag=ItemSaveNA] positioned ~ 10 ~ run execute at @e[tag=ECChestMarker,limit=1,distance=..30,tag=NA1] run tellraw @a[distance=..200] ["",{"text":"The cavern chest has gained an ","color":"gold"},{"text":"effect","color":"gold","underlined":true,"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Consumed item: Notch Apple.\nEffect: None currently. Sucks, eh?","color":"green"}]}}},{"text":"!","color":"gold","underlined":false}]

#execute at @s[tag=ItemSaveEmBlock] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..40] run tag @a[distance=..100] add KyuEmeraldLuck
#execute at @s[tag=ItemSaveEmBlock] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..50,limit=1] run tellraw @a[distance=..100] ["",{"text":"The chest demolishes the emerald block, scattering the effects of luck around the area!","color":"dark_green"}]
#scoreboard players add @a[tag=KyuEmeraldLuck] KyuLuck 1
#scoreboard players add @a[tag=KyuEmeraldLuck] KyuLuck20min 20
#tag @a remove KyuEmeraldLuck


execute at @s[tag=ItemSavePumpkin] run summon item ~ ~ ~ {Item:{id:"minecraft:carved_pumpkin",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.follow_range",Name:"generic.follow_range",Amount:-.05,Operation:2,UUID:[I;6969,6969,6969,1121],Slot:"head"},{AttributeName:"generic.armor",Name:"generic.armor",Amount:3,Operation:0,UUID:[I;6969,6969,6969,1122],Slot:"head"},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:2,Operation:0,UUID:[I;6969,6969,6969,1123],Slot:"head"}],display:{Name:"Sturdy Pumpkin"}}}}


execute if predicate suhc:25percent run execute if predicate suhc:25percent run execute at @s[tag=ItemSaveBS] run summon item ~ ~ ~ {Tags:["BlazePowderKyu"],Item:{id:"minecraft:blaze_powder",Count:1b}}
execute as @s[tag=ItemSaveBS] run execute store result entity @e[tag=BlazePowderKyu,limit=1,sort=nearest,type=item] Item.Count byte 1 run data get entity @s Item.Count 1
execute at @s[tag=ItemSaveBS] run tag @e[tag=BlazePowderKyu,limit=1,sort=nearest,type=item] remove BlazePowderKyu
#execute at @s[tag=ItemSaveBS] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:4b}}
execute at @s[tag=ItemSaveBS] run summon item ~ ~ ~ {Tags:["PotionChestKyu"],Item:{id:"minecraft:chest",Count:1b,tag:{display:{Name:'{"text":"Super Potion Chest","color":"aqua"}'},BlockEntityTag:{LootTable:"chests/superpotionchest"}}}}
execute as @s[tag=ItemSaveBS] run execute store result entity @e[tag=PotionChestKyu,limit=1,sort=nearest,type=item] Item.Count byte 1 run data get entity @s Item.Count 1
execute at @s[tag=ItemSaveBS] run tag @e[tag=PotionChestKyu,limit=1,sort=nearest,type=item] remove PotionChestKyu



#execute at @s[tag=ItemSaveET] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:8b}}
execute at @s[tag=ItemSaveET] run summon item ~ ~ ~ {Tags:["BookChestKyu"],Item:{id:"minecraft:chest",Count:1b,tag:{display:{Name:'{"text":"Book Chest","color":"aqua"}'},BlockEntityTag:{LootTable:"chests/bookchest"}}}}
execute as @s[tag=ItemSaveET] run execute store result entity @e[tag=BookChestKyu,limit=1,sort=nearest,type=item] Item.Count byte 1 run data get entity @s Item.Count 1
execute at @s[tag=ItemSaveET] run tag @e[tag=BookChestKyu,limit=1,sort=nearest,type=item] remove BookChestKyu

#execute at @s[tag=ItemSaveGT] run execute at @e[tag=ECChestMarker,distance=..40] run effect give @a[distance=..100] instant_health 1 1
#execute if predicate suhc:50percent run execute at @s[tag=ItemSaveGT] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..40] run effect give @a[distance=..100] regeneration 10 0
#execute if predicate suhc:25percent run execute at @s[tag=ItemSaveGT] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..40] run effect give @a[distance=..100] regeneration 20 0
#execute at @s[tag=ItemSaveGT] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..50,limit=1] run tellraw @a[distance=..100] ["",{"text":"The chest crushes the ghast tear, spreading some of its effects in the process!","color":"light_purple"}]
#execute at @s[tag=ItemSaveGT] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:5b}}
#execute if predicate suhc:50percent run execute at @s[tag=ItemSaveGT] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:5b}}

#execute at @s[tag=ItemSaveBP] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..70,limit=1] run effect give @a[distance=..100] fire_resistance 2700 0
#execute at @s[tag=ItemSaveBP] positioned ~ 12 ~ run execute at @e[tag=ECChestMarker,distance=..50,limit=1] run tellraw @a[distance=..100] ["",{"text":"The chest destroys the blaze powder, spreading an aura of fire resistance within the area!","color":"gold"}]
#execute at @s[tag=ItemSaveBP] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:8b}}
#execute if predicate suhc:50percent run execute at @s[tag=ItemSaveBP] run summon item ~ ~ ~ {Item:{id:"minecraft:experience_bottle",Count:8b}}




###Do chance to give back enchantments
execute as @s[scores={KyuDummy2=2250..2749}] run execute if predicate suhc:25percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=2750..3249}] run execute if predicate suhc:30percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=3250..3749}] run execute if predicate suhc:35percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=3750..4249}] run execute if predicate suhc:40percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=4250..4749}] run execute if predicate suhc:45percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=4750..5249}] run execute if predicate suhc:50percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=5250..5749}] run execute if predicate suhc:55percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=5750..6249}] run execute if predicate suhc:60percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=6250..6749}] run execute if predicate suhc:65percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=6750..7249}] run execute if predicate suhc:70percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=7250..7749}] run execute if predicate suhc:75percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=7750..8249}] run execute if predicate suhc:80percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=8250..8749}] run execute if predicate suhc:85percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=8750..9249}] run execute if predicate suhc:90percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=9250..9749}] run execute if predicate suhc:95percent run tag @s add EnchantSave
execute as @s[scores={KyuDummy2=9750..}] run tag @s add EnchantSave
#execute as @s[tag=EnchantSave,tag=EnchB] run tellraw @a ["",{"color":"gold","score":{"name":"@s","objective":"KyuDummy2"}},{"text":" score, is ","color":"yellow"},{"text":"ENCHANTED","color":"green"}]
#execute as @s[tag=!EnchantSave,tag=EnchB] run tellraw @a ["",{"color":"gold","score":{"name":"@s","objective":"KyuDummy2"}},{"text":" score, is ","color":"yellow"},{"text":"NO ENCHANTS","color":"red"}]
execute as @s[tag=EnchantSave,tag=EnchB] run function zzzzdonotuse:structures/enchantedcavern/chest/enchantments




kill @s[type=item,tag=!ItemSaveEffects]






