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;
}
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));
}
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;
}
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;
}
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());
}
Aggregations