
# -> If block is not in air then return and break
execute unless block ~ ~ ~ #air \
    unless block ~ ~ ~ #campfires run \
        return run \
            function overly_realistic:general/custom_blocks/clay_mold/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/clay_mold/clay_mold_break

# -> Advancement
#execute if block ~ ~ ~ #campfires[lit=true] run \
    advancement grant @p[tag=OverlyRealistic.Player.PlacedCustomBlock,distance=..64] only overly_realistic:advancements/copper_age/pretty_much_a_microwave

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

# -> Place display
summon interaction ~ ~ ~ {response:1b,Tags:["OverlyRealistic.Block.ClayMold","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.ClayMold_TempMold","OverlyRealistic.Block.Block_CanBeFired"],width:0.5f,height:0.3f,data:{or_custom_block_id:"clay_mold",or_is_custom_block:1b,interaction_call:"overly_realistic:general/custom_blocks/clay_mold/clay_mold_interaction",break_call:"overly_realistic:general/custom_blocks/clay_mold/clay_mold_break"},Passengers:[{id:"item_display",Tags:["OverlyRealistic.Block.ClayMold"],item: {count: 1, id: "minecraft:clay_ball", components:{item_model:"overlyrealistic:blocks/clay_mold/clay_mold"}}, transformation: {left_rotation: [-5.1391045E-5f, -0.7071068f, 0.7071068f, -5.1391045E-5f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.7500002f, 0.7500001f, 0.74999976f], translation: [0.0f, -0.27499998f, 0.0f]}}]}

# -> If clay mold has been molded already then place with data
execute if entity @s[tag=OverlyRealistic.Block.ClayMold_HasMoldType] run \
    return run \
        function overly_realistic:general/custom_blocks/clay_mold/clay_mold_placed_edit_with_data with entity @s data

# -> Edit interaction & display
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.ClayMold_TempMold,dx=0,dy=0,dz=0,sort=arbitrary] run \
        function overly_realistic:general/custom_blocks/clay_mold/clay_mold_placed_edit
