Beispiel #1
0
        public override void updatePlayerActionState()
        {
            if (worldObj.difficultySetting == 0)
            {
                setEntityDead();
            }
            prevAttackCounter = attackCounter;
            double d  = waypointX - posX;
            double d1 = waypointY - posY;
            double d2 = waypointZ - posZ;
            double d3 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);

            if (d3 < 1.0D || d3 > 60D)
            {
                waypointX = posX + ((rand.nextFloat() * 2.0F - 1.0F) * 16F);
                waypointY = posY + ((rand.nextFloat() * 2.0F - 1.0F) * 16F);
                waypointZ = posZ + ((rand.nextFloat() * 2.0F - 1.0F) * 16F);
            }
            if (courseChangeCooldown-- <= 0)
            {
                courseChangeCooldown += rand.nextInt(5) + 2;
                if (isCourseTraversable(waypointX, waypointY, waypointZ, d3))
                {
                    motionX += (d / d3) * 0.10000000000000001D;
                    motionY += (d1 / d3) * 0.10000000000000001D;
                    motionZ += (d2 / d3) * 0.10000000000000001D;
                }
                else
                {
                    waypointX = posX;
                    waypointY = posY;
                    waypointZ = posZ;
                }
            }
            if (targetedEntity != null && targetedEntity.isDead)
            {
                targetedEntity = null;
            }
            if (targetedEntity == null || aggroCooldown-- <= 0)
            {
                targetedEntity = worldObj.getClosestPlayerToEntity(this, 100D);
                if (targetedEntity != null)
                {
                    aggroCooldown = 20;
                }
            }
            double d4 = 64D;

            if (targetedEntity != null && targetedEntity.getDistanceSqToEntity(this) < d4 * d4)
            {
                double d5 = targetedEntity.posX - posX;
                double d6 = (targetedEntity.boundingBox.minY + (targetedEntity.height / 2.0F)) -
                            (posY + (height / 2.0F));
                double d7 = targetedEntity.posZ - posZ;
                renderYawOffset = rotationYaw = (-(float)Math.atan2(d5, d7) * 180F) / 3.141593F;
                if (canEntityBeSeen(targetedEntity))
                {
                    if (attackCounter == 10)
                    {
                        worldObj.playSoundAtEntity(this, "mob.ghast.charge", getSoundVolume(),
                                                   (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
                    }
                    attackCounter++;
                    if (attackCounter == 20)
                    {
                        worldObj.playSoundAtEntity(this, "mob.ghast.fireball", getSoundVolume(),
                                                   (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
                        var    entityfireball = new EntityFireball(worldObj, this, d5, d6, d7);
                        double d8             = 4D;
                        Vec3D  vec3d          = getLook(1.0F);
                        entityfireball.posX = posX + vec3d.xCoord * d8;
                        entityfireball.posY = posY + (height / 2.0F) + 0.5D;
                        entityfireball.posZ = posZ + vec3d.zCoord * d8;
                        worldObj.entityJoinedWorld(entityfireball);
                        attackCounter = -40;
                    }
                }
                else if (attackCounter > 0)
                {
                    attackCounter--;
                }
            }
            else
            {
                renderYawOffset = rotationYaw = (-(float)Math.atan2(motionX, motionZ) * 180F) / 3.141593F;
                if (attackCounter > 0)
                {
                    attackCounter--;
                }
            }
            texture = attackCounter <= 10 ? "/mob/ghast.png" : "/mob/ghast_fire.png";
        }
Beispiel #2
0
        public virtual void updatePlayerActionState()
        {
            age++;
            EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, -1D);

            if (entityplayer != null)
            {
                double d  = ((entityplayer)).posX - posX;
                double d1 = ((entityplayer)).posY - posY;
                double d2 = ((entityplayer)).posZ - posZ;
                double d3 = d * d + d1 * d1 + d2 * d2;
                if (d3 > 16384D)
                {
                    setEntityDead();
                }
                if (age > 600 && rand.nextInt(800) == 0)
                {
                    if (d3 < 1024D)
                    {
                        age = 0;
                    }
                    else
                    {
                        setEntityDead();
                    }
                }
            }
            moveStrafing = 0.0F;
            moveForward  = 0.0F;
            float f = 8F;

            if (rand.nextFloat() < 0.02F)
            {
                EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, f);
                if (entityplayer1 != null)
                {
                    currentTarget         = entityplayer1;
                    numTicksToChaseTarget = 10 + rand.nextInt(20);
                }
                else
                {
                    randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
                }
            }
            if (currentTarget != null)
            {
                faceEntity(currentTarget, 10F);
                if (numTicksToChaseTarget-- <= 0 || currentTarget.isDead ||
                    currentTarget.getDistanceSqToEntity(this) > (f * f))
                {
                    currentTarget = null;
                }
            }
            else
            {
                if (rand.nextFloat() < 0.05F)
                {
                    randomYawVelocity = (rand.nextFloat() - 0.5F) * 20F;
                }
                rotationYaw  += randomYawVelocity;
                rotationPitch = defaultPitch;
            }
            bool flag  = handleWaterMovement();
            bool flag1 = handleLavaMovement();

            if (flag || flag1)
            {
                isJumping = rand.nextFloat() < 0.8F;
            }
        }