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

# -> Remove charcoal clump
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.CharcoalClump,dx=0,dy=0,dz=0] run \
        function overly_realistic:general/custom_blocks/charcoal_clump/charcoal_clump_break_from_external_source

# -> If charcoal clump doesn't exist then return and send tip to nearby players if possible
execute if score #or.iron_fragment_heat_success OverlyRealistic.General.ArbitraryData matches 0 run \
    return run \
        execute if score #or.setting.tips OverlyRealistic.Settings.ArbitrarySetting matches 1 \
        as @a[tag=OverlyRealistic.Player.InteractedWithCustomBlock,distance=..8] \
        unless score @s OverlyRealistic.Player.Tips.HasReceivedTip_NoCharcoalClumpIronFragmentsHeat matches 1 \
        at @s run \
            function overly_realistic:players/tips/send_tip_no_charcoal_clump_iron_frag_heat

# -> Get the amount of deepslate bricks that make up the furnace
execute store result score #or.furnace_wall_1_block_amount OverlyRealistic.General.ArbitraryData run \
    fill ~1 ~ ~ ~1 ~2 ~ command_block{Command:"say overlyrealistic:cbac"} replace deepslate_bricks strict
execute store result score #or.furnace_wall_2_block_amount OverlyRealistic.General.ArbitraryData run \
    fill ~-1 ~ ~ ~-1 ~2 ~ command_block{Command:"say overlyrealistic:cbac"} replace deepslate_bricks strict
execute store result score #or.furnace_wall_3_block_amount OverlyRealistic.General.ArbitraryData run \
    fill ~ ~ ~1 ~ ~2 ~1 command_block{Command:"say overlyrealistic:cbac"} replace deepslate_bricks strict
execute store result score #or.furnace_wall_4_block_amount OverlyRealistic.General.ArbitraryData run \
    fill ~ ~ ~-1 ~ ~2 ~-1 command_block{Command:"say overlyrealistic:cbac"} replace deepslate_bricks strict
fill ~1 ~ ~1 ~-1 ~2 ~-1 deepslate_bricks replace command_block{Command:"say overlyrealistic:cbac"} strict

scoreboard players operation #or.furnace_wall_1_block_amount OverlyRealistic.General.ArbitraryData += #or.furnace_wall_2_block_amount OverlyRealistic.General.ArbitraryData
scoreboard players operation #or.furnace_wall_1_block_amount OverlyRealistic.General.ArbitraryData += #or.furnace_wall_3_block_amount OverlyRealistic.General.ArbitraryData
scoreboard players operation #or.furnace_wall_1_block_amount OverlyRealistic.General.ArbitraryData += #or.furnace_wall_4_block_amount OverlyRealistic.General.ArbitraryData

# -> If the amount is less than 10 then return and set fire to the furnace
execute unless score #or.furnace_wall_1_block_amount OverlyRealistic.General.ArbitraryData matches 10.. run \
    return run \
        function overly_realistic:general/custom_blocks/bellow/bellow_events/heat_iron_fragments_fail

# -> Add tag
tag @s add OverlyRealistic.Block.Crucible_HasHeatedIronFragments
tag @s add OverlyRealistic.Block.Crucible_HasContents
tag @s remove OverlyRealistic.Block.Crucible_NeedsHeat
tag @s remove OverlyRealistic.Block.Crucible_HasIronFragments

# -> (@NOTE: Can be replaced with an item modifer)
# -> Modify display
execute on passengers run \
    data modify entity @s[type=item_display,tag=OverlyRealistic.Block.Crucible] item.components."minecraft:item_model" set value "overlyrealistic:blocks/placed_crucible/placed_crucible_heated_iron_fragments"

# -> Set dropped item data
#tag @s add OverlyRealistic.Block.Crucible_DropsItem
#data modify entity @s data.item_drop set value "heated_bloom"

# -> Player operations
scoreboard players set #or.heat_crucible_success OverlyRealistic.General.ArbitraryData 4
