From 200b783efe6f65b0c2309efdd7d27e39f61d755c Mon Sep 17 00:00:00 2001 From: Rin Date: Thu, 15 Jan 2026 04:00:13 +0800 Subject: [PATCH] feat(minecraft): improve goToCoordinate --- services/minecraft/src/agents/action/tools.ts | 4 ++-- services/minecraft/src/skills/movement.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/services/minecraft/src/agents/action/tools.ts b/services/minecraft/src/agents/action/tools.ts index a4236b7da..1e59fda7a 100644 --- a/services/minecraft/src/agents/action/tools.ts +++ b/services/minecraft/src/agents/action/tools.ts @@ -126,14 +126,14 @@ export const actionsList: Action[] = [ }, }, { - name: 'goToCoordinates', + name: 'goToCoordinate', description: 'Go to the given x, y, z location.', execution: 'sequential', schema: z.object({ x: z.number().describe('The x coordinate.'), y: z.number().describe('The y coordinate.').min(-64).max(320), z: z.number().describe('The z coordinate.'), - closeness: z.number().describe('How close to get to the location in blocks.').min(0), + closeness: z.number().describe('0 If want to be exactly at the position, otherwise a positive number in blocks for leniency.').min(0), }), perform: mineflayer => async (x: number, y: number, z: number, closeness: number) => { await skills.goToPosition(mineflayer, x, y, z, closeness) diff --git a/services/minecraft/src/skills/movement.ts b/services/minecraft/src/skills/movement.ts index d91ade9ec..9735b1ede 100644 --- a/services/minecraft/src/skills/movement.ts +++ b/services/minecraft/src/skills/movement.ts @@ -33,6 +33,14 @@ export async function goToPosition( log(mineflayer, `Teleported to ${x}, ${y}, ${z}.`) return true } + const targetBlock = mineflayer.bot.blockAt(new Vec3(Math.floor(x), Math.floor(y), Math.floor(z))) + const blockAbove1 = mineflayer.bot.blockAt(new Vec3(Math.floor(x), Math.floor(y) + 1, Math.floor(z))) + const blockAbove2 = mineflayer.bot.blockAt(new Vec3(Math.floor(x), Math.floor(y) + 2, Math.floor(z))) + + if (targetBlock?.name !== 'air' && blockAbove1?.name === 'air' && blockAbove2?.name === 'air') { + // Nudge one block up so we don't dig a silly hole in the ground when using the ground block as reference + y += 1 + } await mineflayer.bot.pathfinder.goto(new goals.GoalNear(x, y, z, minDistance)) log(mineflayer, `You have reached ${x}, ${y}, ${z}.`)