onProjectileLaunch issue

Discussion in 'Spigot Plugin Development' started by Astro, May 12, 2016.

  1. Hi there! I need help with a plugin I've been developing for quite awhile and I came across a rather odd issue. In 1.8 I had this code inside of a ProjectileLaunchEvent handler, which ran whenever a snowball was fired by a player.
    Code (Text):

    Player player = (Player) ball.getShooter();
    player.getInventory().addItem(new ItemStack(Material.SNOW_BALL, 1));
    Basically what this code did (and it worked too) was add another snowball to the inventory because one left each time it was fired-- simple enough-- and it provided the illusion of an infinite amount of snowballs coming from one.

    But with 1.9.2-- this happens (I also have a cooldown on it is why it's jittery.):
    well, edit: that gyazo gif doesn't work but basically it increments count every time it's attempted to be thrown and the stack size gets higher and higher, it even starts new stacks.

    So basically I need to fix this ASAP, and as a recap I just need one snowball with the illusion of an infinite stack effect without its count ever changing.
  2. You cancelled the event, and since the event is cancelled I believe that it wont take the snowball from your inventory. That is why the number keeps getting higher.
    • Agree Agree x 2