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

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

# -> Place interaction
summon interaction ~ ~ ~ {response:1b,Tags:["OverlyRealistic.Block.Gift","OverlyRealistic.Block.IsCustomBlock","OverlyRealistic.Block.Gift_TempGift"],width:0.6f,height:0.5f,data:{interaction_call:"overly_realistic:general/custom_blocks/gift/gift_interaction",break_call:"overly_realistic:general/custom_blocks/gift/gift_break"},Passengers:[{id:"item_display", Tags:["OverlyRealistic.Block.Gift"]}]}

# -> Get gift item
data modify storage overly_realistic:blocks gift_type set from entity @s data.type

# -> Get gift contents item if possible
scoreboard players set #or.gift_has_item OverlyRealistic.General.ArbitraryData 0
execute if data entity @s data.gift_content_item run \
    scoreboard players set #or.gift_has_item OverlyRealistic.General.ArbitraryData 1
execute if score #or.gift_has_item OverlyRealistic.General.ArbitraryData matches 1 run \
    data modify storage overly_realistic:blocks gift_content_item set from entity @s data.gift_content_item

# -> Edit gift
execute align xyz \
    as @n[type=interaction,tag=OverlyRealistic.Block.Gift_TempGift,dx=0,dy=0,dz=0] run \
        function overly_realistic:general/custom_blocks/gift/gift_edit with storage overly_realistic:blocks
