Java Code Examples for net.minecraft.entity.EntityLivingBase.getEyeHeight()

The following are Jave code examples for showing how to use getEyeHeight() of the net.minecraft.entity.EntityLivingBase class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: CustomWorldGen   File: BlockPistonBase.java   Source Code and License Vote up 6 votes
public static EnumFacing getFacingFromEntity(BlockPos pos, EntityLivingBase p_185647_1_)
{
    if (MathHelper.abs((float)p_185647_1_.posX - (float)pos.getX()) < 2.0F && MathHelper.abs((float)p_185647_1_.posZ - (float)pos.getZ()) < 2.0F)
    {
        double d0 = p_185647_1_.posY + (double)p_185647_1_.getEyeHeight();

        if (d0 - (double)pos.getY() > 2.0D)
        {
            return EnumFacing.UP;
        }

        if ((double)pos.getY() - d0 > 0.0D)
        {
            return EnumFacing.DOWN;
        }
    }

    return p_185647_1_.getHorizontalFacing().getOpposite();
}
 
Example 2
Project: DecompiledMinecraft   File: EntityBlaze.java   Source Code and License Vote up 6 votes
protected void updateAITasks()
{
    if (this.isWet())
    {
        this.attackEntityFrom(DamageSource.drown, 1.0F);
    }

    --this.heightOffsetUpdateTime;

    if (this.heightOffsetUpdateTime <= 0)
    {
        this.heightOffsetUpdateTime = 100;
        this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F;
    }

    EntityLivingBase entitylivingbase = this.getAttackTarget();

    if (entitylivingbase != null && entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset)
    {
        this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D;
        this.isAirBorne = true;
    }

    super.updateAITasks();
}
 
Example 3
Project: DecompiledMinecraft   File: EntityBlaze.java   Source Code and License Vote up 6 votes
protected void updateAITasks()
{
    if (this.isWet())
    {
        this.attackEntityFrom(DamageSource.drown, 1.0F);
    }

    --this.heightOffsetUpdateTime;

    if (this.heightOffsetUpdateTime <= 0)
    {
        this.heightOffsetUpdateTime = 100;
        this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F;
    }

    EntityLivingBase entitylivingbase = this.getAttackTarget();

    if (entitylivingbase != null && entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset)
    {
        this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D;
        this.isAirBorne = true;
    }

    super.updateAITasks();
}
 
Example 4
Project: Halloween   File: EntityHaunter.java   Source Code and License Vote up 6 votes
@Override
protected void updateAITasks()
{
	if (this.isWet())
	{
		this.attackEntityFrom(DamageSource.DROWN, 1.0F);
	}

	--this.heightOffsetUpdateTime;

	if (this.heightOffsetUpdateTime <= 0)
	{
		this.heightOffsetUpdateTime = 100;
		this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F;
	}

	EntityLivingBase attackTarget = this.getAttackTarget();
	if (attackTarget != null && attackTarget.posY + (double)attackTarget.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset)
	{
		this.motionY += (0.3D - this.motionY) * 0.3D;
		this.isAirBorne = true;
	}

	super.updateAITasks();
}
 
Example 5
Project: BaseClient   File: BlockPistonBase.java   Source Code and License Vote up 6 votes
public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn)
{
    if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
    {
        double d0 = entityIn.posY + (double)entityIn.getEyeHeight();

        if (d0 - (double)clickedBlock.getY() > 2.0D)
        {
            return EnumFacing.UP;
        }

        if ((double)clickedBlock.getY() - d0 > 0.0D)
        {
            return EnumFacing.DOWN;
        }
    }

    return entityIn.getHorizontalFacing().getOpposite();
}
 
Example 6
Project: CustomWorldGen   File: EntityBlaze.java   Source Code and License Vote up 6 votes
protected void updateAITasks()
{
    if (this.isWet())
    {
        this.attackEntityFrom(DamageSource.drown, 1.0F);
    }

    --this.heightOffsetUpdateTime;

    if (this.heightOffsetUpdateTime <= 0)
    {
        this.heightOffsetUpdateTime = 100;
        this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F;
    }

    EntityLivingBase entitylivingbase = this.getAttackTarget();

    if (entitylivingbase != null && entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset)
    {
        this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D;
        this.isAirBorne = true;
    }

    super.updateAITasks();
}
 
Example 7
Project: pnc-repressurized   File: PneumaticCraftUtils.java   Source Code and License Vote up 5 votes
public static Pair<Vec3d, Vec3d> getStartAndEndLookVec(EntityLivingBase entity, float maxDistance) {
    Vec3d entityVec;
    if (entity.world.isRemote && entity instanceof EntityPlayer) {
        entityVec = new Vec3d(entity.posX, entity.posY + 1.6200000000000001D, entity.posZ);
    } else {
        entityVec = new Vec3d(entity.posX, entity.posY + entity.getEyeHeight() - (entity.isSneaking() ? 0.08 : 0), entity.posZ);
    }
    Vec3d entityLookVec = entity.getLook(1.0F);
    Vec3d maxDistVec = entityVec.addVector(entityLookVec.x * maxDistance, entityLookVec.y * maxDistance, entityLookVec.z * maxDistance);
    return new ImmutablePair<>(entityVec, maxDistVec);
}
 
