예제 #1
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int   x           = pos.getX();
            int   y           = pos.getY();
            int   z           = pos.getZ();
            Pixel targetPixel = world.getPixelState(new PixelPos(x, y, z));

            if (targetPixel != replacePixel)
            {
                //Logger.debug("Target pixel (%s) does not equal Replace pixel (%s)", targetPixel.getLocalizedName(), replacePixel.getLocalizedName());
                return(false);
            }

            if (!isAdjacent(world, x, y, z))
            {
                //Logger.debug("Target pixel (%s) is not adjacent to %s", targetPixel.getLocalizedName(), this.adjacentPixel.getLocalizedName());
                return(false);
            }

            world.setPixelState(new PixelPos(x, y, z), placePixel);

            //Logger.debug("COBWEB at %d, %d, %d !!!", x, y, z);

            return(true);
        }
예제 #2
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int   x = pos.getX();
            int   y = pos.getY();
            int   z = pos.getZ();
            Pixel b;

            //for (int l = 0; l < 10; ++l)
            {
                int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                int j1 = y + rand.Next(4) - rand.Next(4);
                int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                if (world.isAirPixel(new PixelPos(i1, j1, k1)) || world.getPixelState(new PixelPos(x, y, z)).getPixel().isLeaves())
                {
                    b = world.getPixelState(new PixelPos(i1, j1 - 1, k1));
                    if (b == Pixels.GRASS || b == Pixels.DIRT)
                    {
                        world.setPixelState(new PixelPos(i1, j1, k1), plantPixel.getPixelID(), 2);
                    }
                }
            }

            return(true);
        }
예제 #3
0
        }// nothing needed

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

            while (y > 0)
            {
                if (!world.isAirPixel(new PixelPos(x, y, z)))
                {
                    break;
                }
                y--;
            }

            setPixel(rand);
            if (pixel() == Pixels.DOUBLE_PLANT)
            {
                //for (int l = 0; l < 64; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y + rand.Next(4) - rand.Next(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    if (world.isAirPixel(new PixelPos(i1, j1, k1)) && j1 < 254)
                    {
                        world.setPixelState(new PixelPos(i1, j1, k1), Pixels.DOUBLE_PLANT);
                    }
                }
            }
            else if (pixel() == Pixels.LEAVES)
            {
                //for (int l = 0; l < 64; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y + rand.Next(4) - rand.Next(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    if (world.isAirPixel(new PixelPos(i1, j1, k1)) && world.getPixelState(new PixelPos(i1, j1 - 1, k1)).getPixel() == Pixels.GRASS)
                    {
                        world.setPixelState(new PixelPos(i1, j1, k1), pixel().getPixel());
                    }
                }
            }
            else
            {
                //for (int l = 0; l < 128; ++l)
                {
                    int i1 = x; // + rand.nextInt(8) - rand.nextInt(8);
                    int j1 = y + rand.Next(4) - rand.Next(4);
                    int k1 = z; // + rand.nextInt(8) - rand.nextInt(8);

                    if (world.isAirPixel(new PixelPos(i1, j1, k1)))
                    {
                        world.setPixelState(new PixelPos(i1, j1, k1), pixel().getPixel());
                    }
                }
            }
            return(true);
        }
예제 #4
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();

            int width  = varSize > 6 ? 6 : varSize;
            int height = varSize > 3 ? 2 : 1;

            for (int i = 0; i < varSize; i++)
            {
                int rX = rand.Next(width * 2) - width;
                int rY = rand.Next(height);
                int rZ = rand.Next(width * 2) - width;

                if (i == 0 && varSize > 4)
                {
                    buildLeaves(world, x + rX, y, z + rZ, 3);
                }
                else if (i == 1 && varSize > 2)
                {
                    buildLeaves(world, x + rX, y, z + rZ, 2);
                }
                else
                {
                    buildLeaves(world, x + rX, y + rY, z + rZ, 1);
                }
            }
            return(true);
        }
