Search in sources :

Example 1 with EntityTakumiPotion

use of com.tntmodders.takumi.entity.item.EntityTakumiPotion in project takumicraft by TNTModders.

the class EntityWitchCreeper method attackEntityWithRangedAttack.

/**
 * Attack the specified entity using a ranged attack.
 */
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    if (!this.isDrinkingPotion()) {
        double d0 = target.posY + 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 EntityTakumiPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -15.0F;
        entitypotion.setThrowableHeading(d1, d2 + f * 0.2F, d3, 0.75F, 8.0F);
        this.world.playSound(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(entitypotion);
    }
}
Also used : EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityTakumiPotion(com.tntmodders.takumi.entity.item.EntityTakumiPotion) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityTakumiPotion (com.tntmodders.takumi.entity.item.EntityTakumiPotion)1 EntityPotion (net.minecraft.entity.projectile.EntityPotion)1 ItemStack (net.minecraft.item.ItemStack)1 PotionType (net.minecraft.potion.PotionType)1