Solved Player pickup certain amount of item

Discussion in 'Plugin Development' started by VerdentCz, Apr 17, 2015.

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

    VerdentCz

    Hi,
    I would love to ask if there is someone who knows how to let player pick up only certain amount of items. (for example during PlayerPickupItemEvent)

    Let's say there is ItemStack on the ground which has 20 pieces amount. And I want player to be able to pickup only 14 pieces and leave the rest on the ground.

    Is it possible somehow?
     
  2. Offline

    xmarinusx

    @VerdentCz
    I think the best way to do this would be as followed:

    - Cancel the PickupEvent.
    - Get the item from the event, get the ItemStack from it, modify its amount and set the new ItemStack to the item.
    - Manually add the wanted amount of items to the player's inventory.
     
  3. Offline

    VerdentCz

    @xmarinusx
    Thank you for your response:)

    To be honest, that was the only idea which I had. But I was wondering if there is some nicer solution.
    Well if no one else will response I will mark it as SOLVED.
     
    Last edited: Apr 17, 2015
Thread Status:
Not open for further replies.

Share This Page