当前位置: 首页>>代码示例>>Java>>正文


Java EntityLivingBase.getEntityBoundingBox方法代码示例

本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getEntityBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getEntityBoundingBox方法的具体用法?Java EntityLivingBase.getEntityBoundingBox怎么用?Java EntityLivingBase.getEntityBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.EntityLivingBase的用法示例。


在下文中一共展示了EntityLivingBase.getEntityBoundingBox方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: throwPearl

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void throwPearl(EntityLiving entity, EntityLivingBase target) {
	World world = entity.getEntityWorld();
	EntityEnderPearl pearl = new EntityEnderPearl(world, entity);

	double dX = target.posX - entity.posX;
	double dY = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - pearl.posY;
	double dZ = target.posZ - entity.posZ;

	double distanceSq = dX * dX + dY * dY + dZ * dZ;

	if (distanceSq < 20) {
		return;
	}

	double levelDistance = MathHelper.sqrt(dX * dX + dZ * dZ);

	pearl.setThrowableHeading(dX, dY + levelDistance * 0.20000000298023224D, dZ, 1.6F,
			(float) (14 - world.getDifficulty().getDifficultyId() * 4));

	entity.playSound(SoundEvents.ENTITY_ENDERPEARL_THROW, 1.0F, 1.0F / (world.rand.nextFloat() * 0.4F + 0.8F));

	world.spawnEntity(pearl);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:24,代码来源:NemesisActions.java

示例2: EntityMob_isValidLightLevel

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Checks to make sure the light is not too bright where the mob is spawning
 * Adapted from net.minecraft.entity.monster.EntityMob#isValidLightLevel
 *
 */
private static boolean EntityMob_isValidLightLevel(EntityLivingBase entity)
{
	BlockPos pos = new BlockPos(entity.posX, entity.getEntityBoundingBox().minY, entity.posZ);
	if (entity.world.getLightFor(EnumSkyBlock.SKY, pos) > entity.world.rand.nextInt(32))
	{
		return false;
	}
	else
	{
		int i = entity.world.getLightFromNeighbors(pos);
		if (entity.world.isThundering())
		{
			int j = entity.world.getSkylightSubtracted();
			entity.world.setSkylightSubtracted(10);
			i = entity.world.getLightFromNeighbors(pos);
			entity.world.setSkylightSubtracted(j);
		}
		return i <= entity.world.rand.nextInt(8);
	}
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:26,代码来源:EntityUtils.java

示例3: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    double d0 = 64.0D;

    if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D && this.parentEntity.canEntityBeSeen(entitylivingbase))
    {
        World world = this.parentEntity.world;
        ++this.attackTimer;

        if (this.attackTimer == 10)
        {
            world.playEvent((EntityPlayer)null, 1015, new BlockPos(this.parentEntity), 0);
        }

        if (this.attackTimer == 20)
        {
            double d1 = 4.0D;
            Vec3d vec3d = this.parentEntity.getLook(1.0F);
            double d2 = entitylivingbase.posX - (this.parentEntity.posX + vec3d.xCoord * 4.0D);
            double d3 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (0.5D + this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F));
            double d4 = entitylivingbase.posZ - (this.parentEntity.posZ + vec3d.zCoord * 4.0D);
            world.playEvent((EntityPlayer)null, 1016, new BlockPos(this.parentEntity), 0);
            EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.parentEntity, d2, d3, d4);
            entitylargefireball.explosionPower = this.parentEntity.getFireballStrength();
            entitylargefireball.posX = this.parentEntity.posX + vec3d.xCoord * 4.0D;
            entitylargefireball.posY = this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F) + 0.5D;
            entitylargefireball.posZ = this.parentEntity.posZ + vec3d.zCoord * 4.0D;
            world.spawnEntityInWorld(entitylargefireball);
            this.attackTimer = -40;
        }
    }
    else if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:EntityGhast.java