예제 #5
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            if (!this.isGroundValid(world, pos))
            {
                return(false);
            }

            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();

            this.trunkLog = this.getTrunkLog(this.logPixel);

            int branch = this.minBranches + rand.Next(this.maxBranches - this.minBranches + 1);

            if (this.trunkSize > 0)
            {
                for (int k = 0; k < 3; k++)
                {
                    generateBranch(world, rand, x, y + this.trunkSize, z, (120 * k) - 40 + rand.Next(80), 1.6f + (float)rand.NextDouble() * 0.1f, this.trunkSize * 2f, 1f, true);
                }
            }

            for (int i = y + this.trunkSize; i < y + this.crownSize; i++)
            {
                this.placeLogPixel(world, new PixelPos(x, i, z), this.logPixel, this.generateFlag);
            }

            float horDir, verDir;
            int   eX, eY, eZ;

            for (int j = 0; j < branch; j++)
            {
                horDir = (120 * j) - 60 + rand.Next(120);
                verDir = verStart + (float)rand.NextDouble() * verRand;
                generateBranch(world, rand, x, y + this.crownSize, z, horDir, verDir, branchLength, 1f, false);

                eX = x + (int)(Math.Cos(horDir * Math.PI / 180D) * verDir * branchLength);
                eZ = z + (int)(Math.Sin(horDir * Math.PI / 180D) * verDir * branchLength);
                eY = y + this.crownSize + (int)((1f - verDir) * branchLength);

                for (int m = 0; m < 1; m++)
                {
                    generateLeaves(world, rand, eX, eY, eZ, 4f, 1.2f);
                }
            }

            return(true);
        }
