Files
pepa-pi-bot/runtime/movement-profiles.js
T
mayatnikovandClaude Opus 4.7 86f0c1799e fix(runtime): pin MC_VERSION=1.21.4 + ground-truth probe + close-loop dig
Two-pronged response to user-confirmed "bot stands still, doesn't actually
chop" on play.xmatic.team:

1. Pin protocol — .env now sets MC_VERSION=1.21.4. minecraft-data has
   wrong packet ID mappings for protocol 775 (server 26.1.2 via
   ViaBackwards 5.9.1) — see mineflayer#3888 and #3717. 1.21.5 also has
   an enchants decoder bug that breaks bot.dig. 1.21.4 is the last
   protocol mineflayer 4.37.1 can speak cleanly through VIA.

2. Don't trust dig success — runtime/actions.js chopNearestTree and
   runtime/skills/gather-stone.js now lookAt(face center)+forceLook,
   await collectBlock, then re-read the target block. If the log/stone
   is STILL there, return ok:false code:"silent_dig_failure" and
   blacklist the position. Prevents the curriculum from reporting
   "wood.16 in progress" while the world hasn't actually changed.

3. Defensive default — runtime/movement-profiles.js: canDig=false on
   every profile until dig is confirmed working live. Otherwise
   pathfinder schedules paths through must-dig blocks and the bot loops.

4. Ground-truth probe — runtime/skills/diagnose-physics.js dispatches
   forward/jump/dig probes and writes the result to the diary. New
   IPC command cmd:run-skill lets the operator (or a future curriculum
   trigger) fire any skill on demand; it waits for the current action
   to finish before dispatching. /tmp/pepa-runskill.mjs is a one-shot
   client.

Live probe on play.xmatic.team confirmed: forward Δ=0.003 over 2s
(BROKEN — server rejects movement packets), jump ΔY=0.42 (likely
physics jitter, not a real jump). Strongly suggests an anti-cheat
plugin gating bot-style movements server-side — beyond protocol pin.

npm test 124/124.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 11:51:43 +03:00

58 lines
2.2 KiB
JavaScript

// Movement safety profiles. mineflayer-pathfinder's Movements object
// is shared per-bot — if one skill sets canDig=false and another
// inherits that, you get the live regression from earlier: flee with
// canDig=false leaves the bot stuck in a tree canopy forever.
//
// Each named profile is a flat descriptor (pure JS object) that the
// caller can either inspect directly (tests do this) or apply to a
// pathfinder Movements via applyProfile(profile, bot).
import pathfinderPkg from "mineflayer-pathfinder";
const { Movements } = pathfinderPkg;
export const PROFILES = Object.freeze({
GATHER: "gather",
TRAVEL: "travel",
FLEE: "flee",
BUILD: "build",
RETURN_TO_BASE: "return_to_base",
});
// Pure descriptors — safe to import without a live bot.
//
// canDig is FALSE everywhere by default (2026-05-26). On the live server
// (play.xmatic.team 26.1.2+ViaBackwards 5.9.1) bot.dig silently fails —
// the packet ID table for protocol 775 is wrong in minecraft-data
// (mineflayer#3888) — so pathfinder would schedule paths through
// must-dig blocks the bot can't actually break, and we'd loop. Once
// 1.21.4 pin + lookAt+wait fix is verified live, we can re-enable
// canDig for gather/travel profiles.
export const PROFILE_DEFAULTS = Object.freeze({
[PROFILES.GATHER]: { canDig: false, canPlace: false, allow1by1towers: false },
[PROFILES.TRAVEL]: { canDig: false, canPlace: false, allow1by1towers: false },
[PROFILES.FLEE]: { canDig: false, canPlace: false, allow1by1towers: false, maxDropDown: 8 },
[PROFILES.BUILD]: { canDig: false, canPlace: true, allow1by1towers: true },
[PROFILES.RETURN_TO_BASE]: { canDig: false, canPlace: false, allow1by1towers: false },
});
export function describeProfile(profile) {
const desc = PROFILE_DEFAULTS[profile];
if (!desc) throw new Error(`unknown movement profile: ${profile}`);
return desc;
}
// Build a fresh Movements applying the descriptor; does NOT call setMovements.
export function buildProfile(profile, bot) {
const desc = describeProfile(profile);
const m = new Movements(bot);
for (const [k, v] of Object.entries(desc)) m[k] = v;
return m;
}
// Convenience: build + apply.
export function applyProfile(profile, bot) {
const m = buildProfile(profile, bot);
bot.pathfinder.setMovements(m);
return m;
}