Example #1
0
		public virtual void GrowTree(net.minecraft.src.World world, int i, int j, int k, 
			SharpBukkitLive.SharpBukkit.SharpRandom random)
		{
			int l = world.GetBlockMetadata(i, j, k) & 3;
			world.SetBlock(i, j, k, 0);
			object obj = null;
			if (l == 1) //TODO: Bukkit fix???
			{
				obj = new net.minecraft.src.WorldGenTaiga2();
			}
			else
			{
				if (l == 2)
				{
					obj = new net.minecraft.src.WorldGenForest();
				}
				else
				{
					obj = new net.minecraft.src.WorldGenTrees();
					if (random.Next(10) == 0)
					{
						obj = new net.minecraft.src.WorldGenBigTree();
					}
				}
			}
			if (!((net.minecraft.src.WorldGenerator)(obj)).Generate(world, random, i, j, k))
			{
				world.SetBlockAndMetadata(i, j, k, ID, l);
			}
		}
Example #2
0
 // Referenced classes of package net.minecraft.src:
 //            WorldGenerator, World, Material, Block
 public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                               , int i, int j, int k)
 {
     for (int l = 0; l < 20; l++)
     {
         int i1 = (i + random.Next(4)) - random.Next(4);
         int j1 = j;
         int k1 = (k + random.Next(4)) - random.Next(4);
         if (!world.IsAirBlock(i1, j1, k1) || world.GetBlockMaterial(i1 - 1, j1 - 1, k1) !=
             net.minecraft.src.Material.water && world.GetBlockMaterial(i1 + 1, j1 - 1, k1)
             != net.minecraft.src.Material.water && world.GetBlockMaterial(i1, j1 - 1, k1 - 1
                                                                           ) != net.minecraft.src.Material.water && world.GetBlockMaterial(i1, j1 - 1, k1 +
                                                                                                                                           1) != net.minecraft.src.Material.water)
         {
             continue;
         }
         int l1 = 2 + random.Next(random.Next(3) + 1);
         for (int i2 = 0; i2 < l1; i2++)
         {
             if (net.minecraft.src.Block.SUGAR_CANE_BLOCK.CanBlockStay(world, i1, j1 + i2, k1))
             {
                 world.SetBlock(i1, j1 + i2, k1, net.minecraft.src.Block.SUGAR_CANE_BLOCK.ID);
             }
         }
     }
     return(true);
 }
