Removing Item From PickUpItemEvent

Discussion in 'Plugin Development' started by Warreo, Sep 11, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Warreo

    Ok... so I just can't figure this out... this is what I want to happen, When the player picks up an item (specifically Gold_Nugget) I went it to be picked up and removed from their Inventory no matter how many Gold_Nuggets they have in their Inventory... it seems way easier than it actually is, I just can't get it down. Any help would be really appreciated...

    Note: this method doesn't work...
    (the this.getAmountTotal(player, goldNug); gets the total amount in the Inventory)
    PHP:
    int goldNug Material.GOLD_NUGGET.getId();
    if(
    item == goldNug){
                    
    ItemStack pickedUp event.getItem().getItemStack();
                    
    int amt pickedUp.getAmount();
                    
    int total this.getAmountTotal(playergoldNug);
                    
    player.getInventory().removeItem(new ItemStack(Material.GOLD_NUGGETamt));
    Also, I have tried removing all GoldNugs in the Inventory and then try adding only the leftover amount (total - amt), but the problem is that the player still gets the amount of pickup items (even when pickedUp.setAmount(0); )
     
  2. Offline

    APlusMalware

    Couldn't you just cancel PickUpItemEvent if the item is a gold nugget? Or do you want something else?
     
  3. Offline

    Warreo

    I want them to pickup the item, get the amount that was picked up and then remove them. I need the amount that they picked up :p sorry should have clarified that.

    EDIT: even if you cancel the event after you get the amount of items, how do you remove them from the world?
     
  4. Offline

    APlusMalware

    Have you tried "event.getItem().remove();" to remove the item, and then cancel the event?
     
  5. Offline

    Warreo

    Thank you very much! I really appreciate it! I'm like uber face palming tho :p Thanks Again!
     
Thread Status:
Not open for further replies.

Share This Page