string getContentsText() { string contents = "Contents:"; if (Inventory[0].Empty && Inventory[1].Empty) { contents += "\nNone."; } else { if (!Inventory[1].Empty) { ItemStack stack = Inventory[1].Itemstack; WaterTightContainableProps props = BlockLiquidContainerBase.GetInContainerProps(stack); if (props != null) { string incontainername = Lang.Get("incontainer-" + stack.Class.ToString().ToLowerInvariant() + "-" + stack.Collectible.Code.Path); contents += "\n" + Lang.Get(props.MaxStackSize > 0 ? "{0}x of {1}" : "{0} litres of {1}", (float)stack.StackSize / props.ItemsPerLitre, incontainername); } else { contents += "\n" + Lang.Get("{0}x of {1}", stack.StackSize, stack.GetName()); } } if (!Inventory[0].Empty) { ItemStack stack = Inventory[0].Itemstack; contents += "\n" + Lang.Get("{0}x of {1}", stack.StackSize, stack.GetName()); } BlockEntityBarrel bebarrel = capi.World.BlockAccessor.GetBlockEntity(BlockEntityPosition) as BlockEntityBarrel; if (bebarrel.CurrentRecipe != null) { ItemStack outStack = bebarrel.CurrentRecipe.Output.ResolvedItemstack; WaterTightContainableProps props = BlockLiquidContainerBase.GetInContainerProps(outStack); string timeText = bebarrel.CurrentRecipe.SealHours > 24 ? Lang.Get("{0} days", Math.Round(bebarrel.CurrentRecipe.SealHours / capi.World.Calendar.HoursPerDay, 1)) : Lang.Get("{0} hours", bebarrel.CurrentRecipe.SealHours); if (props != null) { string incontainername = Lang.Get("incontainer-" + outStack.Class.ToString().ToLowerInvariant() + "-" + outStack.Collectible.Code.Path); float litres = (float)bebarrel.CurrentOutSize / props.ItemsPerLitre; contents += "\n\n" + Lang.Get("Will turn into {0} litres of {1} after {2} of sealing.", litres, incontainername, timeText); } else { contents += "\n\n" + Lang.Get("Will turn into {0}x {1} after {2} of sealing.", bebarrel.CurrentOutSize, outStack.GetName(), timeText); } } } return(contents); }
public override bool CanTakeFrom(ItemSlot sourceSlot, EnumMergePriority priority = EnumMergePriority.AutoMerge) { if (inventory?.PutLocked == true) { return(false); } ItemStack sourceStack = sourceSlot.Itemstack; if (sourceStack == null) { return(false); } WaterTightContainableProps props = BlockLiquidContainerBase.GetInContainerProps(sourceStack); return(props != null && (itemstack == null || itemstack.Collectible.GetMergableQuantity(itemstack, sourceStack, priority) > 0) && RemainingSlotSpace > 0); }
private void fullnessMeterDraw(Context ctx, ImageSurface surface, ElementBounds currentBounds) { ItemSlot liquidSlot = Inventory[1]; if (liquidSlot.Empty) { return; } BlockEntityBarrel bebarrel = capi.World.BlockAccessor.GetBlockEntity(BlockEntityPosition) as BlockEntityBarrel; float itemsPerLitre = 1f; int capacity = bebarrel.CapacityLitres; WaterTightContainableProps props = BlockLiquidContainerBase.GetInContainerProps(liquidSlot.Itemstack); if (props != null) { itemsPerLitre = props.ItemsPerLitre; capacity = Math.Max(capacity, props.MaxStackSize); } float fullnessRelative = liquidSlot.StackSize / itemsPerLitre / capacity; double offY = (1 - fullnessRelative) * currentBounds.InnerHeight; ctx.Rectangle(0, offY, currentBounds.InnerWidth, currentBounds.InnerHeight - offY); //ctx.SetSourceRGBA(ravg/255.0, gavg / 255.0, bavg / 255.0, aavg / 255.0); //ctx.Fill(); CompositeTexture tex = liquidSlot.Itemstack.Collectible.Attributes?["waterTightContainerProps"]?["texture"]?.AsObject <CompositeTexture>(null, liquidSlot.Itemstack.Collectible.Code.Domain); if (tex != null) { ctx.Save(); Matrix m = ctx.Matrix; m.Scale(GuiElement.scaled(3), GuiElement.scaled(3)); ctx.Matrix = m; AssetLocation loc = tex.Base.Clone().WithPathAppendixOnce(".png"); GuiElement.fillWithPattern(capi, ctx, loc.Path, true, false); ctx.Restore(); } }
public override bool CanHold(ItemSlot itemstackFromSourceSlot) { WaterTightContainableProps props = BlockLiquidContainerBase.GetInContainerProps(itemstackFromSourceSlot.Itemstack); return(props != null); }