Example usage for net.minecraftforge.event.entity.player ArrowLooseEvent getBow

List of usage examples for net.minecraftforge.event.entity.player ArrowLooseEvent getBow

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity.player ArrowLooseEvent getBow.

Prototype

@Nonnull
    public ItemStack getBow() 

Source Link

Usage

From source file:com.lothrazar.cyclicmagic.enchant.EnchantMultishot.java

License:Open Source License

@SubscribeEvent
public void onPlayerUpdate(ArrowLooseEvent event) {
    ItemStack stackBow = event.getBow();
    int level = this.getCurrentLevelTool(stackBow);
    if (level <= 0) {
        return;/*w  w  w.  j a v  a 2  s  .  co  m*/
    }
    EntityPlayer player = event.getEntityPlayer();
    World worldIn = player.world;
    if (worldIn.isRemote == false) {
        float charge = ItemBow.getArrowVelocity(stackBow.getMaxItemUseDuration() - event.getCharge());
        //use cross product to push arrows out to left and right
        Vec3d playerDirection = UtilEntity.lookVector(player.rotationYaw, player.rotationPitch);
        Vec3d left = playerDirection.crossProduct(new Vec3d(0, 1, 0));
        Vec3d right = playerDirection.crossProduct(new Vec3d(0, -1, 0));
        spawnArrow(worldIn, player, stackBow, charge, left.normalize());
        spawnArrow(worldIn, player, stackBow, charge, right.normalize());
    }
}