Pocketmine-mp: Argument 1 passed to pocketmine\utils\Binary::writeVarLong_64() must be of the type integer

Created on 5 Jun 2017  路  17Comments  路  Source: pmmp/PocketMine-MP

Issue description




Since the new update, my server crashes quite often with this error message attached down.
Sounds similar like some previous issues like #990.
It looks like it's related to my FloatingText plugin, but I'm not sure yet.

OS and versions

  • PocketMine-MP: d586ad03ec36c236356056fc3cc0f371e855d6e9
  • PHP: 7.0.19
  • Server OS: Debian 8
  • Game version: PE

Crashdump, backtrace or other files

PocketMine-MP Crash Dump Mon Jun 5 11:17:30 CEST 2017

Error: Argument 1 passed to pocketmine\utils\Binary::writeVarLong_64() must be of the type integer, null given, called in phar:///home/surva/network/phars/PocketMine-MP.phar/src/pocketmine/utils/Binary.php on line 650
File: /src/pocketmine/utils/Binary
Line: 677
Type: notice

Code:
[668]       return self::writeUnsignedVarLong_32($v);
[669]   }
[670] 
[671]   /**
[672]    * 64-bit VarLong encoder.
[673]    *
[674]    * @param int $v
[675]    * @return string
[676]    */
[677]   public static function writeVarLong_64(int $v) : string{
[678]       return self::writeUnsignedVarLong_64(($v << 1) ^ ($v >> 63));
[679]   }
[680] 
[681]   /**
[682]    * Writes a 64-bit integer as a variable-length long
[683]    *
[684]    * @param int|string $v
[685]    * @return string up to 10 bytes
[686]    */
[687]   public static function writeUnsignedVarLong($v) : string{

Backtrace:
#0 /src/pocketmine/utils/Binary(650): pocketmine\utils\Binary::writeVarLong_64(NULL )
#1 /src/pocketmine/utils/BinaryStream(333): pocketmine\utils\Binary::writeVarLong(NULL )
#2 /src/pocketmine/network/mcpe/protocol/DataPacket(268): pocketmine\utils\BinaryStream->putVarLong(NULL )
#3 /src/pocketmine/network/mcpe/protocol/AddEntityPacket(68): pocketmine\network\mcpe\protocol\DataPacket->putEntityUniqueId(NULL )
#4 /src/pocketmine/network/mcpe/RakLibInterface(193): pocketmine\network\mcpe\protocol\AddEntityPacket->encode(boolean)
#5 /src/pocketmine/Player(1081): pocketmine\network\mcpe\RakLibInterface->putPacket(pocketmine\Player object, pocketmine\network\mcpe\protocol\AddEntityPacket object, boolean , boolean )
#6 /Pets_v1.0.0.phar/src/surva/pets/entities/Pet(51): pocketmine\Player->dataPacket(pocketmine\network\mcpe\protocol\AddEntityPacket object)
#7 /src/pocketmine/Player(913): surva\pets\entities\Pet->spawnTo(pocketmine\Player object)
#8 /src/pocketmine/Player(861): pocketmine\Player->doFirstSpawn(boolean)
#9 /src/pocketmine/Player(1743): pocketmine\Player->sendNextChunk(boolean)
#10 /src/pocketmine/Server(2420): pocketmine\Player->checkNetwork(boolean)
#11 /src/pocketmine/Server(2182): pocketmine\Server->tick(boolean)
#12 /src/pocketmine/Server(2064): pocketmine\Server->tickProcessor(boolean)
#13 /src/pocketmine/Server(1646): pocketmine\Server->start(boolean)
#14 /src/pocketmine/PocketMine(501): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar:///home/surva/network/phars/PocketMine-MP.phar/, string /home/surva/network/servers/lobby/, string /home/surva/network/servers/lobby/plugins/)
#15 (1): require_once(string phar:///home/surva/network/phars/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

PocketMine-MP version: 1.6.2dev #0 [Protocol 113; API 3.0.0-ALPHA5]
Git commit: 0000000000000000000000000000000000000000
uname -a: Linux surva.net 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64
PHP Version: 7.0.18
Zend version: 3.0.0
OS : Linux, linux

Loaded plugins:
FastInteract 1.0.0 by  for API(s) 3.0.0
Network 1.0.0 by  for API(s) 3.0.0
BanSystem 1.0.1 by  for API(s) 3.0.0
Pets 1.0.0 by  for API(s) 3.0.0
Permissions 1.0.0 by  for API(s) 2.0.0, 3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4, 3.0.0-ALPHA5
VoteRank 1.0.1 by  for API(s) 3.0.0
ChatFilter 1.0.0 by  for API(s) 3.0.0
QueryCount 1.0.0 by  for API(s) 3.0.0
Friends 1.0.0 by  for API(s) 3.0.0
Core 1.0.0 by  for API(s) 3.0.0
Localization 1.0.2 by  for API(s) 3.0.0
Auth 1.0.0 by  for API(s) 3.0.0
Particles 1.0.0 by  for API(s) 3.0.0
RandomParkour 1.0.0 by  for API(s) 3.0.0
DiscordDeployment 1.0.2 by  for API(s) 3.0.0
Economy 1.0.0 by  for API(s) 3.0.0
VIP 1.0.0 by  for API(s) 3.0.0
Statistics 1.0.0 by  for API(s) 3.0.0
FloatingText 1.1.0 by  for API(s) 3.0.0
Core Invalid

Most helpful comment

tbh I'd probably better change them all for consistency's sake... I only changed the ones that have both unique and runtime IDs.

All 17 comments

eid needs to be updated to entityRuntimeId for that packet... have you updated your plugins?

Yes, I'm quite sure I've done this in every plugin

#6 /Pets_v1.0.0.phar/src/surva/pets/entities/Pet(51): pocketmine\Player->dataPacket(pocketmine\network\mcpe\protocol\AddEntityPacket object)
#7 /src/pocketmine/Player(913): surva\pets\entities\Pet->spawnTo(pocketmine\Player object)

floating text? :/

Sorry, didn't saw this

But it's ->entityRuntimeId there:

bildschirmfoto 2017-06-05 um 14 02 02

what is $this->getID() returning?

int(57) - but it doesn't crash when I call spawnTo()

The only explanation I can see is a fault with your code... do you have source-code anywhere public?

Sorry, it's not public - I'm just getting the suspicion that I've mixed up the PHARs because it worked before the update

Looks like, I'm very sorry for wasting your time

Same for me : (code)

$pk = new MovePlayerPacket ();
$pk->eid = $entity->getId();
$pk->x = $player->getX();
$pk->y = $player->getY();
$pk->z = $player->getZ();
$pk->yaw = $player->getYaw();
$pk->pitch = $player->getPitch();
foreach ($player->getLevel()->getPlayers() as $players) {
$players->dataPacket($pk);

}

Knowing that code works perfectly before

`[12:19:56] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'TESTER': Argument 1 passed to pocketmine\utils\Binary::writeLFloat() must be of the type float, null given, called in phar://G:/PocketMine/PocketMine-MP.phar/src/pocketmine/utils/BinaryStream.php on line 160 on Testtester\Movement

`

Knowing that code works perfectly before

no. it would silently not behave as expected when core changes were made. Strict types will now highlight these issues when they occur.

Your problem is that you haven't specified the bodyYaw field.

And you have $pk->eid instead of $pk->entityRuntimeId.

I think it's OK in EntityMovePacket, or am I wrong?

tbh I'd probably better change them all for consistency's sake... I only changed the ones that have both unique and runtime IDs.

@dktapps Using $pk->yaw and $pk->pitch as 0.0 instead of $this->yaw and $this->pitch solved me my problem. The problem could be solved by calling parent::__construct() in Entity because yaw and pitch values in Location are defined in the constructor.

@Muqsit they are already set when the fields are read from the entity NBT... as I said he simply forgot to specify the bodyYaw field.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XDqrkneZ picture XDqrkneZ  路  3Comments

L3ice picture L3ice  路  3Comments

Ox531 picture Ox531  路  3Comments

TheDiamondYT1 picture TheDiamondYT1  路  3Comments

nmo0ory picture nmo0ory  路  3Comments