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

Solved PlayerInteractEvent on Position click

Comments in 'Plugin Development' started by Taha_The_Hacker, Oct 15, 2015.

  1. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Hey,

    How can i detect what position the player touches a position with PlayerInteractEvent? Not an item a position

    Thanks for your reply :)
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    You think like player touches a block at x=20,y=10,z=30 and you want to get 20,10,30? You can do this with $ev->getBlock()->getX(),$ev...
    Taha_The_Hacker likes this.
  3. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    PHP:
    $block $event->getBlock();
    $block->getX();
    $block->getY();
    $block->getZ();
    Primus and Taha_The_Hacker like this.
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Thanks lemme try :)
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    or
    PHP:
    $event->getBlock()->getPosition();
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I wanna know...
    it doesn't work, i want it if the player Touches a position at X,Y,Z something happens.. but no.
    PHP:
    public function onInteract(PlayerInteractEvent $event){
    if(
    $event->getBlock()->getX() === $this->yml["spleef-start-block-X"] && $event->getBlock()->getY() === $this->yml["spleef-start-block-Y"] && $event->getBlock()->getZ() === $this->yml["spleef-start-block-Z"]){
    if(
    $this->gameStarted false){
    $this->gameStart();
    }
    }
    //if1
    }//onInteract
  7. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    How is "yml" defined?
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    $yml = new Config($this->getDataFolder()."config.yml",Config::YAML);
    $this->yml $yml->getAll();
  9. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    I tought he was doing it wrong. Thats why I asked.
  10. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I have found the bug!
    Use
    PHP:
    if ($this->gameStarted === false){
    ;)
    Taha_The_Hacker and GmWM like this.
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    oops my mistake xD
  12. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I can't believe i did =
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You know, there is a yaml_parse_file function.
    No difference. You are creating an unnecessary copy of the coordinates while the block already has the information.

Share This Page

Advertisement