Go to file
2021-05-03 02:59:23 +00:00
docs Add docs about grabbing supplies 2021-05-02 01:26:06 +00:00
mosfet Make bot look where he's going while trading 2021-05-03 02:59:23 +00:00
web_interface Commit web interface build and serve statically 2021-04-26 03:07:06 +00:00
.gitignore Commit web interface build and serve statically 2021-04-26 03:07:06 +00:00
cache-items.png Add picture of trapped chest 2021-05-02 00:15:13 +00:00
LICENSE Initial commit 2020-05-20 15:41:01 -06:00
main.py Try different ports for web interface 2021-05-02 01:47:40 +00:00
README.md Add docs about grabbing supplies 2021-05-02 01:26:06 +00:00
requirements.txt Add support for Python 3.6 (thanks sose) 2021-04-28 02:12:15 -06:00
run_linux.sh Add support for Python 3.6 (thanks sose) 2021-04-28 02:12:15 -06:00
update_linux.sh Add support for Python 3.6 (thanks sose) 2021-04-28 02:12:15 -06:00

Mosfet Minecraft Bot

A general-purpose Minecraft 1.16 bot written in Python that uses an actual Minecraft account to play.

Mosfet is able to farm wood by cutting trees, farm crops, gather sand, farm netherwart, and trade with villagers to get emeralds. He can eat, sleep, and flee from threats.

Requirements

  • Python >= 3.6
  • pip, virtualenv, git, wget, unzip

Linux Setup

Assuming Debian / Ubuntu based distro:

$ sudo apt update
$ sudo apt install build-essential python3 python3-dev python3-pip virtualenv git wget unzip

$ git clone https://git.tannercollin.com/tanner/minecraft-bot.git
$ cd minecraft-bot/

Running

If you want to use the built-in burner account (Minecraft name mattstack):

$ SERVER=minecraft.example.com ./run_linux.sh

Use PORT to specify a custom port to connect to:

$ SERVER=localhost PORT=12345 ./run_linux.sh

If you have your own alt account for the bot:

$ EMAIL=you@domain.com PASSWORD=supersecret SERVER=minecraft.example.com ./run_linux.sh

Usage

How to Cache Items

How to Grab Supplies

Commands

The command prefix character is the last character of the bot's name. For example, if the bot's name is mattstack, then you would issue commands like kfarm wood or kpos. This lets you run multiple bots on the same server.

In the following examples, we'll assume the bot's name is mosfet1, so commands would be ran like 1farm wood or 1pos.

The exception are the below public commands, they can optionally be prefixed with ! and all bots will run the command.

Commands can be issued in public chat or private message like /msg mosfet1 1farm wood. The bot will reply the same way the command was issued.

Use echo to make Mosfet run Minecraft commands. For example, 1echo /sethome home will cause him to issue the /sethome command.

Public Commands

These can be ran by anyone, all bots will reply.

!help - prints this whole help message to console

!help [command] - replies in-game explaining command

!ping - replies with "pong"

!echo [data] - replies with "data"

!pos - replies with position and dimension

!afk - goes AFK with /afk

!unafk - goes not AFK with /afk

!error - raises an error

!inv - prints current inventory

!time - replies with Minecraft world time

!count [id] - counts the number of items with that id

!loaded - replies with the current loaded area

!players - prints the current players

!players clear - clears the current player list

!objects - prints the current items on ground

!objects clear - clears the current object list

!mobs - prints the current mobs

!mobs clear - clears the current mob list

!monsters - prints the current monsters

!villagers - prints the current villagers

!threats - prints the dangerous monsters within 20 blocks

!threats [num] - prints the dangerous monsters within num blocks

"zzz" or !zzz - bot does /afk to let others sleep

!tree - replies with the closest tree

!block x y z - replies what block is at (x, y, z)

Bot-specific Commands

These will only run for the bot they are addressed to. Replace 1 with the last character of the bot's name.

1respawn - respawns the bot if it's dead

1gather wood - gathers wood from the world

1gather sand - gathers sand from the world

1farm wood - farms wood from a certain area

1farm sand - farms sand from a certain area

1farm wart - farms netherwart from a certain area

1farm crop - farms mature crops from a certain area

1loiter - stands still but eats, sleeps, and flees

1trade - sells items to villagers to get emeralds

1stop - stops the current job and resets bot

1drop - drops the current stack its holding

1select [id] - moves item with id into main hand

1dump [id] - drops all items matching id

1drain - drops all items in inventory

1fill [x] [y] [z] [x] [y] [z] - fills the cuboid with the block at the first coordinate

1here - bot comes to your location

1goto [x] [y] [z] - sends the bot to coordinate (x, y, z)

1close - closes the current Minecraft window

1click [slot] [button] [mode] - clicks the current window

1use - use the item it's currently holding

1interact [entity id] - interacts with that entity

Authorized Commands

These dangerous commands can only be ran by the bot owner.

1print [expression] - replies with Python eval(expression)

1exit - exits the program

License

This program is free and open-source software licensed under the MIT License. Please see the LICENSE file for details.

That means you have the right to study, change, and distribute the software and source code to anyone and for any purpose. You deserve these rights. Please take advantage of them because I like pull requests and would love to see this code put to use.

Acknowledgements

Thanks to Isaia, sose, and the devs behind pyCraft.