示例4: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    double d0 = 64.0D;

    if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D && this.parentEntity.canEntityBeSeen(entitylivingbase))
    {
        World world = this.parentEntity.worldObj;
        ++this.attackTimer;

        if (this.attackTimer == 10)
        {
            world.playEvent((EntityPlayer)null, 1015, new BlockPos(this.parentEntity), 0);
        }

        if (this.attackTimer == 20)
        {
            double d1 = 4.0D;
            Vec3d vec3d = this.parentEntity.getLook(1.0F);
            double d2 = entitylivingbase.posX - (this.parentEntity.posX + vec3d.xCoord * 4.0D);
            double d3 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (0.5D + this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F));
            double d4 = entitylivingbase.posZ - (this.parentEntity.posZ + vec3d.zCoord * 4.0D);
            world.playEvent((EntityPlayer)null, 1016, new BlockPos(this.parentEntity), 0);
            EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.parentEntity, d2, d3, d4);
            entitylargefireball.explosionPower = this.parentEntity.getFireballStrength();
            entitylargefireball.posX = this.parentEntity.posX + vec3d.xCoord * 4.0D;
            entitylargefireball.posY = this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F) + 0.5D;
            entitylargefireball.posZ = this.parentEntity.posZ + vec3d.zCoord * 4.0D;
            world.spawnEntityInWorld(entitylargefireball);
            this.attackTimer = -40;
        }
    }
    else if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:EntityGhast.java

示例5: EntityArrow

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public EntityArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
    super(worldIn);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.canBePickedUp = 1;
    }

    this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D;
    double d0 = p_i1755_3_.posX - shooter.posX;
    double d1 = p_i1755_3_.getEntityBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
    double d2 = p_i1755_3_.posZ - shooter.posZ;
    double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D)
    {
        float f = (float)(MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f1 = (float)(-(MathHelper.func_181159_b(d1, d3) * 180.0D / Math.PI));
        double d4 = d0 / d3;
        double d5 = d2 / d3;
        this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f, f1);
        float f2 = (float)(d3 * 0.20000000298023224D);
        this.setThrowableHeading(d0, d1 + (double)f2, d2, p_i1755_4_, p_i1755_5_);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:EntityArrow.java

示例6: attackEntityWithRangedAttack

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    EntityArrow entityarrow = this.func_190726_a(distanceFactor);
    double d0 = target.posX - this.posX;
    double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entityarrow.posY;
    double d2 = target.posZ - this.posZ;
    double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
    entityarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4));
    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntityInWorld(entityarrow);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:AbstractSkeleton.java

示例7: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    double d0 = 64.0D;

    if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < d0 * d0 && this.parentEntity.canEntityBeSeen(entitylivingbase))
    {
        World world = this.parentEntity.worldObj;
        ++this.attackTimer;

        if (this.attackTimer == 10)
        {
            world.playAuxSFXAtEntity((EntityPlayer)null, 1007, new BlockPos(this.parentEntity), 0);
        }

        if (this.attackTimer == 20)
        {
            double d1 = 4.0D;
            Vec3 vec3 = this.parentEntity.getLook(1.0F);
            double d2 = entitylivingbase.posX - (this.parentEntity.posX + vec3.xCoord * d1);
            double d3 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (0.5D + this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F));
            double d4 = entitylivingbase.posZ - (this.parentEntity.posZ + vec3.zCoord * d1);
            world.playAuxSFXAtEntity((EntityPlayer)null, 1008, new BlockPos(this.parentEntity), 0);
            EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.parentEntity, d2, d3, d4);
            entitylargefireball.explosionPower = this.parentEntity.getFireballStrength();
            entitylargefireball.posX = this.parentEntity.posX + vec3.xCoord * d1;
            entitylargefireball.posY = this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F) + 0.5D;
            entitylargefireball.posZ = this.parentEntity.posZ + vec3.zCoord * d1;
            world.spawnEntityInWorld(entitylargefireball);
            this.attackTimer = -40;
        }
    }
    else if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:40,代码来源:EntityGhast.java

示例8: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
    this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
    double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
    --this.delayCounter;

    if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
    {
        this.targetX = entitylivingbase.posX;
        this.targetY = entitylivingbase.getEntityBoundingBox().minY;
        this.targetZ = entitylivingbase.posZ;
        this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);

        if (d0 > 1024.0D)
        {
            this.delayCounter += 10;
        }
        else if (d0 > 256.0D)
        {
            this.delayCounter += 5;
        }

        if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
        {
            this.delayCounter += 15;
        }
    }

    this.attackTick = Math.max(this.attackTick - 1, 0);
    this.checkAndPerformAttack(entitylivingbase, d0);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:EntityAIAttackMelee.java

