Search in sources :

Example 1 with EntityInvisArrow

use of pokefenn.totemic.entity.projectile.EntityInvisArrow in project Totemic by TeamTotemic.

the class EntityBaykok method attackEntityWithRangedAttack.

@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    EntityInvisArrow arrow = new EntityInvisArrow(world, this);
    double dx = target.posX - this.posX;
    double dy = target.getEntityBoundingBox().minY + target.height / 3.0F - arrow.posY;
    double dz = target.posZ - this.posZ;
    double xzdist = MathHelper.sqrt(dx * dx + dz * dz);
    float velocity = 2.0F + 1.0F * distanceFactor;
    float inaccuracy = 4.5F - world.getDifficulty().getDifficultyId();
    arrow.shoot(dx, dy + 0.125 * xzdist, dz, velocity, inaccuracy);
    arrow.setDamage(2.0 * distanceFactor + 1.0 + 0.25 * rand.nextGaussian() + 0.4 * world.getDifficulty().getDifficultyId());
    playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F));
    world.spawnEntity(arrow);
}
Also used : EntityInvisArrow(pokefenn.totemic.entity.projectile.EntityInvisArrow)

Example 2 with EntityInvisArrow

use of pokefenn.totemic.entity.projectile.EntityInvisArrow in project Totemic by TeamTotemic.

the class ItemBaykokBow method onPlayerStoppedUsing.

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int timeLeft) {
    if (!(entity instanceof EntityPlayer))
        return;
    EntityPlayer player = (EntityPlayer) entity;
    boolean infinity = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
    ItemStack arrow = findAmmo0(player);
    int chargeTicks = this.getMaxItemUseDuration(stack) - timeLeft;
    chargeTicks = ForgeEventFactory.onArrowLoose(stack, world, player, chargeTicks, !arrow.isEmpty() || infinity);
    if (chargeTicks < 0)
        return;
    if (!arrow.isEmpty() || infinity) {
        if (arrow.isEmpty())
            arrow = new ItemStack(Items.ARROW);
        float charge = getArrowVelocity(chargeTicks);
        if (charge >= 0.1) {
            // Forge: Fix consuming custom arrows.
            boolean flag1 = infinity && arrow.getItem() instanceof ItemArrow;
            if (!world.isRemote) {
                ItemArrow itemarrow = ((ItemArrow) (arrow.getItem() instanceof ItemArrow ? arrow.getItem() : Items.ARROW));
                EntityArrow entityarrow;
                if (// Mundane arrows will become invisible
                itemarrow == Items.ARROW) {
                    entityarrow = new EntityInvisArrow(world, player);
                } else {
                    entityarrow = itemarrow.createArrow(world, arrow, entity);
                }
                if (entityarrow.getDamage() < 2.5)
                    entityarrow.setDamage(2.5);
                entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, charge * 4.0F, 1.0F);
                if (charge == 1.0F)
                    entityarrow.setIsCritical(true);
                int power = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
                if (power > 0)
                    entityarrow.setDamage(entityarrow.getDamage() + power * 0.5D + 0.5D);
                int punch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
                if (punch > 0)
                    entityarrow.setKnockbackStrength(punch);
                if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
                    entityarrow.setFire(100);
                stack.damageItem(1, player);
                if (flag1)
                    entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                world.spawnEntity(entityarrow);
            }
            world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + charge * 0.5F);
            if (!flag1) {
                arrow.shrink(1);
                if (arrow.isEmpty())
                    player.inventory.deleteStack(arrow);
            }
            player.addStat(StatList.getObjectUseStats(this));
        }
    }
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityInvisArrow(pokefenn.totemic.entity.projectile.EntityInvisArrow) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ItemArrow(net.minecraft.item.ItemArrow)

Aggregations

EntityInvisArrow (pokefenn.totemic.entity.projectile.EntityInvisArrow)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityArrow (net.minecraft.entity.projectile.EntityArrow)1 ItemArrow (net.minecraft.item.ItemArrow)1 ItemStack (net.minecraft.item.ItemStack)1