PlayerInventoryAddEvent.setCancelled() has a small bug when adding more than one stacks

  • This is the code I am using:


    Java
    @EventMethod
    public void onItemPickUp(PlayerInventoryAddEvent event){
    Player player = event.getPlayer();
    Item item = event.getItem();
    if (item.getName().equals("tnt")){
    event.setCancelled(true);
    player.sendTextMessage(item.getName() + " removed!");
    }
    }

    Now to explain:
    1) When I try to pick up items from the ground (F key) I cannot as expected.
    2) When I spawn items through the console if I spawn 1 stack or less of items (e.g. 8 for tnt) they do not appear in my inventory
    3) When I spawn say 9 items (which is more than 1 stack for tnt), 8 of them appear in my inventory while the 9th does not. Same happens if I craft 9+ items in the crafting bench.


    Hope it is not that hard for you to patch with the next update @red51 we all know how busy you are trying to get the player model update to us as soon as possible :)

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!