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

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

Introduction

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

Prototype

public int getCharge() 

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;//from w w w.j  a v a 2s.c om
    }
    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());
    }
}