Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Invalid Argument in sendPosition

Comments in 'Plugin Development' started by Andrey Nazarchuk, Sep 9, 2015.

  1. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Hello people, I am still alive and still have questions because I am ALWAYS eager to learn.
    I have done what the error says and it just tells me to revert it.
    My plugin runs just fine, until it hits this code and does not anymore:
    PHP:
    public function portal($player$x$y$z){
            
    $xMin $x 1;
            
    $xMax $x 1;
            
    $yMin $y 1;
            
    $yMax $y 1;
            
    $zMin $z 1;
            
    $zMax $z 1;
            
    $pos = new Vector3($x,$y,$z);
            for(
    $x $xMin$x <= $xMax$x++){
                for(
    $y $yMin$y <= $yMax$y++){
                    for(
    $z $zMin$z <= $zMax$z++){
                        
    $id $player->getLevel()->getBlock($pos)->getId();
                        if(!(
    $id === or $id === 9)) return;
                        
    $this->play($player$this->arena);
                    }
                }
            }
            return;
        }
        
        
    //inside a public function with other code that does not pertain to this issue
        
    $this->cords $this->worlds->getNested("$this->arena.$this->nextSpawnLoc");
        
    $this->world $this->getServer()->getLevelByName($this->arena);
        
    $this->pos = new Position($this->cords[0], $this->cords[1], $this->cords[2], $this->world);
        
    $player->teleport($this->pos);
    Here is the error:

    Code:
    [Server thread/NOTICE]: InvalidArgumentException: "Argument 1 passed to pocketmine\Player::sendPosition() must be an instance of pocketmine\math\Vector3, null given, called in phar://C:/Users/Andrey/Downloads/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Player__32bit.php on line 1859 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/Player__32bit" at line 3176
    
    Thanks for reading, and expect more questions soon :D
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It would be really helpful if you could post the code in its entirety.
    Andrey Nazarchuk likes this.
  3. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    I swear none of the code above or below does anything to it. If classes were not so selfish about variable contents I would have learned php by now.
  4. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please enable debug (set debug.level to 2 in pocketmine.yml) and post the backtrace that displays on console when that happens again with debug on.
    Andrey Nazarchuk likes this.
  6. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    PHP:
    //try
    $this->cords $this->worlds->getNested($this->arena.".".$this->nextSpawnLoc);
    or
    PHP:
    //if getNested return the coordinates.
    $this->cords = new Vector3($this->worlds->getNested($this->arena.".".$this->nextSpawnLoc));
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It wouldn't work because Vector3 doesn't accept an array as constructor. Please check before replying.
  8. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Heres the BackTrace:
    Code:
    [05:33:44] [Server thread/DEBUG]: #0 /src/pocketmine/Player__32bit(1859): pocketmine\Player->sendPosition(NULL , double 79, double 0)
    [05:33:44] [Server thread/DEBUG]: #1 /src/pocketmine/network/RakLibInterface(140): pocketmine\Player->handleDataPacket(pocketmine\network\protocol\MovePlayerPacket object)
    [05:33:44] [Server thread/DEBUG]: #2 /src/raklib/server/ServerHandler__32bit(90): pocketmine\network\RakLibInterface->handleEncapsulated(string 192.168.1.17:52152, raklib\protocol\EncapsulatedPacket `▒CX▒B▒=qB▒▒0B▒B▒, integer 0)
    [05:33:44] [Server thread/DEBUG]: #3 /src/pocketmine/network/RakLibInterface(79): raklib\server\ServerHandler->handlePacket()
    [05:33:44] [Server thread/DEBUG]: #4 /src/pocketmine/network/Network(146): pocketmine\network\RakLibInterface->process()
    [05:33:44] [Server thread/DEBUG]: #5 /src/pocketmine/Server__32bit(2485): pocketmine\network\Network->processInterfaces()
    [05:33:44] [Server thread/DEBUG]: #6 /src/pocketmine/Server__32bit(2300): pocketmine\Server->tick()
    [05:33:44] [Server thread/DEBUG]: #7 /src/pocketmine/Server__32bit(2178): pocketmine\Server->tickProcessor()
    [05:33:44] [Server thread/DEBUG]: #8 /src/pocketmine/Server__32bit(1778): pocketmine\Server->start()
    [05:33:44] [Server thread/DEBUG]: #9 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/Andrey/Downloads/PocketMine-MP/PocketMine-MP.phar/, string C:\Users\Andrey\Downloads\PocketMine-MP\, string C:\Users\Andrey\Downloads\PocketMine-MP\plugins\)
    [05:33:44] [Server thread/DEBUG]: #10 (1): require(string phar://C:/Users/Andrey/Downloads/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    
  9. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Oops, Sorry everyone, Seems that the issue was that I only set 8 positions in the config, and it was teleporting me so many times it quickly ran through those 8 positions and crashed. :p:oops::eek::rolleyes::(:)

Share This Page

Advertisement