Files
minecraft-bot/README.md
T

5.8 KiB
Raw Blame History

Mosfet Minecraft Bot

Mosfet is a Python bot for Minecraft 26.3. It connects with an offline-mode account over protocol 777.

It can navigate the world, farm crops, trees, sand and nether wart, manage inventory and chests, sleep and eat, and respond to nearby threats.

Setup

Requirements: Python 3.11+ and uv.

From the repository root:

uv venv env
source env/bin/activate
uv pip install -r requirements.txt

This installs pyCraft from the pinned Git revision. To develop against a sibling checkout at ../pyCraft, use uv pip install -r requirements-dev.txt instead; it installs that checkout in editable mode.

Run

For a local offline-mode server:

SERVER=127.0.0.1 PLAYER_NAME=mosfet1 python mosfet.py

The defaults are SERVER=127.0.0.1 and PLAYER_NAME=mosfet1. Set PORT or GAME_PASSWORD through the environment when needed. The bot uses AuthMe; it does not use Microsoft authentication.

The dashboard is normally at http://localhost:3300. Rebuild its assets with:

npm --prefix web_interface run build

Python edits under mosfet/ hot-reload without disconnecting the player. Connection and startup changes take effect after restarting the bot.

Item icons use bundled Minecraft textures where available. Missing textures are fetched and cached from the Minecraft 26.3 asset CDN. The icon collection is also credited to mcitemgallery.com.

Commands

The command prefix is the last character of the bot's name. For mosfet1, use 1; for mosfet2, use 2.

Command Action
1farm crops Harvest and replant mature crops
1farm logs / 1farm wood Harvest trees and cache the logs
1farm sand Gather sand and red sand
1farm wart Farm nether wart
1gather wood Gather wood
1gather sand Gather sand and red sand
1sleep [new] Sleep; new requests a newly placed bed
1eat Eat when needed
1cache Run an inventory cache pass
1drain Drop inventory stacks
1goto x y z Navigate to coordinates
1respawn Respawn after death
1loiter Stand by while handling food, sleep and threats
1stop Stop the current job

Public commands include !ping, !pos, !dist, !signs [distance], and !safesand x y z. Use !help in chat for the full command list.

Signs

Signs are read on both sides. Use !signs [distance] to inspect nearby text; the default search distance is 32 blocks. Matching ignores case. Bot-addressed signs start with a full bot name (mosfet1) or group name (mosfet). A group name addresses bots ending in digits 1–9; the colon after an address is optional.

Work-area boundaries

A work sign can limit where a bot selects work targets:

mosfet1 stay within 24 circle
mosfet stay within 12 squares

The default shape is a circle. square and squares use the larger horizontal X/Z offset; height does not count. The nearest matching policy sign among loaded signs is active, and all rules on it apply. Work destinations must be inside the boundary; the path to them may cross outside it. After a support trip exceeds the boundary by more than 40 blocks, the bot returns to a reachable position inside before finishing the task.

Supply chests

Address a chest with supplies to make its contents available to jobs:

mosfet1 supplies

The address and supplies can be on separate lines. The bot searches within 80 blocks and takes only items requested by its current job. For example, wood-farming can retrieve an axe from a supply chest.

Cache chests and labels

Attach a sign to a chest or place it on top. A side-adjacent chest takes priority over one below the sign; double chests count as one container.

Use cache for a general-purpose destination:

mosfet cache

General cache chests are searched within 105 blocks, after item-specific chests. If no signed destination is usable, the bot can place a chest from its inventory.

Item-category labels on a sign direct matching items to that chest:

Label Items
Seeds Crop seeds and propagules
Wheat Wheat only; not wheat seeds
Sand / Red Sand The matching sand type
Logs All log items, including stripped and wood forms
Oak Logs, Spruce Logs, etc. That tree's log family
Saplings Saplings and propagules

Labels can be combined on one sign. They ignore case and surrounding spaces or colons. See How to Cache Items for more detail.

Throw directives

A throw directive drops matching inventory stacks near a sign:

mosfet1 throw Logs
mosfet throw Wheat Seeds
mosfet1 throw oak_log

Use category labels, tree-family labels, or an exact item name with or without the minecraft: prefix. The bot looks for a reachable position within three blocks, with line of sight to the sign.

Sand origin

Use sand origin to set the center for 1gather sand and 1farm sand:

mosfet sand origin

The nearest matching loaded sign within 200 blocks is used. Without one, the job keeps its previous origin or starts from the bot's current position. Sand and red sand are collected in safe 3×3×1 sections.

Safety refuges

Mark a refuge with safety or refuge:

mosfet1 safety
mosfet refuge

When a hostile is detected during a job, the bot searches for an addressed refuge within 80 blocks. It waits for tracked hostiles to leave the 40-block area, then waits 10 seconds before resuming the job. While waiting, it may eat or use a nearby bed at night or during a storm; refuge mode does not place a new bed.

More information

License and acknowledgements

Licensed under the MIT License; see LICENSE. Thanks to Isaia, sose, and the pyCraft developers.