Example #1
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            float f = random.nextFloat() * 3.141593F;
            double d = (float)(i + 8) + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
            double d1 = (float)(i + 8) - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
            double d2 = (float)(k + 8) + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
            double d3 = (float)(k + 8) - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
            double d4 = (j + random.nextInt(3)) - 2;
            double d5 = (j + random.nextInt(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)(MathHelper.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
                double d11 = (double)(MathHelper.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
                int i1 = MathHelper.floor_double(d6 - d10 / 2D);
                int j1 = MathHelper.floor_double(d7 - d11 / 2D);
                int k1 = MathHelper.floor_double(d8 - d10 / 2D);
                int l1 = MathHelper.floor_double(d6 + d10 / 2D);
                int i2 = MathHelper.floor_double(d7 + d11 / 2D);
                int j2 = MathHelper.floor_double(d8 + d10 / 2D);
                for (int k2 = i1; k2 <= l1; k2++)
                {
                    double d12 = (((double)k2 + 0.5D) - d6) / (d10 / 2D);
                    if (d12 * d12 >= 1.0D)
                    {
                        continue;
                    }
                    for (int l2 = j1; l2 <= i2; l2++)
                    {
                        double d13 = (((double)l2 + 0.5D) - d7) / (d11 / 2D);
                        if (d12 * d12 + d13 * d13 >= 1.0D)
                        {
                            continue;
                        }
                        for (int i3 = k1; i3 <= j2; i3++)
                        {
                            double d14 = (((double)i3 + 0.5D) - d8) / (d10 / 2D);
                            if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.GetBlock(k2, l2, i3) == (byte)Blocks.Stone)
                            {
                                world.SetBlock(k2, l2, i3, (byte)minableBlockId);
                            }
                        }

                    }

                }

            }

            return true;
        }
Example #2
0
 public override WorldGenerator getRandomWorldGenForTrees(java.util.Random random)
 {
     if(random.nextInt(5) == 0)
     {
         return forestGenerator;
     }
     if(random.nextInt(10) == 0)
     {
         return bigTreeGenerator;
     } else
     {
         return treeGenerator;
     }
 }
Example #3
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
            {
                return false;
            }
            int l = random.nextInt(field_35290_b - 2) + 2;
            byte byte0 = 2;
            for (int i1 = i - l; i1 <= i + l; i1++)
            {
                for (int j1 = k - l; j1 <= k + l; j1++)
                {
                    int k1 = i1 - i;
                    int l1 = j1 - k;
                    if (k1 * k1 + l1 * l1 > l * l)
                    {
                        continue;
                    }
                    for (int i2 = j - byte0; i2 <= j + byte0; i2++)
                    {
                        int j2 = world.GetBlock(i1, i2, j1);
                        if (j2 == (byte)Blocks.Dirt || j2 == (byte)Blocks.Grass)
                        {
                            world.SetBlock(i1, i2, j1, (byte)field_35291_a);
                        }
                    }

                }

            }

            return true;
        }
Example #4
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
            {
                return false;
            }
            int l = random.nextInt(numberOfBlocks - 2) + 2;
            int i1 = 1;
            for (int j1 = i - l; j1 <= i + l; j1++)
            {
                for (int k1 = k - l; k1 <= k + l; k1++)
                {
                    int l1 = j1 - i;
                    int i2 = k1 - k;
                    if (l1 * l1 + i2 * i2 > l * l)
                    {
                        continue;
                    }
                    for (int j2 = j - i1; j2 <= j + i1; j2++)
                    {
                        int k2 = world.GetBlock(j1, j2, k1);
                        if (k2 == (byte)Blocks.Dirt || k2 == (byte)Blocks.ClayBlock)
                        {
                            world.SetBlock(j1, j2, k1, (byte)clayBlockId);
                        }
                    }

                }

            }

            return true;
        }
Example #5
0
        public ChunkPosition func_35139_a(int i, int j, int k, List<BiomeGenBase> list, java.util.Random random)
        {
            int l = i - k >> 2;
            int i1 = j - k >> 2;
            int j1 = i + k >> 2;
            int k1 = j + k >> 2;
            int l1 = (j1 - l) + 1;
            int i2 = (k1 - i1) + 1;
            int[] ai = field_34907_a.func_35018_a(l, i1, l1, i2);
            ChunkPosition chunkposition = null;
            int j2 = 0;
            for(int k2 = 0; k2 < ai.Length; k2++)
            {
                int l2 = l + k2 % l1 << 2;
                int i3 = i1 + k2 / l1 << 2;
                BiomeGenBase biomegenbase = BiomeGenBase.biomeList[ai[k2]];
                if(list.Contains(biomegenbase) && (chunkposition == null || random.nextInt(j2 + 1) == 0))
                {
                    chunkposition = new ChunkPosition(l2, 0, i3);
                    j2++;
                }
            }

            return chunkposition;
        }
