loot replace entity @s container.0 loot ws:scientist/meteorite
scoreboard players reset @s meteorite.common
scoreboard players reset @s meteorite.uncommon
scoreboard players reset @s meteorite.rare
execute store result score @s material.pallete run random value 1..150
data modify entity @s[scores={material.pallete=1..50}] item.components."minecraft:custom_data".uncommon_material set value 'coal'
execute unless data entity @s item.components."minecraft:custom_data"{common_material:'iron'} run data modify entity @s[scores={material.pallete=51..84}] item.components."minecraft:custom_data".uncommon_material set value 'iron'
execute unless data entity @s item.components."minecraft:custom_data"{common_material:'gold'} run data modify entity @s[scores={material.pallete=85..100}] item.components."minecraft:custom_data".uncommon_material set value 'gold'
scoreboard players reset @s material.pallete
execute store result score @s material.pallete run random value 1..100
data modify entity @s[scores={material.pallete=1..10}] item.components."minecraft:custom_data".rare_material set value 'amethyst'
data modify entity @s[scores={material.pallete=11..16}] item.components."minecraft:custom_data".rare_material set value 'emerald'
data modify entity @s[scores={material.pallete=17}] item.components."minecraft:custom_data".rare_material set value 'diamond'
scoreboard players reset @s material.pallete
execute store result score @s meteorite.health run random value 150..250
scoreboard players operation @s meteorite.study.health = @s meteorite.health
scoreboard players operation @s meteorite.study.health += @s meteorite.health
execute as @e[tag=meteorite.health] run function ws:work/misc/tier2/scientist/displayhealth
execute as @e[tag=meteorite.study] run function ws:work/misc/tier2/scientist/displaystudy
execute unless data entity @s item.components."minecraft:custom_data".uncommon_material unless data entity @s item.components."minecraft:custom_data".rare_material run return run scoreboard players operation @s meteorite.common = @s meteorite.health  
execute store result score @s meteorite.percent run random value 60..80
scoreboard players operation @s meteorite.common = @s meteorite.health
scoreboard players operation @s meteorite.common *= @s meteorite.percent
scoreboard players operation @s meteorite.common /= .100 meteorite.percent
execute if data entity @s item.components."minecraft:custom_data".uncommon_material store result score @s meteorite.uncommon run scoreboard players operation @s meteorite.health -= @s meteorite.common
execute unless data entity @s item.components."minecraft:custom_data".uncommon_material store result score @s meteorite.rare run scoreboard players operation @s meteorite.health -= @s meteorite.common
scoreboard players operation @s meteorite.health += @s meteorite.common
execute unless data entity @s item.components."minecraft:custom_data".uncommon_material run return 0
execute unless data entity @s item.components."minecraft:custom_data".rare_material run return 0
execute store result score @s meteorite.percent run random value 20..40
scoreboard players operation @s meteorite.rare = @s meteorite.uncommon
scoreboard players operation @s meteorite.rare *= @s meteorite.percent
scoreboard players operation @s meteorite.rare /= .100 meteorite.percent
scoreboard players operation @s meteorite.uncommon -= @s meteorite.rare