Exemple #1
0
        /// <summary>
        /// Checks to see if this enderman should be attacking this player
        /// </summary>
        private bool ShouldAttackPlayer(EntityPlayer par1EntityPlayer)
        {
            ItemStack itemstack = par1EntityPlayer.Inventory.ArmorInventory[3];

            if (itemstack != null && itemstack.ItemID == Block.Pumpkin.BlockID)
            {
                return(false);
            }

            Vec3D  vec3d  = par1EntityPlayer.GetLook(1.0F).Normalize();
            Vec3D  vec3d1 = Vec3D.CreateVector(PosX - par1EntityPlayer.PosX, (BoundingBox.MinY + (double)(Height / 2.0F)) - (par1EntityPlayer.PosY + (double)par1EntityPlayer.GetEyeHeight()), PosZ - par1EntityPlayer.PosZ);
            double d      = vec3d1.LengthVector();

            vec3d1 = vec3d1.Normalize();
            double d1 = vec3d.DotProduct(vec3d1);

            if (d1 > 1.0D - 0.025000000000000001D / d)
            {
                return(par1EntityPlayer.CanEntityBeSeen(this));
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (Field_35126_c > 0)
            {
                Field_35126_c--;
            }

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            MotionY -= 0.029999999329447746F;

            if (WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) == Material.Lava)
            {
                MotionY = 0.20000000298023224F;
                MotionX = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                MotionZ = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                WorldObj.PlaySoundAtEntity(this, "random.fizz", 0.4F, 2.0F + Rand.NextFloat() * 0.4F);
            }

            PushOutOfBlocks(PosX, (BoundingBox.MinY + BoundingBox.MaxY) / 2F, PosZ);
            float        d            = 8F;
            EntityPlayer entityplayer = WorldObj.GetClosestPlayerToEntity(this, d);

            if (entityplayer != null)
            {
                float d1 = (entityplayer.PosX - PosX) / d;
                float d2 = ((entityplayer.PosY + entityplayer.GetEyeHeight()) - PosY) / d;
                float d3 = (entityplayer.PosZ - PosZ) / d;
                float d4 = (float)Math.Sqrt(d1 * d1 + d2 * d2 + d3 * d3);
                float d5 = 1.0F - d4;

                if (d5 > 0.0F)
                {
                    d5      *= d5;
                    MotionX += (d1 / d4) * d5 * 0.10000000000000001F;
                    MotionY += (d2 / d4) * d5 * 0.10000000000000001F;
                    MotionZ += (d3 / d4) * d5 * 0.10000000000000001F;
                }
            }

            MoveEntity(MotionX, MotionY, MotionZ);
            float f = 0.98F;

            if (OnGround)
            {
                f = 0.5880001F;
                int i = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                if (i > 0)
                {
                    f = Block.BlocksList[i].Slipperiness * 0.98F;
                }
            }

            MotionX *= f;
            MotionY *= 0.98000001907348633F;
            MotionZ *= f;

            if (OnGround)
            {
                MotionY *= -0.89999997615814209F;
            }

            XpColor++;
            XpOrbAge++;

            if (XpOrbAge >= 6000)
            {
                SetDead();
            }
        }