public override void GetHeldItemInfo(ItemStack stack, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(stack, dsc, world, withDebugInfo);

            CookingRecipe recipe = GetMealRecipe(world, stack);

            int servings = stack.Attributes.GetInt("servings");

            if (recipe != null)
            {
                if (servings == 1)
                {
                    dsc.AppendLine(Lang.Get("{0} serving of {1}", servings, recipe.GetOutputName(world, GetContents(world, stack))));
                }
                else
                {
                    dsc.AppendLine(Lang.Get("{0} servings of {1}", servings, recipe.GetOutputName(world, GetContents(world, stack))));
                }
            }

            BlockMeal mealblock  = api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(api.World, GetContents(world, stack), null);

            if (nutriFacts != null)
            {
                dsc.AppendLine(nutriFacts);
            }
        }
예제 #2
0
        public string GetOutputText(IWorldAccessor world, ISlotProvider cookingSlotsProvider, ItemSlot inputSlot)
        {
            if (inputSlot.Itemstack == null)
            {
                return(null);
            }
            if (!(inputSlot.Itemstack.Collectible is BlockCookingContainer))
            {
                return(null);
            }

            ItemStack[] stacks = GetCookingStacks(cookingSlotsProvider);

            CookingRecipe recipe = GetMatchingCookingRecipe(world, stacks);

            if (recipe != null)
            {
                double quantity = recipe.GetQuantityServings(stacks);
                if (quantity != 1)
                {
                    return(Lang.Get("mealcreation-makeplural", (int)quantity, recipe.GetOutputName(world, stacks).ToLowerInvariant()));
                }
                else
                {
                    return(Lang.Get("mealcreation-makesingular", (int)quantity, recipe.GetOutputName(world, stacks).ToLowerInvariant()));
                }
            }

            return(null);
        }
예제 #3
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            BlockEntityCrock becrock = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityCrock;

            if (becrock == null)
            {
                return(null);
            }

            BlockMeal mealblock = world.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;

            CookingRecipe recipe = world.CookingRecipes.FirstOrDefault((rec) => becrock.RecipeCode == rec.Code);

            ItemStack[] stacks = becrock.inventory.Where(slot => !slot.Empty).Select(slot => slot.Itemstack).ToArray();

            if (stacks == null || stacks.Length == 0)
            {
                return("Empty");
            }

            StringBuilder dsc = new StringBuilder();

            if (recipe != null)
            {
                DummySlot firstContentItemSlot = new DummySlot(stacks != null && stacks.Length > 0 ? stacks[0] : null, becrock.inventory);

                if (recipe != null)
                {
                    dsc.AppendLine(recipe.GetOutputName(world, stacks).UcFirst());
                }

                string facts = mealblock.GetContentNutritionFacts(world, new DummySlot(OnPickBlock(world, pos)), null);

                if (facts != null)
                {
                    dsc.Append(facts);
                }

                firstContentItemSlot.Itemstack?.Collectible.AppendPerishableInfoText(firstContentItemSlot, dsc, world);
            }
            else
            {
                dsc.AppendLine("Contents:");
                foreach (var stack in stacks)
                {
                    if (stack == null)
                    {
                        continue;
                    }

                    dsc.AppendLine(stack.StackSize + "x  " + stack.GetName());
                }

                becrock.inventory[0].Itemstack.Collectible.AppendPerishableInfoText(becrock.inventory[0], dsc, api.World);
            }


            return(dsc.ToString());
        }