Example #6
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (!world.IsAirBlock(i, j, k) || world.GetBlock(i, j - 1, k) != field_40207_a)
            {
                return false;
            }
            int l = random.nextInt(32) + 6;
            int i1 = random.nextInt(4) + 1;
            for (int j1 = i - i1; j1 <= i + i1; j1++)
            {
                for (int l1 = k - i1; l1 <= k + i1; l1++)
                {
                    int j2 = j1 - i;
                    int l2 = l1 - k;
                    if (j2 * j2 + l2 * l2 <= i1 * i1 + 1 && world.GetBlock(j1, j - 1, l1) != field_40207_a)
                    {
                        return false;
                    }
                }

            }

            for (int k1 = j; k1 < j + l && k1 < world.worldYMax; k1++)
            {
                for (int i2 = i - i1; i2 <= i + i1; i2++)
                {
                    for (int k2 = k - i1; k2 <= k + i1; k2++)
                    {
                        int i3 = i2 - i;
                        int j3 = k2 - k;
                        if (i3 * i3 + j3 * j3 <= i1 * i1 + 1)
                        {
                            world.SetBlock(i2, k1, k2, (byte)Blocks.Obsidian);
                        }
                    }

                }

            }

            // TODO
            /*EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world);
            entityendercrystal.setLocationAndAngles((float)i + 0.5F, j + l, (float)k + 0.5F, random.nextFloat() * 360F, 0.0F);
            world.entityJoinedWorld(entityendercrystal);*/
            world.SetBlock(i, j + l, k, (byte)Blocks.Bedrock);
            return true;
        }
Example #7
0
 public override WorldGenerator getRandomWorldGenForTrees(java.util.Random random)
 {
     if(random.nextInt(3) == 0)
     {
         return new WorldGenTaiga1();
     } else
     {
         return new WorldGenTaiga2(false);
     }
 }
Example #8
0
 protected void func_35545_a(World world, java.util.Random random, int i)
 {
     int j = world.worldOceanHeight - i;
     int k = boundingBox.bbHeight() + 1;
     if (k < j)
     {
         k += random.nextInt(j - k);
     }
     int l = k - boundingBox.y2;
     boundingBox.offset(0, l, 0);
     StructureComponent structurecomponent;
     for (IEnumerator<StructureComponent> iterator = components.GetEnumerator(); iterator.MoveNext(); structurecomponent.getStructureBoundingBox().offset(0, l, 0))
     {
         structurecomponent = (StructureComponent)iterator.Current;
     }
 }
Example #9
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            for (int l = 0; l < 64; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = (j + random.nextInt(4)) - random.nextInt(4);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (world.IsAirBlock(i1, j1, k1) && world.GetBlock(i1, j1 - 1, k1) == (byte)Blocks.Grass && world.CanPlaceAt((byte)Blocks.Pumpkin, i1, j1, k1))
                {
                    world.SetBlock(i1, j1, k1, (byte)Blocks.Pumpkin, (byte)random.nextInt(4));
                }
            }

            return true;
        }
Example #10
0
        public static WeightedRandomChoice func_35693_a(java.util.Random random, ICollection<WeightedRandomChoice> collection, int i)
        {
            if(i <= 0)
            {
                throw new ArgumentException();
            }
            int j = random.nextInt(i);
            for(IEnumerator<WeightedRandomChoice> iterator = collection.GetEnumerator(); iterator.MoveNext();)
            {
                WeightedRandomChoice weightedrandomchoice = (WeightedRandomChoice)iterator.Current;
                j -= weightedrandomchoice.field_35483_d;
                if(j < 0)
                {
                    return weightedrandomchoice;
                }
            }

            return null;
        }
Example #11
0
 protected void func_40209_a(World world, java.util.Random random, int i, int j)
 {
     int k = ((j - i) + 1) - boundingBox.bbHeight();
     int l = 1;
     if (k > 1)
     {
         l = i + random.nextInt(k);
     }
     else
     {
         l = i;
     }
     int i1 = l - boundingBox.y1;
     boundingBox.offset(0, i1, 0);
     StructureComponent structurecomponent;
     for (IEnumerator<StructureComponent> iterator = components.GetEnumerator(); iterator.MoveNext(); structurecomponent.getStructureBoundingBox().offset(0, i1, 0))
     {
         structurecomponent = (StructureComponent)iterator.Current;
     }
 }
Example #12
0
        public NoisePerlin(java.util.Random random)
        {
            permutations = new int[512];
            xCoord = random.nextDouble() * 256D;
            yCoord = random.nextDouble() * 256D;
            zCoord = random.nextDouble() * 256D;
            for(int i = 0; i < 256; i++)
            {
                permutations[i] = i;
            }

            for(int j = 0; j < 256; j++)
            {
                int k = random.nextInt(256 - j) + j;
                int l = permutations[j];
                permutations[j] = permutations[k];
                permutations[k] = l;
                permutations[j + 256] = permutations[j];
            }
        }
