Skip to content

nmalthouse/mcbot

Repository files navigation

A Minecraft Bot written in zig

Linux only because epoll() is used.

Lua API documentation

Running:

    # Install zig version 0.15.2
    # make sure you have the following libraries installed system-wide:
    # lua
    # 
    # Setup a 1.21.3 Minecraft server and ensure the following is set in server.properties:
    # online-mode=false

    git clone https://github.com/nmalthouse/mcbot.git
    cd mcbot
    git submodule update --init --recursive
    cd ratgraph
    ./setup_libs.sh
    cd ..
    zig build run

The file bot_config.lua sets port, ip, and bots that will be added.

Current features:

  • Code generation for the Minecraft protocol.
  • Dimensions
  • Pathfinding, (includes: ladders, gaps)
  • Debug rendering
  • Block breaking
  • Basic inventory interaction
  • Crafting
  • Multiple bots
  • Lua scripting

A picture of the debug renderer.

astar pathfinding

Depends on

  • zig-nbt
  • Everything listed under ratgraph's dependencies

Architecture overview:

    fn main
        reads bot_config.lua
        Establishes connections with Minecraft server for all bots specified.
        Spawn a thread per bot, see function luaBotScript
        Sets up epoll() to monitor all the tcp file descriptors.
        Respond to epoll events, parsing Minecraft packets and updating our version of the Minecraft state.
        This thread sends some packets back to the server, (keepalive, respawn, confirm teleport request).
        Optionally spawn the draw() thread.
    
    fn draw()
        Renders a basic view of the Minecraft world. Can show entities, inventory, pathfinding nodes.
        launch with zig build run -- draw

About

Minecraft bot for 1.21.3. Written in zig

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages