
# -> If wooden rack is already filled then return
execute if entity @s[tag=OverlyRealistic.Block.WoodenRack_Status_Filled] run \
    return fail

# -> Set as filled
tag @s add OverlyRealistic.Block.WoodenRack_RequiresContinuousOperations
tag @s add OverlyRealistic.Block.WoodenRack_Status_Filled
tag @s add OverlyRealistic.Block.WoodenRack_Status_Filled_Item_NaturalFibers
tag @s remove OverlyRealistic.Block.WoodenRack_Status_Empty
tag @s remove OverlyRealistic.Block.WoodenRack_Status_Filled_Item_DousedHide
tag @s remove OverlyRealistic.Block.WoodenRack_Status_Filled_Item_Hide

# -> Remove item from player
execute on target run \
    item modify entity @s[gamemode=!creative] weapon.mainhand overly_realistic:multipurpose/remove_one_item

# -> Attach hide item
summon item_display ~ ~ ~ {Tags:["OverlyRealistic.Block.WoodenRack_Item","OverlyRealistic.Block.WoodenRack_TempItem"]}
execute align xyz run \
    ride @n[type=item_display,tag=OverlyRealistic.Block.WoodenRack_TempItem,dx=0,dy=0,dz=0] mount @s

# -> Set rotation
scoreboard players set #or.wooden_rack_rotation_get OverlyRealistic.General.ArbitraryData 0
execute if entity @s[tag=OverlyRealistic.Block.WoodenRack_Rot_EastWest] run \
    scoreboard players set #or.wooden_rack_rotation_get OverlyRealistic.General.ArbitraryData 1
execute if entity @s[tag=OverlyRealistic.Block.WoodenRack_Rot_SouthNorth] run \
    scoreboard players set #or.wooden_rack_rotation_get OverlyRealistic.General.ArbitraryData 2

# -> Edit hide item
execute on passengers \
    if entity @s[tag=OverlyRealistic.Block.WoodenRack_TempItem] run \
        function overly_realistic:general/custom_blocks/wooden_rack/interactions/apply_natural_fibers_edit
