/** * ArrowLooseEvent handler. * <p> * Check, if a player tries to shoot an arrow. * Deny if: * - If the shooting happens in the colony * - player is neutral or hostile to colony * * @param event EntityItemPickupEvent */ @SubscribeEvent public void on(final ArrowLooseEvent event) { checkEventCancelation(Action.SHOOT_ARROW, event.getEntityPlayer(), event.getEntityPlayer().getEntityWorld(), event, event.getEntity().getPosition()); }
ItemStack stack = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer()); if(stack.getItem() instanceof IArrowContainer2){ IArrowContainer2 quiver = (IArrowContainer2) stack.getItem(); World world = event.getEntityPlayer().world; EntityArrow entityarrow = quiver.getArrowType(stack, world, event.getEntityPlayer(), f*3.0F); if(entityarrow!=null){ PlayerEventChild.QuiverArrowEvent.Firing arrowEvent = new PlayerEventChild.QuiverArrowEvent.Firing(event, stack, entityarrow); event.getBow().damageItem(arrowEvent.bowDamage, event.getEntityPlayer()); event.getEntityPlayer().addStat(StatList.getObjectUseStats(event.getBow().getItem()));
@SubscribeEvent public static void onArrowFire(ArrowLooseEvent event) World world = event.getEntityPlayer().getEntityWorld(); ItemStack stack = event.getBow(); EntityPlayer player = event.getEntityPlayer();
@SubscribeEvent public void onPlayerUpdate(ArrowLooseEvent event) { ItemStack stackBow = event.getBow(); int level = this.getCurrentLevelTool(stackBow); if (level <= 0) { return; } 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()); } }
EntityPlayer player = event.getEntityPlayer(); ItemStack arrowStack = findAmmo(player); World world = event.getWorld();