Conflict with Bag of Holding

I've found that there's a conflict with the Bag of Holding plugin or Backpacks. If a player has a Bag in their backpack (using the Backpack plugin from umod), no food will go into it if this plugin is loaded. If the plugin is moved to the players inventory, then the food can be placed in the Bag of Holding. I'm not sure if this is a problem with this plugin, Backpacks or Bag of Holding but since it only happens with this plugin, I thought I'd start here. 

As per the current behavior where food is allowed in backpacks (since backpacks are considered an extension of the player inventory), it makes sense that food should also be allowed inside of Bag of Holding bags (or any item with a container) that is inside a backpack. In order to make this possible, Fridge Food can be updated to check whether the root container of an item is a backpack, instead of just checking the immediate container that the item is being added to. Here is some sample code for the developer.

void OnItemAddedToContainer(ItemContainer container, Item item)
{
    // Instead of checking whether the target container is a backpack, check whether the root of the target container is a backpack
    var rootContainer = GetRootContainer(item) ?? container;
    var backpacksOwnerResult = Backpacks?.Call("API_GetBackpackOwnerId", rootContainer);
    if (backpacksOwnerResult is ulong && (ulong)backpacksOwnerResult > 0)
        return;

    ...
}

// Helper method copied from Backpacks
// Alternatively, there is item.GetRootContainer() in Rust, but the recursion is capped at 8.
private static ItemContainer GetRootContainer(Item item)
{
    var container = item.parent;
    if (container == null)
        return null;

    while (container.parent?.parent != null && container.parent != item)
    {
        container = container.parent.parent;
    }

    return container;
}

Does today's update fix this?

Cd9dTp0SiGV4IwK.png BetterDeadThanZed

Does today's update fix this?

It appears so, since I see the above code in the current version of the plugin (though I haven't tested).