Skip to main content

BotMine

BotMine is a small native Python library for Minecraft Java bots. It is not a Mineflayer wrapper and does not start Node.js.

The first release focuses on a simple Python API and the protocol pieces needed to connect to offline-mode Java servers, read server status, and disconnect cleanly.

Install

pip install botmine

Shortest bot:

import botmine

bot = botmine.Bot("127.0.0.1", 25565, nickname="Bs", version="26.1.2")
bot.reconnect(True)
bot.say("BotMine online")
bot.command("help")
bot.follow_player("wawca")
bot.wait()

Run the bundled example from the project root:

python -m examples.simple

BotMine has no runtime dependencies outside Python itself. requirements.txt is empty on purpose. The package uses only the Python standard library and does not start JavaScript, Node.js, or Mineflayer.

The same thing with with:

import botmine

with botmine.Bot("127.0.0.1", 25565, nickname="Bs", version="26.1.2") as bot:
    bot.say("BotMine online")
    bot.follow_player("wawca")
    bot.wait()

Settings can also be changed through property():

bot = botmine.Bot("127.0.0.1", 25565, auto_connect=False)
bot.property(nickname="Bs", version="26.1.2", auto_swap_tools=True)
bot.connect()
bot.say("Hello from BotMine")
bot.command("/help")
bot.wait(30)
bot.leave()

follow_player() is packet-level movement, not full pathfinding. It follows a visible player while wait() or run_for() is running. It can jump one-block steps, but it is still not full pathfinding.

Events:

def on_chat(player, message):
    if message == "come":
        bot.follow_player(player)

bot.on("chat", on_chat)
bot.on("join", lambda player: print("join", player))
bot.on("leave", lambda player: print("leave", player))
bot.on("death", lambda message: print("death", message))
bot.on("respawn", lambda: print("respawn"))
bot.on("kicked", lambda reason: print("kicked", reason))

Movement:

bot.goto(x=100, y=64, z=-50)
bot.look_at("wawca")
bot.jump()
bot.sprint(True)
bot.sneak(True)
bot.follow_player("wawca")
bot.follow_stop("wawca")
print(bot.position())

Inventory and item actions:

inv = bot.inventory()
bot.equip("diamond_sword")
bot.use_item()
bot.drop("dirt", count=64)
bot.destroy(x=100, y=64, z=-50)
bot.respawn()

The inventory API is a local snapshot from server packets. equip("name") works only after the server has sent a matching tracked slot. auto_swap_tools can select a known hotbar tool before destroy().

Server snapshot:

info = bot.server_info()
print(info["players_count"])
print(info["nearest_player"])
print(info["spawn"])
print(info["time"])

wait() can also take seconds:

bot.wait(4)

Known Java protocol versions are mapped directly for 1.20.1 through 26.1.2. For version="auto" or a future unknown version label, BotMine uses the server status ping to detect the protocol ID before login.

Current limits

  • Java Edition protocol only.
  • Offline-mode login only. Online-mode/Microsoft authentication is intentionally not faked.
  • The library currently handles login/configuration enough for basic connection, chat, simple movement, tracked inventory actions and clean disconnect. Full pathfinding, signed chat sessions and full game-state tracking are not implemented yet.

Release

Build and check the package before uploading:

python -B -m unittest discover -s tests
python -m build
python -m twine check dist/*

Upload to TestPyPI first:

python -m twine upload --repository testpypi dist/*

Then upload to PyPI:

python -m twine upload dist/*

Metadata

Release files for botmine 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for botmine 0.1.0
File Size Uploaded Provenance Actions
botmine-0.1.0.tar.gz 24.1 kB Without provenance Details for botmine-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for botmine 0.1.0
File Interpreter ABI Platform Actions
botmine-0.1.0-py3-none-any.whl Python 3 none any Details for botmine-0.1.0-py3-none-any.whl

Total release size: 44.5 kB

Release files / botmine-0.1.0.tar.gz

Download URL botmine-0.1.0.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5172878ec67ea40dd1c56dbb62998fe02ac32410ec80ee9eb52fdb58e6301e6f
BLAKE2b-256 checksum
How to use checksums
cd4ec3f6c0ff797bc6a11ba4ac402807e2053ea9fc561ecc93a8783498bfe4d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / botmine-0.1.0-py3-none-any.whl

Download URL botmine-0.1.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1da5a86513a3401525d01974f48e3667bdb512baf00b3c91b1672b8893256d9b
BLAKE2b-256 checksum
How to use checksums
37e1f11d42189956d67f1ab6d4dce9f5167ab8efebe55d5871fe6697290f08b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Security for botmine 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page