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
I'm not interested in activating sneaking. I'm interested in using item id's in onPlayerItemHeld event
Special for you... http://docs.pocketmine.net/dd/de9/classpocketmine_1_1event_1_1player_1_1_player_item_held_event.html
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. Thanks - GmWM
In deed, you can via Player Flags :3 The same as does with FloatingText: Hide a "NPC" but keep showing the nametag
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
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_FLAGS, Entity::DATA_FLAG_SNEAKING, true); }elseif($it->getID() === 0){//Air$p->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SNEAKING, false);}}
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.
EDITED! (Especially for SPOCKET Server). - Major Bug Fixed (When you type the /isneak on command you will get again the items. Fixed! ) - +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