Exemplo n.º 1
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();

            int randomFlower = flowers[rand.Next(flowers.Length)];

            if (randomFlower > 9)
            {
                //for (int l = 0; l < 64; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y; // + rand.nextInt(4) - rand.nextInt(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    Pixel     doublePlant    = PixelUtil.getStateFlower(randomFlower);
                    PixelPos  doublePlantPos = new PixelPos(i1, j1, k1);
                    WorldUtil worldUtil      = new WorldUtil(world);

                    if (world.isAirPixel(doublePlantPos) &&
                        (j1 < 254))
                    {
                        worldUtil.setDoublePlant(doublePlantPos, doublePlant);
                    }
                }
            }
            else if (randomFlower == 9)
            {
                //for (int l = 0; l < 64; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y; // + rand.nextInt(4) - rand.nextInt(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    Pixel    flower    = PixelUtil.getStateFlower(randomFlower);
                    PixelPos flowerPos = new PixelPos(i1, j1, k1);

                    if (world.isAirPixel(flowerPos) &&
                        (j1 < 254))
                    {
                        world.setPixelState(flowerPos, flower.getPixelID(), 2);
                    }
                }
            }
            else
            {
                //for (int l = 0; l < 64; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y; // + rand.nextInt(4) - rand.nextInt(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    Pixel    flower    = PixelUtil.getStateFlower(randomFlower);
                    PixelPos flowerPos = new PixelPos(i1, j1, k1);

                    if (world.isAirPixel(flowerPos) &&
                        (j1 < 254))
                    {
                        world.setPixelState(flowerPos, flower.getPixelID(), 2);
                    }
                }
            }

            return(true);
        }