Search in sources :

Example 6 with EntityTippedArrow

use of net.minecraft.entity.projectile.EntityTippedArrow in project Pearcel-Mod by MiningMark48.

the class ItemPearcelArrow method createArrow.

public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter) {
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(worldIn, shooter);
    entitytippedarrow.setPotionEffect(stack);
    return entitytippedarrow;
}
Also used : EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow)

Example 7 with EntityTippedArrow

use of net.minecraft.entity.projectile.EntityTippedArrow in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ItemExplosiveArrow method createArrow.

@Override
public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter) {
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(worldIn, shooter) {

        private boolean doExpl = true;

        @Override
        public void onUpdate() {
            super.onUpdate();
        }

        @Override
        public boolean isImmuneToExplosions() {
            return true;
        }

        @Override
        protected void onHit(RayTraceResult raytraceResultIn) {
            super.onHit(raytraceResultIn);
            worldObj.createExplosion(this, posX, posY, posZ, 20F, true);
            kill();
        }
    };
    entitytippedarrow.setPotionEffect(stack);
    return entitytippedarrow;
}
Also used : EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) RayTraceResult(net.minecraft.util.math.RayTraceResult)

Example 8 with EntityTippedArrow

use of net.minecraft.entity.projectile.EntityTippedArrow in project SpongeCommon by SpongePowered.

the class EntityHuman method attackEntityWithRangedAttack.

@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    // Borrowed from Skeleton
    // TODO Figure out how to API this out
    final EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this);
    double d0 = target.posX - this.posX;
    double d1 = target.getEntityBoundingBox().minY + target.height / 3.0F - entitytippedarrow.posY;
    double d2 = target.posZ - this.posZ;
    double d3 = MathHelper.sqrt(d0 * d0 + d2 * d2);
    entitytippedarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, 14 - this.world.getDifficulty().getDifficultyId() * 4);
    // These names are wrong
    int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
    int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this);
    entitytippedarrow.setDamage(distanceFactor * 2.0F + this.rand.nextGaussian() * 0.25D + this.world.getDifficulty().getDifficultyId() * 0.11F);
    if (i > 0) {
        entitytippedarrow.setDamage(entitytippedarrow.getDamage() + i * 0.5D + 0.5D);
    }
    if (j > 0) {
        entitytippedarrow.setKnockbackStrength(j);
    }
    final ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);
    if (itemstack.getItem() == Items.TIPPED_ARROW) {
        entitytippedarrow.setPotionEffect(itemstack);
    }
    this.playSound(SoundEvents.ENTITY_ARROW_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntity(entitytippedarrow);
}
Also used : EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) ItemStack(net.minecraft.item.ItemStack)

Example 9 with EntityTippedArrow

use of net.minecraft.entity.projectile.EntityTippedArrow in project Tropicraft by Tropicraft.

the class EntityAshenHunter method attackEntityWithRangedAttack.

/**
 * Attack the specified entity using a ranged attack.
 *
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    ItemStack headGear = target.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
    if (headGear != null && headGear.getItem() != null) {
        if (headGear.getItem() instanceof ItemAshenMask)
            return;
    }
    EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, 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);
    entitytippedarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().getDifficultyId() * 4));
    entitytippedarrow.setDamage(1);
    entitytippedarrow.setKnockbackStrength(0);
    ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
    itemstack = PotionUtils.addPotionToItemStack(itemstack, PotionType.getPotionTypeForName("slowness"));
    entitytippedarrow.setPotionEffect(itemstack);
    entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 10));
    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntity(entitytippedarrow);
}
Also used : EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack) ItemAshenMask(net.tropicraft.core.common.item.armor.ItemAshenMask)

Example 10 with EntityTippedArrow

use of net.minecraft.entity.projectile.EntityTippedArrow in project Cavern2 by kegare.

the class EntityCavenicSkeleton method getArrow.

@Override
protected EntityArrow getArrow(float dist) {
    ItemStack heldOff = getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
    if (heldOff.getItem() == Items.SPECTRAL_ARROW) {
        EntitySpectralArrow arrow = new EntitySpectralArrow(this.world, this);
        arrow.setEnchantmentEffectsFromEntity(this, dist);
        return arrow;
    } else {
        EntityArrow arrow = new EntityCavenicArrow(world, this);
        arrow.setEnchantmentEffectsFromEntity(this, dist);
        if (heldOff.getItem() == Items.TIPPED_ARROW && arrow instanceof EntityTippedArrow) {
            ((EntityTippedArrow) arrow).setPotionEffect(heldOff);
        }
        return arrow;
    }
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) EntitySpectralArrow(net.minecraft.entity.projectile.EntitySpectralArrow) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityTippedArrow (net.minecraft.entity.projectile.EntityTippedArrow)14 ItemStack (net.minecraft.item.ItemStack)5 EntityArrow (net.minecraft.entity.projectile.EntityArrow)3 Random (java.util.Random)2 ItemArrow (net.minecraft.item.ItemArrow)2 PotionEffect (net.minecraft.potion.PotionEffect)2 ItemSentientBow (WayofTime.bloodmagic.item.soul.ItemSentientBow)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntitySpectralArrow (net.minecraft.entity.projectile.EntitySpectralArrow)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 IItemHandler (net.minecraftforge.items.IItemHandler)1 ItemAshenMask (net.tropicraft.core.common.item.armor.ItemAshenMask)1