本文整理汇总了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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}