
# -> Remove interaction data
data remove entity @s interaction

# -> If rack is filled then return and drop current item
execute if entity @s[tag=OverlyRealistic.Block.TanningRack_Status_Filled] run \
    return run \
        function overly_realistic:general/custom_blocks/tanning_rack/drop_current_item_filled_rack

# -> If player is not holding hide then return
execute unless score #or.global OverlyRealistic.General.ArbitraryData matches 1.. run \
    return fail

# -> Set score depending on rotation
execute if entity @s[tag=OverlyRealistic.Block.TanningRack_Rot_EastWest] run \
    scoreboard players set #or.equation_part_1 OverlyRealistic.General.ArbitraryData 1
execute if entity @s[tag=OverlyRealistic.Block.TanningRack_Rot_SouthNorth] run \
    scoreboard players set #or.equation_part_1 OverlyRealistic.General.ArbitraryData 2

# -> Add item display
execute summon item_display run \
    function overly_realistic:general/custom_blocks/tanning_rack/create_displayed_item_in_rack

# -> Change tag
tag @s add OverlyRealistic.Block.TanningRack_Status_Filled
tag @s remove OverlyRealistic.Block.TanningRack_Status_Empty

# -> Sound
playsound minecraft:item.armor.equip_leather block @a ~ ~ ~ 0.45 0.7

# -> Set score
scoreboard players set #or.global OverlyRealistic.General.ArbitraryData 3
