public override ItemStack[] GetDrops(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1f) { ItemStack[] stacks = base.GetDrops(world, pos, byPlayer); BlockEntity be = world.BlockAccessor.GetBlockEntity(pos); if (be is BlockEntitySmeltedContainer) { BlockEntitySmeltedContainer belmc = (BlockEntitySmeltedContainer)be; ItemStack contents = belmc.contents.Clone(); SetContents(stacks[0], contents, belmc.units); belmc.contents?.ResolveBlockOrItem(world); stacks[0].Collectible.SetTemperature(world, stacks[0], belmc.contents.Collectible.GetTemperature(world, contents)); } return(stacks); }
public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer) { BlockEntity be = world.BlockAccessor.GetBlockEntity(pos); if (be is BlockEntitySmeltedContainer) { BlockEntitySmeltedContainer belmc = (BlockEntitySmeltedContainer)be; belmc.contents.ResolveBlockOrItem(world); /*return * "Units: " + (int)(belmc.units) + "\n" + * "Metal: " + belmc.contents.GetName() + "\n" + * "Temperature: " + (int)belmc.Temperature + " °C\n" * ;*/ return(Lang.Get("blocksmeltedcontainer-contents", (int)(belmc.units), belmc.contents.GetName(), (int)belmc.Temperature)); } return(base.GetPlacedBlockInfo(world, pos, forPlayer)); }
public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel, ref string failureCode) { if (!world.Claims.TryAccess(byPlayer, blockSel.Position, EnumBlockAccessFlags.BuildOrBreak)) { byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty(); failureCode = "claimed"; return(false); } if (!byPlayer.Entity.Controls.Sneak || world.BlockAccessor.GetBlockEntity(blockSel.Position.DownCopy()) is ILiquidMetalSink) { failureCode = "__ignore__"; return(false); } if (!IsSuitablePosition(world, blockSel.Position, ref failureCode)) { return(false); } if (world.BlockAccessor.GetBlock(blockSel.Position.DownCopy()).SideSolid[BlockFacing.UP.Index]) { DoPlaceBlock(world, blockSel.Position, blockSel.Face, itemstack); BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position); if (be is BlockEntitySmeltedContainer) { BlockEntitySmeltedContainer belmc = (BlockEntitySmeltedContainer)be; KeyValuePair <ItemStack, int> contents = GetContents(world, itemstack); contents.Key.Collectible.SetTemperature(world, contents.Key, GetTemperature(world, itemstack)); belmc.contents = contents.Key.Clone(); belmc.units = contents.Value; } return(true); } failureCode = "requiresolidground"; return(false); }