Example #13
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            for (int l = 0; l < 64; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = (j + random.nextInt(4)) - random.nextInt(4);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (world.IsAirBlock(i1, j1, k1) && world.CanBlockStay((byte)plantBlockId, i1, j1, k1))
                {
                    world.SetBlock(i1, j1, k1, (byte)plantBlockId);
                }
            }

            return true;
        }
Example #14
0
        public static WeightedRandomChoice func_35688_a(java.util.Random random, WeightedRandomChoice[] aweightedrandomchoice, int i)
        {
            if(i <= 0)
            {
                throw new ArgumentException();
            }
            int j = random.nextInt(i);
            WeightedRandomChoice[] aweightedrandomchoice1 = aweightedrandomchoice;
            int k = aweightedrandomchoice1.Length;
            for(int l = 0; l < k; l++)
            {
                WeightedRandomChoice weightedrandomchoice = aweightedrandomchoice1[l];
                j -= weightedrandomchoice.field_35483_d;
                if(j < 0)
                {
                    return weightedrandomchoice;
                }
            }

            return null;
        }
Example #15
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            for (int l = 0; ((l = world.GetBlock(i, j, k)) == 0 || l == (byte)Blocks.Leaves) && j > 0; j--) { }
            for (int i1 = 0; i1 < 128; i1++)
            {
                int j1 = (i + random.nextInt(8)) - random.nextInt(8);
                int k1 = (j + random.nextInt(4)) - random.nextInt(4);
                int l1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (world.IsAirBlock(j1, k1, l1) && world.CanBlockStay((byte)field_28057_a, j1, k1, l1))
                {
                    world.SetBlock(j1, k1, l1, (byte)field_28057_a, (byte)field_28056_b);
                }
            }

            return true;
        }
Example #16
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            for (int l = 0; l < 10; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = (j + random.nextInt(4)) - random.nextInt(4);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (!world.IsAirBlock(i1, j1, k1))
                {
                    continue;
                }
                int l1 = 1 + random.nextInt(random.nextInt(3) + 1);
                for (int i2 = 0; i2 < l1; i2++)
                {
                    if (world.CanBlockStay((byte)Blocks.Cactus, i1, j1 + i2, k1))
                    {
                        world.SetBlock(i1, j1 + i2, k1, (byte)Blocks.Cactus);
                    }
                }

            }

            return true;
        }
