use of WayofTime.bloodmagic.item.soul.ItemSentientBow in project BloodMagic by WayofTime.
the class EntitySentientSpecter method attackEntityWithRangedAttack.
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) {
EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity);
if (arrowEntity != null) {
List<PotionEffect> effects = getPotionEffectsForArrowRemovingDuration(0.2f);
for (PotionEffect eff : effects) {
arrowEntity.addEffect(eff);
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(arrowEntity);
}
} else {
// TODO: Change to an arrow created by the Sentient Bow
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.getEntityWorld(), 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(d0 * d0 + d2 * d2);
// TODO: Yes, it is an accurate arrow. Don't be hatin'
entitytippedarrow.shoot(d0, d1 + d3 * 0.2, d2, 1.6F, 0);
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F));
if (i > 0) {
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D);
}
if (j > 0) {
entitytippedarrow.setKnockbackStrength(j);
}
boolean burning = this.isBurning();
burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (burning) {
entitytippedarrow.setFire(100);
}
if (// TODO: Add potion effects to the arrows
true) {
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.getEntityWorld().spawnEntity(entitytippedarrow);
}
}
Aggregations