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

Solved sendBlocks error

Discussion in 'Development' started by Aviv, Jun 6, 2017.

  1. Aviv

    Aviv Baby Zombie

    Messages:
    156
    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->floor($player->x);
    $block->floor($player->y)-2;
    $block->floor($player->z);
    $block->level $player->level;
    $player->level->sendBlocks([$player],[$block]); // this line has been giving me the problem
     
  2. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    First what does sendTitle have anything to do with this code.
    try removing float
     
    corytortoise likes this.
  3. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    Otherwise it's something you're not showing us.
     
  4. Aviv

    Aviv Baby Zombie

    Messages:
    156
    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.
     
  5. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    sorry mean't floor
    and i was commenting on how you said "sendTitle" not "SendBlocks"
     
  6. Aviv

    Aviv Baby Zombie

    Messages:
    156
    Im assuming its the code fault because it worked until now
     
  7. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    floor turns the value to a float and that requires a integer so you have to remove the floor code
     
  8. Aviv

    Aviv Baby Zombie

    Messages:
    156
    oh yeah sendBlocks XD my bad
     
  9. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    :p
     
  10. Aviv

    Aviv Baby Zombie

    Messages:
    156
    I have tried that, no luck
     
  11. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    show code? Errors?
     
  12. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    PHP:
    $block Block::get(54);
    $block->$player->x;
    $block->$player->-2;
    $block->$player->z;
    $block->level $player->level;
    $player->level->sendBlocks([$player],[$block]);
     
  13. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    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->= (int) $player->x;
    $block->= (int) $player->-2;
    $block->= (int) $player->z;
    $block->level $player->level;
    $player->level->sendBlocks([$player],[$block]);
     
    Awzaw likes this.
  14. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    are you show it sendTitle() haven't checked but i think its addTitle()
     
  15. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    He meant sendBlocks:
     
  16. Aviv

    Aviv Baby Zombie

    Messages:
    156
    I've tried out this method
    PHP:
    $pk = new UpdateBlockPacket();
    $pk->blockId Block::CHEST;
    $pk->blockData 0;
    $pk->= (int) $player->x;
    $pk->= (int) $player->2;
    $pk->= (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?
     
  17. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    $pk = new \pocketmine\network\mcpe\protocol\UpdateBlockPacket();
     
    Aviv and corytortoise like this.
  18. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    PHP:
    $player $e->getPlayer();
    $block Block::get(54);
    $block->$player->getFloorX();
    $block->$player->getFloorY() -2;
    $block->$player->getFloorZ();
    $block->level $player->level;
    $player->level->sendBlocks([$player],[$block]);
    Works fine for me, @corytortoise 's (int) cast will work too.
     
    corytortoise likes this.
  19. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    corytortoise and Awzaw like this.
  20. Aviv

    Aviv Baby Zombie

    Messages:
    156
    Thanks. I will never understand how these work XD
     
  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.