
# -> If block is inside a large charcoal clump then return
execute align xyz \
    if entity @n[type=interaction,tag=OverlyRealistic.Block.LargeCharcoalClump,dx=0,dy=0,dz=0] run \
        return run \
            kill @s

# -> Get the fuel of the campfire
execute align xyz \
    as @n[type=marker,tag=OverlyRealistic.CampfireBlock,dx=0,dy=0,dz=0,sort=arbitrary] run \
        scoreboard players operation #or.current_campfire_fuel_time OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.World.CampfireFireTime

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

# -> Add to large_charcoal_clump_level_pre_def depending on fuel time
scoreboard players operation #or.current_campfire_fuel_time OverlyRealistic.General.ArbitraryData /= #or.static_num_100 OverlyRealistic.General.ArbitraryData
scoreboard players operation #or.large_charcoal_clump_level_pre_def OverlyRealistic.General.ArbitraryData += #or.current_campfire_fuel_time OverlyRealistic.General.ArbitraryData

# -> Get items from campfire
data modify block -29999985 2 -29999985 Items set from block ~ ~ ~ Items

# -> Get how many logs the campfire has
execute store result score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData \
    if items block -29999985 2 -29999985 container.* #logs_that_burn

# -> Add pre_def to clump_level
scoreboard players operation #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData += #or.large_charcoal_clump_level_pre_def OverlyRealistic.General.ArbitraryData

# -> Tag item
tag @s add OverlyRealistic.Item.LargeCharcoalClumpHasBeenOperatedOn

# -> Get same-tick outputs
execute align xyz \
    as @e[type=item,tag=!OverlyRealistic.Item.LargeCharcoalClumpHasBeenOperatedOn,dx=0,dy=0,dz=0] \
    if items entity @s contents *[custom_data~{or_specialized_drop_type:"charcoal_from_pit"}] run \
        function overly_realistic:general/custom_blocks/large_charcoal_clump/count_same_tick_outputs

# -> Place block
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches ..0 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity1"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 1 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity2"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 2 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity3"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 3 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity4"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 4..5 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity5"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 6..7 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity6"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 8..9 \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity7"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}
execute if score #or.large_charcoal_clump_level OverlyRealistic.General.ArbitraryData matches 10.. \
    align xyz run \
        summon interaction ~0.5 ~ ~0.5 {response:1b,Tags:["OverlyRealistic.Block.LargeCharcoalClump","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.LargeCharcoalClump_Quantity8"],width:1.0f,height:0.4f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/large_charcoal_clump/large_charcoal_clump_break"},Passengers:[{id:"item_display",item: {count: 1, id: "minecraft:coal_block", components:{"minecraft:item_model":"overlyrealistic:blocks/large_charcoal_clump_placed"}}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.1f, 0.0f]}}]}

# -> Remove campfire
setblock ~ ~ ~ air strict
