
# -> If block is not in air then return and break
execute unless block ~ ~ ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/telescope/telescope_break
execute unless block ~ ~1 ~ #air run \
    return run \
        function overly_realistic:general/custom_blocks/telescope/telescope_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=1,dz=0] run \
        return run \
            function overly_realistic:general/custom_blocks/telescope/telescope_break

# -> Set blocks
fill ~ ~ ~ ~ ~1 ~ barrier replace air

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

# -> Place display
summon interaction ~ ~-0.01 ~ {response:1b,Tags:["OverlyRealistic.Block.Telescope","OverlyRealistic.Block.Telescope_TempBlock","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.SpecializedLifeTimeBlock"],width:1.01f,height:2.03f,data:{or_custom_block_id:"telescope",or_is_custom_block:1b,interaction_call:"overly_realistic:general/custom_blocks/telescope/telescope_interaction",break_call:"overly_realistic:general/custom_blocks/telescope/telescope_break"},Passengers:[{id:"item_display",Tags:["OverlyRealistic.Block.Telescope"],item: {count: 1, id: "minecraft:dirt", components:{item_model:"overlyrealistic:blocks/telescope_placed"}}, teleport_duration:10, 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,-1.520f,0.0f]}}]}

# -> Edit block
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.Telescope_TempBlock,dx=0,dy=0,dz=0] run \
        function overly_realistic:general/custom_blocks/telescope/telescope_edit