示例9: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateTask()
{
    --this.field_179468_c;
    EntityLivingBase entitylivingbase = this.blaze.getAttackTarget();
    double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase);

    if (d0 < 4.0D)
    {
        if (this.field_179468_c <= 0)
        {
            this.field_179468_c = 20;
            this.blaze.attackEntityAsMob(entitylivingbase);
        }

        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }
    else if (d0 < 256.0D)
    {
        double d1 = entitylivingbase.posX - this.blaze.posX;
        double d2 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (this.blaze.posY + (double)(this.blaze.height / 2.0F));
        double d3 = entitylivingbase.posZ - this.blaze.posZ;

        if (this.field_179468_c <= 0)
        {
            ++this.field_179467_b;

            if (this.field_179467_b == 1)
            {
                this.field_179468_c = 60;
                this.blaze.setOnFire(true);
            }
            else if (this.field_179467_b <= 4)
            {
                this.field_179468_c = 6;
            }
            else
            {
                this.field_179468_c = 100;
                this.field_179467_b = 0;
                this.blaze.setOnFire(false);
            }

            if (this.field_179467_b > 1)
            {
                float f = MathHelper.sqrt_float(MathHelper.sqrt_double(d0)) * 0.5F;
                this.blaze.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, new BlockPos((int)this.blaze.posX, (int)this.blaze.posY, (int)this.blaze.posZ), 0);

                for (int i = 0; i < 1; ++i)
                {
                    EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.blaze.worldObj, this.blaze, d1 + this.blaze.getRNG().nextGaussian() * (double)f, d2, d3 + this.blaze.getRNG().nextGaussian() * (double)f);
                    entitysmallfireball.posY = this.blaze.posY + (double)(this.blaze.height / 2.0F) + 0.5D;
                    this.blaze.worldObj.spawnEntityInWorld(entitysmallfireball);
                }
            }
        }

        this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F);
    }
    else
    {
        this.blaze.getNavigator().clearPathEntity();
        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }

    super.updateTask();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:67,代码来源:EntityBlaze.java

示例10: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
    this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
    double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
    --this.delayCounter;

    if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
    {
        this.targetX = entitylivingbase.posX;
        this.targetY = entitylivingbase.getEntityBoundingBox().minY;
        this.targetZ = entitylivingbase.posZ;
        this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);

        if (this.canPenalize)
        {
            this.delayCounter += failedPathFindingPenalty;
            if (this.attacker.getNavigator().getPath() != null)
            {
                net.minecraft.pathfinding.PathPoint finalPathPoint = this.attacker.getNavigator().getPath().getFinalPathPoint();
                if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1)
                    failedPathFindingPenalty = 0;
                else
                    failedPathFindingPenalty += 10;
            }
            else
            {
                failedPathFindingPenalty += 10;
            }
        }

        if (d0 > 1024.0D)
        {
            this.delayCounter += 10;
        }
        else if (d0 > 256.0D)
        {
            this.delayCounter += 5;
        }

        if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
        {
            this.delayCounter += 15;
        }
    }

    this.attackTick = Math.max(this.attackTick - 1, 0);
    this.checkAndPerformAttack(entitylivingbase, d0);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:53,代码来源:EntityAIAttackMelee.java

示例11: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
    this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
    double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
    double d1 = this.func_179512_a(entitylivingbase);
    --this.delayCounter;

    if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
    {
        this.targetX = entitylivingbase.posX;
        this.targetY = entitylivingbase.getEntityBoundingBox().minY;
        this.targetZ = entitylivingbase.posZ;
        this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);

        if (d0 > 1024.0D)
        {
            this.delayCounter += 10;
        }
        else if (d0 > 256.0D)
        {
            this.delayCounter += 5;
        }

        if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
        {
            this.delayCounter += 15;
        }
    }

    this.attackTick = Math.max(this.attackTick - 1, 0);

    if (d0 <= d1 && this.attackTick <= 0)
    {
        this.attackTick = 20;

        if (this.attacker.getHeldItem() != null)
        {
            this.attacker.swingItem();
        }

        this.attacker.attackEntityAsMob(entitylivingbase);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:48,代码来源:EntityAIAttackOnCollide.java

示例12: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateTask()
{
    --this.attackTime;
    EntityLivingBase entitylivingbase = this.blaze.getAttackTarget();
    double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase);

    if (d0 < 4.0D)
    {
        if (this.attackTime <= 0)
        {
            this.attackTime = 20;
            this.blaze.attackEntityAsMob(entitylivingbase);
        }

        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }
    else if (d0 < this.func_191523_f() * this.func_191523_f())
    {
        double d1 = entitylivingbase.posX - this.blaze.posX;
        double d2 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (this.blaze.posY + (double)(this.blaze.height / 2.0F));
        double d3 = entitylivingbase.posZ - this.blaze.posZ;

        if (this.attackTime <= 0)
        {
            ++this.attackStep;

            if (this.attackStep == 1)
            {
                this.attackTime = 60;
                this.blaze.setOnFire(true);
            }
            else if (this.attackStep <= 4)
            {
                this.attackTime = 6;
            }
            else
            {
                this.attackTime = 100;
                this.attackStep = 0;
                this.blaze.setOnFire(false);
            }

            if (this.attackStep > 1)
            {
                float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F;
                this.blaze.world.playEvent((EntityPlayer)null, 1018, new BlockPos((int)this.blaze.posX, (int)this.blaze.posY, (int)this.blaze.posZ), 0);

                for (int i = 0; i < 1; ++i)
                {
                    EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.blaze.world, this.blaze, d1 + this.blaze.getRNG().nextGaussian() * (double)f, d2, d3 + this.blaze.getRNG().nextGaussian() * (double)f);
                    entitysmallfireball.posY = this.blaze.posY + (double)(this.blaze.height / 2.0F) + 0.5D;
                    this.blaze.world.spawnEntityInWorld(entitysmallfireball);
                }
            }
        }

        this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F);
    }
    else
    {
        this.blaze.getNavigator().clearPathEntity();
        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }

    super.updateTask();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:67,代码来源:EntityBlaze.java