Example #17
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            for (int l = 0; l < 20; l++)
            {
                int i1 = (i + random.nextInt(4)) - random.nextInt(4);
                int j1 = j;
                int k1 = (k + random.nextInt(4)) - random.nextInt(4);
                if (!world.IsAirBlock(i1, j1, k1) || BlockData.BlockMaterial(world.GetBlock(i1 - 1, j1 - 1, k1)) != Material.Water && BlockData.BlockMaterial(world.GetBlock(i1 + 1, j1 - 1, k1)) != Material.Water && BlockData.BlockMaterial(world.GetBlock(i1, j1 - 1, k1 - 1)) != Material.Water && BlockData.BlockMaterial(world.GetBlock(i1, j1 - 1, k1 + 1)) != Material.Water)
                {
                    continue;
                }
                int l1 = 2 + random.nextInt(random.nextInt(3) + 1);
                for (int i2 = 0; i2 < l1; i2++)
                {
                    if (world.CanBlockStay((byte)Blocks.SugarCane, i1, j1 + i2, k1))
                    {
                        world.SetBlock(i1, j1 + i2, k1, (byte)Blocks.SugarCane);
                    }
                }

            }

            return true;
        }
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            int l;
            int i1;
            bool flag;
            label0:
            {
                l = random.nextInt(2);
                if(mushroomType >= 0)
                {
                    l = mushroomType;
                }
                i1 = random.nextInt(3) + 4;
                flag = true;
                bool label0 = false;
                if(j >= 1)
                {
                    if (j + i1 + 1 <= world.worldYMax)
                    {
                        label0 = true;
                    }
                }
                if (!label0) return false;
            }
            for(int j1 = j; j1 <= j + 1 + i1; j1++)
            {
                byte byte0 = 3;
                if(j1 == j)
                {
                    byte0 = 0;
                }
                for(int j2 = i - byte0; j2 <= i + byte0 && flag; j2++)
                {
                    for(int i3 = k - byte0; i3 <= k + byte0 && flag; i3++)
                    {
                        if(j1 >= 0)
                        {
                            if(j1 < 128)
                            {
                                int k3 = world.GetBlock(j2, j1, i3);
                                if (k3 != 0 && k3 != (byte)Blocks.Leaves)
                                {
                                    flag = false;
                                }
                                continue;
                            }
                        }
                        flag = false;
                    }

                }

            }

            if(!flag)
            {
                return false;
            }
            int k1 = world.GetBlock(i, j - 1, k);
            if (k1 != (byte)Blocks.Dirt && k1 != (byte)Blocks.Grass && k1 != (byte)Blocks.Mycelium)
            {
                return false;
            }
            if (!world.CanPlaceAt((byte)Blocks.MushroomBrown, i, j, k))
            {
                return false;
            }
            world.SetBlock(i, j - 1, k, (byte)Blocks.Dirt);
            int l1 = j + i1;
            if (l == 1)
            {
                l1 = (j + i1) - 3;
            }
            for (int j2 = l1; j2 <= j + i1; j2++)
            {
                int i3 = 1;
                if (j2 < j + i1)
                {
                    i3++;
                }
                if (l == 0)
                {
                    i3 = 3;
                }
                for (int l3 = i - i3; l3 <= i + i3; l3++)
                {
                    for (int i4 = k - i3; i4 <= k + i3; i4++)
                    {
                        int j4 = 5;
                        if (l3 == i - i3)
                        {
                            j4--;
                        }
                        if (l3 == i + i3)
                        {
                            j4++;
                        }
                        if (i4 == k - i3)
                        {
                            j4 -= 3;
                        }
                        if (i4 == k + i3)
                        {
                            j4 += 3;
                        }
                        if (l == 0 || j2 < j + i1)
                        {
                            if ((l3 == i - i3 || l3 == i + i3) && (i4 == k - i3 || i4 == k + i3))
                            {
                                continue;
                            }
                            if (l3 == i - (i3 - 1) && i4 == k - i3)
                            {
                                j4 = 1;
                            }
                            if (l3 == i - i3 && i4 == k - (i3 - 1))
                            {
                                j4 = 1;
                            }
                            if (l3 == i + (i3 - 1) && i4 == k - i3)
                            {
                                j4 = 3;
                            }
                            if (l3 == i + i3 && i4 == k - (i3 - 1))
                            {
                                j4 = 3;
                            }
                            if (l3 == i - (i3 - 1) && i4 == k + i3)
                            {
                                j4 = 7;
                            }
                            if (l3 == i - i3 && i4 == k + (i3 - 1))
                            {
                                j4 = 7;
                            }
                            if (l3 == i + (i3 - 1) && i4 == k + i3)
                            {
                                j4 = 9;
                            }
                            if (l3 == i + i3 && i4 == k + (i3 - 1))
                            {
                                j4 = 9;
                            }
                        }
                        if (j4 == 5 && j2 < j + i1)
                        {
                            j4 = 0;
                        }
                        if ((j4 != 0 || j >= (j + i1) - 1) && Chunk.LightOpacity[world.GetBlock(l3, j2, i4)] < 0xf)
                        {
                            world.SetBlock(l3, j2, i4, (byte)((byte)Blocks.HugeBrownMushroom + l), (byte)j4);
                        }
                    }

                }

            }

            for (int k2 = 0; k2 < i1; k2++)
            {
                int j3 = world.GetBlock(i, j + k2, k);
                if (Chunk.LightOpacity[j3] < 0xf)
                {
                    world.SetBlock(i, j + k2, k, (byte)((byte)Blocks.HugeBrownMushroom + l), 10);
                }
            }

            return true;
        }
Example #19
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            int l;
            bool flag;
            label0:
            {
                l = random.nextInt(3) + 4;
                flag = true;
                bool label0 = false;
                if(j >= 1)
                {
                    if(j + l + 1 <= 128)
                    {
                        label0 = true;
                    }
                }
                if (!label0) return false;
            }
            label1:
            {
                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)
                            {
                                if(i1 < 128)
                                {
                                    int j3 = world.GetBlock(i2, i1, l2);
                                    if (j3 != 0 && j3 != (byte)Blocks.Leaves)
                                    {
                                        flag = false;
                                    }
                                    continue;
                                }
                            }
                            flag = false;
                        }

                    }

                }

                if(!flag)
                {
                    return false;
                }
                int j1 = world.GetBlock(i, j - 1, k);
                bool label1 = false;
                if (j1 == (byte)Blocks.Grass || j1 == (byte)Blocks.Dirt)
                {
                    if(j < 128 - l - 1)
                    {
                        label1 = true;
                    }
                }
                if (!label1) return false;
            }
            world.SetBlock(i, j - 1, k, (byte)Blocks.Dirt);
            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 ((java.lang.Math.abs(l3) != i3 || java.lang.Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && Chunk.LightOpacity[world.GetBlock(k3, k1, i4)] < 0xf)
                        {
                            func_41043_a(world, k3, k1, i4, (byte)Blocks.Leaves, 0);
                        }
                    }

                }

            }

            for(int l1 = 0; l1 < l; l1++)
            {
                int k2 = world.GetBlock(i, j + l1, k);
                if (k2 == 0 || k2 == (byte)Blocks.Leaves)
                {
                    func_41043_a(world, i, j + l1, k, (byte)Blocks.Wood, 0);
                }
            }

            return true;
        }
