示例#1
0
        private void PopulateChunk(ChunkColumn chunk)
        {
            var bottom = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);
            var overhang = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);
            overhang.SetScale(1/OverhangScale);
            bottom.SetScale(1/Groundscale);

            for (var x = 0; x < 16; x++)
            {
                for (var z = 0; z < 16; z++)
                {
                    float ox = x + chunk.X*16;
                    float oz = z + chunk.Z*16;

                    var cBiome = _biomeManager.GetBiome((int) ox, (int) oz);
                    chunk.BiomeId[x*16 + z] = cBiome.MinecraftBiomeId;

                    var bottomHeight =
                        (int)
                            ((bottom.Noise(ox, oz, BottomsFrequency, BottomsAmplitude)*BottomsMagnitude) + BottomOffset + cBiome.BaseHeight);

                    var maxHeight =
                        (int)
                            ((overhang.Noise(ox, oz, OverhangFrequency, OverhangAmplitude)*OverhangsMagnitude) + bottomHeight +
                             OverhangOffset);
                    maxHeight = Math.Max(1, maxHeight);

                    for (var y = 0; y < maxHeight && y < 256; y++)
                    {
                        if (y == 0)
                        {
                            chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(7));
                            continue;
                        }

                        if (y > bottomHeight)
                        {
                            //part where we do the overhangs
                            if (EnableOverhang)
                            {
                                var density = overhang.Noise(ox, y, oz, OverhangFrequency, OverhangAmplitude);
                                if (density > Threshold) chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(1));
                            }
                        }
                        else
                        {
                            chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(1));
                        }
                    }

                    //Turn the blocks ontop into the correct material
                    for (var y = 0; y < 256; y++)
                    {
                        if (chunk.GetBlock(x, y + 1, z) == 0 && chunk.GetBlock(x, y, z) == 1)
                        {
                            chunk.SetBlock(x, y, z, cBiome.TopBlock);

                            chunk.SetBlock(x, y - 1, z, cBiome.Filling);
                            chunk.SetBlock(x, y - 2, z, cBiome.Filling);
                        }
                    }

                    foreach (var decorator in cBiome.Decorators)
                    {
                        decorator.Decorate(chunk, cBiome, x, z);
                    }
                    new OreDecorator().Decorate(chunk, cBiome, x, z); //Ores :)
                    new BedrockDecorator().Decorate(chunk, cBiome, x, z); //Random bedrock :)
                }
            }

            new WaterDecorator().Decorate(chunk, new PlainsBiome()); //For now, ALWAYS use the water decorator on all chunks...
            _cavegen.GenerateCave(chunk);
            new LavaDecorator().Decorate(chunk, new PlainsBiome());
        }
示例#2
0
        private void PopulateChunk(ChunkColumn chunk)
        {
            var bottom   = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);
            var overhang = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);

            overhang.SetScale(1 / OverhangScale);
            bottom.SetScale(1 / Groundscale);


            for (var x = 0; x < 16; x++)
            {
                for (var z = 0; z < 16; z++)
                {
                    float ox = x + chunk.X * 16;
                    float oz = z + chunk.Z * 16;

                    var cBiome = _biomeManager.GetBiome((int)ox, (int)oz);
                    chunk.BiomeId[x * 16 + z] = cBiome.MinecraftBiomeId;

                    var bottomHeight =
                        (int)
                        ((bottom.Noise(ox, oz, BottomsFrequency, BottomsAmplitude) * BottomsMagnitude) + BottomOffset + cBiome.BaseHeight);

                    var maxHeight =
                        (int)
                        ((overhang.Noise(ox, oz, OverhangFrequency, OverhangAmplitude) * OverhangsMagnitude) + bottomHeight +
                         OverhangOffset);
                    maxHeight = Math.Max(1, maxHeight);

                    for (var y = 0; y < maxHeight && y < 256; y++)
                    {
                        if (y == 0)
                        {
                            chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(7));
                            continue;
                        }

                        if (y > bottomHeight)
                        {
                            //part where we do the overhangs
                            if (EnableOverhang)
                            {
                                var density = overhang.Noise(ox, y, oz, OverhangFrequency, OverhangAmplitude);
                                if (density > Threshold)
                                {
                                    chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(1));
                                }
                            }
                        }
                        else
                        {
                            chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(1));
                        }
                    }

                    //Turn the blocks ontop into the correct material
                    for (var y = 0; y < 256; y++)
                    {
                        if (chunk.GetBlock(x, y + 1, z) == 0 && chunk.GetBlock(x, y, z) == 1)
                        {
                            chunk.SetBlock(x, y, z, cBiome.TopBlock);

                            chunk.SetBlock(x, y - 1, z, cBiome.Filling);
                            chunk.SetBlock(x, y - 2, z, cBiome.Filling);
                        }
                    }

                    foreach (var decorator in cBiome.Decorators)
                    {
                        decorator.Decorate(chunk, cBiome, x, z);
                    }
                    new OreDecorator().Decorate(chunk, cBiome, x, z);                     //Ores :)
                    new BedrockDecorator().Decorate(chunk, cBiome, x, z);                 //Random bedrock :)
                }
            }

            new WaterDecorator().Decorate(chunk, new PlainsBiome());             //For now, ALWAYS use the water decorator on all chunks...
            _cavegen.GenerateCave(chunk);
            new LavaDecorator().Decorate(chunk, new PlainsBiome());
        }
示例#3
0
        private void PopulateChunk(ChunkColumn chunk)
        {
            var bottom = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);
            var top = new SimplexOctaveGenerator(ServerSettings.Seed.GetHashCode(), 8);
            bottom.SetScale(1/Groundscale);
            top.SetScale(1/Topscale);

            for (var x = 0; x < 16; x++)
            {
                for (var z = 0; z < 16; z++)
                {
                    float ox = x + chunk.X*16;
                    float oz = z + chunk.Z*16;

                    var bottomHeight =
                        (int) ((bottom.Noise(ox, oz, BottomsFrequency, BottomsAmplitude)*BottomsMagnitude) + BottomOffset);
                    var topHeight = (int) ((top.Noise(ox, oz, TopFrequency, TopAmplitude)*TopMagnitude) + TopOffset);

                    for (var y = 0; y < 256; y++)
                    {
                        if (y == 0 || y == 255)
                        {
                            chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(7));
                            continue;
                        }

                        if (y < bottomHeight)
                        {
                            chunk.SetBlock(x, y, z, new BlockNetherrack());
                        }

                        if (y < topHeight)
                        {
                            chunk.SetBlock(x, 256 - y, z, new BlockNetherrack());
                            if (GetRandomNumber(1, 50) == 25)
                            {
                                chunk.SetBlock(x, 256 - (y + 1), z, new Block(89));
                            }
                        }
                    }

                    //Turn the blocks ontop into the correct material
                    for (var y = bottomHeight; y < 254; y++)
                    {
                        if (chunk.GetBlock(x, y + 1, z) == 0 && chunk.GetBlock(x, y, z) == 1)
                        {
                            chunk.SetBlock(x, y, z, new BlockNetherrack());

                            chunk.SetBlock(x, y - 1, z, new BlockNetherrack());
                            chunk.SetBlock(x, y - 2, z, new BlockNetherrack());
                        }
                    }
                }
            }

            new NetherLavaDecorator().Decorate(chunk, new PlainsBiome());
        }