Goals
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user