예제 #4
0
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            float temp = GetTemperature(world, inSlot.Itemstack);

            if (temp > 20)
            {
                dsc.AppendLine(Lang.Get("Temperature: {0}°C", (int)temp));
            }

            CookingRecipe recipe = GetCookingRecipe(world, inSlot.Itemstack);

            ItemStack[] stacks = GetNonEmptyContents(world, inSlot.Itemstack);
            ItemSlot    slot   = BlockCrock.GetDummySlotForFirstPerishableStack(world, stacks, null, inSlot.Inventory);

            slot.Itemstack?.Collectible.AppendPerishableInfoText(slot, dsc, world);

            float servings = GetQuantityServings(world, inSlot.Itemstack);

            if (recipe != null)
            {
                if (Math.Round(servings, 1) < 0.05)
                {
                    dsc.AppendLine(Lang.Get("{1}% serving of {0}", recipe.GetOutputName(world, stacks).UcFirst(), Math.Round(servings * 100, 0)));
                }
                else
                {
                    dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks).UcFirst()));
                }
            }
            else
            {
                if (inSlot.Itemstack.Attributes.HasAttribute("quantityServings"))
                {
                    dsc.AppendLine(Lang.Get("{0} servings left", Math.Round(servings, 1)));
                }
                else if (displayContentsInfo)
                {
                    dsc.AppendLine(Lang.Get("Contents:"));
                    if (stacks != null && stacks.Length > 0)
                    {
                        dsc.AppendLine(stacks[0].StackSize + "x " + stacks[0].GetName());
                    }
                }
            }

            if (!MealMeshCache.ContentsRotten(stacks))
            {
                string facts = GetContentNutritionFacts(world, inSlot, null, recipe == null);

                if (facts != null)
                {
                    dsc.Append(facts);
                }
            }
        }
예제 #5
0
        public override void GetHeldItemInfo(ItemStack stack, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(stack, dsc, world, withDebugInfo);

            CookingRecipe recipe = GetCookingRecipe(world, stack);

            if (recipe != null)
            {
                dsc.AppendLine(recipe.GetOutputName(world, GetContents(world, stack)).UcFirst());
            }

            string facts = GetContentNutritionFacts(world, stack, null);

            if (facts != null)
            {
                dsc.Append(facts);
            }
        }
예제 #6
0
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo);

            CookingRecipe recipe = GetCookingRecipe(world, inSlot.Itemstack);

            ItemStack[] stacks = GetContents(world, inSlot.Itemstack);
            DummySlot   firstContentItemSlot = new DummySlot(stacks != null && stacks.Length > 0 ? stacks[0] : null);

            float servings = GetQuantityServings(world, inSlot.Itemstack);

            if (recipe != null)
            {
                if (Math.Round(servings, 1) < 0.05)
                {
                    dsc.AppendLine(Lang.Get("<5% serving of {1}", recipe.GetOutputName(world, stacks).UcFirst()));
                }
                else
                {
                    dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks).UcFirst()));
                }
            }
            else
            {
                if (stacks != null && stacks.Length > 0)
                {
                    dsc.AppendLine(stacks[0].StackSize + "x " + stacks[0].GetName());
                }
            }

            string facts = GetContentNutritionFacts(world, inSlot, null, true);

            if (facts != null)
            {
                dsc.Append(facts);
            }

            firstContentItemSlot.Itemstack?.Collectible.AppendPerishableInfoText(firstContentItemSlot, dsc, world);
        }
예제 #7
0
        public override string GetBlockInfo(IPlayer forPlayer)
        {
            CookingRecipe recipe = FromRecipe;

            if (recipe == null)
            {
                return("Unknown recipe :O");
            }

            StringBuilder dsc = new StringBuilder();

            dsc.AppendLine(recipe.GetOutputName(forPlayer.Entity.World, GetContentStacks()).UcFirst());

            if (ownBlock == null)
            {
                return(dsc.ToString());
            }


            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = "Cold";
            }

            dsc.AppendLine(Lang.Get("Temperature: {0}", temppretty));

            string nutriFacts = ownBlock.GetContentNutritionFacts(api.World, ownBlock.OnPickBlock(api.World, pos), forPlayer.Entity);

            if (nutriFacts != null)
            {
                dsc.Append(nutriFacts);
            }


            return(dsc.ToString());
        }