Example 8
Project: HeroUtils   File: PlasmaArrow.java   Source Code and License Vote up 5 votes
public PlasmaArrow(World worldIn, EntityLivingBase shooter)
{
    this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ);
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
    }
}
 
Example 9
Project: Backmemed   File: EntityWitch.java   Source Code and License Vote up 5 votes
/**
 * 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)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.world.spawnEntityInWorld(entitypotion);
    }
}
 
Example 10
Project: Backmemed   File: EntityArrow.java   Source Code and License Vote up 5 votes
public EntityArrow(World worldIn, EntityLivingBase shooter)
{
    this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ);
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
    }
}
 
Example 11
Project: DecompiledMinecraft   File: EntitySnowman.java   Source Code and License Vote up 5 votes
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 12
Project: CustomWorldGen   File: EntityArrow.java   Source Code and License Vote up 5 votes
public EntityArrow(World worldIn, EntityLivingBase shooter)
{
    this(worldIn, shooter.posX, shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D, shooter.posZ);
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
    }
}
 
Example 13
Project: BaseClient   File: EntityWitch.java   Source Code and License Vote up 5 votes
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    if (!this.getAggressive())
    {
        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
        double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
        entitypotion.rotationPitch -= -20.0F;
        double d1 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);

        if (f >= 8.0F && !p_82196_1_.isPotionActive(Potion.moveSlowdown))
        {
            entitypotion.setPotionDamage(32698);
        }
        else if (p_82196_1_.getHealth() >= 8.0F && !p_82196_1_.isPotionActive(Potion.poison))
        {
            entitypotion.setPotionDamage(32660);
        }
        else if (f <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            entitypotion.setPotionDamage(32696);
        }

        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
Example 14
Project: DecompiledMinecraft   File: EntitySnowman.java   Source Code and License Vote up 5 votes
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 15
Project: DecompiledMinecraft   File: EntityWitch.java   Source Code and License Vote up 5 votes
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    if (!this.getAggressive())
    {
        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
        double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
        entitypotion.rotationPitch -= -20.0F;
        double d1 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);

        if (f >= 8.0F && !p_82196_1_.isPotionActive(Potion.moveSlowdown))
        {
            entitypotion.setPotionDamage(32698);
        }
        else if (p_82196_1_.getHealth() >= 8.0F && !p_82196_1_.isPotionActive(Potion.poison))
        {
            entitypotion.setPotionDamage(32660);
        }
        else if (f <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            entitypotion.setPotionDamage(32696);
        }

        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
Example 16
Project: BaseClient   File: EntitySnowman.java   Source Code and License Vote up 5 votes
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 17
Project: Halloween   File: EntityHallowitch.java   Source Code and License Vote up 5 votes
/**
 * Adapted from {@link net.minecraft.entity.monster.EntityWitch#attackEntityWithRangedAttack(EntityLivingBase, float)}
 */
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
	double x = target.posX + target.motionX - this.posX;
	double z = target.posZ + target.motionZ - this.posZ;
	double y = ((target.posY + (double)target.getEyeHeight() - 1.1D) - this.posY) + (double)(MathHelper.sqrt(x * x + z * z) * 0.2F);

	EntityCurseOrb entity = new EntityCurseOrb(this.world, this);
	entity.rotationPitch -= -20.0F;
	entity.setThrowableHeading(x, y, z, 0.75F, 8.0F);

	this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
	this.world.spawnEntity(entity);
}
 
Example 18
Project: uniquecrops   File: ItemEnderSnooker.java   Source Code and License Vote up 5 votes
private List<EntityLivingBase> acquireAllLookTargets(EntityLivingBase seeker, int distance, double radius) {
	
	if (distance < 0 || distance > MAX_DISTANCE) {
		distance = MAX_DISTANCE;
	}
	List<EntityLivingBase> targets = new ArrayList<EntityLivingBase>();
	Vec3d vec3 = seeker.getLookVec();
	double targetX = seeker.posX;
	double targetY = seeker.posY + seeker.getEyeHeight() - 0.10000000149011612D;
	double targetZ = seeker.posZ;
	double distanceTraveled = 0;

	while ((int) distanceTraveled < distance) {
		targetX += vec3.xCoord;
		targetY += vec3.yCoord;
		targetZ += vec3.zCoord;
		distanceTraveled += vec3.lengthVector();
		AxisAlignedBB bb = new AxisAlignedBB(targetX-radius, targetY-radius, targetZ-radius, targetX+radius, targetY+radius, targetZ+radius);
		List<EntityLivingBase> list = seeker.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb);
		for (EntityLivingBase target : list) {
			if (target != seeker && target.canBeCollidedWith() && isTargetInSight(vec3, seeker, target)) {
				if (!targets.contains(target)) {
					targets.add(target);
				}
			}
		}
	}
	return targets;
}
 
