[SPIGOT-7380] Get exact clicked position on PlayerInteractEvent Created: 10/Jun/23 Updated: 25/Dec/24 Resolved: 17/Jun/23 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | Rothes | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | None |
Version: | 1.20 |
Guidelines Read: | Yes |
Description |
Add a field for getting the exact(float) clicked position, which can be used for detecting the clicked slot of a chiseled bookshelf. On current version, there's only interacted block position, so we have to use `player.getEyeLocation().getDirection()` and impl a method to reach the block in order to get the final clicked position. However it's not safe, because of the latency. The result we get is not equal with the client sends. Wrap the Vec3D in MovingObjectPositionBlock will return a safe, accurate position. |
Comments |
Comment by Rothes [ 10/Jun/23 ] |
Yes. It's to expose the vector (MovingObjectPosition.a), like the location and used for Chiseled Bookshelf only. I can't think of any other blocks that would relate to the specific position of the interaction. As far as I know there's no other events called for now. Add a event for it is also great, but mojang uses that vector for detecting the clicked slot too. |
Comment by Doc [ 10/Jun/23 ] |
Then the request is expose the vector in the packet like the location not? if the use is only for Chiseled Bookshelf its not better a event with the info about the slot being modified (not sure if already exists or is handled in a inventory event) |