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

No drop

Comments in 'Plugin Development' started by AndrewBit, Dec 28, 2015.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Hi!
    There is any way for evite items in the ground?
    And, yes, I try cancelling PlayerDropEvent, but it doesn't cancel the drop when player die! :eek:
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Hmm another way is to scan the level for entities on a PlayerDeathEvent. The code:

    PHP:
    public function onDeath(PlayerDeathEvent $ev){

    $ents $event->getPlayer()->getLevel()->getEntities();

    foreach(
    $ents as $ent){

    $ent->close();

    }}
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $ev->setDrops(array());
    Last edited: Dec 28, 2015
    AndrewBit likes this.
  4. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I forgot, that 1vs1 uses that, yep thats easier....
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    :facepalm:
    That will basically kick all players in that world and kill all other entities there.
  6. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    xD
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Wait...
    PHP:
    $ents$event->getEntity()->getLevel()->getEntities();
    $event->setDrops($ents);
    will work? I'm a bit confused.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    nope
    $event->setDrops(array());
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    The array has to have Item instances inside.
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    How do you know? xD
    shorthand
    PHP:
    $event->setDrops([]);
  11. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Look at the source and try it without.
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Item can also be instance of dropped entity. And as there is no information what entities are currently on that level you don't know will it contain Item object inside or not.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    pocketmine\item\Item and pocketmine\entity\Item are different. The former is a real item, only representing an item, and the latter is an entity (dropped item).

    Was there any argument with your second sentence? Whether it contains items or not, it must be an array of only pocketmine\item\Item.
    1. pocketmine\entity\Item isn't an accepted object.
    2. It must be all items. Obviously that array will return plaeyrs.
  14. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PHP:
     if($ent instanceof pocketmine\entity\Item){ 
  15. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    *facepalm*, you write "*faceplalm* with *
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Is there even a difference...
    write \pocketmine\entity\Item instead if you are referencing the FQN inline.
    MyNameIsTriXz likes this.
  17. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I was fooling around manupulating with identical class names.

Share This Page

Advertisement