set_block
Place a block at specified coordinates in a Minecraft world using the /setblock command. Define block type and placement mode to modify terrain or structures.
Instructions
Place a block at a specific position. Uses the /setblock command.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate | |
| block | Yes | Block ID (e.g., 'diamond_block', 'stone', 'oak_planks') | |
| mode | No | Placement mode | replace |
Implementation Reference
- src/tools/command-tools.ts:145-179 (handler)The 'set_block' tool is defined and registered within the registerCommandTools function using server.tool. It accepts coordinates, a block ID, and a placement mode, then executes the '/setblock' command via RCON.
server.tool( "set_block", "Place a block at a specific position. Uses the /setblock command.", { x: z.number().describe("X coordinate"), y: z.number().describe("Y coordinate"), z: z.number().describe("Z coordinate"), block: z .string() .describe("Block ID (e.g., 'diamond_block', 'stone', 'oak_planks')"), mode: z .enum(["destroy", "keep", "replace"]) .optional() .default("replace") .describe("Placement mode"), }, async ({ x, y, z: zCoord, block, mode }) => { try { const response = await manager.rcon.send( `setblock ${x} ${y} ${zCoord} ${block} ${mode}` ); return { content: [{ type: "text", text: response }] }; } catch (error) { return { content: [ { type: "text", text: `Failed: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } );