
# -> If bellow is currently being animated then return
execute if entity @s[tag=OverlyRealistic.Block.Bellow_HasBeenUsed] run \
    return fail

# -> Tag as used
tag @s add OverlyRealistic.Block.Bellow_HasBeenUsed

# -> If bellow is compressed then return and operate accordingly
execute if entity @s[tag=OverlyRealistic.Block.Bellow_IsCompressed] run \
    return run \
        function overly_realistic:general/custom_blocks/bellow/bellow_player_interact_compressed

# -> Sound
playsound block.wool.hit block @a ~ ~ ~ 0.3 2
playsound minecraft:entity.breeze.idle_ground block @a ~ ~ ~ 0.1 2
playsound minecraft:entity.breeze.shoot block @a ~ ~ ~ 0.6 2

# -> Add compression tag
tag @s add OverlyRealistic.Block.Bellow_IsCompressed

# -> Modify display
execute on passengers run \
    data merge entity @s[type=item_display,tag=OverlyRealistic.Block.Bellow_Part_0] {start_interpolation:-1, transformation: {left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f],scale:[0.8125f,0.3125f,0.8125f],translation:[0.0f,0.5f,0.0f]}}

# -> Set wait time
scoreboard players set @s OverlyRealistic.General.ArbitraryData 20

# -> Set loop
schedule function overly_realistic:general/custom_blocks/bellow/bellow_loops/bellow_loop_main_temp 1t append

# -> If faced block is air then return and display particles
execute if block ^ ^ ^1 #overly_realistic:spear_can_passthrough run \
    return run \
        particle white_smoke ^ ^0.05 ^0.65 0 0 0 0.01 3 normal @a

# -> Particles
particle white_smoke ^ ^0.05 ^1.65 0 0 0 0.01 3 normal @a

# -> If facing block is not connected to a campfire then return
execute unless block ^ ^ ^2 #campfires[lit=true] run \
    return fail

# -> Particles
particle lava ^ ^ ^2 0.1 0 0.1 0.1 8 normal @a
particle campfire_signal_smoke ^ ^ ^2 0.1 0 0.1 0.1 4 normal @a

# -> Reset success
scoreboard players set #or.heat_crucible_success OverlyRealistic.General.ArbitraryData 0

# -> Operate on crucible if there is one, if the setup is correct, then operate
execute positioned ^ ^ ^2 \
    align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.Crucible,tag=OverlyRealistic.Block.Crucible_HasContents,dx=0,dy=0,dz=0] \
    if predicate overly_realistic:world/blocks/has_blocks_around_crucible run \
        function overly_realistic:general/custom_blocks/bellow/bellow_events/operate_on_crucible_from_bellow_int

# -> Display heat percentage to user
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 1 \
    on target run \
        function overly_realistic:general/custom_blocks/bellow/bellow_events/bellow_heat_display

# -> Display heat percentage to user (max)
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 2.. \
    on target run \
        function overly_realistic:general/custom_blocks/bellow/bellow_events/bellow_heat_display_max

# -> If heating was not successful then return
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 0..2 run \
    return fail

# --> Success operations

# -> Heat copper fragments
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 3 \
    on target run \
        return run \
            function overly_realistic:general/custom_blocks/bellow/bellow_events/player_operations/heat_copper_fragments

# -> Heat iron fragments
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 4 \
    on target run \
        return run \
            function overly_realistic:general/custom_blocks/bellow/bellow_events/player_operations/heat_iron_fragments

# -> Heat gold fragments
execute if score #or.heat_crucible_success OverlyRealistic.General.ArbitraryData matches 5 \
    on target run \
        return run \
            function overly_realistic:general/custom_blocks/bellow/bellow_events/player_operations/heat_gold_fragments
