Esempio n. 1
0
 protected void GenerateVanillaCircle(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0, double corner = 0)
 {
     for (int i = -radius; i <= radius; i = (i + 1))
     {
         for (int j = -radius; j <= radius; j = (j + 1))
         {
             int max = (int)Math.Sqrt((i * i) + (j * j));
             if (max <= radius)
             {
                 if (i.Equals(-radius) && j.Equals(-radius) ||
                     i.Equals(-radius) && j.Equals(radius) ||
                     i.Equals(radius) && j.Equals(-radius) ||
                     i.Equals(radius) && j.Equals(radius))
                 {
                     if (corner + radius * 0.2 < 0.4 || corner + radius * 0.2 > 0.7 || corner.Equals(0))
                     {
                         continue;
                     }
                 }
                 int x            = location.X + i;
                 int z            = location.Z + j;
                 var currentBlock = new Coordinates3D(x, location.Y, z);
                 if (chunk.GetBlockID(currentBlock).Equals(0))
                 {
                     chunk.SetBlockID(currentBlock, block);
                     chunk.SetMetadata(currentBlock, meta);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        protected static void GenerateSphere(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
        {
            for (int i = -radius; i <= radius; i = (i + 1))
            {
                for (int j = -radius; j <= radius; j = (j + 1))
                {
                    for (int k = -radius; k <= radius; k = (k + 1))
                    {
                        int max = (int)Math.Sqrt((i * i) + (j * j) + (k * k));
                        if (max <= radius)
                        {
                            int x = location.X + i;
                            int y = location.Y + k;
                            int z = location.Z + j;

                            if (x < 0 || x >= Chunk.Width || z < 0 || z >= Chunk.Depth || y < 0 || y >= Chunk.Height)
                            {
                                continue;
                            }

                            var currentBlock = new Coordinates3D(x, y, z);
                            if (chunk.GetBlockID(currentBlock).Equals(0))
                            {
                                chunk.SetBlockID(currentBlock, block);
                                chunk.SetMetadata(currentBlock, meta);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected static void GenerateSphere(IChunk chunk, Coordinates3D location, int radius, byte block,
                                             byte meta = 0x0)
        {
            for (var i = -radius; i <= radius; i = i + 1)
            {
                for (var j = -radius; j <= radius; j = j + 1)
                {
                    for (var k = -radius; k <= radius; k = k + 1)
                    {
                        var max = (int)Math.Sqrt(i * i + j * j + k * k);
                        if (max <= radius)
                        {
                            var x = location.X + i;
                            var y = location.Y + k;
                            var z = location.Z + j;

                            if (x < 0 || x >= Chunk.Width || z < 0 || z >= Chunk.Depth || y < 0 || y >= Chunk.Height)
                            {
                                continue;
                            }

                            var currentBlock = new Coordinates3D(x, y, z);
                            if (chunk.GetBlockID(currentBlock).Equals(0))
                            {
                                chunk.SetBlockID(currentBlock, block);
                                chunk.SetMetadata(currentBlock, meta);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 /*
  * Generates the top of the pine/conifer trees.
  * Type:
  * 0x0 - two level topper
  * 0x1 - three level topper
  */
 protected void GenerateTopper(IChunk chunk, Coordinates3D location, byte type = 0x0)
 {
     const int sectionRadius = 1;
     GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockID, 0x1);
     var top = location + Coordinates3D.Up;
     chunk.SetBlockID(top, LeavesBlock.BlockID);
     chunk.SetMetadata(top, 0x1);
     if (type == 0x1 && (top + Coordinates3D.Up).Y < Chunk.Height)
         GenerateVanillaCircle(chunk, top + Coordinates3D.Up, sectionRadius, LeavesBlock.BlockID, 0x1); 
 }
Esempio n. 5
0
 public static void GenerateColumn(IChunk chunk, Coordinates3D location, int height, byte block, byte meta = 0x0)
 {
     for (int offset = 0; offset < height; offset++)
     {
         var blockLocation = location + new Coordinates3D(0, offset, 0);
         if (blockLocation.Y >= Chunk.Height)
             return;
         chunk.SetBlockID(blockLocation, block);
         chunk.SetMetadata(blockLocation, meta);
     }
 }
Esempio n. 6
0
 public static void GenerateColumn(IChunk chunk, Coordinates3D location, int height, byte block, byte meta = 0x0)
 {
     for (int offset = 0; offset < height; offset++)
     {
         var blockLocation = location + new Coordinates3D(0, offset, 0);
         if (blockLocation.Y >= Chunk.Height)
         {
             return;
         }
         chunk.SetBlockID(blockLocation, block);
         chunk.SetMetadata(blockLocation, meta);
     }
 }
Esempio n. 7
0
        /*
         * Generates the top of the pine/conifer trees.
         * Type:
         * 0x0 - two level topper
         * 0x1 - three level topper
         */
        protected void GenerateTopper(IChunk chunk, Coordinates3D location, byte type = 0x0)
        {
            const int sectionRadius = 1;

            GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockId, 0x1);
            var top = location + Coordinates3D.Up;

            chunk.SetBlockID(top, LeavesBlock.BlockId);
            chunk.SetMetadata(top, 0x1);
            if (type == 0x1 && (top + Coordinates3D.Up).Y < Chunk.Height)
            {
                GenerateVanillaCircle(chunk, top + Coordinates3D.Up, sectionRadius, LeavesBlock.BlockId, 0x1);
            }
        }
Esempio n. 8
0
        /*
         * Cuboid Modes
         * 0x0 - Solid cuboid of the specified block
         * 0x1 - Hollow cuboid of the specified block
         * 0x2 - Outlines the area of the cuboid using the specified block
         */
        public static void GenerateCuboid(IChunk chunk, Coordinates3D location, Vector3 size, byte block,
                                          byte meta = 0x0, byte mode = 0x0)
        {
            //If mode is 0x2 offset the size by 2 and change mode to 0x1
            if (mode.Equals(0x2))
            {
                size += new Vector3(2, 2, 2);
                mode  = 0x1;
            }

            for (var w = location.X; w < location.X + size.X; w++)
            {
                for (var l = location.Z; l < location.Z + size.Z; l++)
                {
                    for (var h = location.Y; h < location.Y + size.Y; h++)
                    {
                        if (w < 0 || w >= Chunk.Width || l < 0 || l >= Chunk.Depth || h < 0 || h >= Chunk.Height)
                        {
                            continue;
                        }
                        var BlockLocation = new Coordinates3D(w, h, l);
                        if (!h.Equals(location.Y) && !h.Equals(location.Y + (int)size.Y - 1) &&
                            !IsCuboidWall(new Coordinates2D(w, l), location, size) &&
                            !IsCuboidCorner(new Coordinates2D(w, l), location, size))
                        {
                            continue;
                        }

                        chunk.SetBlockID(BlockLocation, block);
                        if (meta != 0x0)
                        {
                            chunk.SetMetadata(BlockLocation, meta);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 void GenerateTallGrass(IChunk chunk, Coordinates3D location, byte meta)
 {
     chunk.SetBlockID(location, TallGrassBlock.BlockID);
     chunk.SetMetadata(location, meta);
 }
Esempio n. 10
0
 void GenerateTallGrass(IChunk chunk, Coordinates3D location, byte meta)
 {
     chunk.SetBlockID(location, TallGrassBlock.BlockID);
     chunk.SetMetadata(location, meta);
 }
Esempio n. 11
0
        /*
         * Cuboid Modes
         * 0x0 - Solid cuboid of the specified block
         * 0x1 - Hollow cuboid of the specified block
         * 0x2 - Outlines the area of the cuboid using the specified block
         */
        public static void GenerateCuboid(IChunk chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0)
        {
            //If mode is 0x2 offset the size by 2 and change mode to 0x1
            if (mode.Equals(0x2))
            {
                size += new Vector3(2, 2, 2);
                mode = 0x1;
            }

            for (int w = location.X; w < location.X + size.X; w++)
            {
                for (int l = location.Z; l < location.Z + size.Z; l++)
                {
                    for (int h = location.Y; h < location.Y + size.Y; h++)
                    {

                        if (w < 0 || w >= Chunk.Width || l < 0 || l >= Chunk.Depth || h < 0 || h >= Chunk.Height)
                            continue;
                        Coordinates3D BlockLocation = new Coordinates3D(w, h, l);
                        if (!h.Equals(location.Y) && !h.Equals(location.Y + (int)size.Y - 1)
                            && !IsCuboidWall(new Coordinates2D(w, l), location, size)
                            && !IsCuboidCorner(new Coordinates2D(w, l), location, size))
                            continue;

                        chunk.SetBlockID(BlockLocation, block);
                        if (meta != 0x0)
                            chunk.SetMetadata(BlockLocation, meta);
                    }
                }
            }
        }
Esempio n. 12
0
        protected static void GenerateSphere(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
        {
            for (int i = -radius; i <= radius; i = (i + 1))
            {
                for (int j = -radius; j <= radius; j = (j + 1))
                {
                    for (int k = -radius; k <= radius; k = (k + 1))
                    {
                        int max = (int)Math.Sqrt((i * i) + (j * j) + (k * k));
                        if (max <= radius)
                        {
                            int x = location.X + i;
                            int y = location.Y + k;
                            int z = location.Z + j;

                            if (x < 0 || x >= Chunk.Width || z < 0 || z >= Chunk.Depth || y < 0 || y >= Chunk.Height)
                                continue;

                            var currentBlock = new Coordinates3D(x, y, z);
                            if (chunk.GetBlockID(currentBlock).Equals(0))
                            {
                                chunk.SetBlockID(currentBlock, block);
                                chunk.SetMetadata(currentBlock, meta);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 13
0
 protected void GenerateVanillaCircle(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0, double corner = 0)
 {
     for (int i = -radius; i <= radius; i = (i + 1))
     {
         for (int j = -radius; j <= radius; j = (j + 1))
         {
             int max = (int)Math.Sqrt((i * i) + (j * j));
             if (max <= radius)
             {
                 if (i.Equals(-radius) && j.Equals(-radius)
                     || i.Equals(-radius) && j.Equals(radius)
                     || i.Equals(radius) && j.Equals(-radius)
                     || i.Equals(radius) && j.Equals(radius))
                 {
                     if (corner + radius * 0.2 < 0.4 || corner + radius * 0.2 > 0.7 || corner.Equals(0))
                         continue;
                 }
                 int x = location.X + i;
                 int z = location.Z + j;
                 var currentBlock = new Coordinates3D(x, location.Y, z);
                 if (chunk.GetBlockID(currentBlock).Equals(0))
                 {
                     chunk.SetBlockID(currentBlock, block);
                     chunk.SetMetadata(currentBlock, meta);
                 }
             }
         }
     }
 }