Check when Interacting with entity?

Discussion in 'Plugin Development' started by cvcs1, May 17, 2011.

Thread Status:
Not open for further replies.
  1. Hey guys,

    I'd like to know when a player interacts with an entity, like this:

    if(player.getTarget().getType() == entity){
    //do stuff.
    }

    Unfortunately this doesn't work ;(
    Anyone know?

    Thanks,
    cvcs1
     
  2. Offline

    desmin88

    @cvcs1
    if(player.getTarget().getType() instanceof Entity) { // do stuff)
     
  3. Do you mean .getCompassTarget? .getTarget is non-existent.
    Thanks though.
    EDIT: I am doing this in onPlayerInteract. Should it be elsewhere? Right now I have:

    public void onPlayerInteract(PlayerInteractEvent event){
    Player player = event.getPlayer();
    if (player.getTarget().getType() instanceof Entity){

    }
    }
    This is in my PlayerListener
     
  4. Offline

    DreadKyller

    you might get away with:

    player.getLineOfSight(null, 500).toArray()[0] instanceof Entity

    I could be wrong though...
     
  5. You are wrong unfortunately. Shoot.
     
Thread Status:
Not open for further replies.

Share This Page