Using the following function with a registered listener, I noticed that the PlayerToggleSneakEvent is never called. PHP: public function onSneakToggle(PlayerToggleSneakEvent $event) { $this->getLogger()->info("Sneak Triggered!");} Can someone help me understand why this is occurring?
https://github.com/pmmp/PocketMine-...5ea301a/src/pocketmine/Player.php#L2286-L2303 if it really isn't called, other players wouldn't be able to see you sneaking
sorry to only answer with questions did you register your listener? did you check if other events work? did you check if your plugin is loaded?
Code: public function onSneak(\pocketmine\event\player\PlayerToggleSneakEvent $ev){ var_dump($ev); } works for me. Make sure you imported it correctly? idk
If it's working properly for you, then I don't know what could be wrong. I know that I registered the class as a Listener and move events are called....
PHP: <?phpnamespace jasonwynn10;/* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * @author jasonwynn10 * @link https://github.com/jasonwynn10/AirSneakBoots */use pocketmine\block\Air;use pocketmine\block\Block;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\player\PlayerToggleSneakEvent;use pocketmine\item\Armor;use pocketmine\item\DiamondBoots;use pocketmine\item\enchantment\Enchantment;use pocketmine\item\Item;use pocketmine\math\Vector3;use pocketmine\Player;use pocketmine\plugin\PluginBase;class Main extends PluginBase implements Listener { public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if(strtolower($command) == "boots") { if($sender instanceof Player) { $item = Item::get(Armor::DIAMOND_BOOTS); $item->setCustomName("Diamond Boots of Flight"); $ench = Enchantment::getEnchantment(Enchantment::TYPE_ARMOR_PROTECTION); $ench->setLevel(3); $item->addEnchantment($ench); #$sender->getInventory()->addItem($item); return $sender->getInventory()->setBoots($item); } return false; } return true; } public function onMove(PlayerMoveEvent $event) { $to = $event->getTo(); $from = $event->getFrom(); $p = $event->getPlayer(); if($p->getInventory()->getBoots() instanceof DiamondBoots and $p->getInventory()->getBoots()->getCustomName() == "Diamond Boots of Flight") { $this->getLogger()->debug("Named Item Found (Movement)"); if($p->isSneaking()) { for($x = -1; $x <= 1; $x++) { for($z = -1; $z <= 1; $z++) { $newVector = new Vector3($to->getX()+$x, $to->getY()-1, $to->getZ()+$z); $oldVector = new Vector3($from->getX()+$x, $from->getY()-1, $from->getZ()+$z); $block = $p->getLevel()->getBlock($newVector); if($block instanceof Air) { $p->getLevel()->setBlock($oldVector, Block::get(Block::AIR), false, false); $this->getLogger()->debug("Placed air under {$p->getName()}'s last position"); $p->getLevel()->setBlock($newVector, Block::get(Block::DIRT), false, false); // TODO set back to invisible bedrock $this->getLogger()->debug("Placed bedrock under {$p->getName()}'s next position"); } } } } } } public function onSneakToggle(PlayerToggleSneakEvent $event) { var_dump($event); if(!$event->getPlayer()->isSneaking() or $event->getPlayer()->getInventory()->getBoots() instanceof DiamondBoots) { if($event->getPlayer()->getInventory()->getBoots()->getCustomName() != "Diamond Boots of Flight") { return; } $this->getLogger()->debug("Named Item Found (Sneak Toggle)"); $p = $event->getPlayer(); for($x = $p->getX()-1;$x <= 1; $x++) { for($z = $p->getZ()-1;$z <= 1; $z++) { $vector = new Vector3($p->getX()+$x, $p->getY()-1, $p->getZ()+$z); $p->getLevel()->setBlock($vector, Block::get(Block::AIR), false, false); $this->getLogger()->debug("Placed air under {$p->getName()}'s last position"); } } } }} Maybe someone can pick out an error I may have missed?