예제 #8
0
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo);

            CookingRecipe recipe   = GetMealRecipe(world, inSlot.Itemstack);
            float         servings = inSlot.Itemstack.Attributes.GetFloat("quantityServings");

            ItemStack[] stacks = GetContents(world, inSlot.Itemstack);

            DummySlot firstContentItemSlot = new DummySlot(stacks != null && stacks.Length > 0 ? stacks[0] : null, inSlot.Inventory);

            if (recipe != null)
            {
                if (servings == 1)
                {
                    dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks)));
                }
                else
                {
                    dsc.AppendLine(Lang.Get("{0} servings of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks)));
                }
            }

            BlockMeal mealblock  = api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(api.World, inSlot, stacks, null);

            if (nutriFacts != null)
            {
                dsc.AppendLine(nutriFacts);
            }

            firstContentItemSlot.Itemstack?.Collectible.AppendPerishableInfoText(firstContentItemSlot, dsc, world);
        }
예제 #9
0
        public override void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc)
        {
            CookingRecipe recipe = FromRecipe;

            if (recipe == null)
            {
                if (inventory.Count > 0 && !inventory[0].Empty)
                {
                    dsc.AppendLine(inventory[0].StackSize + "x " + inventory[0].Itemstack.GetName());
                }

                return;
            }


            dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(QuantityServings, 1), recipe.GetOutputName(forPlayer.Entity.World, GetNonEmptyContentStacks()).UcFirst()));

            if (ownBlock == null)
            {
                return;
            }


            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = Lang.Get("Cold");
            }

            dsc.AppendLine(Lang.Get("Temperature: {0}", temppretty));

            string nutriFacts = ownBlock.GetContentNutritionFacts(Api.World, inventory[0], GetNonEmptyContentStacks(false), forPlayer.Entity);

            if (nutriFacts != null)
            {
                dsc.Append(nutriFacts);
            }


            foreach (var slot in inventory)
            {
                if (slot.Empty)
                {
                    continue;
                }

                TransitionableProperties[] propsm = slot.Itemstack.Collectible.GetTransitionableProperties(Api.World, slot.Itemstack, null);
                if (propsm != null && propsm.Length > 0)
                {
                    slot.Itemstack.Collectible.AppendPerishableInfoText(slot, dsc, Api.World);
                    break;
                }
            }
        }
예제 #10
0
        public override string GetBlockInfo(IPlayer forPlayer)
        {
            ItemStack[]   contentStacks = GetContentStacks();
            CookingRecipe recipe        = api.World.CookingRecipes.FirstOrDefault(rec => rec.Code == RecipeCode);

            if (recipe == null)
            {
                return(null);
            }

            int    servings   = QuantityServings;
            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = "Cold";
            }

            BlockMeal mealblock  = api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(api.World, contentStacks, forPlayer.Entity);

            if (servings == 1)
            {
                return(Lang.Get("{0} serving of {1}\nTemperature: {2}{3}{4}", servings, recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }
            else
            {
                return(Lang.Get("{0} servings of {1}\nTemperature: {2}{3}{4}", servings, recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }
        }
예제 #11
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            BlockEntityCrock becrock = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityCrock;

            if (becrock == null)
            {
                return(null);
            }

            BlockMeal mealblock = world.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;

            CookingRecipe recipe = world.CookingRecipes.FirstOrDefault((rec) => becrock.RecipeCode == rec.Code);

            ItemStack[] stacks = becrock.inventory.Where(slot => !slot.Empty).Select(slot => slot.Itemstack).ToArray();

            if (stacks == null || stacks.Length == 0)
            {
                return("Empty");
            }

            StringBuilder dsc = new StringBuilder();

            if (recipe != null)
            {
                ItemSlot slot = GetDummySlotForFirstPerishableStack(api.World, stacks, forPlayer.Entity, becrock.inventory);

                if (recipe != null)
                {
                    if (becrock.QuantityServings == 1)
                    {
                        dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(becrock.QuantityServings, 1), recipe.GetOutputName(world, stacks)));
                    }
                    else
                    {
                        dsc.AppendLine(Lang.Get("{0} servings of {1}", Math.Round(becrock.QuantityServings, 1), recipe.GetOutputName(world, stacks)));
                    }
                }

                string facts = mealblock.GetContentNutritionFacts(world, new DummySlot(OnPickBlock(world, pos)), null);

                if (facts != null)
                {
                    dsc.Append(facts);
                }

                slot.Itemstack?.Collectible.AppendPerishableInfoText(slot, dsc, world);
            }
            else
            {
                dsc.AppendLine("Contents:");
                foreach (var stack in stacks)
                {
                    if (stack == null)
                    {
                        continue;
                    }

                    dsc.AppendLine(stack.StackSize + "x  " + stack.GetName());
                }

                becrock.inventory[0].Itemstack?.Collectible.AppendPerishableInfoText(becrock.inventory[0], dsc, api.World);
            }

            if (becrock.Sealed)
            {
                dsc.AppendLine("<font color=\"lightgreen\">" + Lang.Get("Sealed.") + "</font>");
            }


            return(dsc.ToString());
        }
