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

Solved Compass tracking?

Comments in 'Plugin Development' started by TryoneLegendZzz, Oct 22, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    how can i make a compass track something. such as: a player's death spot.
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onDeath(PlayerDeathEvent $e){
       
    $p $e->getEntity();
       
    $p->setSpawn($p->getPosition());
    }
    Last edited: Oct 22, 2015
  3. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    The compass points to a players spawn location, if you want to make the compass point towards a specific location you need a Vector3 or Position instance to set the players spawn location.

    I'm pretty sure the compass is know to not work as it's supposed to (not point to the players spawn location but the worlds spawn).
    TryoneLegendZzz likes this.
  4. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    getEntity()*
  5. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    That depends.... if you only want the player's death position, then you should use getPlayer(), however, if you also want an enitity (Zombie, Player etc...), you should use getEntity()
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    please learn PM api... getPlayer() dosent extend PlayerDeathEvent
    CrazedMiner and MCPEPIG like this.
  7. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    ?
    PlayerDeathEvent extends EntityDeathEvent.

    PlayerDeathEvent::getEntity() returns a Player instance.
    EntityDeathEvent::getEntity($ returns any sort of entity.

    PlayerDeathEvent can't extend getPlayer() as it is a function and not a class.
  8. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Try Falk's code.
  9. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    sorry I was thinking of another event
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is called "doesn't exist in PlayerDeathEvent", or "PlayerDeathEvent doesn't extend any classes that have the getPlayer() method". Wrong concept.
    TryoneLegendZzz and jojoe77777 like this.
  11. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    nvm :p
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PlayerDeathEvent cant extend getPlayer(), as it is a function.
    And PlayerDeathEvent uses pocketmine\Player;
    So therefore, getPlayer() does work and will return a Player instance.
  13. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    :rolleyes: PlayerDeathEvent has a getEntity() function, but not a getPlayer() function.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use pocketmine\Player only means that that class is used in its internal code. It doesn't mean it has functions from the Player class directly...
    CrazedMiner likes this.
  15. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    My apologies on that. I haven't used the PlayerDeathEvent for some time :oops:

Share This Page

Advertisement