SetDataAt() public abstract method

public abstract SetDataAt ( int x, int y, int z, byte p ) : void
x int
y int
z int
p byte
return void
Example #1
0
        public virtual void AddTrees(ref IMapHandler mh, BiomeType[,] biomes, ref Random rand, int X, int Z, int H)
        {
            int             xo           = (int)(X * mh.ChunkScale.X);
            int             zo           = (int)(Z * mh.ChunkScale.Z);
            List <Vector2i> PlantedTrees = new List <Vector2i>();
            int             DistanceReqd = 3;

            for (int t = 0; t < (int)((HumidityNoise.Noise((double)(xo) / BIOME_SCALE, (double)(zo) / BIOME_SCALE, 0) + HumidityOffset) * 5.0); t++)
            {
                Vector2i me = new Vector2i(rand.Next(0, 15), rand.Next(0, 15));
                if (!Biome.NeedsTrees(biomes[me.X, me.Y]))
                {
                    continue;
                }
                bool tooclose = false;
                foreach (Vector2i tree in PlantedTrees)
                {
                    if (Vector2i.Distance(tree, me) < DistanceReqd)
                    {
                        tooclose = true;
                        break;
                    }
                }

                if (tooclose)
                {
                    continue;
                }
                bool founddert = false;
                for (int y = (int)H - 10; y > 0; y--)
                {
                    switch (mh.GetBlockAt(me.X + xo, y, me.Y + zo))
                    {
                    case 0:     // Air
                    case 78:    // Snow cover
                        continue;

                    // case 1: // ROCK
                    case 2:                                            // GRASS
                    case 3:                                            // DIRT
                        //Utils.GrowTree(ref blocks, rand, (int)me.X, (int)y + 1, (int)me.Y);
                        mh.SetBlockAt(me.X + xo, y + 1, me.Y + zo, 6); // Sapling
                        mh.SetDataAt(me.X + xo, y + 1, me.Y + zo, 15); // Growth stage 15.

                        /*
                         * Tree tree = new NormalTree(me.X + xo, y + 1, me.Y + zo, rand.Next(5, 8));
                         * tree.MakeTrunk(ref mh);
                         * tree.MakeFoliage(ref mh);
                         */
                        mh.SaveAll();
                        founddert = true;
                        break;

                    case 11:     // SAND
                        //Utils.GrowCactus(ref b, rand, me.X, y + 1, me.Y);
                        break;

                    default:
                        founddert = true;
                        break;
                    }
                    if (founddert)
                    {
                        break;
                    }
                }
                PlantedTrees.Add(me);
            }
        }
Example #2
0
        public virtual void AddTrees(ref IMapHandler mh, BiomeType[,] biomes, ref Random rand, int X, int Z, int H)
        {
            int xo = (int)(X * mh.ChunkScale.X);
            int zo = (int)(Z * mh.ChunkScale.Z);
            List<Vector2i> PlantedTrees = new List<Vector2i>();
            int DistanceReqd = 3;
            for (int t = 0; t < (int)((HumidityNoise.Noise((double)(xo) / BIOME_SCALE, (double)(zo) / BIOME_SCALE, 0) + HumidityOffset) * 5.0); t++)
            {
                Vector2i me = new Vector2i(rand.Next(0, 15),rand.Next(0, 15));
                if (!Biome.NeedsTrees(biomes[me.X, me.Y]))
                    continue;
                bool tooclose=false;
                foreach (Vector2i tree in PlantedTrees)
                {
                    if (Vector2i.Distance(tree, me) < DistanceReqd)
                    {
                        tooclose = true;
                        break;
                    }
                }

                if (tooclose) continue;
                bool founddert = false;
                for (int y = (int)H - 10; y > 0; y--)
                {
                    switch (mh.GetBlockAt(me.X+xo, y, me.Y+zo))
                    {
                        case 0: // Air
                        case 78: // Snow cover
                            continue;
                        // case 1: // ROCK
                        case 2: // GRASS
                        case 3: // DIRT
                            //Utils.GrowTree(ref blocks, rand, (int)me.X, (int)y + 1, (int)me.Y);
                            mh.SetBlockAt(me.X + xo, y + 1, me.Y + zo, 6); // Sapling
                            mh.SetDataAt(me.X + xo, y + 1, me.Y + zo, 15); // Growth stage 15.
                            /*
                            Tree tree = new NormalTree(me.X + xo, y + 1, me.Y + zo, rand.Next(5, 8));
                            tree.MakeTrunk(ref mh);
                            tree.MakeFoliage(ref mh);
                            */
                            mh.SaveAll();
                            founddert = true;
                            break;
                        case 11: // SAND
                            //Utils.GrowCactus(ref b, rand, me.X, y + 1, me.Y);
                            break;
                        default:
                            founddert = true;
                            break;
                    }
                    if (founddert) break;
                }
                PlantedTrees.Add(me);
            }
        }