Fix: use distance from boundbox edge for targeting distance#267
Fix: use distance from boundbox edge for targeting distance#267TwinkNet wants to merge 6 commits intolambda-client:1.21.11from
Conversation
|
you need to account for AABB epsilon when calculating distance to closest AABB edge |
| /** | ||
| * Returns the distance squared to the closest side of a [Box] | ||
| */ | ||
| fun Vec3d.distanceToSide(box: Box, epsilon: Double = 1e-7): Double { |
There was a problem hiding this comment.
this seems to return a squared distance. Maybe a better name could be distToClosestPointSq? Or without the Sq if we square root it. Maybe another version of the function could be made for FastVector too to avoid the transformation in world utils
beanbag44
left a comment
There was a problem hiding this comment.
Sorry its taken me a while to get around to reviewing pr's. This changes the internalGetFastEntities function, but the change should also be applied to internalGetEntities. I still think a second function for getting the distance to the edge of a bounding box using FastVector would be nice to avoid the extra conversion to Vec3d in WorldUtils.kt. They could also be changed to infix functions like how Vec3d.distSq does it.
|
Yeah I got busy with another project and haven't been able to finish this. I've converted this to a draft for now. |
Currently Lambda uses the
Entity.posto calculate distance from the player, which results in inconsistent targeting when fighting entities with large hitboxes, such as big slimes, ender dragons, and withers. I keep my targeting distance set to 3 blocks and there are certain mobs that it just won't hit unless i'm kissing them.This PR adds a helper function for calculating the distance from a
Vec3dto the closest side of aBox, and uses that function inWorldUtils.internalGetFastEntities()to calculate distance.Additionally,
fastEntitySearch()now accepts aFastVectorrather than aBlockPos, as I found that this helps achieve a bit more consistency in targeting when standing on the edge of a block.