Example 19
Project: Backmemed   File: EntityThrowable.java   Source Code and License Vote up 4 votes
public EntityThrowable(World worldIn, EntityLivingBase throwerIn)
{
    this(worldIn, throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight() - 0.10000000149011612D, throwerIn.posZ);
    this.thrower = throwerIn;
}
 
Example 20
Project: Mods   File: TF2EventsClient.java   Source Code and License Vote up 4 votes
public static void renderBeam(EntityLivingBase ent, float partialTicks) {
	if (!ent.hasCapability(TF2weapons.WEAPONS_CAP, null))
		return;
	// System.out.println("Drawing");
	Entity healTarget = ent.world.getEntityByID(ent.getCapability(TF2weapons.WEAPONS_CAP, null).getHealTarget());
	if (healTarget != null) {
		Entity camera = Minecraft.getMinecraft().getRenderViewEntity();
		double cameraX = camera.prevPosX + (camera.posX - camera.prevPosX) * partialTicks;
		double cameraY = camera.prevPosY + (camera.posY - camera.prevPosY) * partialTicks;
		double cameraZ = camera.prevPosZ + (camera.posZ - camera.prevPosZ) * partialTicks;
		// System.out.println("rendering");
		double xPos1 = ent.prevPosX + (ent.posX - ent.prevPosX) * partialTicks;
		double yPos1 = ent.prevPosY + (ent.posY - ent.prevPosY) * partialTicks;
		double zPos1 = ent.prevPosZ + (ent.posZ - ent.prevPosZ) * partialTicks;
		double xPos2 = healTarget.prevPosX + (healTarget.posX - healTarget.prevPosX) * partialTicks;
		double yPos2 = healTarget.prevPosY + (healTarget.posY - healTarget.prevPosY) * partialTicks;
		double zPos2 = healTarget.prevPosZ + (healTarget.posZ - healTarget.prevPosZ) * partialTicks;
		double xDist = xPos2 - xPos1;
		double yDist = (yPos2 + (healTarget.getEntityBoundingBox().maxY - healTarget.getEntityBoundingBox().minY) / 2 + 0.1) - (yPos1 + ent.getEyeHeight() - 0.1);
		double zDist = zPos2 - zPos1;
		float f = MathHelper.sqrt(xDist * xDist + zDist * zDist);
		float fullDist = MathHelper.sqrt(xDist * xDist + yDist * yDist + zDist * zDist);
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder renderer = tessellator.getBuffer();
		GlStateManager.pushMatrix();
		GlStateManager.translate((float) xPos1 - cameraX, (float) (yPos1 + ent.getEyeHeight() - 0.1) - cameraY, (float) zPos1 - cameraZ);
		GL11.glRotatef((float) (Math.atan2(xDist, zDist) * 180.0D / Math.PI), 0.0F, 1.0F, 0.0F);
		GL11.glRotatef((float) (Math.atan2(yDist, f) * 180.0D / Math.PI) * -1, 1.0F, 0.0F, 0.0F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		GL11.glEnable(GL11.GL_BLEND);
		OpenGlHelper.glBlendFunc(770, 771, 1, 0);
		ClientProxy.setColor(TF2Util.getTeamColor(ent), 0.23f, 0, 0f, 1f);
		/*if (TF2Util.getTeamForDisplay(ent) == 0) {
			GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.23F);
		} else {
			GL11.glColor4f(0.0F, 0.0F, 1.0F, 0.23F);
		}*/
		renderer.begin(7, DefaultVertexFormats.POSITION);
		renderer.pos(-0.04, -0.04, 0).endVertex();
		renderer.pos(0.04, 0.04, 0).endVertex();
		renderer.pos(0.04, 0.04, fullDist).endVertex();
		renderer.pos(-0.04, -0.04, fullDist).endVertex();
		tessellator.draw();
		renderer.begin(7, DefaultVertexFormats.POSITION);
		renderer.pos(-0.04, -0.04, fullDist).endVertex();
		renderer.pos(0.04, 0.04, fullDist).endVertex();
		renderer.pos(0.04, 0.04, 0).endVertex();
		renderer.pos(-0.04, -0.04, 0).endVertex();
		tessellator.draw();
		renderer.begin(7, DefaultVertexFormats.POSITION);
		renderer.pos(0.04, -0.04, 0).endVertex();
		renderer.pos(-0.04, 0.04, 0).endVertex();
		renderer.pos(-0.04, 0.04, fullDist).endVertex();
		renderer.pos(0.04, -0.04, fullDist).endVertex();
		tessellator.draw();
		renderer.begin(7, DefaultVertexFormats.POSITION);
		renderer.pos(0.04, -0.04, fullDist).endVertex();
		renderer.pos(-0.04, 0.04, fullDist).endVertex();
		renderer.pos(-0.04, 0.04, 0).endVertex();
		renderer.pos(0.04, -0.04, 0).endVertex();
		tessellator.draw();
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		GL11.glDisable(GL11.GL_BLEND);
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
		GlStateManager.popMatrix();
	}
}