Example #20
0
        public override bool generate(World world, java.util.Random 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.nextInt(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;
                        }
                        byte block = world.GetBlock(i + j1, j + j3, k + j2);
                        if(j3 >= 4 && BlockData.IsLiquid(block))
                        {
                            return false;
                        }
                        if (j3 < 4 && !BlockData.IsSolid(block) && world.GetBlock(i + j1, j + j3, k + j2) != blockIndex)
                        {
                            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, (byte)(k3 < 4 ? blockIndex : 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.GetBlock(i + l1, (j + l3) - 1, k + l2) == (byte)Blocks.Dirt /*&& world.getSavedLightValue(EnumSkyBlock.Sky, i + l1, j + l3, k + l2) > 0*/) // TODO: Lighting stuffs!
                        {
                            world.SetBlock(i + l1, (j + l3) - 1, k + l2, (byte)Blocks.Grass);
                        }
                    }

                }

            }

            if(BlockData.BlockMaterial((byte)blockIndex) == 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.nextInt(2) != 0) && BlockData.IsSolid(world.GetBlock(i + i2, j + i4, k + i3)))
                            {
                                world.SetBlock(i + i2, j + i4, k + i3, (byte)Blocks.Stone);
                            }
                        }

                    }

                }

            }
            return true;
        }
        private static void func_35311_a(java.util.Random random, StructurePieceTreasure[] astructurepiecetreasure, ContainerChest tileentitychest, int i)
        {
            for(int j = 0; j < i; j++)
            {
                StructurePieceTreasure structurepiecetreasure = (StructurePieceTreasure)WeightedRandom.func_35691_a(random, astructurepiecetreasure);
                int k = structurepiecetreasure.field_35488_c + random.nextInt((structurepiecetreasure.field_35486_e - structurepiecetreasure.field_35488_c) + 1);
                if(Inventory.isStackable((short)structurepiecetreasure.field_35489_a) >= k)
                {
                    tileentitychest.SetSlot(random.nextInt(tileentitychest.Size), new Item((short)structurepiecetreasure.field_35489_a, (byte)k, (short)structurepiecetreasure.field_35487_b));
                    continue;
                }
                for(int l = 0; l < k; l++)
                {
                    tileentitychest.SetSlot(random.nextInt(tileentitychest.Size), new Item((short)structurepiecetreasure.field_35489_a, 1, (short)structurepiecetreasure.field_35487_b));
                }

            }
        }
Example #22
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            int l;
            int i1;
            int k1;
            bool flag;
            label0:
            {
                l = random.nextInt(5) + 7;
                i1 = l - random.nextInt(2) - 3;
                int j1 = l - i1;
                k1 = 1 + random.nextInt(j1 + 1);
                flag = true;
                bool label0 = false;
                if(j >= 1)
                {
                    if(j + l + 1 <= 128)
                    {
                        label0 = true;
                    }
                }
                if (!label0) return false;
            }
            label1:
            {
                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)
                            {
                                if(l1 < 128)
                                {
                                    int j4 = world.GetBlock(l2, l1, k3);
                                    if (j4 != 0 && j4 != (byte)Blocks.Leaves)
                                    {
                                        flag = false;
                                    }
                                    continue;
                                }
                            }
                            flag = false;
                        }

                    }

                }

                if(!flag)
                {
                    return false;
                }
                int i2 = world.GetBlock(i, j - 1, k);
                bool label1 = false;
                if (i2 == (byte)Blocks.Grass || i2 == (byte)Blocks.Dirt)
                {
                    if(j < 128 - l - 1)
                    {
                        label1 = true;
                    }
                }
                if (!label1) return false;
            }
            world.SetBlock(i, j - 1, k, (byte)Blocks.Dirt);
            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 ((java.lang.Math.abs(k4) != k2 || java.lang.Math.abs(i5) != k2 || k2 <= 0) && Chunk.LightOpacity[world.GetBlock(l3, i3, l4)] < 0xf)
                        {
                            world.SetBlock(l3, i3, l4, (byte)Blocks.Leaves, 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.GetBlock(i, j + j3, k);
                if (i4 == 0 || i4 == (byte)Blocks.Leaves)
                {
                    world.SetBlock(i, j + j3, k, (byte)Blocks.Wood, 1);
                }
            }

            return true;
        }
Example #23
0
 public virtual WorldGenerator getRandomWorldGenForTrees(java.util.Random random)
 {
     if(random.nextInt(10) == 0)
     {
         return bigTreeGenerator;
     } else
     {
         return treeGenerator;
     }
 }
