Solved Getting a Player that left clicked a player in creative

Discussion in 'Plugin Development' started by SuperOriginal, Jun 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    SuperOriginal

    I need to know if there is a way that I can get a player that left clicked a player in creative mode. EntityDamageByEntityEvent will not work because the entity is in creative. Any ideas?
     
  2. Offline

    fireblast709

  3. Offline

    AoH_Ruthless

    supercube101
    1. Listen for PlayerInteractEvent
    2. Check if action was left-click
    3. Loop through all world entities, check if any entity was a player and in the clicker's line of sight
    4. Do your code
    Do the above in that order.
     
  4. Offline

    SuperOriginal

    A list of events doesn't help me at all. A little more in depth explanation shouldn't be considered "spoonfeeding." I'm not a complete noob and i'm pretty sure I know the events that apply to my situation.

    I am fairly sure the getLineOfSight method only returns a list of blocks, not a list of entities.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  5. Offline

    AoH_Ruthless

    Don't act like a complete noob with your question then. Try to tell us what you tried, and what you think is a right approach and some feedback about what you are doing maybe.

    And actually, fireblast709 's suggestion might have given you the answer. It appears that because getLineOfSight returns blocks in a list, it would be harder, but not impossible. However, if you actually look at the list of events without lashing out, you will see that there is a PlayerInteractEntityEvent. Look into that.
     
  6. Offline

    xTigerRebornx

    AoH_Ruthless likes this.
  7. Offline

    AoH_Ruthless

    xTigerRebornx
    Didn't know that (never worked with PlayerInteractEntityEvent), thank you for that.

    In hindsight, that actually makes sense because right click is the "interact / use" button and left clicks would trigger a damage event / PlayerInteractEvent.
     
  8. Offline

    fireblast709

    supercube101 get all entities nearby, perform some math magic using the player direction and both locations to see if you look at the player
     
Thread Status:
Not open for further replies.

Share This Page