Published On Feb 13, 2022
Minecraft lets you connect to a WebSocket server when you’re in a game. The server can receive and send any commands. This lets you build a bot that you can do almost anything.
This tutorial explains how to create a Python WebSocket server that Minecraft can connect to, send messages using the undocumented MCWSS protocol.
0:00 - We'll show how you can use Python to automate Minecraft
0:27 - You need Minecraft, Python, and an editor
0:56 - Import WebSockets
1:22 - Create a WebSocket server
2:40 - Connect to the WebSocket server
4:36 - Troubleshooting
6:17 - Listen to player messages
9:12 - Print player messages
10:18 - Structure of a player message response
11:14 - Listen for a "pyramid" message
14:06 - Structure of commands to set blocks
14:42 - Sending commands to set blocks
16:43 - Algorithm to draw a pyramid
20:05 - Need for queueing messages
21:24 - Create a queue for messages
24:12 - Conclusion & uses
The code repository is at https://github.com/sanand0/minecraft-...
Delivered first at PyCon Iran on 16 Feb 2022: https://ir.pycon.org/schedule?lang=en (( • Talk / S Anand / Programming Minecraf... )