
# -> If preparation plate already has a special item in it then return
execute if entity @s[tag=OverlyRealistic.Block.PreparationPlateHasSpecialItem] run \
    return fail

# -> If player is carrying a stripped log then return and place log
execute if items entity 00000001-0000-002b-0000-00010000002b contents #overly_realistic:stripped_logs run \
    return run \
        function overly_realistic:general/custom_blocks/preparation_plate/interactions/int_place_stripped_log

# -> If player is carrying a sharpened stick then return and place stick
execute if items entity 00000001-0000-002b-0000-00010000002b contents *[custom_data~{IsSharpenedStick:1b}] run \
    return run \
        function overly_realistic:general/custom_blocks/preparation_plate/interactions/int_place_sharpened_stick

# -> If plate is full then return
execute if score @s OverlyRealistic.World.BlockItemAmount matches 9.. run \
    return fail

# -> Sound
playsound block.leaf_litter.step block @a ~ ~ ~ 0.5 1

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

# -> Add and store new item amount
execute store result storage overly_realistic:temp_values generic_value_0 int 1 run \
    scoreboard players add @s OverlyRealistic.World.BlockItemAmount 1

# --> Add item

# -> Create new item depending on item amount
function overly_realistic:general/custom_blocks/preparation_plate/interactions/create_displayed_item/create_new_item with storage overly_realistic:temp_values

# -> Attach to display
ride @n[type=item_display,tag=OverlyRealistic.Block.PlateItemNotAttached,distance=..0.5] mount @s

# -> Set data for item
execute on passengers \
    if entity @s[type=item_display,tag=OverlyRealistic.Block.PlateItemNotAttached] run \
        function overly_realistic:general/custom_blocks/preparation_plate/interactions/int_add_item_general_item_data

# -> Append new item data
data modify entity @s data.PlateItems append from entity 00000001-0000-002b-0000-00010000002b item
