public void ServeInto(IPlayer player, ItemSlot slot)
        {
            float servings = Math.Min(QuantityServings, slot.Itemstack.Collectible.Attributes["servingCapacity"].AsInt());

            ItemStack mealstack = new ItemStack(api.World.GetBlock(AssetLocation.Create(slot.Itemstack.Collectible.Attributes["mealBlockCode"].AsString(), slot.Itemstack.Collectible.Code.Domain)));

            mealstack.StackSize = 1;
            (mealstack.Collectible as IBlockMealContainer).SetContents(RecipeCode, mealstack, GetNonEmptyContentStacks(), servings);

            if (slot.StackSize == 1)
            {
                slot.Itemstack = mealstack;
            }
            else
            {
                slot.TakeOut(1);
                if (!player.InventoryManager.TryGiveItemstack(mealstack, true))
                {
                    api.World.SpawnItemEntity(mealstack, pos.ToVec3d().Add(0.5, 0.5, 0.5));
                }
                slot.MarkDirty();
            }

            QuantityServings -= servings;

            if (QuantityServings <= 0)
            {
                Block block = api.World.GetBlock(ownBlock.CodeWithPath(ownBlock.FirstCodePart() + "-burned"));
                api.World.BlockAccessor.SetBlock(block.BlockId, pos);
                return;
            }

            if (api.Side == EnumAppSide.Client)
            {
                currentMesh = GenMesh();
            }

            MarkDirty(true);
        }
        internal void ServePlayer(IPlayer player)
        {
            ItemStack mealstack = new ItemStack(api.World.GetBlock(new AssetLocation("bowl-meal")));

            (mealstack.Collectible as BlockMeal).SetContents(RecipeCode, mealstack, GetContentStacks());

            if (player.InventoryManager.ActiveHotbarSlot.StackSize == 1)
            {
                player.InventoryManager.ActiveHotbarSlot.Itemstack = mealstack;
            }
            else
            {
                player.InventoryManager.ActiveHotbarSlot.TakeOut(1);
                if (!player.InventoryManager.TryGiveItemstack(mealstack, true))
                {
                    api.World.SpawnItemEntity(mealstack, pos.ToVec3d().Add(0.5, 0.5, 0.5));
                }
                player.InventoryManager.ActiveHotbarSlot.MarkDirty();
            }

            QuantityServings--;

            if (QuantityServings <= 0)
            {
                Block block = api.World.GetBlock(ownBlock.CodeWithPath(ownBlock.FirstCodePart() + "-burned"));
                api.World.BlockAccessor.SetBlock(block.BlockId, pos);
                return;
            }

            if (api.Side == EnumAppSide.Client)
            {
                currentMesh = GenMesh();
            }

            MarkDirty(true);
        }
        public bool ServeInto(IPlayer player, ItemSlot slot)
        {
            // Lets try to catch #504
            // https://github.com/anegostudios/VintageStory-Issues/issues/504
            try
            {
                int   capacity = slot.Itemstack.Collectible.Attributes["servingCapacity"].AsInt();
                float servings = Math.Min(QuantityServings, capacity);

                ItemStack           mealStack;
                IBlockMealContainer ibm = (slot.Itemstack.Collectible as IBlockMealContainer);

                if (ibm != null && ibm.GetQuantityServings(Api.World, slot.Itemstack) > 0)
                {
                    float existingServings = ibm.GetQuantityServings(Api.World, slot.Itemstack);
                    //string recipeCode = ibm.GetRecipeCode(Api.World, slot.Itemstack);
                    ItemStack[] existingContent = ibm.GetNonEmptyContents(Api.World, slot.Itemstack);

                    servings = Math.Min(servings, capacity - existingServings);
                    ItemStack[] potStacks = GetNonEmptyContentStacks();

                    if (servings == 0)
                    {
                        return(false);
                    }
                    if (existingContent.Length != potStacks.Length)
                    {
                        return(false);
                    }
                    for (int i = 0; i < existingContent.Length; i++)
                    {
                        if (!existingContent[i].Equals(Api.World, potStacks[i], GlobalConstants.IgnoredStackAttributes))
                        {
                            return(false);
                        }
                    }

                    if (slot.StackSize == 1)
                    {
                        mealStack = slot.Itemstack;
                        ibm.SetContents(RecipeCode, slot.Itemstack, GetNonEmptyContentStacks(), existingServings + servings);
                    }
                    else
                    {
                        mealStack = slot.Itemstack.Clone();
                        ibm.SetContents(RecipeCode, mealStack, GetNonEmptyContentStacks(), existingServings + servings);
                    }
                }
                else
                {
                    mealStack           = new ItemStack(Api.World.GetBlock(AssetLocation.Create(slot.Itemstack.Collectible.Attributes["mealBlockCode"].AsString(), slot.Itemstack.Collectible.Code.Domain)));
                    mealStack.StackSize = 1;
                    (mealStack.Collectible as IBlockMealContainer).SetContents(RecipeCode, mealStack, GetNonEmptyContentStacks(), servings);
                }


                if (slot.StackSize == 1)
                {
                    slot.Itemstack = mealStack;
                    slot.MarkDirty();
                }
                else
                {
                    slot.TakeOut(1);
                    if (!player.InventoryManager.TryGiveItemstack(mealStack, true))
                    {
                        Api.World.SpawnItemEntity(mealStack, Pos.ToVec3d().Add(0.5, 0.5, 0.5));
                    }
                    slot.MarkDirty();
                }

                QuantityServings -= servings;

                if (QuantityServings <= 0)
                {
                    Block block = Api.World.GetBlock(ownBlock.CodeWithPath(ownBlock.FirstCodePart() + "-burned"));
                    Api.World.BlockAccessor.SetBlock(block.BlockId, Pos);
                    return(true);
                }

                if (Api.Side == EnumAppSide.Client)
                {
                    currentMesh = GenMesh();
                    (player as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                }

                MarkDirty(true);
            } catch (NullReferenceException e)
            {
                Api.World.Logger.Error("NRE in BECookedContainer.");
                Api.World.Logger.Error("slot: " + slot?.Itemstack?.GetName());
                Api.World.Logger.Error("slot cap: " + slot?.Itemstack?.Collectible?.Attributes?["servingCapacity"]);

                throw e;
            }

            return(true);
        }