Example #24
0
 private int pickMobSpawner(java.util.Random random)
 {
     int i = random.nextInt(4);
     if (i == 0)
     {
         return (int)MobType.Skeleton;
     }
     if (i == 1)
     {
         return (int)MobType.Zombie;
     }
     if (i == 2)
     {
         return (int)MobType.Zombie;
     }
     if (i == 3)
     {
         return (int)MobType.Spider;
     }
     else
     {
         return 0;
     }
 }
Example #25
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            byte byte0 = 3;
            int l = random.nextInt(2) + 2;
            int i1 = random.nextInt(2) + 2;
            int j1 = 0;
            for(int k1 = i - l - 1; k1 <= i + l + 1; k1++)
            {
                for(int j2 = j - 1; j2 <= j + byte0 + 1; j2++)
                {
                    for(int i3 = k - i1 - 1; i3 <= k + i1 + 1; i3++)
                    {
                        byte block = world.GetBlock(k1, j2, i3);
                        if(j2 == j - 1 && !BlockData.IsSolid(block))
                        {
                            return false;
                        }
                        if (j2 == j + byte0 + 1 && !BlockData.IsSolid(block))
                        {
                            return false;
                        }
                        if((k1 == i - l - 1 || k1 == i + l + 1 || i3 == k - i1 - 1 || i3 == k + i1 + 1) && j2 == j && world.IsAirBlock(k1, j2, i3) && world.IsAirBlock(k1, j2 + 1, i3))
                        {
                            j1++;
                        }
                    }

                }

            }

            if(j1 < 1 || j1 > 5)
            {
                return false;
            }
            for(int l1 = i - l - 1; l1 <= i + l + 1; l1++)
            {
                for(int k2 = j + byte0; k2 >= j - 1; k2--)
                {
                    for(int j3 = k - i1 - 1; j3 <= k + i1 + 1; j3++)
                    {
                        if(l1 == i - l - 1 || k2 == j - 1 || j3 == k - i1 - 1 || l1 == i + l + 1 || k2 == j + byte0 + 1 || j3 == k + i1 + 1)
                        {
                            if(k2 >= 0 && !BlockData.IsSolid(world.GetBlock(l1, k2 - 1, j3)))
                            {
                                world.SetBlock(l1, k2, j3, 0);
                                continue;
                            }
                            if (!BlockData.IsSolid(world.GetBlock(l1, k2, j3)))
                            {
                                continue;
                            }
                            if(k2 == j - 1 && random.nextInt(4) != 0)
                            {
                                world.SetBlock(l1, k2, j3, (byte)Blocks.MossStone);
                            } else
                            {
                                world.SetBlock(l1, k2, j3, (byte)Blocks.CobbleStone);
                            }
                        } else
                        {
                            world.SetBlock(l1, k2, j3, 0);
                        }
                    }

                }

            }

            for(int i2 = 0; i2 < 2; i2++)
            {
                label0:
                for(int l2 = 0; l2 < 3; l2++)
                {
                    int k3 = (i + random.nextInt(l * 2 + 1)) - l;
                    int l3 = j;
                    int i4 = (k + random.nextInt(i1 * 2 + 1)) - i1;
                    if(!world.IsAirBlock(k3, l3, i4))
                    {
                        continue;
                    }
                    int j4 = 0;
                    if (BlockData.IsSolid(world.GetBlock(k3 - 1, l3, i4)))
                    {
                        j4++;
                    }
                    if (BlockData.IsSolid(world.GetBlock(k3 + 1, l3, i4)))
                    {
                        j4++;
                    }
                    if(BlockData.IsSolid(world.GetBlock(k3, l3, i4 - 1)))
                    {
                        j4++;
                    }
                    if(BlockData.IsSolid(world.GetBlock(k3, l3, i4 + 1)))
                    {
                        j4++;
                    }
                    if(j4 != 1)
                    {
                        continue;
                    }
                    world.SetBlock(k3, l3, i4, (byte)Blocks.Chest);
                    Container tileentitychest = world.GetBlockContainer(k3, l3, i4);
                    if(tileentitychest == null || !(tileentitychest is ContainerChest))
                    {
                        break;
                    }
                    int k4 = 0;
                    bool label0 = false;
                    do
                    {
                        if(k4 >= 8)
                        {
                            label0 = true;
                            break;
                        }
                        Item itemstack = pickCheckLootItem(random);
                        if(itemstack != null)
                        {
                            tileentitychest.SetSlot(random.nextInt(tileentitychest.Size), itemstack);
                        }
                        k4++;
                    } while(true);
                    if (label0) break;
                }

            }

            world.SetBlock(i, j, k, (byte)Blocks.MonsterSpawner);
            world.SetExtra(i, j, k, (ushort)pickMobSpawner(random));
            //TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(i, j, k);
            //tileentitymobspawner.setMobID(pickMobSpawner(random));
            return true;
        }
