1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved AdventureSettingsPacket

Discussion in 'Development' started by Khaled, Apr 20, 2020.

  1. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    code:
    PHP:
    $pk = new AdventureSettingsPacket();
    $pk->setFlag(AdventureSettingsPacket::WORLD_IMMUTABLEtrue);
    $pk->setFlag(AdventureSettingsPacket::AUTO_JUMPfalse);
    $player->dataPacket($pk);    
    error:
    Code:
    "Argument 1 passed to pocketmine\utils\BinaryStream::putLLong() must be of the type int, null given, called in C:\Users\ziad0\OneDrive\Desktop\PocketMine\PocketMine-MP\src\pocketmine\network\mcpe\protocol\AdventureSettingsPacket.php on line 93" (EXCEPTION) in "vendor/pocketmine/binaryutils/src/BinaryStream" at line 307
    Please help me
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    As we can see here, line 93 of the AdventureSettingsPacket encodes the entityUniqueId of the player.
    You didn't add that in your code, that's why it's null and thus crashes because putLLong doesn't accept null.

    We can see a reference implementation in the Player.php file:
    https://github.com/pmmp/PocketMine-...87565a7a91575/src/pocketmine/Player.php#L1418

    Adapting this to your code would look like this:
    PHP:
    $pk = new AdventureSettingsPacket();
    $pk->setFlag(AdventureSettingsPacket::WORLD_IMMUTABLEtrue);
    $pk->setFlag(AdventureSettingsPacket::AUTO_JUMPfalse);
    $pk->entityUniqueId $player->getId();
    $player->dataPacket($pk);
     
  3. lunix

    lunix Spider

    Messages:
    8
    As @HimbeersaftLP pointed out, you need to set the player ID.
    Though I do not quite understand why (& how) you work with packets already while not understanding such a simple error message.

    Your error says a method called
    PHP:
    pocketmine\utils\BinaryStream::putLLong()
    wants an integer as the first argument, but received null. If you take a look at where it is called, you see this:
    PHP:
    $this->putLLong($this->entityUniqueId);
    With a little bit of logic understanding, you will now know that
    PHP:
    $this->entityUniqueId
    is null, or "not set", resulting in you having to set it.
     
    HimbeersaftLP likes this.
  4. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Yeah actually i figured it out yesterday i didn't have time to set this thread as solved, but thank you guys anyway! :)
     
    HimbeersaftLP likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.