Beispiel #1
0
        private Color GetBiomeColor(int bx, int bz)
        {
            if (bx < 0)
            {
                bx = 0;
            }
            if (bz < 0)
            {
                bz = 0;
            }
            if (bx > 15)
            {
                bx = 15;
            }
            if (bz > 15)
            {
                bz = 15;
            }

            BiomeUtils utils = new BiomeUtils();
            var        biome = GetBiome(bx, bz);
            int        color = utils.ComputeBiomeColor(biome, 0, true);

            if (random.Next(30) == 0)
            {
                Color col = Color.FromArgb(color);
                color = Color.FromArgb(0, Math.Max(0, col.R - 160), Math.Max(0, col.G - 160), Math.Max(0, col.B - 160)).ToArgb();
            }

            return(Color.FromArgb(color));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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();
        }