Пример #1
0
        /// <summary>
        /// Checks if the entity's current position is a valid location to spawn this entity.
        /// </summary>
        public override bool GetCanSpawnHere()
        {
            if (WorldObj.Rand.Next(3) == 0)
            {
                return(false);
            }

            if (WorldObj.CheckIfAABBIsClear(BoundingBox) && WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox))
            {
                int i = MathHelper2.Floor_double(PosX);
                int j = MathHelper2.Floor_double(BoundingBox.MinY);
                int k = MathHelper2.Floor_double(PosZ);

                if (j < 63)
                {
                    return(false);
                }

                int l = WorldObj.GetBlockId(i, j - 1, k);

                if (l == Block.Grass.BlockID || l == Block.Leaves.BlockID)
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// True if the ghast has an unobstructed line of travel to the waypoint.
        /// </summary>
        private bool IsCourseTraversable(float par1, float par3, float par5, float par7)
        {
            float         d             = (WaypointX - PosX) / par7;
            float         d1            = (WaypointY - PosY) / par7;
            float         d2            = (WaypointZ - PosZ) / par7;
            AxisAlignedBB axisalignedbb = BoundingBox.Copy();

            for (int i = 1; i < par7; i++)
            {
                axisalignedbb.Offset(d, d1, d2);

                if (WorldObj.GetCollidingBoundingBoxes(this, axisalignedbb).Count > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// checks to make sure painting can be placed there
        /// </summary>
        public virtual bool OnValidSurface()
        {
            if (WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count > 0)
            {
                return(false);
            }

            int i  = Art.SizeX / 16;
            int j  = Art.SizeY / 16;
            int k  = XPosition;
            int l  = YPosition;
            int i1 = ZPosition;

            if (Direction == 0)
            {
                k = MathHelper2.Floor_double(PosX - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 1)
            {
                i1 = MathHelper2.Floor_double(PosZ - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 2)
            {
                k = MathHelper2.Floor_double(PosX - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 3)
            {
                i1 = MathHelper2.Floor_double(PosZ - (double)((float)Art.SizeX / 32F));
            }

            l = MathHelper2.Floor_double(PosY - (double)((float)Art.SizeY / 32F));

            for (int j1 = 0; j1 < i; j1++)
            {
                for (int k1 = 0; k1 < j; k1++)
                {
                    Material material;

                    if (Direction == 0 || Direction == 2)
                    {
                        material = WorldObj.GetBlockMaterial(k + j1, l + k1, ZPosition);
                    }
                    else
                    {
                        material = WorldObj.GetBlockMaterial(XPosition, l + k1, i1 + j1);
                    }

                    if (!material.IsSolid())
                    {
                        return(false);
                    }
                }
            }

            List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox);

            for (int l1 = 0; l1 < list.Count; l1++)
            {
                if (list[l1] is EntityPainting)
                {
                    return(false);
                }
            }

            return(true);
        }
 /// <summary>
 /// Checks if the entity's current position is a valid location to spawn this entity.
 /// </summary>
 public override bool GetCanSpawnHere()
 {
     return(WorldObj.DifficultySetting > 0 && WorldObj.CheckIfAABBIsClear(BoundingBox) && WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox));
 }
Пример #5
0
        /// <summary>
        /// Teleport the enderman
        /// </summary>
        protected virtual bool TeleportTo(float par1, float par3, float par5)
        {
            float d  = PosX;
            float d1 = PosY;
            float d2 = PosZ;

            PosX = par1;
            PosY = par3;
            PosZ = par5;
            bool flag = false;
            int  i    = MathHelper2.Floor_double(PosX);
            int  j    = MathHelper2.Floor_double(PosY);
            int  k    = MathHelper2.Floor_double(PosZ);

            if (WorldObj.BlockExists(i, j, k))
            {
                bool flag1;

                for (flag1 = false; !flag1 && j > 0;)
                {
                    int i1 = WorldObj.GetBlockId(i, j - 1, k);

                    if (i1 == 0 || !Block.BlocksList[i1].BlockMaterial.BlocksMovement())
                    {
                        PosY--;
                        j--;
                    }
                    else
                    {
                        flag1 = true;
                    }
                }

                if (flag1)
                {
                    SetPosition(PosX, PosY, PosZ);

                    if (WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox))
                    {
                        flag = true;
                    }
                }
            }

            if (!flag)
            {
                SetPosition(d, d1, d2);
                return(false);
            }

            int l = 128;

            for (int j1 = 0; j1 < l; j1++)
            {
                double d3 = (double)j1 / ((double)l - 1.0D);
                float  f  = (Rand.NextFloat() - 0.5F) * 0.2F;
                float  f1 = (Rand.NextFloat() - 0.5F) * 0.2F;
                float  f2 = (Rand.NextFloat() - 0.5F) * 0.2F;
                double d4 = d + (PosX - d) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D;
                double d5 = d1 + (PosY - d1) * d3 + Rand.NextDouble() * (double)Height;
                double d6 = d2 + (PosZ - d2) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D;
                WorldObj.SpawnParticle("portal", d4, d5, d6, f, f1, f2);
            }

            WorldObj.PlaySoundEffect(d, d1, d2, "mob.endermen.portal", 1.0F, 1.0F);
            WorldObj.PlaySoundAtEntity(this, "mob.endermen.portal", 1.0F, 1.0F);
            return(true);
        }