public BlockState this[Int3 location] { get { Int3 chunkSectionKey = location.GetChunk(); Int2 chunkKey = new Int2(chunkSectionKey.X, chunkSectionKey.Z); if (Chunks.ContainsKey(chunkKey)) { ChunkColumn chunk = Chunks[chunkKey]; ChunkSection section = chunk[chunkSectionKey.Y]; if (section == null) { return(new BlockState()); } else { Int3 bp = location.InChunkBlock(); BlockId id = section.GetBlock(bp.X, bp.Y, bp.Z); return(GlobalPalette.GetState(id.StateId)); } } else { return(new BlockState()); } } }
public void Read(ref byte[] data) { idToState = new Dictionary <uint, BlockState>(); stateToId = new Dictionary <BlockState, uint>(); // Palette Length McVarint.TryParse(ref data, out int length); // Palette for (uint id = 0; id < length; id++) { McVarint.TryParse(ref data, out int stateId); BlockState state = GlobalPalette.GetState((uint)stateId); idToState[id] = state; stateToId[state] = id; } }
public override string ToString() { return($"{StateId} {GlobalPalette.GetState(StateId).Name}"); }
public BlockState StateForId(uint id) { return GlobalPalette.GetState(id); }