Exemple #1
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);
        }
        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);
            }
        }
        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));
            }
        }
Exemple #4
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            BlockEntityPie bep = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityPie;

            if (bep?.Inventory == null || bep.Inventory.Count < 1 || bep.Inventory.Empty)
            {
                return("");
            }

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

            ItemStack pieStack = bep.Inventory[0].Itemstack;

            ItemStack[]   stacks = GetContents(api.World, pieStack);
            StringBuilder sb     = new StringBuilder();

            TransitionableProperties[] propsm = pieStack.Collectible.GetTransitionableProperties(api.World, pieStack, null);
            if (propsm != null && propsm.Length > 0)
            {
                pieStack.Collectible.AppendPerishableInfoText(bep.Inventory[0], sb, api.World);
            }

            float servingsLeft = GetQuantityServings(world, bep.Inventory[0].Itemstack);

            if (!bep.Inventory[0].Itemstack.Attributes.HasAttribute("quantityServings"))
            {
                servingsLeft = bep.SlicesLeft / 4f;
            }

            float[] nmul = GetNutritionHealthMul(pos, null, forPlayer.Entity);

            sb.AppendLine(mealblock.GetContentNutritionFacts(api.World, bep.Inventory[0], stacks, null, true, nmul[0] * servingsLeft, nmul[1] * servingsLeft));

            return(sb.ToString());
        }
Exemple #5
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());
        }
Exemple #6
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;
                }
            }
        }
        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;
                }
            }
        }
        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());
        }
        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);
        }
Exemple #10
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());
        }
Exemple #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());
        }
Exemple #12
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>");
            }
        }
Exemple #13
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());
        }
Exemple #14
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."));
            }
        }