public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer) { StringBuilder builder = new StringBuilder(base.GetPlacedBlockInfo(world, pos, forPlayer)); BlockEntityCraftingStation craftingStation = (pos.BlockEntity(world) as BlockEntityCraftingStation); builder = craftingStation?.inventory?[0]?.Itemstack != null?builder.AppendLine().AppendLine(craftingStation.inventory[0].StackSize + "x " + Lang.Get(craftingStation.inventory[0].Itemstack.Collectible.Code.ToString())) : builder; return(builder.ToString()); }
public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer) { StringBuilder builder = new StringBuilder(base.GetPlacedBlockInfo(world, pos, forPlayer)); BlockEntityDryingStation craftingStation = (pos.BlockEntity(world) as BlockEntityDryingStation); ItemStack stack = craftingStation?.inventory?[0]?.Itemstack; builder = stack != null?builder.AppendLine().AppendLine(stack.StackSize + "x " + Lang.Get("incontainer-" + stack.Class.ToString().ToLowerInvariant() + "-" + stack.Collectible.Code.Path)) : builder; return(builder.ToString()); }
public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer) { StringBuilder bdr = new StringBuilder(base.GetPlacedBlockInfo(world, pos, forPlayer)); BlockEntityWell well = pos.BlockEntity(world) as BlockEntityWell; if (well != null) { int progress = (int)GameMath.Min((float)Math.Round(100 * well.MiningProgress), 100f); bdr.AppendLine("Depth: " + well.Depth) .AppendLine("FoundLiquid: " + well.FoundLiquidCode) .AppendLine("Mining Progress: " + progress + "%") .AppendLine("Mining Difficulty: " + Math.Round(100 * (1.0f - well.Difficulty)) + "%"); } return(bdr.ToString()); }
public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos Pos, IPlayer forPlayer) { StringBuilder builder = new StringBuilder(base.GetPlacedBlockInfo(world, Pos, forPlayer)); BlockEntityDryingStation craftingStation = (Pos.BlockEntity(world) as BlockEntityDryingStation); ItemStack stack = craftingStation?.inventory?[0]?.Itemstack; builder = stack != null?builder.AppendLine().AppendLine(stack.StackSize + "x " + Lang.Get("incontainer-" + stack.Class.ToString().ToLowerInvariant() + "-" + stack.Collectible.Code.Path)) : builder.AppendLine(); if (craftingStation != null) { int hours = (int)Math.Round(craftingStation.timeWhenDone - world.Calendar.TotalHours); hours = hours < 0 ? 0 : hours; builder.AppendLine("Remaining Drying Time: " + hours.ToString() + " Hours"); } return(builder.ToString()); }
public static List <BlockEntity> GetBlockEntities(this IWorldAccessor world, BlockPos pos, Vec3i range) { List <BlockEntity> blockEntities = new List <BlockEntity>(); for (int x = pos.X - range.X; x < pos.X + range.X; x++) { for (int y = pos.Y - range.Y; y < pos.Y + range.Y; y++) { for (int z = pos.Z - range.Z; z < pos.Z + range.Z; z++) { BlockPos p = new BlockPos(x, y, z); BlockEntity be = p.BlockEntity(world); if (be != null) { blockEntities.Add(be); } } } } return(blockEntities); }
public static BlockEntity BlockEntity(this BlockPos Pos, ICoreAPI Api) => Pos.BlockEntity(Api.World);
public static BlockEntity BlockEntity(this BlockPos pos, ICoreAPI api) => pos.BlockEntity(api.World);