The event PlayerToggleFlightEvent only called if the player try double tap the jump button in creative (try to fly in creative) but is there any Packet which send to the player when he try it in survival?
question unclear, if you meant to allow fly in survival i remember there a setfly or something named similar
you can try creating a onmove listener and if player rapidly jump twice within X time then you can do whatever you want there
but i want to check if a player press the jump button if he is already in the air :=) i need to do this with packets but which packet i should check for this? does MCPE only send packets if player toggle jump in creative and spectator gamemode?
You just need to listen for PlayerActionPacket action 8 https://github.com/pmmp/PocketMine-...e/network/protocol/PlayerActionPacket.php#L38 Code: [13:30:54] [Server thread/DEBUG]: [PacketLogger] object(pocketmine\network\protocol\PlayerActionPacket)#12444 (9) { ["eid"]=> int(0) ["action"]=> int(8) ["x"]=> int(0) ["y"]=> int(0) ["z"]=> int(0) ["face"]=> int(0) ["isEncoded"]=> bool(false) ["offset"]=> int(7) ["buffer"]=> string(14) "24001000000000" } I don't know why mcpe sends no coordinates here though...
PHP: public function onDataPacketReceive(DataPacketReceiveEvent $event){ $packet = $event->getPacket(); if ($packet instanceof PlayerActionPacket) { $this->plugin->getLogger()->warning("DataPacket: PlayerActionPacket was received with action id: " . $packet->action); }} simple ^^ PHP: $packet->action only returns action ID 8 if i tap jump and if i am not in the air ^^
Set flying on jump. Haven't tested this tho. PHP: public function setFlyOnJump(PlayerToggleFlightEvent $event) { $player = $event->getPlayer(); if($event->isFlying() && $player->getGamemode() !== 1) { $player->setFlying(false); $jump = $player->getLocation()->multiply(0.2); $jump->y = 1.1; $player->setMotion($jump); $event->setCancelled(true); } elseif ($player->getGamemode() === 0) $player->setFlying(true); }
There's no packet being sent when pressing jump in Survival & you're not on the ground (unless you're using hacks)
PHP: public function onMove(PlayerMoveEvent $e){ $o = $e->getPlayer(); if($o->isSurvival() && $o->moveFlying()){ // not tested }}