Example #26
0
 private Item pickCheckLootItem(java.util.Random random)
 {
     int i = random.nextInt(11);
     if (i == 0)
     {
         return new Item((short)Items.Saddle);
     }
     if (i == 1)
     {
         return new Item((short)Items.IronIngot, (byte)(random.nextInt(4) + 1));
     }
     if (i == 2)
     {
         return new Item((short)Items.Bread);
     }
     if (i == 3)
     {
         return new Item((short)Items.Wheat, (byte)(random.nextInt(4) + 1));
     }
     if (i == 4)
     {
         return new Item((short)Items.Gunpowder, (byte)(random.nextInt(4) + 1));
     }
     if (i == 5)
     {
         return new Item((short)Items.String, (byte)(random.nextInt(4) + 1));
     }
     if (i == 6)
     {
         return new Item((short)Items.Bucket);
     }
     if (i == 7 && random.nextInt(100) == 0)
     {
         return new Item((short)Items.AppleGolden);
     }
     if (i == 8 && random.nextInt(2) == 0)
     {
         return new Item((short)Items.Redstone, (byte)(random.nextInt(4) + 1));
     }
     if (i == 9 && random.nextInt(10) == 0)
     {
         return new Item((short)((short)Items.GreenMusicDisc + random.nextInt(2)));
     }
     if (i == 10)
     {
         return new Item((short)Items.Dye, 1, 3);
     }
     else
     {
         return null;
     }
 }
Example #27
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            int l;
            bool flag;
            label0:
            {
                l = random.nextInt(4) + 5;
                for(; BlockData.BlockMaterial(world.GetBlock(i, j - 1, k)) == Material.Water; j--) { }
                flag = true;
                bool label0 = false;
                if(j >= 1)
                {
                    if(j + l + 1 <= 128)
                    {
                        label0 = true;
                    }
                }
                if (!label0) return false;
            }
            label1:
            {
                for(int i1 = j; i1 <= j + 1 + l; i1++)
                {
                    byte byte0 = 1;
                    if(i1 == j)
                    {
                        byte0 = 0;
                    }
                    if(i1 >= (j + 1 + l) - 2)
                    {
                        byte0 = 3;
                    }
                    for(int j2 = i - byte0; j2 <= i + byte0 && flag; j2++)
                    {
                        for(int j3 = k - byte0; j3 <= k + byte0 && flag; j3++)
                        {
                            if(i1 >= 0)
                            {
                                if(i1 < 128)
                                {
                                    int i4 = world.GetBlock(j2, i1, j3);
                                    if(i4 == 0 || i4 == (byte)Blocks.Leaves)
                                    {
                                        continue;
                                    }
                                    if(i4 == (byte)Blocks.SWater || i4 == (byte)Blocks.AWater)
                                    {
                                        if(i1 > j)
                                        {
                                            flag = false;
                                        }
                                    } else
                                    {
                                        flag = false;
                                    }
                                    continue;
                                }
                            }
                            flag = false;
                        }

                    }

                }

                if(!flag)
                {
                    return false;
                }
                int j1 = world.GetBlock(i, j - 1, k);
                bool label1 = false;
                if(j1 == (byte)Blocks.Grass || j1 == (byte)Blocks.Dirt)
                {
                    if(j < 128 - l - 1)
                    {
                        label1 = true;
                    }
                }
                if (!label1) return false;
            }
            world.SetBlock(i, j - 1, k, (byte)Blocks.Dirt);
            for(int k1 = (j - 3) + l; k1 <= j + l; k1++)
            {
                int k2 = k1 - (j + l);
                int k3 = 2 - k2 / 2;
                for(int j4 = i - k3; j4 <= i + k3; j4++)
                {
                    int l4 = j4 - i;
                    for(int j5 = k - k3; j5 <= k + k3; j5++)
                    {
                        int k5 = j5 - k;
                        if ((java.lang.Math.abs(l4) != k3 || java.lang.Math.abs(k5) != k3 || random.nextInt(2) != 0 && k2 != 0) && Chunk.LightOpacity[world.GetBlock(j4, k1, j5)] < 0xf)
                        {
                            world.SetBlock(j4, k1, j5, (byte)Blocks.Leaves);
                        }
                    }

                }

            }

            for(int l1 = 0; l1 < l; l1++)
            {
                int l2 = world.GetBlock(i, j + l1, k);
                if(l2 == 0 || l2 == (byte)Blocks.Leaves || l2 == (byte)Blocks.AWater || l2 == (byte)Blocks.SWater)
                {
                    world.SetBlock(i, j + l1, k, (byte)Blocks.Wood);
                }
            }

            for(int i2 = (j - 3) + l; i2 <= j + l; i2++)
            {
                int i3 = i2 - (j + l);
                int l3 = 2 - i3 / 2;
                for(int k4 = i - l3; k4 <= i + l3; k4++)
                {
                    for(int i5 = k - l3; i5 <= k + l3; i5++)
                    {
                        if(world.GetBlock(k4, i2, i5) != (byte)Blocks.Leaves)
                        {
                            continue;
                        }
                        if(random.nextInt(4) == 0 && world.GetBlock(k4 - 1, i2, i5) == 0)
                        {
                            func_35292_a(world, k4 - 1, i2, i5, 8);
                        }
                        if(random.nextInt(4) == 0 && world.GetBlock(k4 + 1, i2, i5) == 0)
                        {
                            func_35292_a(world, k4 + 1, i2, i5, 2);
                        }
                        if(random.nextInt(4) == 0 && world.GetBlock(k4, i2, i5 - 1) == 0)
                        {
                            func_35292_a(world, k4, i2, i5 - 1, 1);
                        }
                        if(random.nextInt(4) == 0 && world.GetBlock(k4, i2, i5 + 1) == 0)
                        {
                            func_35292_a(world, k4, i2, i5 + 1, 4);
                        }
                    }

                }

            }

            return true;
        }
