コード例 #1
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            float litres = GetCurrentLitres(world, pos);

            BlockEntityContainer becontainer = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityContainer;

            if (becontainer == null)
            {
                return("");
            }

            ItemSlot  slot         = becontainer.Inventory[GetContainerSlotId(world, pos)];
            ItemStack contentStack = slot.Itemstack;


            if (litres <= 0)
            {
                return(Lang.Get("Empty"));
            }

            string incontainername = Lang.Get("incontainer-" + contentStack.Class.ToString().ToLowerInvariant() + "-" + contentStack.Collectible.Code.Path);
            string text            = Lang.Get("Contents:\n{0} litres of {1}", litres, incontainername);

            text += BlockBucket.PerishableInfoCompact(api, slot, 0, false);

            return(text);
        }
コード例 #2
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            string text = base.GetPlacedBlockInfo(world, pos, forPlayer);

            float litres = GetCurrentLitres(world, pos);

            if (litres <= 0)
            {
                text = "";
            }

            BlockEntityBarrel bebarrel = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityBarrel;

            if (bebarrel != null)
            {
                ItemSlot slot = bebarrel.Inventory[0];
                if (!slot.Empty)
                {
                    if (text.Length > 0)
                    {
                        text += "\n";
                    }
                    else
                    {
                        text += Lang.Get("Contents:") + "\n";
                    }

                    text += Lang.Get("{0}x {1}", slot.Itemstack.StackSize, slot.Itemstack.GetName());

                    text += BlockBucket.PerishableInfoCompact(api, slot, 0, false);
                }

                if (bebarrel.Sealed && bebarrel.CurrentRecipe != null)
                {
                    double hoursPassed    = world.Calendar.TotalHours - bebarrel.SealedSinceTotalHours;
                    string timePassedText = hoursPassed > 24 ? Lang.Get("{0} days", Math.Round(hoursPassed / api.World.Calendar.HoursPerDay, 1)) : Lang.Get("{0} hours", Math.Round(hoursPassed));
                    string timeTotalText  = bebarrel.CurrentRecipe.SealHours > 24 ? Lang.Get("{0} days", Math.Round(bebarrel.CurrentRecipe.SealHours / api.World.Calendar.HoursPerDay, 1)) : Lang.Get("{0} hours", Math.Round(bebarrel.CurrentRecipe.SealHours));
                    text += "\n" + Lang.Get("Sealed for {0} / {1}", timePassedText, timeTotalText);
                }
            }


            return(text);
        }