
# -> If item is special then do custom logic
execute if items entity @s contents #overly_realistic:editable_item_special run \
    function overly_realistic:general/items/get_item_special

# -> If item has a max stack already then return
execute if items entity @s contents *[custom_data~{or_edited_item:1b}] run \
    return fail

# -> Edited data
item modify entity @s contents overly_realistic:item_edit/or_edited_item_data

# --> Item stacks

# -> Weighted blocks
execute if items entity @s contents #overly_realistic:item_stacks/stack_1 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_1_a
execute if items entity @s contents #overly_realistic:item_stacks/stack_50 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_50_a
execute if items entity @s contents #overly_realistic:item_stacks/stack_4 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_4_a
execute if items entity @s contents #overly_realistic:item_stacks/stack_32 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_32_a
execute if items entity @s contents #overly_realistic:item_stacks/stack_16 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_16_a
execute if items entity @s contents #overly_realistic:item_stacks/stack_8 run \
    return run \
        function overly_realistic:general/items/unstacking_display/stack_8_a

# -> If not any of the above then set to 20

# -> Get count
execute store result score @s OverlyRealistic.General.ArbitraryData run \
    data get entity @s item.count

# -> If count is not higher than max then return and modify item
execute unless score @s OverlyRealistic.General.ArbitraryData matches 21.. run \
    return run \
        item modify entity @s contents overly_realistic:item_edit/stack_size_20

# -> Set count
item modify entity @s contents overly_realistic:multipurpose/count_set/set_count_20

# -> Set max stack size
item modify entity @s contents overly_realistic:item_edit/stack_size_20
