A Minecraft bot created using the Mineflayer library that connects to a Minecraft server and responds to player commands. The bot can be used as a foundation for creating more complex Minecraft automation.
- Connect to a Minecraft server on port 61619 (configurable)
- Respond to in-game chat commands
- Navigate the Minecraft world
- Basic inventory management
- Error handling and reconnection capabilities
- First-person view capabilities through a web interface
- Path visualization for tracking bot movements
- Node.js (version 14 or higher)
- A running Minecraft Java Edition server (or LAN world)
- Modern web browser for viewing the first-person perspective
-
Clone this repository:
git clone https://github.com/bhoyte/minecraft-bot.git cd minecraft-bot -
Install dependencies:
npm install
You can configure the bot by editing the parameters in index.js:
const bot = mineflayer.createBot({
host: 'localhost', // Server IP address
port: 61619, // Server port
username: 'MinecraftBot', // Bot username
auth: 'offline', // Authentication type (offline or microsoft)
version: false // Game version (false for auto-detect)
});To start the bot, run:
npm startOr directly with:
node index.jsThe bot now features a first-person view capability:
- After the bot connects to the server, a web server starts on port 3000
- Open your web browser and navigate to
http://localhost:3000 - You'll see the Minecraft world from the bot's perspective in real-time
The bot responds to the following in-game chat commands:
hello: The bot will greet youinventory: The bot will list items in its inventorypositionorwhere are you: The bot will announce its positionjump: The bot will jump (useful for locating it)look at me: The bot will turn to face youcome to me: The bot will teleport in front of you (requires commands to be enabled)viewerorview: The bot will remind you of the URL for the first-person viewtoggle path: Enables or disables the visualization of the bot's movement path
For instructions on setting up a Minecraft server for your bot to connect to, see SERVER_SETUP.md.
index.js- Main bot codepackage.json- Project configuration and dependenciesREADME.md- This documentation fileSERVER_SETUP.md- Instructions for setting up a Minecraft serverdoc.md- Documentation for advanced features and architecturebot-view.md- Documentation for the first-person view implementation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License - see the LICENSE file for details.
- PrismarineJS for creating the Mineflayer library
- prismarine-viewer for the web-based visualization
- Minecraft community for their continuous support
If you encounter any issues:
- Ensure your Minecraft server is running on the correct port (default: 61619)
- Check that the server is in offline mode if you're using
auth: 'offline' - Verify that your Node.js version is compatible (v14+)
- Check the console for any error messages
- Make sure your firewall isn't blocking the connection
- If the viewer doesn't work, ensure you have all required dependencies installed