示例13: attackEntityWithRangedAttack

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this);
    double d0 = target.posX - this.posX;
    double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entitytippedarrow.posY;
    double d2 = target.posZ - this.posZ;
    double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
    entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
    int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
    int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
    DifficultyInstance difficultyinstance = this.worldObj.getDifficultyForLocation(new BlockPos(this));
    entitytippedarrow.setDamage((double)(distanceFactor * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

    if (i > 0)
    {
        entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double)i * 0.5D + 0.5D);
    }

    if (j > 0)
    {
        entitytippedarrow.setKnockbackStrength(j);
    }

    boolean flag = this.isBurning() && difficultyinstance.isHard() && this.rand.nextBoolean() || this.getSkeletonType() == SkeletonType.WITHER;
    flag = flag || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;

    if (flag)
    {
        entitytippedarrow.setFire(100);
    }

    ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);

    if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW)
    {
        entitytippedarrow.setPotionEffect(itemstack);
    }
    else if (this.getSkeletonType() == SkeletonType.STRAY)
    {
        entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
    }

    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitytippedarrow);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:51,代码来源:EntitySkeleton.java

示例14: updateTask

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    --this.attackTime;
    EntityLivingBase entitylivingbase = this.blaze.getAttackTarget();
    double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase);

    if (d0 < 4.0D)
    {
        if (this.attackTime <= 0)
        {
            this.attackTime = 20;
            this.blaze.attackEntityAsMob(entitylivingbase);
        }

        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }
    else if (d0 < 256.0D)
    {
        double d1 = entitylivingbase.posX - this.blaze.posX;
        double d2 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (this.blaze.posY + (double)(this.blaze.height / 2.0F));
        double d3 = entitylivingbase.posZ - this.blaze.posZ;

        if (this.attackTime <= 0)
        {
            ++this.attackStep;

            if (this.attackStep == 1)
            {
                this.attackTime = 60;
                this.blaze.setOnFire(true);
            }
            else if (this.attackStep <= 4)
            {
                this.attackTime = 6;
            }
            else
            {
                this.attackTime = 100;
                this.attackStep = 0;
                this.blaze.setOnFire(false);
            }

            if (this.attackStep > 1)
            {
                float f = MathHelper.sqrt_float(MathHelper.sqrt_double(d0)) * 0.5F;
                this.blaze.worldObj.playEvent((EntityPlayer)null, 1018, new BlockPos((int)this.blaze.posX, (int)this.blaze.posY, (int)this.blaze.posZ), 0);

                for (int i = 0; i < 1; ++i)
                {
                    EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.blaze.worldObj, this.blaze, d1 + this.blaze.getRNG().nextGaussian() * (double)f, d2, d3 + this.blaze.getRNG().nextGaussian() * (double)f);
                    entitysmallfireball.posY = this.blaze.posY + (double)(this.blaze.height / 2.0F) + 0.5D;
                    this.blaze.worldObj.spawnEntityInWorld(entitysmallfireball);
                }
            }
        }

        this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F);
    }
    else
    {
        this.blaze.getNavigator().clearPathEntity();
        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }

    super.updateTask();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:70,代码来源:EntityBlaze.java


注:本文中的net.minecraft.entity.EntityLivingBase.getEntityBoundingBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。