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

Directions.. Need help

Comments in 'Plugin Development' started by XFuryMCPE, Apr 15, 2016.

  1. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Okay, so I'm trying to make a border plugin where if a player tries to walk out of the border it knocks them away from it. How can I get the direction that the player is facing in and how do I get the opposite of that..
    applqpak and matthww like this.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Player::getDirection()
    applqpak, XFuryMCPE and matthww like this.
  3. matthww
    Offline

    matthww Active Member

    Joined:
    May 13, 2014
    Posts:
    91
    Minecraft User:
    Matthww
  4. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    applqpak likes this.
  5. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    Using Player::getDirection() is bad practice as you are statically accessing the Player. Instead you should use $event->getPlayer()->getDirection();
    Last edited: Apr 15, 2016
    XFuryMCPE likes this.
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    That is an example...
    applqpak likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    To knock a player a player to his back, use $player->getDirectionVector();

    PHP:
    // on border event
     
    $player->setMotion($player->getDirectionVector()->multiply(-2));

    applqpak likes this.
  8. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    Yes, it was an example. But he gave an incorrect example.
  9. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    But everyone knows what he means?
    applqpak likes this.
  10. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    I don't see a problem with me correcting him. He should've just done it the right way.
  11. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I also use $player it reprents the same as Player - objects.
    applqpak likes this.
  12. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    You need to get the player from the event...
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    No you don't. Also, Player::functionName is just a way of showing a function. I believe getDirection cannot be statically used on Player object.

    Also, nobody said it has to be $event->getPlayer()...
    applqpak, MyNameIsTriXz and Vaivez66 like this.
  14. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    Sorry, I'm getting things mixed up with the MiNET API :p. I thought he was saying to use it statically, that's why I was correcting him.
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Undefined variable $event. Who gives the wrong examples? Please go and check what Player::getDirection() means. I am pointing on the function getDirection() in the Player class. Doesn't matter what player event, $event->getPlayer() returns a Player.
    applqpak, MyNameIsTriXz and KubixQ like this.
  16. Addisonep
    Offline

    Addisonep New Member

    Joined:
    May 11, 2015
    Posts:
    14
    Minecraft User:
    Addisonep
    If you knew where to put event then it would work
  17. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You don't "put event" somewhere.
    ankitmaharjan252 and applqpak like this.

Share This Page

Advertisement