
# -> If block is not in air then return and break
execute unless block ~ ~ ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/wooden_rack/rack_break_from_place with entity @s data

# -> If block is inside another custom block then return and break
execute align xyz \
    if entity @n[type=interaction,tag=OverlyRealistic.Block.IsCustomBlock,tag=!OverlyRealistic.Block.IsFullBlock,dx=0,dy=0,dz=0] run \
        return run \
            function overly_realistic:general/custom_blocks/cooking_board/cooking_board_break

# -> Sound
playsound block.wood.place block @a ~ ~ ~ 0.45 1

# -> Place interaction
summon interaction ~ ~-0.5 ~ {response:1b,Tags:["OverlyRealistic.Block.CookingBoard","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.TempCookingBoard"],width:1.0f,height:0.1f,data:{interaction_call:"",break_call:"overly_realistic:general/custom_blocks/charcoal_clump/charcoal_clump_break"},Passengers:[{id:"item_display", item: {count: 1, id: "minecraft:oak_slab", components:{"minecraft:item_model":"air"}}, 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.4f, 0.0f]}}]}

# -> Advancement
advancement grant @p[tag=OverlyRealistic.Player.PlacedCustomBlock,distance=..64] only overly_realistic:advancements/iron_age/town_of_ember

# -> Edit cooking board
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.TempCookingBoard,dx=0,dy=0,dz=0] run \
        function overly_realistic:general/custom_blocks/cooking_board/cooking_board_placed_edit

# -> Remove marker
kill @s
