Skip to content

Fix: use distance from boundbox edge for targeting distance#267

Open
TwinkNet wants to merge 5 commits intolambda-client:1.21.11from
TwinkNet:TwinkNet/Targeting-Distance
Open

Fix: use distance from boundbox edge for targeting distance#267
TwinkNet wants to merge 5 commits intolambda-client:1.21.11from
TwinkNet:TwinkNet/Targeting-Distance

Conversation

@TwinkNet
Copy link
Contributor

Currently Lambda uses the Entity.pos to 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 Vec3d to the closest side of a Box, and uses that function in WorldUtils.internalGetFastEntities() to calculate distance.

Additionally, fastEntitySearch() now accepts a FastVector rather than a BlockPos, as I found that this helps achieve a bit more consistency in targeting when standing on the edge of a block.

@cattyngmd
Copy link
Contributor

cattyngmd commented Mar 13, 2026

you need to account for AABB epsilon when calculating distance to closest AABB edge

@beanbag44 beanbag44 self-requested a review March 17, 2026 02:04
/**
* Returns the distance squared to the closest side of a [Box]
*/
fun Vec3d.distanceToSide(box: Box, epsilon: Double = 1e-7): Double {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants