This commit is contained in:
2026-11-21 14:52:33 -03:00
parent 357f8f2bd4
commit b4f07272d8
7 changed files with 195 additions and 30 deletions
+8 -2
View File
@@ -99,11 +99,18 @@ export class PathNavigation {
const next = points[this.#index];
mob.move_control.move_to(next.x, next.y, next.z, this.#speed);
// it stays blocked for as long as the block is solid and in its way, even when its path is searched again, so a
// goal can count how long it's been there
if (this.blocked_by) {
this.blocked_by = this.#solid_block_toward(next);
if (this.blocked_by) return;
this.#closest = Infinity;
this.#stuck = 0;
}
const distance = Math.hypot(next.x - mob.x, next.z - mob.z);
if (distance < this.#closest - 0.01) {
this.#closest = distance;
this.#stuck = 0;
this.blocked_by = undefined;
return;
}
this.#stuck += 1;
@@ -143,7 +150,6 @@ export class PathNavigation {
this.#closest = Infinity;
this.#stuck = 0;
this.#searched_again = searched_again;
this.blocked_by = undefined;
}
// close enough to a waypoint to go on to the next, like minecraft's maxDistanceToWaypoint