execute if score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..5] if items entity @s contents minecraft:snow_block if data entity @s Thrower run data modify entity @n[type=minecraft:happy_ghast,distance=..2,limit=1,sort=nearest] data.Owner set from entity @s Thrower
execute if score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..5] if items entity @s contents minecraft:snow_block unless data entity @s Thrower if data entity @s Owner run data modify entity @n[type=minecraft:happy_ghast,distance=..2,limit=1,sort=nearest] data.Owner set from entity @s Owner
execute unless score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..1.5] if items entity @s contents minecraft:snow_block if data entity @s Thrower run data modify entity @n[type=minecraft:happy_ghast,distance=..2,limit=1,sort=nearest] data.Owner set from entity @s Thrower
execute unless score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..1.5] if items entity @s contents minecraft:snow_block unless data entity @s Thrower if data entity @s Owner run data modify entity @n[type=minecraft:happy_ghast,distance=..2,limit=1,sort=nearest] data.Owner set from entity @s Owner

tag @s add Happy_Ghast.Tamed

execute unless entity @s[tag=Happy_Ghast.BetterStats] run function better_happy_ghast:tick/happy_ghast/apply_tamed_attributes

execute if score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..5] if items entity @s contents minecraft:snow_block run function better_happy_ghast:tick/happy_ghast/tame/consume_item
execute unless score @s better_happy_ghast.happy_ghast.age matches 0.. at @s as @n[type=minecraft:item,distance=..1.5] if items entity @s contents minecraft:snow_block run function better_happy_ghast:tick/happy_ghast/tame/consume_item

execute if score @s better_happy_ghast.happy_ghast.age matches 0.. run particle minecraft:heart ~ ~ ~ 2 2 2 0 40 force
execute unless score @s better_happy_ghast.happy_ghast.age matches 0.. run particle minecraft:heart ~ ~ ~ 0.75 0.75 0.75 0 10 force

function better_happy_ghast:tick/happy_ghast/tame/give_advancement_to_player with entity @s data
