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

onPlayerItemHeld Event

Comments in 'Plugin Development' started by Kvetinac97, Jun 12, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hallo.

    How can I use onPlayerItemHeld event?

    What I want to my plugin do:

    => when you hold redstone, you activate sneaking
    => when you hold iron sword, you disable it.

    I know how set sneaking, but i don't know how get item ID
    (if I know it I can do if($id == 311) {action}

    PS: Sorry for bad English
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    I don't think you can active sneaking via PocketMine.
    hoyinm14mc likes this.
  3. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I'm not interested in activating sneaking. I'm interested in using item id's in onPlayerItemHeld event
    Minecrafter9203 and TheKofola12 like this.
  4. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    iksaku likes this.
  5. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    There you go. ItemSneaking Plugin for you! :) PM me if you want to change it. (Or change it by yourself.)
    Commands:
    - /isneaking on -> Enable the ItemSneaking Plugin and also gives you the Redstone and the Iron Sword.
    - /isneaking off -> Disable the ItemSneaking Plugin and removes Redstone and the Iron Sword from players inventory.

    Permissions:
    - isneaking.command -> Permission for /isneaking commands.
    - isneaking.use -> Permission to use the plugin (the items more exactly).

    Iron Sword - Sneaking Off.
    Redstone - Sneaking On.

    I hope this is what you need. :D
    Thanks - GmWM

    Attached Files:

    PEMapModder and Falk like this.
  6. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    =,=
    PEMapModder likes this.
  7. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    You know, its MAGIC! :D
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    GmWM, great work!
  9. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Thank you! :D
  10. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    In deed, you can via Player Flags :3 The same as does with FloatingText: Hide a "NPC" but keep showing the nametag
    PEMapModder likes this.
  11. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    yes you can ...
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    My question is, does it activate real sneaking or is it simply sneaking shown to others?
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It really lets you sneak. You walk slower than normal
  14. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Check the plugin, it lets you sneak for real. Someone already submitted a plugin like this but it needs approval.
    Instead of using commands I made this little concept, whenever you hold a specified item, you will sneak. Its simple. Also, check the source code if you want.(DevTools)

    Thanks - GmWM
    Last edited: Jun 13, 2015
    Legoboy0215 likes this.
  15. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Touch the ground with compass to sneak. Touch the ground with empty/bare hand to unsneak.
    PHP:
    public function onTouch(PlayerInteractEvent $e){
    $p $e->get player();
    $it $e->getItem();

    if(
    $it->getID() === 345){//Compass
     
       
    $p->setDataFlag(Entity::DATA_FLAGSEntity::DATA_FLAG_SNEAKINGtrue);

      }elseif(
    $it->getID() === 0){//Air
    $p->setDataFlag(Entity::DATA_FLAGSEntity::DATA_FLAG_SNEAKINGfalse);

    }
    }
  16. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    I remember trying sneaking on 0.9.0 with ModPE - the player that was sneaking could use it and see it but others couldn't see it.
  17. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    ModPE its not PocketMine.. :|
    PEMapModder likes this.
  18. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    EDITED! (Especially for SPOCKET Server).

    - Major Bug Fixed (When you type the /isneak on command you will get again the items. Fixed! :D)
    - +others.

    Don't use the previous attached file. Use this one instead.

    Commands:
    - /isneak on -> Enable the ItemSneaking Plugin and also gives you the Slimeball for sneaking.
    - /isneak off -> Disable the ItemSneaking Plugin and removes Slimeball from players inventory.

    Permissions:
    - isneak.command -> Permission for /isneak commands.
    - isneak.use -> Permission to use the plugin (the items more exactly).

    Now you only need to hold the Slimeball in oder to sneak. (And air for sneak off).

    Also I'm waiting approval for this plugin.
    Thanks for using ItemSneaking - GmWM

    Attached Files:

    Last edited: Jun 13, 2015
  19. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then why don't you submit it instead of posting it here!

Share This Page

Advertisement