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

How to remove dropped items and arrows?

Comments in 'Plugin Development' started by MyNameIsTriXz, Dec 3, 2015.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    How am I doing that?
  2. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    PHP:
    public function onDrop(PlayerDropItemEvent $event){
            
    $event->setCancelled();
        }
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I tried it but it doesnt really work :/
  4. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    public function onDrop(/pocketmine/event/player/PlayerDropItemEvent $event){
            
    $event->setCancelled();
        }
    USE IT :>
    Last edited: Dec 3, 2015
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    incorrect
    PHP:
    public function onDrop(\pocketmine\event\player\PlayerDropItemEvent $event){
    $event->setCancelled();
    }
    Last edited: Dec 3, 2015
  6. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Awu I forgot I was expedited
    thx
    /
    :)
    Last edited: Dec 3, 2015
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    He wants to know how to remove dropped items. Not prevent players from dropping items.
    You can do this by creating a repeating task.
    To remove the dropped items:
    PHP:
    Foreach($level->getEntities() as $entity) {
      if((!
    $entity instanceof Player) && (!$entity instanceof Monster) && (!entity instanceof Animal)) {
        
    $entity->close();
      }
    }
  8. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It's instanceof, not instance of. Doesn't work that way, bub.
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Auto correct on my phone. Whoops
    Vaivez66 likes this.

Share This Page

Advertisement