A couple plugins I am building need to lock containers, by using .SetLocked(true) on the ItemContainer.

In most circumstances, the item wouldn't move, and sometimes the game would give an error message about the container being locked.  But if the player inventory had some amount of the item, and the item was stackable, and they used right-click to automatically take the items out of the container, it would take the item.  But only for certain containers.  For example, fuel could not be taken out of a locked lantern.  But bullets could be taken out of a locked turrret.

I'm not really sure why it is doing this.  But I found a fix using the CanMoveItem hook.  It feels really weird to do this.

object CanMoveItem(Item item, PlayerInventory playerLoot, uint targetContainer, int targetSlot, int amount)
{
	if (item.parent.IsLocked())
		return false;

	return null;
}​

Anyone know what the heck is going on here?