
# -> Tag player
tag @s add OverlyRealistic.Player.TempPlayer

# --> Interaction checks

# -> Remove items on shift-click
execute if predicate overly_realistic:player/actions/player_is_shifting run \
    return run \
        execute as @n[type=interaction,tag=OverlyRealistic.Block.PreparationPlate,distance=..64,nbt={interaction:{}}] at @s run \
            function overly_realistic:general/custom_blocks/preparation_plate/preparation_plate_remove_items_from_interaction

# -> If the player is not holding any items then craft items
execute unless items entity @s weapon.mainhand * run \
    return run \
        execute as @n[type=interaction,tag=OverlyRealistic.Block.PreparationPlate,distance=..64,nbt={interaction:{}}] \
            at @s \
            align xyz \
            positioned ~0.5 ~0.5 ~0.5 run \
                function overly_realistic:general/custom_blocks/preparation_plate/preparation_plate_general_interact {type:"craft"}

# -> Store currently used item
item replace entity 00000001-0000-002b-0000-00010000002b contents from entity @s weapon.mainhand

# -> Cap item amount
data modify entity 00000001-0000-002b-0000-00010000002b item.count set value 1

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

# -> Add items
execute as @n[type=interaction,tag=OverlyRealistic.Block.PreparationPlate,distance=..64,nbt={interaction:{}}] \
    at @s \
    align xyz \
    positioned ~0.5 ~0.5 ~0.5 run \
        function overly_realistic:general/custom_blocks/preparation_plate/preparation_plate_general_interact {type:"add_item_general"}

# -> Decrease item amount if possible
execute if score #or.global OverlyRealistic.General.ArbitraryData matches 1 run \
    item modify entity @s[gamemode=!creative] weapon.mainhand overly_realistic:multipurpose/remove_one_item
