
# -> If block is not in air then return and break
#execute unless block ~ ~ ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/hardened_clay_mold/hardened_clay_mold_break

# -> 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/tool_handle/handle_break

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

# -> Place display
summon interaction ~ ~ ~ {response:1b,Tags:["OverlyRealistic.Block.ToolHandle","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.ToolHandle_TempHandle"],width:1.0f,height:0.2f,data:{interaction_call:"overly_realistic:general/custom_blocks/tool_handle/handle_interaction",break_call:"overly_realistic:general/custom_blocks/tool_handle/handle_break"},Passengers:[{id:"item_display",Tags:["OverlyRealistic.Block.ToolHandle"], transformation: {left_rotation: [0.65328145f, 0.27059823f, -0.27059823f, 0.65328145f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.8f, 0.8f, 0.8f], translation: [0.05f, -0.18f, 0.0f]}},{id:"text_display",Tags:["OverlyRealistic.Block.ToolHandle_TextBackground"], view_range:0.05f, billboard:"vertical", alignment: "center", background: 0, default_background: 0b, line_width: 200, see_through: 0b, shadow: 0b, text: {atlas: "minecraft:gui", sprite: "minecraft:toast/recipe"}, text_opacity: -107b, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [6.3125f, 1.9171594f, 5.829059f], translation: [-0.153f, 0.5f, 0.0f]}},{id:"text_display",Tags:["OverlyRealistic.Block.ToolHandle_Text"], view_range:0.05f, billboard:"vertical", alignment: "center", background: 0, default_background: 0b, line_width: 200, see_through: 0b, shadow: 0b, text: {color: "black", translate:"block_tooltip.overlyrealistic.tool_handle.step_0", fallback: "[Requires tool head]\n[Required]"}, text_opacity: -107b, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.4f, 0.4f, 0.4f], translation: [0.01f, 0.685f, 0.001f]}}]}

# -> Edit interaction & display
execute align xyz run \
    function overly_realistic:general/custom_blocks/tool_handle/handle_interaction_modify with entity @s data
