using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MinecraftClient.Mapping { /// /// Represents a Minecraft Block /// public struct Block { /// /// Storage for block ID and metadata /// private ushort blockIdAndMeta; /// /// Id of the block /// public short BlockId { get { return (short)(blockIdAndMeta >> 4); } set { blockIdAndMeta = (ushort)(value << 4 | BlockMeta); } } /// /// Metadata of the block /// public byte BlockMeta { get { return (byte)(blockIdAndMeta & 0x0F); } set { blockIdAndMeta = (ushort)((blockIdAndMeta & ~0x0F) | (value & 0x0F)); } } /// /// Check if the block can be passed through or not /// public bool Solid { get { return BlockId != 0; } } /// /// Get a block of the specified type and metadata /// /// Block type /// Block metadata public Block(short type, byte metadata = 0) { this.blockIdAndMeta = 0; this.BlockId = type; this.BlockMeta = metadata; } /// /// Get a block of the specified type and metadata /// /// public Block(ushort typeAndMeta) { this.blockIdAndMeta = typeAndMeta; } /// /// Represents an empty block /// public static Block Air { get { return new Block(0); } } /// /// String representation of the block /// public override string ToString() { return BlockId.ToString() + (BlockMeta != 0 ? ":" + BlockMeta.ToString() : ""); } } }