Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Once connected to a Minecraft server, Claude can use these commands:
- `list-inventory` - List all items in the bot's inventory
- `find-item` - Find a specific item in inventory
- `equip-item` - Equip a specific item
- `open-container` - Open a block container or chest at specified coordinates
- `close-window` - Close the window or inventory that the bot currently has open

### Block Interaction
- `place-block` - Place a block at specified coordinates
Expand Down
46 changes: 46 additions & 0 deletions src/tools/inventory-tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { z } from "zod";
import mineflayer from 'mineflayer';
import { ToolFactory } from '../tool-factory.js';
import { coerceCoordinates } from "./coordinate-utils.js";
import { Vec3 } from "vec3";

interface InventoryItem {
name: string;
Expand Down Expand Up @@ -78,4 +80,48 @@ export function registerInventoryTools(factory: ToolFactory, getBot: () => minef
return factory.createResponse(`Equipped ${item.name} to ${destination}`);
}
);

factory.registerTool(
"open-container",
"Open a block container or chest at the specified position.",
{
x: z.coerce.number().describe("X coordinate"),
y: z.coerce.number().describe("Y coordinate"),
z: z.coerce.number().describe("Z coordinate"),
},
async ({ x, y, z }) => {
({ x, y, z } = coerceCoordinates(x, y, z));

const bot = getBot();
const blockPos = new Vec3(x, y, z);
const block = bot.blockAt(blockPos);

if (!block) {
return factory.createResponse(`No block information found at position (${x}, ${y}, ${z})`);
}

const container = await bot.openContainer(block);

return factory.createResponse(`Opened container (type: ${container.type}) at position (${block.position.x}, ${block.position.y}, ${block.position.z})`);
}
);

factory.registerTool(
"close-window",
"Close the window or inventory that the bot currently has open.",
{
},
async () => {
const bot = getBot();
const currentBotWindow = bot.currentWindow;

if (!currentBotWindow) {
return factory.createResponse('The bot does not have a window currently open.');
}

bot.closeWindow(currentBotWindow);

return factory.createResponse(`Closed bot window (type: ${currentBotWindow.type})`);
}
);
}