Exemple #1
0
        protected override bool CanSpawnStructureAtCoords(int par1, int par2)
        {
            if (!RanBiomeCheck)
            {
                Random random = new Random();
                random.SetSeed((int)WorldObj.GetSeed());
                double d = random.NextDouble() * Math.PI * 2D;

                for (int k = 0; k < StructureCoords.Length; k++)
                {
                    double d1 = (1.25D + random.NextDouble()) * 32D;
                    int    l  = (int)Math.Round(Math.Cos(d) * d1);
                    int    i1 = (int)Math.Round(Math.Sin(d) * d1);
                    List <BiomeGenBase> arraylist     = new List <BiomeGenBase>();
                    BiomeGenBase[]      abiomegenbase = AllowedBiomeGenBases;
                    int j1 = abiomegenbase.Length;

                    for (int k1 = 0; k1 < j1; k1++)
                    {
                        BiomeGenBase biomegenbase = abiomegenbase[k1];
                        arraylist.Add(biomegenbase);
                    }

                    ChunkPosition chunkposition = WorldObj.GetWorldChunkManager().FindBiomePosition((l << 4) + 8, (i1 << 4) + 8, 112, arraylist, random);

                    if (chunkposition != null)
                    {
                        l  = chunkposition.x >> 4;
                        i1 = chunkposition.z >> 4;
                    }
                    else
                    {
                        Console.WriteLine((new StringBuilder()).Append("Placed stronghold in INVALID biome at (").Append(l).Append(", ").Append(i1).Append(")").ToString());
                    }

                    StructureCoords[k] = new ChunkCoordIntPair(l, i1);
                    d += (Math.PI * 2D) / (double)StructureCoords.Length;
                }

                RanBiomeCheck = true;
            }

            ChunkCoordIntPair[] achunkcoordintpair = StructureCoords;
            int i = achunkcoordintpair.Length;

            for (int j = 0; j < i; j++)
            {
                ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[j];

                if (par1 == chunkcoordintpair.ChunkXPos && par2 == chunkcoordintpair.ChunkZPos)
                {
                    Console.WriteLine((new StringBuilder()).Append(par1).Append(", ").Append(par2).ToString());
                    return(true);
                }
            }

            return(false);
        }
        protected override bool CanSpawnStructureAtCoords(int par1, int par2)
        {
            sbyte byte0 = 32;
            sbyte byte1 = 8;
            int   i     = par1;
            int   j     = par2;

            if (par1 < 0)
            {
                par1 -= byte0 - 1;
            }

            if (par2 < 0)
            {
                par2 -= byte0 - 1;
            }

            int    k      = par1 / byte0;
            int    l      = par2 / byte0;
            Random random = WorldObj.SetRandomSeed(k, l, 0x9e7f70);

            k   *= byte0;
            l   *= byte0;
            k   += random.Next(byte0 - byte1);
            l   += random.Next(byte0 - byte1);
            par1 = i;
            par2 = j;

            if (par1 == k && par2 == l)
            {
                bool flag = WorldObj.GetWorldChunkManager().AreBiomesViable(par1 * 16 + 8, par2 * 16 + 8, 0, VillageSpawnBiomes);

                if (flag)
                {
                    return(true);
                }
            }

            return(false);
        }