
# -> If basket does not have water then return
execute if entity @s[tag=!OverlyRealistic.Block.Basket_IsWaterLogged] run \
    return fail

# -> Sound
playsound minecraft:entity.boat.paddle_water block @a ~ ~ ~ 0.85 2

# -> Particle
particle falling_water ~ ~0.5 ~ 0.125 0 0.125 0.001 1 normal @a

# -> Rotation test
#execute as @n[type=block_display,tag=OverlyRealistic.Block.Basket,distance=..0.5] \
    on passengers \
    if entity @s[type=item_display] \
    at @s run \
        rotate @s ~10 ~

# -> Add onto stir amount
execute unless score @s OverlyRealistic.World.BasketStirAmount matches 100.. run \
    return run \
        function overly_realistic:general/custom_blocks/basket/interactions/int_stir_add

# -> Unless stir RNG passes, return
#execute unless predicate overly_realistic:world/basket/basket_stir_success_rng run \
    return fail

# -> Reset stir value
scoreboard players set @s OverlyRealistic.World.BasketStirAmount 0

# -> Cache items data into storage
data modify storage overly_realistic:temp_values temp_basket_items set from entity @s data.BasketItems

# ----> Check recipes

# --> Additional base binary tree

# -> Tannin solution base
execute if entity @s[tag=OverlyRealistic.Block.Basket_Status_HasTanninSolutionBase] run \
    return run \
        function overly_realistic:general/custom_blocks/basket/interactions/int_stir_additional_tannin_solution

# -> Kelp base
execute if entity @s[tag=OverlyRealistic.Block.Basket_Status_HasKelpBase] run \
    return run \
        function overly_realistic:general/custom_blocks/basket/interactions/int_stir_additional_kelp_base

# -> Sweet berry base
execute if entity @s[tag=OverlyRealistic.Block.Basket_Status_HasSweetBerryBase] run \
    return fail

# -> Poison base
execute if entity @s[tag=OverlyRealistic.Block.Basket_Status_HasPoisonBase] run \
    return run \
        function overly_realistic:general/custom_blocks/basket/interactions/int_stir_additional_poison_base

# -> Honey base
execute if entity @s[tag=OverlyRealistic.Block.Basket_Status_HasHoneyBase] run \
    return run \
        function overly_realistic:general/custom_blocks/basket/interactions/int_stir_additional_honey_base

# --> Normal recipes

# --> Bases

# -> Kelp base
execute if data storage overly_realistic:temp_values \
    {temp_basket_items:\
        [\
            {id:"minecraft:kelp"},{id:"minecraft:kelp"},{id:"minecraft:kelp"},\
            {id:"minecraft:kelp"},{id:"minecraft:kelp"},{id:"minecraft:kelp"},\
            {id:"minecraft:kelp"},{id:"minecraft:kelp"},{id:"minecraft:kelp"}\
        ]\
    } run \
        return run \
            function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_kelp_base

# -> Poison base
execute if data storage overly_realistic:temp_values \
    {temp_basket_items:\
        [\
            {id:"minecraft:lily_of_the_valley"},{id:"minecraft:lily_of_the_valley"},{id:"minecraft:lily_of_the_valley"},\
            {id:"minecraft:rotten_flesh"},{id:"minecraft:rotten_flesh"},{id:"minecraft:rotten_flesh"},\
            {id:"minecraft:sweet_berries"},{id:"minecraft:pufferfish"},{id:"minecraft:spider_eye"}\
        ]\
    } run \
        return run \
            execute if score @s OverlyRealistic.World.BasketBoilTime matches 100.. run \
                function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_poison_base

# -> Sweet berry base
execute if data storage overly_realistic:temp_values \
    {temp_basket_items:\
        [\
            {id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"},\
            {id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"},\
            {id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"},{id:"minecraft:sweet_berries"}\
        ]\
    } run \
        return run \
            function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_sweet_berry_base

# -> Honey base
execute if data storage overly_realistic:temp_values \
    {temp_basket_items:\
        [\
            {id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"},\
            {id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"},\
            {id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"},{id:"minecraft:honeycomb"}\
        ]\
    } run \
        return run \
            function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_honey_base

# --> Misc recipes

# -> Tannin solution
execute if score @s OverlyRealistic.World.BasketBoilTime matches 100.. \
    if data storage overly_realistic:temp_values \
        {temp_basket_items:\
            [\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wood_scraps"}}\
            ]\
        } run \
            return run \
                function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_tannin_solution

# -> Dough
execute if data storage overly_realistic:temp_values \
    {temp_basket_items:\
        [\
            {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},\
            {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},\
            {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/wheat_flour"}}\
        ]\
    } run \
        return run \
            function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_dough

# -> Bone glue
execute if score @s OverlyRealistic.World.BasketBoilTime matches 100.. \
    if data storage overly_realistic:temp_values \
        {temp_basket_items:\
            [\
                {id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"},\
                {id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"},\
                {id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"},{id:"minecraft:bone_meal"}\
            ]\
        } run \
            return run \
                function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_bone_glue

# -> Fish glue
execute if score @s OverlyRealistic.World.BasketBoilTime matches 100.. \
    if data storage overly_realistic:temp_values \
        {temp_basket_items:\
            [\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},\
                {id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}},{id:"minecraft:poisonous_potato",components:{"minecraft:item_model":"overlyrealistic:items/fish_scraps"}}\
            ]\
        } run \
            return run \
                function overly_realistic:general/custom_blocks/basket/interactions/stir_interactions/create_fish_glue