Example #3
0
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            if (world.GetBlockMaterial(i, j, k) != net.minecraft.src.Material.water)
            {
                return(false);
            }
            float  f = ((float)random.NextDouble()) * 3.141593F;
            double d = (float)(i + 8) + (net.minecraft.src.MathHelper.Sin(f) * (float)numberOfBlocks
                                         ) / 8F;
            double d1 = (float)(i + 8) - (net.minecraft.src.MathHelper.Sin(f) * (float)numberOfBlocks
                                          ) / 8F;
            double d2 = (float)(k + 8) + (net.minecraft.src.MathHelper.Cos(f) * (float)numberOfBlocks
                                          ) / 8F;
            double d3 = (float)(k + 8) - (net.minecraft.src.MathHelper.Cos(f) * (float)numberOfBlocks
                                          ) / 8F;
            double d4 = j + random.Next(3) + 2;
            double d5 = j + random.Next(3) + 2;

            for (int l = 0; l <= numberOfBlocks; l++)
            {
                double d6  = d + ((d1 - d) * (double)l) / (double)numberOfBlocks;
                double d7  = d4 + ((d5 - d4) * (double)l) / (double)numberOfBlocks;
                double d8  = d2 + ((d3 - d2) * (double)l) / (double)numberOfBlocks;
                double d9  = (random.NextDouble() * (double)numberOfBlocks) / 16D;
                double d10 = (double)(net.minecraft.src.MathHelper.Sin(((float)l * 3.141593F) / (
                                                                           float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
                double d11 = (double)(net.minecraft.src.MathHelper.Sin(((float)l * 3.141593F) / (
                                                                           float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
                int i1 = net.minecraft.src.MathHelper.Floor_double(d6 - d10 / 2D);
                int j1 = net.minecraft.src.MathHelper.Floor_double(d6 + d10 / 2D);
                int k1 = net.minecraft.src.MathHelper.Floor_double(d7 - d11 / 2D);
                int l1 = net.minecraft.src.MathHelper.Floor_double(d7 + d11 / 2D);
                int i2 = net.minecraft.src.MathHelper.Floor_double(d8 - d10 / 2D);
                int j2 = net.minecraft.src.MathHelper.Floor_double(d8 + d10 / 2D);
                for (int k2 = i1; k2 <= j1; k2++)
                {
                    for (int l2 = k1; l2 <= l1; l2++)
                    {
                        for (int i3 = i2; i3 <= j2; i3++)
                        {
                            double d12 = (((double)k2 + 0.5D) - d6) / (d10 / 2D);
                            double d13 = (((double)l2 + 0.5D) - d7) / (d11 / 2D);
                            double d14 = (((double)i3 + 0.5D) - d8) / (d10 / 2D);
                            if (d12 * d12 + d13 * d13 + d14 * d14 >= 1.0D)
                            {
                                continue;
                            }
                            int j3 = world.GetBlockId(k2, l2, i3);
                            if (j3 == net.minecraft.src.Block.SAND.ID)
                            {
                                world.SetBlock(k2, l2, i3, clayBlockId);
                            }
                        }
                    }
                }
            }
            return(true);
        }
Example #4
0
 public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                               , int i, int j, int k)
 {
     for (int l = 0; l < 64; l++)
     {
         int i1 = (i + random.Next(8)) - random.Next(8);
         int j1 = (j + random.Next(4)) - random.Next(4);
         int k1 = (k + random.Next(8)) - random.Next(8);
         if (world.IsAirBlock(i1, j1, k1) && ((net.minecraft.src.BlockFlower)net.minecraft.src.Block
                                              .blocksList[plantBlockId]).CanBlockStay(world, i1, j1, k1))
         {
             world.SetBlock(i1, j1, k1, plantBlockId);
         }
     }
     return(true);
 }
Example #5
0
 public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                               , int i, int j, int k)
 {
     for (int l = 0; ((l = world.GetBlockId(i, j, k)) == 0 || l == net.minecraft.src.Block
                      .LEAVES.ID) && j > 0; j--)
     {
     }
     for (int i1 = 0; i1 < 4; i1++)
     {
         int j1 = (i + random.Next(8)) - random.Next(8);
         int k1 = (j + random.Next(4)) - random.Next(4);
         int l1 = (k + random.Next(8)) - random.Next(8);
         if (world.IsAirBlock(j1, k1, l1) && ((net.minecraft.src.BlockFlower)net.minecraft.src.Block
                                              .blocksList[field_28055_a]).CanBlockStay(world, j1, k1, l1))
         {
             world.SetBlock(j1, k1, l1, field_28055_a);
         }
     }
     return(true);
 }
Example #6
0
 // Referenced classes of package net.minecraft.src:
 //            WorldGenerator, World, Block
 public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                               , int i, int j, int k)
 {
     for (int l = 0; l < 10; l++)
     {
         int i1 = (i + random.Next(8)) - random.Next(8);
         int j1 = (j + random.Next(4)) - random.Next(4);
         int k1 = (k + random.Next(8)) - random.Next(8);
         if (!world.IsAirBlock(i1, j1, k1))
         {
             continue;
         }
         int l1 = 1 + random.Next(random.Next(3) + 1);
         for (int i2 = 0; i2 < l1; i2++)
         {
             if (net.minecraft.src.Block.CACTUS.CanBlockStay(world, i1, j1 + i2, k1))
             {
                 world.SetBlock(i1, j1 + i2, k1, net.minecraft.src.Block.CACTUS.ID);
             }
         }
     }
     return(true);
 }
Example #7
0
        // Referenced classes of package net.minecraft.src:
        //            WorldGenerator, World, Block, BlockLeaves,
        //            BlockGrass
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            int  l    = random.Next(3) + 5;
            bool flag = true;

            if (j < 1 || j + l + 1 > 128)
            {
                return(false);
            }
            for (int i1 = j; i1 <= j + 1 + l; i1++)
            {
                byte byte0 = 1;
                if (i1 == j)
                {
                    byte0 = 0;
                }
                if (i1 >= (j + 1 + l) - 2)
                {
                    byte0 = 2;
                }
                for (int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
                {
                    for (int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
                    {
                        if (i1 >= 0 && i1 < 128)
                        {
                            int j3 = world.GetBlockId(i2, i1, l2);
                            if (j3 != 0 && j3 != net.minecraft.src.Block.LEAVES.ID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }
            if (!flag)
            {
                return(false);
            }
            int j1 = world.GetBlockId(i, j - 1, k);

            if (j1 != net.minecraft.src.Block.GRASS.ID && j1 != net.minecraft.src.Block.
                DIRT.ID || j >= 128 - l - 1)
            {
                return(false);
            }
            world.SetBlock(i, j - 1, k, net.minecraft.src.Block.DIRT.ID);
            for (int k1 = (j - 3) + l; k1 <= j + l; k1++)
            {
                int j2 = k1 - (j + l);
                int i3 = 1 - j2 / 2;
                for (int k3 = i - i3; k3 <= i + i3; k3++)
                {
                    int l3 = k3 - i;
                    for (int i4 = k - i3; i4 <= k + i3; i4++)
                    {
                        int j4 = i4 - k;
                        if ((System.Math.Abs(l3) != i3 || System.Math.Abs(j4) != i3 || random.Next(2)
                             != 0 && j2 != 0) && !net.minecraft.src.Block.opaqueCubeLookup[world.GetBlockId(k3
                                                                                                            , k1, i4)])
                        {
                            world.SetBlockAndMetadata(k3, k1, i4, net.minecraft.src.Block.LEAVES.ID, 2);
                        }
                    }
                }
            }
            for (int l1 = 0; l1 < l; l1++)
            {
                int k2 = world.GetBlockId(i, j + l1, k);
                if (k2 == 0 || k2 == net.minecraft.src.Block.LEAVES.ID)
                {
                    world.SetBlockAndMetadata(i, j + l1, k, net.minecraft.src.Block.LOG.ID, 2);
                }
            }
            return(true);
        }
Example #8
0
        // Referenced classes of package net.minecraft.src:
        //            WorldGenerator, World, Block, BlockLeaves,
        //            BlockGrass
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            int  l    = random.Next(5) + 7;
            int  i1   = l - random.Next(2) - 3;
            int  j1   = l - i1;
            int  k1   = 1 + random.Next(j1 + 1);
            bool flag = true;

            if (j < 1 || j + l + 1 > 128)
            {
                return(false);
            }
            for (int l1 = j; l1 <= j + 1 + l && flag; l1++)
            {
                int j2 = 1;
                if (l1 - j < i1)
                {
                    j2 = 0;
                }
                else
                {
                    j2 = k1;
                }
                for (int l2 = i - j2; l2 <= i + j2 && flag; l2++)
                {
                    for (int k3 = k - j2; k3 <= k + j2 && flag; k3++)
                    {
                        if (l1 >= 0 && l1 < 128)
                        {
                            int j4 = world.GetBlockId(l2, l1, k3);
                            if (j4 != 0 && j4 != net.minecraft.src.Block.LEAVES.ID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }
            if (!flag)
            {
                return(false);
            }
            int i2 = world.GetBlockId(i, j - 1, k);

            if (i2 != net.minecraft.src.Block.GRASS.ID && i2 != net.minecraft.src.Block.
                DIRT.ID || j >= 128 - l - 1)
            {
                return(false);
            }
            world.SetBlock(i, j - 1, k, net.minecraft.src.Block.DIRT.ID);
            int k2 = 0;

            for (int i3 = j + l; i3 >= j + i1; i3--)
            {
                for (int l3 = i - k2; l3 <= i + k2; l3++)
                {
                    int k4 = l3 - i;
                    for (int l4 = k - k2; l4 <= k + k2; l4++)
                    {
                        int i5 = l4 - k;
                        if ((System.Math.Abs(k4) != k2 || System.Math.Abs(i5) != k2 || k2 <= 0) && !net.minecraft.src.Block
                            .opaqueCubeLookup[world.GetBlockId(l3, i3, l4)])
                        {
                            world.SetBlockAndMetadata(l3, i3, l4, net.minecraft.src.Block.LEAVES.ID, 1);
                        }
                    }
                }
                if (k2 >= 1 && i3 == j + i1 + 1)
                {
                    k2--;
                    continue;
                }
                if (k2 < k1)
                {
                    k2++;
                }
            }
            for (int j3 = 0; j3 < l - 1; j3++)
            {
                int i4 = world.GetBlockId(i, j + j3, k);
                if (i4 == 0 || i4 == net.minecraft.src.Block.LEAVES.ID)
                {
                    world.SetBlockAndMetadata(i, j + j3, k, net.minecraft.src.Block.LOG.ID, 1);
                }
            }
            return(true);
        }
Example #9
0
        // Referenced classes of package net.minecraft.src:
        //            WorldGenerator, World, Block, BlockLeaves,
        //            BlockGrass
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            int  l    = random.Next(4) + 6;
            int  i1   = 1 + random.Next(2);
            int  j1   = l - i1;
            int  k1   = 2 + random.Next(2);
            bool flag = true;

            if (j < 1 || j + l + 1 > 128)
            {
                return(false);
            }
            for (int l1 = j; l1 <= j + 1 + l && flag; l1++)
            {
                int j2 = 1;
                if (l1 - j < i1)
                {
                    j2 = 0;
                }
                else
                {
                    j2 = k1;
                }
                for (int l2 = i - j2; l2 <= i + j2 && flag; l2++)
                {
                    for (int j3 = k - j2; j3 <= k + j2 && flag; j3++)
                    {
                        if (l1 >= 0 && l1 < 128)
                        {
                            int k3 = world.GetBlockId(l2, l1, j3);
                            if (k3 != 0 && k3 != net.minecraft.src.Block.LEAVES.ID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }
            if (!flag)
            {
                return(false);
            }
            int i2 = world.GetBlockId(i, j - 1, k);

            if (i2 != net.minecraft.src.Block.GRASS.ID && i2 != net.minecraft.src.Block.
                DIRT.ID || j >= 128 - l - 1)
            {
                return(false);
            }
            world.SetBlock(i, j - 1, k, net.minecraft.src.Block.DIRT.ID);
            int  k2    = random.Next(2);
            int  i3    = 1;
            bool flag1 = false;

            for (int l3 = 0; l3 <= j1; l3++)
            {
                int j4 = (j + l) - l3;
                for (int l4 = i - k2; l4 <= i + k2; l4++)
                {
                    int j5 = l4 - i;
                    for (int k5 = k - k2; k5 <= k + k2; k5++)
                    {
                        int l5 = k5 - k;
                        if ((System.Math.Abs(j5) != k2 || System.Math.Abs(l5) != k2 || k2 <= 0) && !net.minecraft.src.Block
                            .opaqueCubeLookup[world.GetBlockId(l4, j4, k5)])
                        {
                            world.SetBlockAndMetadata(l4, j4, k5, net.minecraft.src.Block.LEAVES.ID, 1);
                        }
                    }
                }
                if (k2 >= i3)
                {
                    k2    = ((flag1) ? 1 : 0);
                    flag1 = true;
                    if (++i3 > k1)
                    {
                        i3 = k1;
                    }
                }
                else
                {
                    k2++;
                }
            }
            int i4 = random.Next(3);

            for (int k4 = 0; k4 < l - i4; k4++)
            {
                int i5 = world.GetBlockId(i, j + k4, k);
                if (i5 == 0 || i5 == net.minecraft.src.Block.LEAVES.ID)
                {
                    world.SetBlockAndMetadata(i, j + k4, k, net.minecraft.src.Block.LOG.ID, 1);
                }
            }
            return(true);
        }
Example #10
0
        public override bool Generate(net.minecraft.src.World world, SharpBukkitLive.SharpBukkit.SharpRandom random
                                      , int i, int j, int k)
        {
            i -= 8;
            for (k -= 8; j > 0 && world.IsAirBlock(i, j, k); j--)
            {
            }
            j -= 4;
            bool[] aflag = new bool[2048];
            int    l     = random.Next(4) + 4;

            for (int i1 = 0; i1 < l; i1++)
            {
                double d  = random.NextDouble() * 6D + 3D;
                double d1 = random.NextDouble() * 4D + 2D;
                double d2 = random.NextDouble() * 6D + 3D;
                double d3 = random.NextDouble() * (16D - d - 2D) + 1.0D + d / 2D;
                double d4 = random.NextDouble() * (8D - d1 - 4D) + 2D + d1 / 2D;
                double d5 = random.NextDouble() * (16D - d2 - 2D) + 1.0D + d2 / 2D;
                for (int j4 = 1; j4 < 15; j4++)
                {
                    for (int k4 = 1; k4 < 15; k4++)
                    {
                        for (int l4 = 1; l4 < 7; l4++)
                        {
                            double d6 = ((double)j4 - d3) / (d / 2D);
                            double d7 = ((double)l4 - d4) / (d1 / 2D);
                            double d8 = ((double)k4 - d5) / (d2 / 2D);
                            double d9 = d6 * d6 + d7 * d7 + d8 * d8;
                            if (d9 < 1.0D)
                            {
                                aflag[(j4 * 16 + k4) * 8 + l4] = true;
                            }
                        }
                    }
                }
            }
            for (int j1 = 0; j1 < 16; j1++)
            {
                for (int j2 = 0; j2 < 16; j2++)
                {
                    for (int j3 = 0; j3 < 8; j3++)
                    {
                        bool flag = !aflag[(j1 * 16 + j2) * 8 + j3] && (j1 < 15 && aflag[((j1 + 1) * 16 +
                                                                                          j2) * 8 + j3] || j1 > 0 && aflag[((j1 - 1) * 16 + j2) * 8 + j3] || j2 < 15 && aflag
                                                                        [(j1 * 16 + (j2 + 1)) * 8 + j3] || j2 > 0 && aflag[(j1 * 16 + (j2 - 1)) * 8 + j3
                                                                        ] || j3 < 7 && aflag[(j1 * 16 + j2) * 8 + (j3 + 1)] || j3 > 0 && aflag[(j1 * 16
                                                                                                                                                + j2) * 8 + (j3 - 1)]);
                        if (!flag)
                        {
                            continue;
                        }
                        net.minecraft.src.Material material = world.GetBlockMaterial(i + j1, j + j3, k +
                                                                                     j2);
                        if (j3 >= 4 && material.GetIsLiquid())
                        {
                            return(false);
                        }
                        if (j3 < 4 && !material.IsSolid() && world.GetBlockId(i + j1, j + j3, k + j2) !=
                            field_15005_a)
                        {
                            return(false);
                        }
                    }
                }
            }
            for (int k1 = 0; k1 < 16; k1++)
            {
                for (int k2 = 0; k2 < 16; k2++)
                {
                    for (int k3 = 0; k3 < 8; k3++)
                    {
                        if (aflag[(k1 * 16 + k2) * 8 + k3])
                        {
                            world.SetBlock(i + k1, j + k3, k + k2, k3 < 4 ? field_15005_a : 0);
                        }
                    }
                }
            }
            for (int l1 = 0; l1 < 16; l1++)
            {
                for (int l2 = 0; l2 < 16; l2++)
                {
                    for (int l3 = 4; l3 < 8; l3++)
                    {
                        if (aflag[(l1 * 16 + l2) * 8 + l3] && world.GetBlockId(i + l1, (j + l3) - 1, k +
                                                                               l2) == net.minecraft.src.Block.DIRT.ID && world.GetSavedLightValue(net.minecraft.src.EnumSkyBlock
                                                                                                                                                  .Sky, i + l1, j + l3, k + l2) > 0)
                        {
                            world.SetBlock(i + l1, (j + l3) - 1, k + l2, net.minecraft.src.Block.GRASS.ID
                                           );
                        }
                    }
                }
            }
            if (net.minecraft.src.Block.blocksList[field_15005_a].blockMaterial == net.minecraft.src.Material
                .lava)
            {
                for (int i2 = 0; i2 < 16; i2++)
                {
                    for (int i3 = 0; i3 < 16; i3++)
                    {
                        for (int i4 = 0; i4 < 8; i4++)
                        {
                            bool flag1 = !aflag[(i2 * 16 + i3) * 8 + i4] && (i2 < 15 && aflag[((i2 + 1) * 16
                                                                                               + i3) * 8 + i4] || i2 > 0 && aflag[((i2 - 1) * 16 + i3) * 8 + i4] || i3 < 15 &&
                                                                             aflag[(i2 * 16 + (i3 + 1)) * 8 + i4] || i3 > 0 && aflag[(i2 * 16 + (i3 - 1)) * 8
                                                                                                                                     + i4] || i4 < 7 && aflag[(i2 * 16 + i3) * 8 + (i4 + 1)] || i4 > 0 && aflag[(i2
                                                                                                                                                                                                                 * 16 + i3) * 8 + (i4 - 1)]);
                            if (flag1 && (i4 < 4 || random.Next(2) != 0) && world.GetBlockMaterial(i + i2,
                                                                                                   j + i4, k + i3).IsSolid())
                            {
                                world.SetBlock(i + i2, j + i4, k + i3, net.minecraft.src.Block.STONE.ID);
                            }
                        }
                    }
                }
            }
            return(true);
        }