當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityLivingBase.getDistanceSqToEntity方法代碼示例

本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.getDistanceSqToEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.getDistanceSqToEntity方法的具體用法?Java EntityLivingBase.getDistanceSqToEntity怎麽用?Java EntityLivingBase.getDistanceSqToEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.EntityLivingBase的用法示例。


在下文中一共展示了EntityLivingBase.getDistanceSqToEntity方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateTask

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
 * Updates the task
 */
public void updateTask()
{
    if (this.parentEntity.getAttackTarget() == null)
    {
        this.parentEntity.rotationYaw = -((float)MathHelper.atan2(this.parentEntity.motionX, this.parentEntity.motionZ)) * (180F / (float)Math.PI);
        this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
        if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D)
        {
            double d1 = entitylivingbase.posX - this.parentEntity.posX;
            double d2 = entitylivingbase.posZ - this.parentEntity.posZ;
            this.parentEntity.rotationYaw = -((float)MathHelper.atan2(d1, d2)) * (180F / (float)Math.PI);
            this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw;
        }
    }
}
 
開發者ID:Herobone,項目名稱:HeroUtils,代碼行數:23,代碼來源:AILookAround.java

示例2: updateTask

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public void updateTask()
{
    if (this.parentEntity.getAttackTarget() == null)
    {
        this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw = -((float)MathHelper.func_181159_b(this.parentEntity.motionX, this.parentEntity.motionZ)) * 180.0F / (float)Math.PI;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
        double d0 = 64.0D;

        if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < d0 * d0)
        {
            double d1 = entitylivingbase.posX - this.parentEntity.posX;
            double d2 = entitylivingbase.posZ - this.parentEntity.posZ;
            this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw = -((float)MathHelper.func_181159_b(d1, d2)) * 180.0F / (float)Math.PI;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:EntityGhast.java

示例3: updateTask

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
 * Updates the task
 */
public void updateTask()
{
    if (this.parentEntity.getAttackTarget() == null)
    {
        this.parentEntity.rotationYaw = -((float)MathHelper.atan2(this.parentEntity.motionX, this.parentEntity.motionZ)) * (180F / (float)Math.PI);
        this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
        double d0 = 64.0D;

        if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D)
        {
            double d1 = entitylivingbase.posX - this.parentEntity.posX;
            double d2 = entitylivingbase.posZ - this.parentEntity.posZ;
            this.parentEntity.rotationYaw = -((float)MathHelper.atan2(d1, d2)) * (180F / (float)Math.PI);
            this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:EntityGhast.java

示例4: explode

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
public void explode(double x, double y, double z, Entity direct, float power) {
	if (!this.world.isRemote) {
		int coatedCount=0;
		for (EntityLivingBase living : this.world.getEntitiesWithinAABB(EntityLivingBase.class,
				this.getEntityBoundingBox().grow(5, 5, 5)))
			if (living.canBeHitWithPotion() && living.getDistanceSqToEntity(this) < 25
					&& living != this.shootingEntity && !TF2Util.isOnSameTeam(this.shootingEntity, living)){
				living.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation(
						ItemFromData.getData(this.usedWeapon).getString(PropertyType.EFFECT_TYPE)),
						300));
				if(TF2Util.isEnemy(this.shootingEntity,living))
					coatedCount++;
			}
			else
				living.extinguish();
		/*if(coatedCount>=5 && this.shootingEntity instanceof EntityPlayer)
			((EntityPlayer) this.shootingEntity).addStat(TF2Achievements.JARATE_MULTIPLE);*/
			
		this.playSound(TF2Sounds.JAR_EXPLODE, 1.5f, 1f);
		this.world.playEvent(2002, new BlockPos(this),
				Potion.getPotionFromResourceLocation(ItemFromData.getData(this.usedWeapon)
						.getString(PropertyType.EFFECT_TYPE)).getLiquidColor());
		this.setDead();
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:27,代碼來源:EntityJar.java

示例5: updateTask

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    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)
        {
            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:Herobone,項目名稱:HeroUtils,代碼行數:40,代碼來源:EntityDummy.java

示例6: 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

示例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) < 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

示例8: apply

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public boolean apply(EntityLivingBase p_apply_1_)
{
    return (p_apply_1_ instanceof EntityPlayer || p_apply_1_ instanceof EntitySquid) && p_apply_1_.getDistanceSqToEntity(this.parentEntity) > 9.0D;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:EntityGuardian.java

示例9: apply

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public boolean apply(@Nullable EntityLivingBase p_apply_1_)
{
    return (p_apply_1_ instanceof EntityPlayer || p_apply_1_ instanceof EntitySquid) && p_apply_1_.getDistanceSqToEntity(this.parentEntity) > 9.0D;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:5,代碼來源:EntityGuardian.java

示例10: updateTask

import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
 * Updates the task
 */
@Override
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 <= 0) {
			double d1 = 4.0D;
			/*
			 * double d2 = entitylivingbase.posX -
			 * (this.parentEntity.posX + vec3d.x * 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.z * 4.0D); world.playEvent((EntityPlayer)null,
			 * 1016, new BlockPos(this.parentEntity), 0);
			 * EntityLargeFireball entitylargefireball = new
			 * EntityLargeFireball(world, this.parentEntity, d2, d3,
			 * d4); entitylargefireball.explosionPower = 3;
			 * entitylargefireball.posX = this.parentEntity.posX +
			 * vec3d.x * 4.0D; entitylargefireball.posY =
			 * this.parentEntity.posY +
			 * (double)(this.parentEntity.height / 2.0F) + 0.5D;
			 * entitylargefireball.posZ = this.parentEntity.posZ +
			 * vec3d.z * 4.0D;
			 * world.spawnEntity(entitylargefireball);
			 */
			if(this.parentEntity.isAngry())
				this.parentEntity.playSound(TF2Sounds.MOB_MONOCULUS_SHOOT_MAD, 3f, 1);
			else
				this.parentEntity.playSound(TF2Sounds.MOB_MONOCULUS_SHOOT, 3f, 1);
			
			((ItemProjectileWeapon) this.parentEntity.getHeldItemMainhand().getItem()).shoot(
					this.parentEntity.getHeldItemMainhand(), this.parentEntity, world, 2, EnumHand.MAIN_HAND);
			if (this.triple > 0) {
				triple--;
				this.attackTimer = Math.max(4, 6 - this.parentEntity.level / 5);
				((ItemProjectileWeapon) this.parentEntity.getHeldItemMainhand().getItem()).shoot(
						this.parentEntity.getHeldItemMainhand(), this.parentEntity, world, 2,
						EnumHand.MAIN_HAND);
			} else {
				this.attackTimer = Math.max(11, 29 - this.parentEntity.level);
				if (this.parentEntity.isAngry())
					triple = 2;
			}

		}
	} else if (this.attackTimer > 0)
		--this.attackTimer;

	// this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:62,代碼來源:EntityMonoculus.java


注:本文中的net.minecraft.entity.EntityLivingBase.getDistanceSqToEntity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。