
# -> Add temp tag
tag @s add OverlyRealistic.Block.GiftInteractedWith

# -> Reset drop completion
scoreboard players set #or.gift_has_dropped_item OverlyRealistic.General.ArbitraryData 0

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

# -> Reset put_item_in_gift
scoreboard players set #or.put_item_in_gift OverlyRealistic.General.ArbitraryData 0

# -> Operate on player
execute on target run \
    function overly_realistic:general/custom_blocks/gift/player_interact_with_gift

# -> Remove temp tag
tag @s remove OverlyRealistic.Block.GiftInteractedWith

# -> If put_item_in_gift = 1 then copy item into gift
execute if score #or.put_item_in_gift OverlyRealistic.General.ArbitraryData matches 1 run \
    function overly_realistic:general/custom_blocks/gift/interaction_actions/gift_put_in_item

# -> If completion hasn't been done then return
execute unless score #or.gift_has_dropped_item OverlyRealistic.General.ArbitraryData matches 1 run \
    return fail

# -> Reset HasItem
scoreboard players set @s OverlyRealistic.General.ArbitraryData 0

# -> Reset lore
execute on passengers run \
    data remove entity @s item.components."minecraft:lore"

# -> Reset data
data remove entity @s data.gift_content_item
