Hey, I have been using sendTitle to send the client the chest so i can open its inventory, but now every time i try to use it it shows me an error Error: Code: [17:31:04] [Server thread/CRITICAL]: Unhandled exception executing command 'pv 1' in pv: Argument 1 passed to pocketmine\utils\Binary::writeVarInt() must be of the type integer, float given, called in C:\server\src\pocketmine\utils\BinaryStream.php on line 301 [17:31:04] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\utils\Binary::writeVarInt() must be of the type integer, float given, called in C:\server\src\pocketmine\utils\BinaryStream.php on line 301" (EXCEPTION) in "/src/pocketmine/utils/Binary" at line 496 Code: PHP: $block = Block::get(54);$block->x = floor($player->x);$block->y = floor($player->y)-2;$block->z = floor($player->z);$block->level = $player->level;$player->level->sendBlocks([$player],[$block]); // this line has been giving me the problem
sending the chest to the client is faster & better, and what does removing the float even mean, i do not have any floats in the code.
PHP: $block = Block::get(54);$block->x = $player->x;$block->y = $player->y -2;$block->z = $player->z;$block->level = $player->level;$player->level->sendBlocks([$player],[$block]);
A player's coordinates aren't integers either. They're typically floats(citation needed). floor rounds the float to the nearest integer AS a float, so it will still cause the same issue. You should be able to fix this by simply casting the coordinates as integers. PHP: $block = Block::get(54);$block->x = (int) $player->x;$block->y = (int) $player->y -2;$block->z = (int) $player->z;$block->level = $player->level;$player->level->sendBlocks([$player],[$block]);
I've tried out this method PHP: $pk = new UpdateBlockPacket();$pk->blockId = Block::CHEST;$pk->blockData = 0;$pk->x = (int) $player->x;$pk->y = (int) $player->y - 2;$pk->z = (int) $player->z;$pk->flags = UpdateBlockPacket::FLAG_NONE;$player->dataPacket($pk); But this error showed Code: [23:07:27] [Server thread/CRITICAL]: Unhandled exception executing command 'pv 1' in pv: Argument 1 passed to pocketmine\Player::dataPacket() must be an instance of pocketmine\network\mcpe\protocol\DataPacket, instance of pocketmine\network\protocol\UpdateBlockPacket given, called in C:\server\plugins\Core\src\Core\Main.php on line 27594 Is UpdateBlockPacket an instance of DataPacket already?? What have i done wrong?
PHP: $player = $e->getPlayer();$block = Block::get(54);$block->x = $player->getFloorX();$block->y = $player->getFloorY() -2;$block->z = $player->getFloorZ();$block->level = $player->level;$player->level->sendBlocks([$player],[$block]); Works fine for me, @corytortoise 's (int) cast will work too.