public byte[] GetBytes() { if (_cache != null) { return(_cache); } using (MemoryStream stream = MiNetServer.MemoryStreamManager.GetStream()) { NbtBinaryWriter writer = new NbtBinaryWriter(stream, true); writer.Write(blocks); writer.Write(metadata.Data); writer.Write(skylight.Data); writer.Write(blocklight.Data); //RecalcHeight(); writer.Write(height); BiomeUtils utils = new BiomeUtils(); utils.PrecomputeBiomeColors(); InterpolateBiomes(); for (int i = 0; i < biomeId.Length; i++) { var biome = biomeId[i]; int color = biomeColor[i]; writer.Write((color & 0x00ffffff) | biome << 24); } short extraSize = 0; writer.Write(extraSize); // No extra data if (BlockEntities.Count == 0) { //NbtFile file = new NbtFile(new NbtCompound(string.Empty)) {BigEndian = false, UseVarInt = true}; //file.SaveToStream(writer.BaseStream, NbtCompression.None); } else { foreach (NbtCompound blockEntity in BlockEntities.Values.ToArray()) { NbtFile file = new NbtFile(blockEntity) { BigEndian = false, UseVarInt = true }; file.SaveToStream(writer.BaseStream, NbtCompression.None); } } _cache = stream.ToArray(); } return(_cache); }
public ChunkColumn() { isDirty = false; //Parallel.For(0, skylight.Data.Length, i => skylight.Data[i] = 0xff); //for (int i = 0; i < skylight.Data.Length; i++) // skylight.Data[i] = 0xff; for (int i = 0; i < biomeColor.Length; i++) { biomeColor[i] = 8761930; // Grass color? } //for (int i = 0; i < biomeColor.Length; i++) // biomeColor[i] = Color.FromArgb(0, 255, 204, 51).ToArgb(); BiomeUtils utils = new BiomeUtils(); utils.PrecomputeBiomeColors(); }