Hey i want use LevelEventPackt on onJoin But i have this error PHP: [19:36:38] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'Core v1': Argument 1 passed to pocketmine\utils\BinaryStream::putVarInt() must be of the type integer, null given, called in phar:///home/arma/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php on line 128 on Core\Main code: PHP: $pk = new LevelEventPacket(); $x = $player->getX(); $z = $player->getZ(); $y = $player->getY(); $pk->x = $x; $pk->y = $y; $pk->z = $z; $pk->evid = LevelEventPacket::EVENT_GUARDIAN_CURSE; $player->dataPacket($pk);
1. LevelEventPacket doesn't take x, y, and z anymore. It takes the position as a whole. 2. You're missing the data parameter. So assuming that $player is an instance of Player. PHP: $pk = new LevelEventPacket();$pk->position = $player;$pk->data = 0;$pk->evid = LevelEventPacket::EVENT_GUARDIAN_CURSE;$player->dataPacket($pk);
You might need to delay it with a task. Test if that's the issue by putting that code under a different event, such as BlockBreakEvent or BlockPlaceEvent.