Skip to content

Commit

Permalink
Fix: closestDistance is always the first entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard127 committed Aug 31, 2023
1 parent 63da500 commit c8b7750
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bot/world/chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (w *World) SearchEntity(f func(entity core.Entity) bool) core.Entity {

func (w *World) ClosestEntity(pos maths.Vec3d) core.Entity {
var closestEntity core.Entity
var closestDistance float64
var closestDistance = math.MaxFloat64
w.entitySearch(1, 1, func(entity core.Entity) bool {
distance := pos.DistanceTo(entity.GetPosition())
if closestEntity == nil || distance < closestDistance {
Expand Down

0 comments on commit c8b7750

Please sign in to comment.