Ejemplo n.º 1
0
        private Vec3D FindPossibleShelter()
        {
            Random random = TheCreature.GetRNG();

            for (int i = 0; i < 10; i++)
            {
                int j = MathHelper2.Floor_double((TheCreature.PosX + (double)random.Next(20)) - 10D);
                int k = MathHelper2.Floor_double((TheCreature.BoundingBox.MinY + (double)random.Next(6)) - 3D);
                int l = MathHelper2.Floor_double((TheCreature.PosZ + (double)random.Next(20)) - 10D);

                if (!TheWorld.CanBlockSeeTheSky(j, k, l) && TheCreature.GetBlockPathWeight(j, k, l) < 0.0F)
                {
                    return(Vec3D.CreateVector(j, k, l));
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private static Vec3D Func_48621_c(EntityCreature par0EntityCreature, int par1, int par2, Vec3D par3Vec3D)
        {
            Random random = par0EntityCreature.GetRNG();
            bool   flag   = false;
            int    i      = 0;
            int    j      = 0;
            int    k      = 0;
            float  f      = -99999F;
            bool   flag1;

            if (par0EntityCreature.HasHome())
            {
                double d = par0EntityCreature.GetHomePosition().GetEuclideanDistanceTo(MathHelper2.Floor_double(par0EntityCreature.PosX), MathHelper2.Floor_double(par0EntityCreature.PosY), MathHelper2.Floor_double(par0EntityCreature.PosZ)) + 4D;
                flag1 = d < (double)(par0EntityCreature.GetMaximumHomeDistance() + (float)par1);
            }
            else
            {
                flag1 = false;
            }

            for (int l = 0; l < 10; l++)
            {
                int i1 = random.Next(2 * par1) - par1;
                int j1 = random.Next(2 * par2) - par2;
                int k1 = random.Next(2 * par1) - par1;

                if (par3Vec3D != null && (double)i1 * par3Vec3D.XCoord + (double)k1 * par3Vec3D.ZCoord < 0.0F)
                {
                    continue;
                }

                i1 += MathHelper2.Floor_double(par0EntityCreature.PosX);
                j1 += MathHelper2.Floor_double(par0EntityCreature.PosY);
                k1 += MathHelper2.Floor_double(par0EntityCreature.PosZ);

                if (flag1 && !par0EntityCreature.IsWithinHomeDistance(i1, j1, k1))
                {
                    continue;
                }

                float f1 = par0EntityCreature.GetBlockPathWeight(i1, j1, k1);

                if (f1 > f)
                {
                    f    = f1;
                    i    = i1;
                    j    = j1;
                    k    = k1;
                    flag = true;
                }
            }

            if (flag)
            {
                return(Vec3D.CreateVector(i, j, k));
            }
            else
            {
                return(null);
            }
        }