public IChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            IChunkColumn c = new ChunkColumn()
            {
                X = chunkCoordinates.X,
                Z = chunkCoordinates.Z
            };

            for (int x = 0; x < ChunkColumn.ChunkWidth; x++)
            {
                for (int z = 0; z < ChunkColumn.ChunkDepth; z++)
                {
                    for (int y = 0; y < ChunkColumn.ChunkHeight; y++)
                    {
                        if (c.X == 0 && c.Z == 0)
                        {
                            IBlockState block;
                            switch (y >> 4)
                            {
                            case 0:
                                block = _dirt;
                                break;

                            case 1:
                                block = _stone;
                                break;

                            case 2:
                                block = _cobble;
                                break;

                            case 3:
                                block = _grass;
                                break;

                            //case 4:
                            //    break;
                            default:
                                continue;
                            }

                            c.SetBlockState(x, y, z, block);
                        }
                        else
                        {
                            //c.SetBlockState(x, y, z, _air);
                        }

                        c.SetSkyLight(x, y, z, 15);
                    }
                    c.SetHeight(x, z, 0);
                }
            }
            return(c);
        }
Exemple #2
0
        private void GenerateTerrain(ChunkColumn column, float[] noise)
        {
            var heightMap = noise;

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    /* var biome = biomes[NoiseMap.GetIndex(x, z)];
                     *
                     * byte biomeId = (byte) biome.Id;
                     * if (ApplyBlocks)
                     * {*/
                    var h = (int)heightMap[NoiseMap.GetIndex(x, z)];

                    var height = h;
                    for (int y = 0; (y <= height || y <= Preset.SeaLevel) && y < 255; y++)
                    {
                        if (y > height)
                        {
                            if (y < Preset.SeaLevel)
                            {
                                column.SetBlock(x, y, z, new Water());
                            }
                            else
                            {
                                column.SetBlock(x, y, z, new Air());
                            }
                        }
                        else if (y == height)
                        {
                            column.SetBlock(x, y, z, new Stone());
                            //    column.SetBlock(x, y, z, BlockFactory.GetBlockById(biome.SurfaceBlock));
                            //column.SetMetadata(x, y, z, biome.SurfaceMetadata);

                            // column.SetBlock(x, y - 1, z,  BlockFactory.GetBlockById(biome.SoilBlock));
                            //column.SetMetadata(x, y -1, z, biome.SoilMetadata);
                        }
                        else if (y < height)
                        {
                            column.SetBlock(x, y, z, new Stone());
                        }
                    }


                    column.SetHeight(x, z, (short)height);
                    //}

                    //column.SetBiome(x, z, biomeId);
                }
            }
        }
Exemple #3
0
 public void PopulateChunk(ChunkColumn chunk)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             chunk.SetBlock(x, 1, z, 7);                     // Bedrock
             chunk.SetBlock(x, 2, z, 3);                     // Dirt
             chunk.SetBlock(x, 3, z, 3);                     // Dirt
             chunk.SetBlock(x, 4, z, 2);                     // Grass
             chunk.SetHeight(x, z, 4);
         }
     }
 }
Exemple #4
0
        public EmptyWorldGenerator()
        {
            _sharedChunk = new ChunkColumn();
            //_sharedChunk.IsAllAir = true;
            for (int x = 0; x < ChunkColumn.ChunkWidth; x++)
            {
                for (int z = 0; z < ChunkColumn.ChunkDepth; z++)
                {
                    for (int y = 0; y < ChunkColumn.ChunkHeight; y++)
                    {
                        //	_sharedChunk.SetBlockState(x, y, z, new Air());
                        _sharedChunk.SetSkyLight(x, y, z, 15);
                    }

                    _sharedChunk.SetHeight(x, z, 0);
                }
            }
        }
Exemple #5
0
        public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            ChunkColumn chunk = new ChunkColumn();

            chunk.X = chunkCoordinates.X;
            chunk.Z = chunkCoordinates.Z;

            int xOffset = chunk.X << 4;
            int zOffset = chunk.Z << 4;

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    for (int y = 0; y < PlotHeight + 1; y++)
                    {
                        if (y == 0)
                        {
                            chunk.SetBlock(x, y, z, new Bedrock());                                 // Bedrock
                        }
                        else if (y == PlotHeight - 1)
                        {
                            chunk.SetBlock(x, y, z, new Grass());                             // grass
                        }
                        else if (y == PlotHeight)
                        {
                            if (!IsZRoad(z + zOffset, true) && !IsXRoad(x + xOffset, true))
                            {
                                var block = PlotPattern.Next(new BlockCoordinates(x, PlotHeight, z));
                                chunk.SetBlock(x, y, z, block);                                 // pattern
                            }
                        }
                        else if (y > PlotHeight - 4)
                        {
                            chunk.SetBlock(x, y, z, new Dirt());                             // dirt
                        }
                        else
                        {
                            chunk.SetBlock(x, y, z, new Stone());                             // stone
                        }
                    }

                    chunk.SetHeight(x, z, PlotHeight);
                }
            }


            var leaves = new Leaves();

            //if (xOffset < 0) xOffset -= PlotAreaWidth;
            //if (zOffset < 0) zOffset -= PlotAreaDepth;

            for (int x = xOffset; x < xOffset + 16; x++)
            {
                for (int z = zOffset; z < zOffset + 16; z++)
                {
                    for (int i = 1; i < RoadWidth - 1; i++)
                    {
                        var block = RoadPattern.Next(new BlockCoordinates(x, PlotHeight, z));
                        if ((x - i) % PlotAreaWidth == 0)
                        {
                            chunk.SetBlock(x - xOffset, PlotHeight - 1, z - zOffset, block);
                        }

                        if ((z - i) % PlotAreaDepth == 0)
                        {
                            chunk.SetBlock(x - xOffset, PlotHeight - 1, z - zOffset, block);
                        }
                    }

                    if (x % PlotAreaWidth == 0 && !IsZRoad(z))
                    {
                        chunk.SetBlock(x - xOffset, PlotHeight, z - zOffset, leaves);
                    }
                    if ((x - RoadWidth + 1) % PlotAreaWidth == 0 && !IsZRoad(z))
                    {
                        chunk.SetBlock(x - xOffset, PlotHeight, z - zOffset, leaves);
                    }

                    if (z % PlotAreaDepth == 0 && !IsXRoad(x))
                    {
                        chunk.SetBlock(x - xOffset, PlotHeight, z - zOffset, leaves);
                    }
                    if ((z - RoadWidth + 1) % PlotAreaDepth == 0 && !IsXRoad(x))
                    {
                        chunk.SetBlock(x - xOffset, PlotHeight, z - zOffset, leaves);
                    }

                    //if (x%PlotAreaWidth == 0 && z%PlotAreaDepth == 0) chunk.SetBlock(x - xOffset, PlotHeight + 1, z - zOffset, new RedstoneBlock().Id);
                    //if (x%PlotAreaWidth == PlotAreaWidth - 1 && z%PlotAreaDepth == PlotAreaDepth - 1) chunk.SetBlock(x - xOffset, PlotHeight + 1, z - zOffset, new LapisBlock().Id); // stone
                }
            }

            return(chunk);
        }