Search in sources :

Example 21 with AbstractArrowEntity

use of net.minecraft.entity.projectile.AbstractArrowEntity in project SupersLegend by superworldsun.

the class Rupee method createArrow.

public AbstractArrowEntity createArrow(World worldIn, ItemStack stack, LivingEntity shooter) {
    ArrowEntity arrowentity = new ArrowEntity(worldIn, shooter);
    arrowentity.setPotionEffect(stack);
    return arrowentity;
}
Also used : AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity)

Example 22 with AbstractArrowEntity

use of net.minecraft.entity.projectile.AbstractArrowEntity in project SupersLegend by superworldsun.

the class BitBow method onItemRightClick.

public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    ItemStack stack = playerIn.getHeldItem(handIn);
    if (!worldIn.isRemote && !playerIn.isCreative() && playerIn.inventory.hasItemStack(new ItemStack(ItemList.rupee))) {
        playerIn.getCooldownTracker().setCooldown(this, 20);
        ArrowItem itemarrow = (ArrowItem) Items.ARROW;
        AbstractArrowEntity entityarrow = itemarrow.createArrow(worldIn, new ItemStack(Items.ARROW), playerIn);
        float arrowVelocity = 2.0F;
        entityarrow.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, arrowVelocity, 1.0F);
        entityarrow.setDamage(1);
        worldIn.addEntity(entityarrow);
        entityarrow.pickupStatus = AbstractArrowEntity.PickupStatus.DISALLOWED;
        for (int i = 0; i < playerIn.inventory.getSizeInventory(); ++i) {
            ItemStack stackslot = playerIn.inventory.getStackInSlot(i);
            if (stackslot.getItem() == ItemList.rupee) {
                stackslot.shrink(1);
                break;
            }
        }
    } else if (!worldIn.isRemote && playerIn.isCreative()) {
        ArrowItem itemarrow = (ArrowItem) Items.ARROW;
        AbstractArrowEntity entityarrow = itemarrow.createArrow(worldIn, new ItemStack(Items.ARROW), playerIn);
        float arrowVelocity = 2.0F;
        entityarrow.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, arrowVelocity, 1.0F);
        entityarrow.setDamage(1);
        worldIn.addEntity(entityarrow);
        entityarrow.pickupStatus = AbstractArrowEntity.PickupStatus.DISALLOWED;
    }
    return new ActionResult<ItemStack>(ActionResultType.PASS, playerIn.getHeldItem(handIn));
}
Also used : ActionResult(net.minecraft.util.ActionResult) ArrowItem(net.minecraft.item.ArrowItem) ItemStack(net.minecraft.item.ItemStack) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity)

Example 23 with AbstractArrowEntity

use of net.minecraft.entity.projectile.AbstractArrowEntity in project minecolonies by Minecolonies.

the class ItemFireArrow method createArrow.

@NotNull
@Override
public AbstractArrowEntity createArrow(@NotNull final World worldIn, @NotNull final ItemStack stack, final LivingEntity shooter) {
    AbstractArrowEntity entity = ModEntities.FIREARROW.create(worldIn);
    entity.setOwner(shooter);
    return entity;
}
Also used : AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with AbstractArrowEntity

use of net.minecraft.entity.projectile.AbstractArrowEntity in project minecolonies by Minecolonies.

the class CombatUtils method createArrowForShooter.

/**
 * Get an arrow entity for the given shooter
 *
 * @param shooter entity
 * @return arrow entity
 */
public static AbstractArrowEntity createArrowForShooter(final LivingEntity shooter) {
    AbstractArrowEntity arrowEntity = ModEntities.MC_NORMAL_ARROW.create(shooter.level);
    arrowEntity.setOwner(shooter);
    final ItemStack rangedWeapon = shooter.getItemInHand(Hand.MAIN_HAND);
    final Item rangedWeaponItem = rangedWeapon.getItem();
    if (rangedWeaponItem instanceof BowItem) {
        arrowEntity = ((BowItem) rangedWeaponItem).customArrow(arrowEntity);
    } else if (rangedWeaponItem instanceof ItemSpear) {
        arrowEntity = ModEntities.SPEAR.create(shooter.level);
    } else if (rangedWeaponItem instanceof TridentItem) {
        arrowEntity = EntityType.TRIDENT.create(shooter.level);
    }
    arrowEntity.setPos(shooter.getX(), shooter.getY() + 1, shooter.getZ());
    return arrowEntity;
}
Also used : Item(net.minecraft.item.Item) TridentItem(net.minecraft.item.TridentItem) BowItem(net.minecraft.item.BowItem) ItemSpear(com.minecolonies.coremod.items.ItemSpear) TridentItem(net.minecraft.item.TridentItem) BowItem(net.minecraft.item.BowItem) ItemStack(net.minecraft.item.ItemStack) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity)

Example 25 with AbstractArrowEntity

use of net.minecraft.entity.projectile.AbstractArrowEntity in project minecolonies by Minecolonies.

the class RaiderRangedAI method doAttack.

@Override
protected void doAttack(final LivingEntity target) {
    user.getNavigation().stop();
    // Setup arrow
    AbstractArrowEntity arrowEntity = CombatUtils.createArrowForShooter(user);
    arrowEntity.setBaseDamage(user.getAttribute(MOB_ATTACK_DAMAGE).getValue());
    if (flightCounter > 5) {
        ((CustomArrowEntity) arrowEntity).setPlayerArmorPierce();
        arrowEntity.setSecondsOnFire(200);
        arrowEntity.setBaseDamage(10);
    }
    if (user.getDifficulty() > ARROW_PIERCE_DIFFICULTY) {
        arrowEntity.setPierceLevel((byte) 2);
    }
    // Shoot arrow
    CombatUtils.shootArrow(arrowEntity, target, 10.0f);
    // Visuals
    user.swing(Hand.MAIN_HAND);
    SoundEvent attackSound = SoundEvents.SKELETON_SHOOT;
    if (arrowEntity instanceof ICustomAttackSound) {
        attackSound = ((ICustomAttackSound) arrowEntity).getAttackSound();
    }
    user.playSound(attackSound, (float) 1.0D, (float) getRandomPitch());
}
Also used : SoundEvent(net.minecraft.util.SoundEvent) ICustomAttackSound(com.minecolonies.api.entity.ICustomAttackSound) CustomArrowEntity(com.minecolonies.coremod.entity.CustomArrowEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity)

Aggregations

AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)42 ItemStack (net.minecraft.item.ItemStack)20 PlayerEntity (net.minecraft.entity.player.PlayerEntity)16 ArrowItem (net.minecraft.item.ArrowItem)8 LivingEntity (net.minecraft.entity.LivingEntity)6 ArrowEntity (net.minecraft.entity.projectile.ArrowEntity)6 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)6 Entity (net.minecraft.entity.Entity)5 Vector3d (net.minecraft.util.math.vector.Vector3d)5 PotionData (org.bukkit.potion.PotionData)5 PotionEntity (net.minecraft.entity.projectile.PotionEntity)4 SpectralArrowEntity (net.minecraft.entity.projectile.SpectralArrowEntity)4 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)4 Overwrite (org.spongepowered.asm.mixin.Overwrite)4 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)3 EnderPearlEntity (net.minecraft.entity.item.EnderPearlEntity)3 ExperienceBottleEntity (net.minecraft.entity.item.ExperienceBottleEntity)3 CreeperEntity (net.minecraft.entity.monster.CreeperEntity)3 GhastEntity (net.minecraft.entity.monster.GhastEntity)3 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)3