
# -> If block has no food then return and remove marker
execute unless items block ~ ~ ~ container.* #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] run \
    return run \
        kill @s

# -> If block doesnt exist then return and remove marker
execute unless block ~ ~ ~ barrel run \
    return run \
        kill @s

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

# -> Tag barrel
tag @s add OverlyRealistic.Barrel.HasInventoryEdited

# -> If barrel does not have food in inventory then return
execute unless items block ~ ~ ~ container.* #overly_realistic:consumables/all_physical_foods run \
    return fail

# -> If surrounded by spoilage preventation then return and add to time
execute unless score @s OverlyRealistic.World.BlockFreezeTimeForSpoilage matches 3.. \
    if predicate overly_realistic:world/containers/prevent_spoil_surrounded run \
        return run \
            scoreboard players add @s OverlyRealistic.World.BlockFreezeTimeForSpoilage 1

# -> Reset time
scoreboard players reset @s OverlyRealistic.World.BlockFreezeTimeForSpoilage

# -> Modify items
execute if items block ~ ~ ~ container.0 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.0 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.0 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.1 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.1 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.1 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.2 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.2 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.2 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.3 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.3 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.3 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.4 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.4 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.4 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.5 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.5 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.5 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.6 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.6 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.6 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.7 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.7 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.7 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.8 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.8 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.8 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.9 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.9 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.9 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.10 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.10 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.10 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.11 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.11 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.11 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.12 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.12 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.12 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.13 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.13 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.13 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.14 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.14 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.14 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.15 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.15 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.15 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.16 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.16 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.16 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.17 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.17 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.17 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.18 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.18 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.18 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.19 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.19 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.19 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.20 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.20 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.20 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.21 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.21 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.21 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.22 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.22 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.22 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.23 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.23 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.23 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.24 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.24 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.24 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.25 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.25 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.25 overly_realistic:food/food_spoil
execute if items block ~ ~ ~ container.26 #overly_realistic:consumables/all_physical_foods[custom_data~{or_is_food:1b}] unless items entity @s container.26 *[custom_data~{or_no_edit:1b}] run item modify block ~ ~ ~ container.26 overly_realistic:food/food_spoil
