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

Get Player by right clicking on him

Discussion in 'Development' started by DenVer9, Feb 25, 2020.

  1. DenVer9

    DenVer9 Creeper

    Messages:
    1
    Good day!
    I didn’t find information in the API, how to get a player by right-clicking on him?


    PHP:
    public function onTap(PlayerInteractEvent $event){
            
    $anotherPlayerName $event->get....
        }
     
  2. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    you have to use EntityDamageEvent
    and $event->getEntity();
     
  3. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
    its impossible whit PlayerInteractEvent . use EntityDamageByEntityEvent .
    $event->getEntity() is the player who you damaged
    $event->getDamager() is you

    you can use $event->setCancelled() to disable damage
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    It is. You can get all the entities in the whole level and check if player is looking at them (maybe there is some voxel ray trace api)... Then just get simply the player :D
     
  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.