예제 #12
0
        public override string GetBlockInfo(IPlayer forPlayer)
        {
            CookingRecipe recipe = FromRecipe;
            StringBuilder dsc    = new StringBuilder();

            if (recipe == null)
            {
                if (inventory.Count > 0 && !inventory[0].Empty)
                {
                    dsc.AppendLine(inventory[0].StackSize + "x " + inventory[0].Itemstack.GetName());
                }

                return(dsc.ToString());
            }


            dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(QuantityServings, 1), recipe.GetOutputName(forPlayer.Entity.World, GetNonEmptyContentStacks()).UcFirst()));

            if (ownBlock == null)
            {
                return(dsc.ToString());
            }


            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = "Cold";
            }

            dsc.AppendLine(Lang.Get("Temperature: {0}", temppretty));

            string nutriFacts = ownBlock.GetContentNutritionFacts(api.World, inventory[0], GetNonEmptyContentStacks(false), forPlayer.Entity);

            if (nutriFacts != null)
            {
                dsc.Append(nutriFacts);
            }

            TransitionState state = inventory[0].Itemstack.Collectible.UpdateAndGetTransitionState(api.World, inventory[0], EnumTransitionType.Perish);

            if (state != null)
            {
                if (state.TransitionLevel > 0)
                {
                    dsc.AppendLine(Lang.Get("<font color=\"orange\">Perishable.</font> {0}% spoiled", (int)Math.Round(state.TransitionLevel * 100)));
                }
                else
                {
                    double hoursPerday = api.World.Calendar.HoursPerDay;
                    if (state.FreshHoursLeft > hoursPerday)
                    {
                        dsc.AppendLine(Lang.Get("<font color=\"orange\">Perishable.</font> Fresh for {0} days", Math.Round(state.FreshHoursLeft / hoursPerday, 1)));
                    }
                    else
                    {
                        dsc.AppendLine(Lang.Get("<font color=\"orange\">Perishable.</font> Fresh for {0} hours", Math.Round(state.FreshHoursLeft, 1)));
                    }
                }
            }


            return(dsc.ToString());
        }
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            //base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo);
            float temp = GetTemperature(world, inSlot.Itemstack);

            if (temp > 20)
            {
                dsc.AppendLine(Lang.Get("Temperature: {0}°C", (int)temp));
            }

            CookingRecipe recipe   = GetMealRecipe(world, inSlot.Itemstack);
            float         servings = inSlot.Itemstack.Attributes.GetFloat("quantityServings");

            ItemStack[] stacks = GetNonEmptyContents(world, inSlot.Itemstack);


            if (recipe != null)
            {
                if (servings == 1)
                {
                    dsc.AppendLine(Lang.Get("{0} serving of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks)));
                }
                else
                {
                    dsc.AppendLine(Lang.Get("{0} servings of {1}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks)));
                }
            }

            BlockMeal mealblock  = api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(api.World, inSlot, stacks, null);

            if (nutriFacts != null)
            {
                dsc.AppendLine(nutriFacts);
            }

            ItemSlot slot = BlockCrock.GetDummySlotForFirstPerishableStack(api.World, stacks, null, inSlot.Inventory);

            slot.Itemstack?.Collectible.AppendPerishableInfoText(slot, dsc, world);
        }
예제 #14
0
        public string CrockInfoCompact(ItemSlot inSlot)
        {
            BlockMeal      mealblock = Api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            BlockCrock     crock     = inSlot.Itemstack.Collectible as BlockCrock;
            IWorldAccessor world     = Api.World;

            CookingRecipe recipe = crock.GetCookingRecipe(world, inSlot.Itemstack);

            ItemStack[] stacks = crock.GetNonEmptyContents(world, inSlot.Itemstack);

            if (stacks == null || stacks.Length == 0)
            {
                return(Lang.Get("Empty Crock") + "\n");
            }

            StringBuilder dsc = new StringBuilder();

            if (recipe != null)
            {
                double servings = inSlot.Itemstack.Attributes.GetDecimal("quantityServings");

                if (recipe != null)
                {
                    if (servings == 1)
                    {
                        dsc.Append(Lang.Get("{0}x {1}.", servings, recipe.GetOutputName(world, stacks)));
                    }
                    else
                    {
                        dsc.Append(Lang.Get("{0}x {1}.", servings, recipe.GetOutputName(world, stacks)));
                    }
                }
            }
            else
            {
                int i = 0;
                foreach (var stack in stacks)
                {
                    if (stack == null)
                    {
                        continue;
                    }
                    if (i++ > 0)
                    {
                        dsc.Append(", ");
                    }
                    dsc.Append(stack.StackSize + "x " + stack.GetName());
                }

                dsc.Append(".");
            }

            DummyInventory dummyInv = new DummyInventory(Api);

            ItemSlot contentSlot = BlockCrock.GetDummySlotForFirstPerishableStack(Api.World, stacks, null, dummyInv);

            dummyInv.OnAcquireTransitionSpeed = (transType, stack, mul) =>
            {
                return(mul * crock.GetContainingTransitionModifierContained(world, inSlot, transType) * inv.GetTransitionSpeedMul(transType, stack));
            };


            TransitionState[] transitionStates = contentSlot.Itemstack?.Collectible.UpdateAndGetTransitionStates(Api.World, contentSlot);
            bool addNewLine = true;

            if (transitionStates != null)
            {
                for (int i = 0; i < transitionStates.Length; i++)
                {
                    TransitionState state = transitionStates[i];

                    TransitionableProperties prop = state.Props;
                    float perishRate = contentSlot.Itemstack.Collectible.GetTransitionRateMul(world, contentSlot, prop.Type);

                    if (perishRate <= 0)
                    {
                        continue;
                    }

                    addNewLine = false;
                    float transitionLevel = state.TransitionLevel;
                    float freshHoursLeft  = state.FreshHoursLeft / perishRate;

                    switch (prop.Type)
                    {
                    case EnumTransitionType.Perish:
                        if (transitionLevel > 0)
                        {
                            dsc.AppendLine(" " + Lang.Get("{0}% spoiled", (int)Math.Round(transitionLevel * 100)));
                        }
                        else
                        {
                            double hoursPerday = Api.World.Calendar.HoursPerDay;

                            if (freshHoursLeft / hoursPerday >= Api.World.Calendar.DaysPerYear)
                            {
                                dsc.AppendLine(" " + Lang.Get("Fresh for {0} years", Math.Round(freshHoursLeft / hoursPerday / Api.World.Calendar.DaysPerYear, 1)));
                            }

                            /*else if (freshHoursLeft / hoursPerday >= Api.World.Calendar.DaysPerMonth)  - confusing. 12 days per months and stuff..
                             * {
                             *  dsc.AppendLine(Lang.Get("<font color=\"orange\">Perishable.</font> Fresh for {0} months", Math.Round(freshHoursLeft / hoursPerday / Api.World.Calendar.DaysPerMonth, 1)));
                             * }*/
                            else if (freshHoursLeft > hoursPerday)
                            {
                                dsc.AppendLine(" " + Lang.Get("Fresh for {0} days", Math.Round(freshHoursLeft / hoursPerday, 1)));
                            }
                            else
                            {
                                dsc.AppendLine(" " + Lang.Get("Fresh for {0} hours", Math.Round(freshHoursLeft, 1)));
                            }
                        }
                        break;
                    }
                }
            }


            if (addNewLine)
            {
                dsc.AppendLine("");
            }

            return(dsc.ToString());
        }
        public override string GetBlockInfo(IPlayer forPlayer)
        {
            ItemStack[]   contentStacks = GetNonEmptyContentStacks();
            CookingRecipe recipe        = api.World.CookingRecipes.FirstOrDefault(rec => rec.Code == RecipeCode);

            if (recipe == null)
            {
                return(null);
            }

            float  servings   = QuantityServings;
            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = "Cold";
            }

            BlockMeal mealblock  = api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(api.World, inventory[0], contentStacks, forPlayer.Entity);

            StringBuilder dsc = new StringBuilder();

            if (servings == 1)
            {
                dsc.Append(Lang.Get("{0} serving of {1}\nTemperature: {2}{3}{4}", Math.Round(servings, 1), recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }
            else
            {
                dsc.Append(Lang.Get("{0} servings of {1}\nTemperature: {2}{3}{4}", Math.Round(servings, 1), recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }


            inventory[0].Itemstack.Collectible.AppendPerishableInfoText(inventory[0], dsc, api.World);

            //dsc.AppendLine(base.GetBlockInfo(forPlayer));


            return(dsc.ToString());
        }
예제 #16
0
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo);

            BlockMeal mealblock = world.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;

            CookingRecipe recipe = GetCookingRecipe(world, inSlot.Itemstack);

            ItemStack[] stacks = GetNonEmptyContents(world, inSlot.Itemstack);

            if (stacks == null || stacks.Length == 0)
            {
                dsc.AppendLine("Empty");
                return;
            }

            DummyInventory dummyInv = new DummyInventory(api);

            ItemSlot slot = GetDummySlotForFirstPerishableStack(api.World, stacks, null, dummyInv);

            dummyInv.OnAcquireTransitionSpeed = (transType, stack, mul) =>
            {
                float val = mul * GetContainingTransitionModifierContained(world, inSlot, transType);

                val *= inSlot.Inventory.GetTransitionSpeedMul(transType, inSlot.Itemstack);

                return(val);
            };


            if (recipe != null)
            {
                double servings = inSlot.Itemstack.Attributes.GetDecimal("quantityServings");

                if (recipe != null)
                {
                    if (servings == 1)
                    {
                        dsc.AppendLine(Lang.Get("{0} serving of {1}", servings, recipe.GetOutputName(world, stacks)));
                    }
                    else
                    {
                        dsc.AppendLine(Lang.Get("{0} servings of {1}", servings, recipe.GetOutputName(world, stacks)));
                    }
                }

                string facts = mealblock.GetContentNutritionFacts(world, inSlot, null);
                if (facts != null)
                {
                    dsc.Append(facts);
                }
            }
            else
            {
                dsc.AppendLine("Contents:");
                foreach (var stack in stacks)
                {
                    if (stack == null)
                    {
                        continue;
                    }

                    dsc.AppendLine(stack.StackSize + "x  " + stack.GetName());
                }
            }


            slot.Itemstack?.Collectible.AppendPerishableInfoText(slot, dsc, world);

            if (inSlot.Itemstack.Attributes.GetBool("sealed"))
            {
                dsc.AppendLine("<font color=\"lightgreen\">" + Lang.Get("Sealed.") + "</font>");
            }
        }
        public string GetContainedInfo(ItemSlot inSlot)
        {
            var world = api.World;

            CookingRecipe recipe   = GetMealRecipe(world, inSlot.Itemstack);
            float         servings = inSlot.Itemstack.Attributes.GetFloat("quantityServings");

            ItemStack[] stacks = GetNonEmptyContents(world, inSlot.Itemstack);

            if (stacks.Length == 0)
            {
                return(Lang.Get("Empty {0}", ContainerNameShort));
            }

            if (recipe != null)
            {
                if (servings == 1)
                {
                    return(Lang.Get("{0} serving of {1} in {2}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks), ContainerNameShort));
                }
                else
                {
                    return(Lang.Get("{0:0.#} servings of {1} in {2}", Math.Round(servings, 1), recipe.GetOutputName(world, stacks), ContainerNameShort));
                }
            }

            StringBuilder sb = new StringBuilder();

            foreach (var stack in stacks)
            {
                if (sb.Length > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(stack.GetName());
            }
            sb.Append(Lang.Get(" in {0}", ContainerNameShort));

            return(sb.ToString());
        }
        public override void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc)
        {
            ItemStack[]   contentStacks = GetNonEmptyContentStacks();
            CookingRecipe recipe        = Api.GetCookingRecipes().FirstOrDefault(rec => rec.Code == RecipeCode);

            if (recipe == null)
            {
                return;
            }

            float  servings   = QuantityServings;
            int    temp       = GetTemperature();
            string temppretty = Lang.Get("{0}°C", temp);

            if (temp < 20)
            {
                temppretty = Lang.Get("Cold");
            }

            BlockMeal mealblock  = Api.World.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;
            string    nutriFacts = mealblock.GetContentNutritionFacts(Api.World, inventory[0], contentStacks, forPlayer.Entity);


            if (servings == 1)
            {
                dsc.Append(Lang.Get("cookedcontainer-servingstemp-singular", Math.Round(servings, 1), recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }
            else
            {
                dsc.Append(Lang.Get("cookedcontainer-servingstemp-plural", Math.Round(servings, 1), recipe.GetOutputName(forPlayer.Entity.World, contentStacks), temppretty, nutriFacts != null ? "\n" : "", nutriFacts));
            }


            foreach (var slot in inventory)
            {
                if (slot.Empty)
                {
                    continue;
                }

                TransitionableProperties[] propsm = slot.Itemstack.Collectible.GetTransitionableProperties(Api.World, slot.Itemstack, null);
                if (propsm != null && propsm.Length > 0)
                {
                    slot.Itemstack.Collectible.AppendPerishableInfoText(slot, dsc, Api.World);
                    break;
                }
            }
        }
예제 #19
0
        public override void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
        {
            base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo);

            BlockMeal mealblock = world.GetBlock(new AssetLocation("bowl-meal")) as BlockMeal;

            CookingRecipe recipe = GetCookingRecipe(world, inSlot.Itemstack);

            ItemStack[] stacks = GetContents(world, inSlot.Itemstack);

            if (stacks == null || stacks.Length == 0)
            {
                dsc.AppendLine("Empty");
                return;
            }

            DummySlot firstContentItemSlot = new DummySlot(stacks != null && stacks.Length > 0 ? stacks[0] : null);

            if (recipe != null)
            {
                double servings = inSlot.Itemstack.Attributes.GetDecimal("quantityServings");

                if (recipe != null)
                {
                    if (servings == 1)
                    {
                        dsc.AppendLine(Lang.Get("{0} serving of {1}", servings, recipe.GetOutputName(world, stacks)));
                    }
                    else
                    {
                        dsc.AppendLine(Lang.Get("{0} servings of {1}", servings, recipe.GetOutputName(world, stacks)));
                    }
                }

                string facts = mealblock.GetContentNutritionFacts(world, inSlot, null);
                if (facts != null)
                {
                    dsc.Append(facts);
                }
            }
            else
            {
                dsc.AppendLine("Contents:");
                foreach (var stack in stacks)
                {
                    if (stack == null)
                    {
                        continue;
                    }

                    dsc.AppendLine(stack.StackSize + "x  " + stack.GetName());
                }
            }


            firstContentItemSlot.Itemstack?.Collectible.AppendPerishableInfoText(firstContentItemSlot, dsc, world);

            if (inSlot.Itemstack.Attributes.GetBool("sealed"))
            {
                dsc.AppendLine(Lang.Get("Sealed."));
            }
        }