A proof of concept for controlling a bot in Minecraft with an AI.
- Clone this project on your local machine
git clone https://github.com/Amagash/minecraft-ai-python.git
You can access mineflayer in Python in addition to any other JavaScript package by first installing the javascript pip package:
pip install javascript
Here is how to start the Minecraft server:
- Choose a host computer. This computer should be fast enough to play Minecraft, while running a server for other players as well.
- Launch the game and click Single Player.
- Create a new world or open an existing one.
- Inside that world, press the Esc key, and click Open to LAN.
- Choose a game mode to set for the other players.
- Choose Creative mode that allows you to fly and place an infinite number of blocks.
- Click Start LAN World, and you'll see a message that a local game has been hosted.
- Take note of the port number.
- In index.py replace the port number with the one you just noted.
bot = mineflayer.createBot({ 'host': 'localhost', 'port': [PORT_NUMBER], 'username':'Claude', 'verbose': True, })
From your terminal, run the following commands:
npm install
python index.py
In a few seconds, you should see a message that the bot is running, and you should see the bot pop up in Minecraft.
Inside the Minecraft client, press the T
key to open the chat box. You can now chat with your bot connected to your AI.
This is a proof of concept. It is not intended to be used in production.