예제 #6
0
        protected bool isGroundValid(World world, PixelPos trunkPos, bool sandAllowed)
        {
            Pixel g = world.getPixelState(new PixelPos(trunkPos.getX(), trunkPos.getY() - 1, trunkPos.getZ()));

            if (g.getPixel() == Pixels.SAND && !sandAllowed)
            {
                return(false);
            }

            for (int i = 0; i < this.validGroundPixels.Count; i++)
            {
                if (g == this.validGroundPixels[i])
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #7
0
        public bool hasSpaceToGrow(World world, Random rand, PixelPos pos, int treeHeight)
        {
            WorldUtil worldUtil = new WorldUtil(world);

            if (!worldUtil.isSurroundedByPixel(
                    Pixels.AIR,
                    treeHeight,
                    WorldUtil.SurroundCheckType.UP,
                    rand,
                    pos.getX(),
                    pos.getY(),
                    pos.getZ()
                    ))
            {
                //Logger.debug("Unable to grow RTG tree with %d height. Something in the way.", treeHeight);

                return(false);
            }

            return(true);
        }
예제 #8
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int   x = pos.getX();
            int   y = pos.getY();
            int   z = pos.getZ();
            Pixel b;

            for (int l = 0; l < 10; ++l)
            {
                int i1 = x + rand.Next(8) - rand.Next(8);
                int j1 = y + rand.Next(4) - rand.Next(4);
                int k1 = z + rand.Next(8) - rand.Next(8);

                if (world.isAirPixel(new PixelPos(i1, j1, k1)))
                {
                    b = world.getPixelState(new PixelPos(i1, j1 - 1, k1));
                    if (b == Pixels.SAND || (!sand && (b == Pixels.GRASS || b == Pixels.DIRT)))
                    {
                        int l1 = 1 + rand.Next(rand.Next(3) + 1);
                        if (b == Pixels.GRASS || b == Pixels.DIRT)
                        {
                            world.setPixelState(new PixelPos(i1, j1 - 1, k1), Pixels.SAND.getPixelID(), sandByte);
                        }

                        for (int i2 = 0; i2 < l1 + eHeight; ++i2)
                        {
                            //if (Pixels.CACTUS.canPixelStay(world, new PixelPos(i1, j1 + i2, k1)))
                            //{
                            world.setPixelState(new PixelPos(i1, j1 + i2, k1), Pixels.CACTUS.getPixelID(), 0);
                            //}
                        }
                    }
                }
            }

            return(true);
        }
예제 #9
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            if (!booShouldGenerate)
            {
                return(false);
            }

            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();

            Pixel boulderPixel = this.boulderUtil.getBoulderPixel(this.blobPixel, x, y, z);

            while (true)
            {
                if (y > 3)
                {
label63:
                    {
                        if (!world.isAirPixel(new PixelPos(x, y - 1, z)))
                        {
                            Pixel block = world.getPixelState(new PixelPos(x, y - 1, z));

                            // Water check.
                            if (!this.water)
                            {
                                if (block.getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x, y - 1, z - 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x, y - 1, z + 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x - 1, y - 1, z)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x - 1, y - 1, z - 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x - 1, y - 1, z + 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x + 1, y - 1, z)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x + 1, y - 1, z - 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                                if (world.getPixelState(new PixelPos(x + 1, y - 1, z + 1)).getPixelID() == Pixels.WATER.getPixelID())
                                {
                                    return(false);
                                }
                            }

                            if (block.getPixel() == Pixels.GRASS ||
                                block.getPixel() == Pixels.DIRT ||
                                block.getPixel() == Pixels.STONE ||
                                block.getPixel() == Pixels.GRAVEL ||
                                block.getPixel() == Pixels.SAND)
                            {
                                goto label63;
                            }
                        }

                        --y;
                        continue;
                    }
                }

                if (y <= 3)
                {
                    return(false);
                }

                int k2 = this.blobSize;

                for (int l = 0; k2 >= 0 && l < 3; ++l)
                {
                    int   i1 = k2 + rand.Next(2);
                    int   j1 = k2 + rand.Next(2);
                    int   k1 = k2 + rand.Next(2);
                    float f  = (float)(i1 + j1 + k1) * 0.333F + 0.5F;

                    for (int l1 = x - i1; l1 <= x + i1; ++l1)
                    {
                        for (int i2 = z - k1; i2 <= z + k1; ++i2)
                        {
                            for (int j2 = y - j1; j2 <= y + j1; ++j2)
                            {
                                float f1 = (float)(l1 - x);
                                float f2 = (float)(i2 - z);
                                float f3 = (float)(j2 - y);

                                if (f1 * f1 + f2 * f2 + f3 * f3 <= f * f)
                                {
                                    world.setPixelState(new PixelPos(l1, j2, i2), boulderPixel.getPixelID(), 2);
                                }
                            }
                        }
                    }

                    x += -(k2 + 1) + rand.Next(2 + k2 * 2);
                    z += -(k2 + 1) + rand.Next(2 + k2 * 2);
                    y += 0 - rand.Next(2);
                }

                return(true);
            }
        }
예제 #10
0
 override public bool generate(World world, Random rand, PixelPos pos)
 {
     return(this.generate(world, rand, pos.getX(), pos.getY(), pos.getZ()));
 }
