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

Help About Player()

Discussion in 'Development' started by tungstenvm, Oct 8, 2019.

  1. tungstenvm

    tungstenvm Witch

    Messages:
    54
    I cant find some function in pocketmine github code, for example, i cant find getX() function in Player class.
    And can i set the X,Y,Z of a player, like:
    $a = $player;
    $a->setX(100);
    but the real player doesnt be affect.Thank in advance
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    The Player class inherits from the Human class which inherits from the Creature class which inherits from the Living class which inherits from the Entity class which inherits from the Location class which inherits from the Position class which inherits from the Vector3 class (located in the Math submodule).
    The Vector3 class has the getX function:
    https://github.com/pmmp/Math/blob/d7fda7a3abb078f6c709f02ddbb79444efa8cbe2/src/Vector3.php#L61-L63

    Inheritance is one of the (if not the) most important principle of OOP programming, see this for more information about how it works in PHP: https://www.php.net/manual/en/language.oop5.inheritance.php

    In order to properly move a player you should use $player->teleport() instead.

    Here's an example:
    PHP:
    $loc $player->getLocation();
    $loc->100;
    $player->teleport($loc);
     
  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.