Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get Item entity on PlayerDropItemEvent

Comments in 'Plugin Development' started by thebigsmileXD, Dec 29, 2015.

  1. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    To get the Item\item you use $event->getItem()
    How to get the actual entity\Item that drops?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Should be something like $event->getDrops(). That should return an array with all Items inside.
  3. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    No. These functions are available:
    PHP:
            $event->getEventName();
            
    $event->getHandlers();
            
    $event->getItem();
            
    $event->getPlayer();
            
    $event->isCancelled();
            
    $event->setCancelled($value);
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The item isn't dropped yet in PlayerDropItemEvent, how could there be an entity for you?
    He wants the entity.
  5. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Ah, i see. So i have to use ItemSpawnEvent?
    And how to get if that spawned item is the thrown one?
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Misread, sorry. I somehow thought about PlayerDeathEvent.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There doesn't seem to be a way to get it without hacks like catching the spawn item packets :(
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I think he misunderstood himself, i supose he actually wants inventory Item object.
  9. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Read the title."get item entity"
    Also.. Can't even catch the packets.. oh man..
    PEMapModder likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Simplest solution, but do it at the HIGHEST (or MONITOR, since this is an edge case, but normally you should not modify the event at MONITOR priority) priority: cancel the event, spawn the entity yourself.
    Then other plugins with a MONITOR level handler will think that the item didn't drop. Bad solution.

Share This Page

Advertisement