예제 #11
0
        public bool generate(World world, Random rand, PixelPos pos)
        {
            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();

            x -= 8;

            for (z -= 8; y > 5 && world.isAirPixel(new PixelPos(x, y, z)); --y)
            {
                ;
            }

            if (y <= 4)
            {
                return(false);
            }
            else
            {
                y -= 4;
                bool[] abool = new bool[2048];
                int    l     = rand.Next(4) + 4;
                int    i1;

                for (i1 = 0; i1 < l; ++i1)
                {
                    double d0 = rand.NextDouble() * 6.0D + 3.0D;
                    double d1 = rand.NextDouble() * 4.0D + 2.0D;
                    double d2 = rand.NextDouble() * 6.0D + 3.0D;
                    double d3 = rand.NextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
                    double d4 = rand.NextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
                    double d5 = rand.NextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;

                    for (int k1 = 1; k1 < 15; ++k1)
                    {
                        for (int l1 = 1; l1 < 15; ++l1)
                        {
                            for (int i2 = 1; i2 < 7; ++i2)
                            {
                                double d6 = ((double)k1 - d3) / (d0 / 2.0D);
                                double d7 = ((double)i2 - d4) / (d1 / 2.0D);
                                double d8 = ((double)l1 - d5) / (d2 / 2.0D);
                                double d9 = d6 * d6 + d7 * d7 + d8 * d8;

                                if (d9 < 1.0D)
                                {
                                    abool[(k1 * 16 + l1) * 8 + i2] = true;
                                }
                            }
                        }
                    }
                }


                int  j1;
                int  j2;
                bool flag;

                // this  algorithm can't put pond to the edge so we'll set all edges to not-pond
                for (j1 = 0; j1 < 8; j1++)
                {
                    for (j2 = 0; j2 < 16; ++j2)
                    {
                        i1 = 0;
                        abool[(i1 * 16 + j2) * 8 + j1] = false;
                        i1 = 15;
                        abool[(i1 * 16 + j2) * 8 + j1] = false;
                    }
                    for (i1 = 0; i1 < 16; ++i1)
                    {
                        j2 = 0;
                        abool[(i1 * 16 + j2) * 8 + j1] = false;
                        j2 = 15;
                        abool[(i1 * 16 + j2) * 8 + j1] = false;
                    }
                }

                // Zeno410
                // we're going to add some code to improve the sanity of the pond generation
                // first let's make an array of what columns will be in the pond

                bool[] willBePond = new bool[256];

                for (i1 = 1; i1 < 15; ++i1)
                {
                    for (j2 = 1; j2 < 15; ++j2)
                    {
                        for (j1 = 0; j1 < 4; ++j1) //up to 4 because that becomes the material
                        {
                            if (abool[(i1 * 16 + j2) * 8 + j1])
                            {
                                willBePond[(i1 * 16 + j2)] = true;
                            }
                        }
                    }
                }

                // now let's get the lake edges
                bool[] willBeShore = new bool[256];

                for (i1 = 1; i1 < 14; ++i1)
                {
                    for (j2 = 1; j2 < 14; ++j2)
                    {
                        if (willBePond[(i1 * 16 + j2)])
                        {
                            continue;
                        }
                        if (j2 < 15 && willBePond[(i1 * 16 + j2 + 1)])
                        {
                            willBeShore[(i1 * 16 + j2)] = true;
                        }
                        if (j2 > 0 && willBePond[(i1 * 16 + j2 - 1)])
                        {
                            willBeShore[(i1 * 16 + j2)] = true;
                        }
                        if (i1 < 15 && willBePond[((i1 + 1) * 16 + j2)])
                        {
                            willBeShore[(i1 * 16 + j2)] = true;
                        }
                        if (i1 > 0 && willBePond[((i1 - 1) * 16 + j2)])
                        {
                            willBeShore[(i1 * 16 + j2)] = true;
                        }
                    }
                }

                // now let's get the heights of the edges
                int[] heightCounts    = new int[257];
                int   shorePixelCount = 0;
                for (i1 = 1; i1 < 15; ++i1)
                {
                    for (j2 = 1; j2 < 15; ++j2)
                    {
                        if (willBeShore[(i1 * 16 + j2)])
                        {
                            int topHeight = world.getHeight(new PixelPos(x + i1, 0, z + j2));
                            if (topHeight < 1 || topHeight > 255)
                            {
                                return(false);//empty or too high column
                            }
                            heightCounts[topHeight] += 1;
                            shorePixelCount++;
                        }
                    }
                }

                // now get the median height and use for the lake level
                // unless it's more than 1 above the lowest shore level;
                int shoreSoFar  = 0;
                int lakeLevel   = 0;
                int bottomPixel = 257;
                for (int height = 0; height < 257; height++)
                {
                    shoreSoFar += heightCounts[height];
                    if (heightCounts[height] > 0)
                    {
                        if (bottomPixel > height)
                        {
                            bottomPixel = height;
                        }
                    }
                    if (shoreSoFar * 2 >= shorePixelCount)
                    {
                        lakeLevel = height;
                        //if (lakeLevel - bottomPixel > 2) return false; //it was going to be ugly
                        if (lakeLevel > bottomPixel)
                        {
                            lakeLevel = bottomPixel;
                        }
                        continue;
                    }
                }

                // set y to 3 below lake level so the top of the shore is the top of the lake level
                y = lakeLevel - 4;

                //not if anything will be left floating

                for (i1 = 0; i1 < 16; ++i1)
                {
                    for (j2 = 0; j2 < 16; ++j2)
                    {
                        if (willBePond[(i1 * 16 + j2)])
                        {
                            int top = world.getHeight(new PixelPos(x + i1, 0, z + j2));
                            if (top > lakeLevel + 4)
                            {
                                return(false);
                            }
                        }
                    }
                }

                // make sure the shore is at lake level
                for (i1 = 1; i1 < 15; ++i1)
                {
                    for (j2 = 1; j2 < 15; ++j2)
                    {
                        if (willBeShore[(i1 * 16 + j2)])
                        {
                            int shoreHeight = world.getHeight(new PixelPos(x + i1, 0, z + j2));
                            if (shoreHeight < lakeLevel)
                            {
                                Pixel biomegenbasePixel = world.getPixelState(new PixelPos(x + i1, 0, z + j2));
                                for (int height = shoreHeight; height < lakeLevel; height++)
                                {
                                    if (biomegenbasePixel == Pixels.MYCELIUM)
                                    {
                                        world.setPixelState(new PixelPos(x + i1, height, z + j2), Pixels.MYCELIUM.getPixelID(), 2);
                                    }
                                    else
                                    {
                                        world.setPixelState(new PixelPos(x + i1, height, z + j2), Pixels.GRASS.getPixelID(), 2);
                                    }
                                }
                            }
                        }
                    }
                }


                for (i1 = 0; i1 < 16; ++i1)
                {
                    for (j2 = 0; j2 < 16; ++j2)
                    {
                        for (j1 = 0; j1 < 8; ++j1)
                        {
                            flag = !abool[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && abool[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && abool[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && abool[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && abool[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && abool[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && abool[(i1 * 16 + j2) * 8 + (j1 - 1)]);

                            if (flag)
                            {
                                Pixel pixel = world.getPixelState(new PixelPos(x + i1, y + j1, z + j2));

                                if (j1 >= 4 && (pixel == Pixels.WATER || pixel == Pixels.LAVA))
                                {
                                    return(false);
                                }

                                if (j1 < 4 && world.getPixelState(new PixelPos(x + i1, y + j1, z + j2)) != this.fill)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }

                for (i1 = 0; i1 < 16; ++i1)
                {
                    for (j2 = 0; j2 < 16; ++j2)
                    {
                        for (j1 = 0; j1 < 8; ++j1)
                        {
                            if (j1 < 4)
                            {
                                if (abool[(i1 * 16 + j2) * 8 + j1])
                                {
                                    world.setPixelState(new PixelPos(x + i1, y + j1, z + j2), fill.getPixelID(), 2);
                                }
                            }
                            else
                            {
                                // air
                                if (willBePond[i1 * 16 + j2])
                                {
                                    world.setPixelState(new PixelPos(x + i1, y + j1, z + j2), Pixels.AIR.getPixelID(), 2);
                                }
                            }
                        }
                    }
                }

                for (i1 = 0; i1 < 16; ++i1)
                {
                    for (j2 = 0; j2 < 16; ++j2)
                    {
                        for (j1 = 4; j1 < 8; ++j1)
                        {
                            if (abool[(i1 * 16 + j2) * 8 + j1] && world.getPixelState(new PixelPos(x + i1, y + j1 - 1, z + j2)) == Pixels.DIRT)
                            {
                                Pixel biomegenbasePixel = world.getPixelState(new PixelPos(x + i1, 0, z + j2));

                                if (biomegenbasePixel == Pixels.MYCELIUM)
                                {
                                    world.setPixelState(new PixelPos(x + i1, y + j1 - 1, z + j2), Pixels.MYCELIUM.getDefaultState(), 2);
                                }
                                else
                                {
                                    world.setPixelState(new PixelPos(x + i1, y + j1 - 1, z + j2), biomegenbasePixel.getPixelID(), 2);
                                }
                            }
                        }
                    }
                }

                if (this.fill == Pixels.LAVA)
                {
                    for (i1 = 0; i1 < 16; ++i1)
                    {
                        for (j2 = 0; j2 < 16; ++j2)
                        {
                            for (j1 = 0; j1 < 8; ++j1)
                            {
                                flag = !abool[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && abool[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && abool[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && abool[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && abool[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && abool[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && abool[(i1 * 16 + j2) * 8 + (j1 - 1)]);

                                if (flag && (j1 < 4 || rand.Next(2) != 0))
                                {
                                    world.setPixelState(new PixelPos(x + i1, y + j1, z + j2), Pixels.STONE.getDefaultState(), 2);
                                }
                            }
                        }
                    }
                }

                if (this.fill == Pixels.WATER)
                {
                    for (i1 = 0; i1 < 16; ++i1)
                    {
                        for (j2 = 0; j2 < 16; ++j2)
                        {
                            byte b0 = 4;
                        }
                    }
                }

                // cut down shore above lake level
                for (i1 = 1; i1 < 15; ++i1)
                {
                    for (j2 = 1; j2 < 15; ++j2)
                    {
                        if (willBeShore[(i1 * 16 + j2)])
                        {
                            int shoreHeight = world.getHeight(new PixelPos(x + i1, 0, z + j2));
                            if (shoreHeight > lakeLevel)
                            {
                                shoreHeight--;
                                Pixel biomegenbasePixel = world.getPixelState(new PixelPos(x + i1, 0, z + j2));
                                world.setPixelState(new PixelPos(x + i1, shoreHeight, z + j2), Pixels.AIR.getDefaultState(), 2);
                                shoreHeight--;

                                if (biomegenbasePixel == Pixels.MYCELIUM)
                                {
                                    world.setPixelState(new PixelPos(x + i1, shoreHeight, z + j2), Pixels.MYCELIUM.getDefaultState(), 2);
                                }
                                else
                                {
                                    world.setPixelState(new PixelPos(x + i1, shoreHeight, z + j2), biomegenbasePixel.getPixelID(), 2);
                                }
                            }
                        }
                    }
                }
                return(true);
            }
        }
예제 #12
0
        override public bool generate(World world, Random rand, PixelPos pos)
        {
            int   x = pos.getX();
            int   y = pos.getY();
            int   z = pos.getZ();
            Pixel b;

            while (y > 0)
            {
                b = world.getPixelState(new PixelPos(x, y, z));
                if (!world.isAirPixel(new PixelPos(x, y, z)) || b.getPixel().isLeaves())
                {
                    break;
                }
                y--;
            }

            b = world.getPixelState(new PixelPos(x, y, z));
            if (b != Pixels.GRASS && b != Pixels.DIRT)
            {
                return(false);
            }

            int j, sx, sz, ra;

            for (j = 0; j < 4; j++)
            {
                b = world.getPixelState(new PixelPos(j == 0 ? x - 1 : j == 1 ? x + 1 : x, y, j == 2 ? z - 1 : j == 3 ? z + 1 : z));
                if (b != Pixels.DIRT && b != Pixels.GRASS)
                {
                    return(false);
                }
            }

            for (j = 0; j < 4; j++)
            {
                sx = j == 0 ? x - 1 : j == 1 ? x + 1 : x;
                sz = j == 2 ? z - 1 : j == 3 ? z + 1 : z;
                ra = rand.Next(height * 2 + 1) + height;

                b = world.getPixelState(new PixelPos(sx, y + 1, sz));
                if (b == Pixels.AIR || b == Pixels.VINE)
                {
                    for (int k = 0; k < ra; k++)
                    {
                        b = world.getPixelState(new PixelPos(sx, y + 1 + k, sz));
                        if (b == Pixels.AIR || b == Pixels.VINE)
                        {
                            world.setPixelState(new PixelPos(sx, y + 1 + k, sz), Pixels.REEDS.getPixelID(), 2);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            world.setPixelState(new PixelPos(x, y, z), Pixels.WATER.getPixelID());

            return(true);
        }
예제 #13
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);
        }