
# -> Set success
scoreboard players set #or.chest_count_success OverlyRealistic.General.ArbitraryData 1

# -> Tag chest
tag @s add OverlyRealistic.Chest.HasInventoryEdited

# -> Operate on right side of the chest (if possible)
execute if block ~ ~ ~ #overly_realistic:chests[type=left,facing=west] \
    positioned ~ ~ ~-1 run \
        function overly_realistic:general/food/food_spoilage/spoil_from_loop/spoil_25_c
execute if block ~ ~ ~ #overly_realistic:chests[type=left,facing=east] \
    positioned ~ ~ ~1 run \
        function overly_realistic:general/food/food_spoilage/spoil_from_loop/spoil_25_c
execute if block ~ ~ ~ #overly_realistic:chests[type=left,facing=south] \
    positioned ~-1 ~ ~ run \
        function overly_realistic:general/food/food_spoilage/spoil_from_loop/spoil_25_c
execute if block ~ ~ ~ #overly_realistic:chests[type=left,facing=north] \
    positioned ~1 ~ ~ run \
        function overly_realistic:general/food/food_spoilage/spoil_from_loop/spoil_25_c

# -> If chest does not have food in inventory then return
execute unless items entity @s container.* #bundles run \
    return fail

# -> Modify items
execute if items block ~ ~ ~ container.0 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.0"}
execute if items block ~ ~ ~ container.1 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.1"}
execute if items block ~ ~ ~ container.2 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.2"}
execute if items block ~ ~ ~ container.3 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.3"}
execute if items block ~ ~ ~ container.4 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.4"}
execute if items block ~ ~ ~ container.5 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.5"}
execute if items block ~ ~ ~ container.6 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.6"}
execute if items block ~ ~ ~ container.7 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.7"}
execute if items block ~ ~ ~ container.8 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.8"}
execute if items block ~ ~ ~ container.9 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.9"}
execute if items block ~ ~ ~ container.10 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.10"}
execute if items block ~ ~ ~ container.11 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.11"}
execute if items block ~ ~ ~ container.12 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.12"}
execute if items block ~ ~ ~ container.13 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.13"}
execute if items block ~ ~ ~ container.14 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.14"}
execute if items block ~ ~ ~ container.15 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.15"}
execute if items block ~ ~ ~ container.16 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.16"}
execute if items block ~ ~ ~ container.17 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.17"}
execute if items block ~ ~ ~ container.18 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.18"}
execute if items block ~ ~ ~ container.19 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.19"}
execute if items block ~ ~ ~ container.20 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.20"}
execute if items block ~ ~ ~ container.21 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.21"}
execute if items block ~ ~ ~ container.22 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.22"}
execute if items block ~ ~ ~ container.23 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.23"}
execute if items block ~ ~ ~ container.24 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.24"}
execute if items block ~ ~ ~ container.25 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.25"}
execute if items block ~ ~ ~ container.26 #bundles run function overly_realistic:general/food/food_spoilage/spoil_from_loop/item_bundle_modify_block {slot: "container.26"}
