Java Code Examples for net.minecraft.entity.projectile.EntityArrow.setThrowableHeading()

The following are Jave code examples for showing how to use setThrowableHeading() of the net.minecraft.entity.projectile.EntityArrow 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: Backmemed   File: AbstractSkeleton.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)
{
    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);
}