## CHEF_INHALE
## CHEF_ACTIVATED.MCFUNCTION
## @s=PLAYER

playsound chef.inhale_loop @a ~ ~ ~

## TELEPORT MOBS FOR INHALE
tag @s add chef_inhale
tag @e[family=mob,family=!ender,type=!enderman,r=1.5,c=1] add swallowed
execute positioned ^ ^ ^1 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^2 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^3 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^4 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^5 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^6 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute positioned ^ ^ ^7 run tag @e[family=mob,family=!ender,type=!enderman,r=1.5] add inhaled
execute as @e[tag=inhaled,c=1] at @s run ride @s evict_riders
execute as @e[tag=inhaled,c=1] at @s run tp @s ~ ~ ~ facing @p[tag=chef_inhale,c=1]
execute as @e[tag=inhaled,c=1] at @s run tp @s ^ ^ ^0.5

## STORE MOB IN STRUCTURE
execute as @e[tag=swallowed,c=1] run scoreboard players add .var ChefInhaled 1
execute as @e[tag=swallowed,c=1] align xyz run tp ~0.5 ~0.5 ~0.5
execute if entity @e[tag=swallowed,c=1] run scoreboard players operation @s ChefInhaled = .var ChefInhaled
execute if entity @e[tag=swallowed,c=1] run scoreboard players operation @s ChefInhaled = .var ChefInhaled
execute if entity @e[tag=swallowed,c=1] run tag @s add chef_dirty
execute if entity @e[tag=swallowed,c=1] run event entity @s set_chef_full_to_true
execute if entity @e[tag=swallowed,c=1] run playsound chef.swallow @a ~ ~ ~
scoreboard objectives add ChefInhaled dummy
scoreboard players add @s ChefInhaled 0
execute if score @s ChefInhaled matches 1 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_1 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 2 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_2 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 3 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_3 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 4 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_4 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 5 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_5 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 6 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_6 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 7 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_7 ~ ~ ~ ~ ~ ~ true disk false
execute if score @s ChefInhaled matches 8 as @e[tag=swallowed,c=1] at @s run structure save swallowed_mob_8 ~ ~ ~ ~ ~ ~ true disk false
event entity @e[tag=swallowed,c=1] despawn

## CLEAR TAGS
tag @s remove chef_inhale
tag @e[tag=inhaled] remove inhaled
tag @e[tag=swallowed] remove swallowed
