moveControl
Control Minecraft player movement with commands for forward, back, left, right, jump, sprint, sneak, or stop actions for specified durations.
Instructions
Control the player with basic movement commands
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Movement action to perform | |
| duration | No | Duration to perform the action in seconds |
Implementation Reference
- src/tools/basicMovement.ts:45-79 (handler)The handler function that executes the moveControl tool logic. It sets the bot's control states based on the action (forward, back, etc., or stop) for a specified duration, using bot.setControlState and setTimeout to stop after duration.async ({ action, duration }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Convert duration to milliseconds const durationMs = duration * 1000 // Execute the requested movement action if (action === 'stop') { // Stop all movement botState.bot.clearControlStates() return createSuccessResponse(`All movement stopped`) } else { // Handle movement actions // We know that the action is a valid control state at this point (not 'stop') const controlState = action as ControlState botState.bot.setControlState(controlState, true) // After specified duration, stop the action setTimeout(() => { if (botState.bot) { botState.bot.setControlState(controlState, false) } }, durationMs) return createSuccessResponse( `Performing action: ${action} for ${duration} seconds` ) } } catch (error) { return createErrorResponse(error) } }
- src/tools/basicMovement.ts:27-44 (schema)Zod schema for input parameters of moveControl: 'action' enum and optional 'duration' in seconds (defaults to 1).action: z .enum([ 'forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak', 'stop', ] as const) .describe('Movement action to perform'), duration: z .number() .optional() .default(1) .describe('Duration to perform the action in seconds'), },
- src/tools/basicMovement.ts:23-80 (registration)The server.tool call that registers the 'moveControl' tool, specifying name, description, input schema, and handler function.server.tool( 'moveControl', 'Control the player with basic movement commands', { action: z .enum([ 'forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak', 'stop', ] as const) .describe('Movement action to perform'), duration: z .number() .optional() .default(1) .describe('Duration to perform the action in seconds'), }, async ({ action, duration }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Convert duration to milliseconds const durationMs = duration * 1000 // Execute the requested movement action if (action === 'stop') { // Stop all movement botState.bot.clearControlStates() return createSuccessResponse(`All movement stopped`) } else { // Handle movement actions // We know that the action is a valid control state at this point (not 'stop') const controlState = action as ControlState botState.bot.setControlState(controlState, true) // After specified duration, stop the action setTimeout(() => { if (botState.bot) { botState.bot.setControlState(controlState, false) } }, durationMs) return createSuccessResponse( `Performing action: ${action} for ${duration} seconds` ) } } catch (error) { return createErrorResponse(error) } } )
- src/tools/basicMovement.ts:11-18 (helper)Type definition for ControlState used in the handler to type-cast the action for bot.setControlState.type ControlState = | 'forward' | 'back' | 'left' | 'right' | 'jump' | 'sprint' | 'sneak'