Search in sources :

Example 1 with ItemSpear

use of com.minecolonies.coremod.items.ItemSpear 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 2 with ItemSpear

use of com.minecolonies.coremod.items.ItemSpear in project minecolonies by ldtteam.

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)

Aggregations

ItemSpear (com.minecolonies.coremod.items.ItemSpear)2 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)2 BowItem (net.minecraft.item.BowItem)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 TridentItem (net.minecraft.item.TridentItem)2