Example #28
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            int l;
            int i1;
            int j1;
            int k1;
            bool flag;
            label0:
            {
                l = random.nextInt(4) + 6;
                i1 = 1 + random.nextInt(2);
                j1 = l - i1;
                k1 = 2 + random.nextInt(2);
                flag = true;
                bool label0 = false;
                if(j >= 1)
                {
                    if(j + l + 1 <= 128)
                    {
                        label0 = true;
                    }
                }
                if (!label0) return false;
            }
            label1:
            {
                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)
                            {
                                if(l1 < 128)
                                {
                                    int k3 = world.GetBlock(l2, l1, j3);
                                    if (k3 != 0 && k3 != (byte)Blocks.Leaves)
                                    {
                                        flag = false;
                                    }
                                    continue;
                                }
                            }
                            flag = false;
                        }

                    }

                }

                if(!flag)
                {
                    return false;
                }
                int i2 = world.GetBlock(i, j - 1, k);
                bool label1 = false;
                if (i2 == (byte)Blocks.Grass || i2 == (byte)Blocks.Dirt)
                {
                    if(j < 128 - l - 1)
                    {
                        label1 = true;
                    }
                }
                if (!label1) return false;
            }
            world.SetBlock(i, j - 1, k, (byte)Blocks.Dirt);
            int k2 = random.nextInt(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 ((java.lang.Math.abs(j5) != k2 || java.lang.Math.abs(l5) != k2 || k2 <= 0) && Chunk.LightOpacity[world.GetBlock(l4, j4, k5)] < 0xf)
                        {
                            func_41043_a(world, l4, j4, k5, (byte)Blocks.Leaves, 1);
                        }
                    }

                }

                if(k2 >= i3)
                {
                    k2 = ((flag1) ? 1 : 0);
                    flag1 = true;
                    if(++i3 > k1)
                    {
                        i3 = k1;
                    }
                } else
                {
                    k2++;
                }
            }

            int i4 = random.nextInt(3);
            for(int k4 = 0; k4 < l - i4; k4++)
            {
                int i5 = world.GetBlock(i, j + k4, k);
                if (i5 == 0 || i5 == (byte)Blocks.Leaves)
                {
                    func_41043_a(world, i, j + k4, k, (byte)Blocks.Wood, 1);
                }
            }

            return true;
        }
Example #29
0
        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (!world.IsAirBlock(i, j, k))
            {
                return false;
            }
            if (world.GetBlock(i, j + 1, k) != (byte)Blocks.Netherrack)
            {
                return false;
            }
            world.SetBlock(i, j, k, (byte)Blocks.GlowstoneBlock);
            for (int l = 0; l < 1500; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = j - random.nextInt(12);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (world.GetBlock(i1, j1, k1) != 0)
                {
                    continue;
                }
                int l1 = 0;
                for (int i2 = 0; i2 < 6; i2++)
                {
                    int j2 = 0;
                    if (i2 == 0)
                    {
                        j2 = world.GetBlock(i1 - 1, j1, k1);
                    }
                    if (i2 == 1)
                    {
                        j2 = world.GetBlock(i1 + 1, j1, k1);
                    }
                    if (i2 == 2)
                    {
                        j2 = world.GetBlock(i1, j1 - 1, k1);
                    }
                    if (i2 == 3)
                    {
                        j2 = world.GetBlock(i1, j1 + 1, k1);
                    }
                    if (i2 == 4)
                    {
                        j2 = world.GetBlock(i1, j1, k1 - 1);
                    }
                    if (i2 == 5)
                    {
                        j2 = world.GetBlock(i1, j1, k1 + 1);
                    }
                    if (j2 == (byte)Blocks.GlowstoneBlock)
                    {
                        l1++;
                    }
                }

                if (l1 == 1)
                {
                    world.SetBlock(i1, j1, k1, (byte)Blocks.GlowstoneBlock);
                }
            }

            return true;
        }