-
-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add entityAtCursor function #2077
Conversation
needs a lint |
shouldnt this be entityAtCursor instead? since you will hit any entity first even if you have a player in range of your cursor? |
I used |
why? defeats the purpose of this since if you have a mob infront of the player you wont notice |
It's mostly because I haven't played around with bounding boxes of other entities (and the use case I had in mind didn't have other entities), but I can always make changes to it so it uses different entities as well. |
Seeing as there's no changes requested, is there anything I need to do? |
There seems to be a weird bug in
when pos is
Am I just using the function wrong, or is it an actual bug? |
What do you mean ? It's unlikely that the position returned by intersect has only integer coordinates, so the first one seems more legit. |
I'm more focused on the distance between the 2 points rather than the position being only integer coordinates. The first coordinate I posted was the intersection while the second one was the pos returned by RaycastIterator.next() (I probably should have explained that earlier oops). There is an approx 3 block distance between the 2 points, while at most it should be roughly 1-2 blocks, so it really should not be intersecting. I forgot to mention, but this was primarily looked into cause I noticed the bot was attacking behind itself. |
Now that i looked the code it makes sense. The 2 pos you are talking about are unrelated. For the bot attacking behind itself you need to check the sign of the dot product of (pos-eyePosition) and viewDirection |
Waiting for @Karang to verify, but it's all right on my part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I think this would be better suited to go into prismarine-world like bot.blockAtCursor.
const entity = entities[i] | ||
const w = entity.width / 2 | ||
|
||
const shapes = [[-w, 0, -w, w, entity.height + (entity.type === 'player' ? 0.18 : 0), w]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does the 0.18 constant come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the 0.18 constant comes is due to this where the bot's height is set to its eye height, 1.62, rather than the bot's actual height 1.80.
I thought that |
this needs docs |
pworld doesn't have entities yet, so it makes sense to be in mineflayer for now. can be moved later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Can you also add it in |
One issue I've ran into with this myself (which I just added a blacklist argument for my own purposes) is that it likes to target experience orbs, which may create unwanted results for some users of this function, as you can interact through experience orbs and such. |
No description provided.