From 40c508a43dbe15982c0e66373754d2acadf36933 Mon Sep 17 00:00:00 2001 From: Rocco A Date: Sun, 28 Jun 2026 10:44:52 -0400 Subject: [PATCH] Revert "Fix: price horizontal water moves at the water cost" --- src/mineflayer-specific/movements/movement.ts | 9 +++------ .../movements/movementProviders.ts | 14 ++++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/mineflayer-specific/movements/movement.ts b/src/mineflayer-specific/movements/movement.ts index 95eb82c..c7d471a 100644 --- a/src/mineflayer-specific/movements/movement.ts +++ b/src/mineflayer-specific/movements/movement.ts @@ -259,13 +259,10 @@ export abstract class Movement { /** * Ticks to travel `blocks` blocks of flat ground. * - * On land the bot sprints when allowed (the fastest way to move), otherwise it - * walks. In water it can do neither, so it is priced at the (much slower) swim - * speed, which is why callers pass `inLiquid`. Pass `1` for one straight block, - * `Math.SQRT2` for one diagonal block, etc. + * The bot sprints when allowed (the fastest way to move), otherwise it walks. + * Pass `1` for one straight block, `Math.SQRT2` for one diagonal block, etc. */ - travelCost (blocks: number, inLiquid = false): number { - if (inLiquid) return blocks * WALK_ONE_IN_WATER_COST + travelCost (blocks: number): number { return blocks * (this.settings.allowSprinting ? SPRINT_ONE_BLOCK_COST : WALK_ONE_BLOCK_COST) } diff --git a/src/mineflayer-specific/movements/movementProviders.ts b/src/mineflayer-specific/movements/movementProviders.ts index 95db898..cd7eaef 100644 --- a/src/mineflayer-specific/movements/movementProviders.ts +++ b/src/mineflayer-specific/movements/movementProviders.ts @@ -48,10 +48,9 @@ export class Forward extends MovementProvider { getMoveForward (start: Move, dir: Vec3, neighbors: Move[]): void { const pos = start.cachedVec - // In water the bot swims (no sprint/walk), so price the block at the water - // cost itself rather than land speed + a flat add (which undercharged it). - const inLiquid = this.getBlockInfo(pos, 0, 0, 0).liquid - let cost = this.travelCost(1, inLiquid) + let cost = this.travelCost(1) // sprint/walk one block forward + + if (this.getBlockInfo(pos, 0, 0, 0).liquid) cost += this.settings.liquidCost const blockC = this.getBlockInfo(pos, dir.x, 0, dir.z) if (blockC.isInvalid) return // out of range. @@ -101,10 +100,7 @@ export class Diagonal extends MovementProvider { } getMoveDiagonal (node: Move, dir: Vec3, neighbors: Move[], goal: goals.Goal): void { - // In water the bot swims (no sprint/walk); price the diagonal at the water - // cost, which also scales with the sqrt(2) distance (a flat add did not). - const inLiquid = this.getBlockInfo(node, 0, 0, 0).liquid - let cost = this.travelCost(Math.SQRT2, inLiquid) + let cost = this.travelCost(Math.SQRT2) // one diagonal block is sqrt(2) blocks of travel const block0 = this.getBlockInfo(node, dir.x, 0, dir.z) @@ -112,6 +108,8 @@ export class Diagonal extends MovementProvider { if (!block0.walkthrough) return + if (this.getBlockInfo(node, 0, 0, 0).liquid) cost += this.settings.liquidCost + const toBreak: BreakHandler[] = [] const toPlace: PlaceHandler[] = [] const block00 = this.getBlockInfo(node, 0, 0, 0)