Pocketmine-mp: Argument 1 passed to pocketmine\utils\Binary::writeLFloat() must be of the type float, string given.

Created on 7 Jun 2017  路  9Comments  路  Source: pmmp/PocketMine-MP

Issue description

When I teleport a player, I have this error.

Steps to reproduce the issue

Teleport a player with the function teleport() and using an instance of Position as the first argument like that : $player->teleport(new Position($x, $y, $z, $level));

OS and versions

  • PocketMine-MP: c445db421f4e4ed37935eb2948cf43767c9c2850
  • PHP: 7.0.14
  • Server OS: Windows 10
  • Game version: PE 1.1.0

Crashdump, backtrace or other files

public function execute(CommandSender $sender, $currentAlias, array $args) { $sender->teleport(new Position(560, 354, 780, $sender->getLevel())); }

Core Invalid

Most helpful comment

That's because they have to be ints. You're simply casting the strings to ints.

All 9 comments

Please enable debug output and paste a backtrace.

I enable debug and I have these messages in the server.log :
#0 /src/pocketmine/utils/BinaryStream(160): pocketmine\utils\Binary::writeLFloat(string 425.2061)

#1 /src/pocketmine/network/mcpe/protocol/DataPacket(354): pocketmine\utils\BinaryStream->putLFloat(string 425.2061)

#2 /src/pocketmine/network/mcpe/protocol/MovePlayerPacket(68): pocketmine\network\mcpe\protocol\DataPacket->putVector3f(string 425.2061, double 67.62, string 266.9693)

#3 /src/pocketmine/network/mcpe/RakLibInterface(193): pocketmine\network\mcpe\protocol\MovePlayerPacket->encode(boolean)

#4 /src/pocketmine/Player(1081): pocketmine\network\mcpe\RakLibInterface->putPacket(pocketmine\Player object, pocketmine\network\mcpe\protocol\MovePlayerPacket object, boolean , boolean )

#5 /src/pocketmine/Player(3966): pocketmine\Player->dataPacket(pocketmine\network\mcpe\protocol\MovePlayerPacket object)

#6 /src/pocketmine/Player(4020): pocketmine\Player->sendPosition(pocketmine\Player object, integer 348, integer 0, integer 1)

#7 /src/pocketmine/Player(1712): pocketmine\Player->checkTeleportPosition(boolean)

#8 /src/pocketmine/level/Level(733): pocketmine\Player->onUpdate(integer 983)

#9 /src/pocketmine/Server(2262): pocketmine\level\Level->doTick(integer 983)

#10 /src/pocketmine/Server(2414): pocketmine\Server->checkTickUpdates(integer 983, double 1496864356.1345)

#11 /src/pocketmine/Server(2179): pocketmine\Server->tick(boolean)

#12 /src/pocketmine/Server(2061): 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/.../PocketMine-MP.phar/, string /home/.../, string /home/.../plugins/)

#15 (1): require_once(string phar:///home/.../PocketMine-MP.phar/src/pocketmine/PocketMine.php)

So this raises the question of how the player's coordinates somehow became strings...

Could you tell us which plugins you have in use on the server?

My plugin... Do you want to have the corresponding file?

I meant a list of plugins in use on the server.

I have this problem too.
It's happens, when I create Position with string values, such as
$player->teleport(new Position(("-400", "20", "-120", $this->level));
But when I convert string to int:
$player->teleport(new Position(((int)"-400", (int)"20", (int)"-120", $this->level));
this code works good o.0

That's because they have to be ints. You're simply casting the strings to ints.

This will become less confusing as the core becomes strict typed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zKoz210 picture zKoz210  路  23Comments

KAGsundaram picture KAGsundaram  路  43Comments

mal0ne-23 picture mal0ne-23  路  17Comments

VCraftMCPE picture VCraftMCPE  路  20Comments

mal0ne-23 picture mal0ne-23  路  32Comments