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

[New API] Position

Comments in 'Plugin Development' started by ArtMik, Jun 10, 2014.

  1. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    I use the Google translator.

    I got a problem: when a player enters a command, you need to know his position. I do not understand how to do it.

    So?

    $position = new Position;
    $x = $position->getX();

    And so on?
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    $sender->getFloorX();
    $sender->getFloorY();
    $sender->getFloorZ();
    $sender->getLevel();
    Last edited: Jun 10, 2014
    ArtMik and PEMapModder like this.
  3. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Thanks!
  4. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    No problem!
  5. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    if broken unit? So?

    public function BlockBreakEvent(BlockBreakEvent $event)
    {
    $user = $event->getPlayer();
    $x = $event->getX();
    $x = $event->getY();
    $x = $event->getZ();
    }
  6. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    What do you mean? Do you want to get the coordinates of the block, or of the player?
  7. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    block and player
  8. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    public function blockBreakEvent(BlockBreakEvent $event){
       
    $playerX $event->getPlayer()->getFloorX();
       
    $playerY $event->getPlayer()->getFloorY();
       
    $playerZ $event->getPlayer()->getFloorZ();
       
    $blockX $event->getBlock()->getFloorX();
       
    $blockY $event->getBlock()->getFloorY();
       
    $blockZ $event->getBlock()->getFloorZ();
    }
  9. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Thanks again!
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Function name conventions...

    BlockBreakEvent is not a proper function name!
  11. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Why?
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Functions names should be like
    onBlockBreaked
    onBlockBreak
    onBlockBreakEventCalled
    These are good examples, although a bit long.
    Using same class names and function names is just tricking yourself.
  13. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Oh I know that, I was just using the same names as him.
  14. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    What I do not understand now :(
  15. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    It's fine, just leave it :)
  16. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    I know! I can not imagine what I would do in the summer, if not PocketMine! But sometimes, when all else fails, I fall into despair)
    I did not understand where you get methods getPlayer (), getFloorZ ();
    they're not built
  17. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    http://docs.pocketmine.net
  18. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Я только там и сижу :D блин, вы же не понимаете :/
    I'm sitting there :D but I do not understand

Share This Page

Advertisement