CommandHelper

CommandHelper

46.5k Downloads

detect "entity in cursor"

LadyCailin opened this issue ยท 5 comments

commented

CMDHELPER-2655 - Reported by Hekta on 2013-04-22 01:38:53 UTC

Is it possible with Bukkit to add a function to detect if a player looks a monster or another player?

commented

Comment by PseudoKnight on 2013-04-22 22:53:26 UTC

Use pcursor() with entities_in_radius() for long-range targets, player_interact_entity event for close targets (player triggered), or, if you really want, iterate through the line-of-sight vector so you can look straight at a mob instead of the block they're on. CommandHelper could do these things for you, but you can do them for yourself. There's no shortcut in Bukkit last I checked.

commented

Comment by PseudoKnight on 2013-10-18 01:36:50 UTC

entity_line_of_sight() and entity_can_see() were added in build #2404.

commented

Comment by Tom.Gebbett on 2013-04-23 10:31:03 UTC

having a built in line of sight function would be handy, as i gave it a go a while ago and was having some trouble with the maths involved. Didn't stick at it for long though.

something like entities_in_view(loc,yaw,pitch,radius,maxdistance,nonobscured)
probably better to split that into a few different functions though.

Understandably low priority though, as i know it's possible to do this myself.

commented

Comment by Hekta on 2013-05-21 12:23:26 UTC

Thank you for your answers

But the method with pcursor() and entities_in_radius() is not enough precise for me and I need a range longer than it is possible with player_interact_entity, I will try to do this myself with the line-of-sight vector.

I had seen that there was a getLineOfSight function in Bukkit
http://jd.bukkit.org/rb/apidocs/org/bukkit/entity/LivingEntity.html#getLineOfSight(java.util.HashSet, int)

commented

Comment by PseudoKnight on 2013-05-21 21:42:51 UTC

I hadn't noticed that. I'd be totally for an entity_los(entityID, [transparentBlockIDs], [range]) function. It'd be useful for more than just entity detection, and it would obviously make los entity detection much easier.