CommandHelper

CommandHelper

46.5k Downloads

detect "entity in cursor"

LadyCailinBot opened this issue ยท 5 comments

commented

CMDHELPER-2655 - Reported by Hekta

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

commented

Comment by PseudoKnight

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 Tom.Gebbett

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

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

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.

commented

Comment by PseudoKnight

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