Code Monkey home page Code Monkey logo

minebot's Introduction

pybot - A Minecraft bot written in Python using Mineflayer

pybot is a Minecraft bot written using the Mineflayer framework via the Python to Javascript bridge. It is built for practical utility automating such tasks as mining for resources, mining out rooms or long corridors, building bridges, farming, chopping wood, building structures and moving around resources between chests. It has a partially complete UI written in Tk.

Tested with Java Edition 1.16.5. It will NOT work with 1.18 or 1.19.

Authors

Guido Appenzeller, Daniel Appenzeller

License

Released under Apache 2.0

Requirements

To run the bot, your system needs to have:

  • A recent version of Python. On macOS, the easiest is to install Python 3 from the www.python.org website. Homebrew python may require the additional install of tkinter.
  • The Python/JavaScript bridge. 'pip3 install javascript' should do the trick.

Setup

Copy the account_sample.py to account/account.py and edit the following fields:

  • User Name
  • Password
  • Server IP or name
  • "master" is the in-game name of the player that the bot should take commands from (i.e. your in-game name)
  • version to the server's minecraft version

You can also specify locations in this file. This is mostly useful to have the bot transfer contents between chests.

Normally the bot will open a Window, but you can also run it without any graphical UX using the "--nowindow" option.

Functionality

Simple commands are given via chat. The bot has a specific "master" player that it will listen to. Try "come", "inventory" or "status" to get an idea. Other users can also give commands but need to preface it with a callsign.

Many activities can be stopped with the command "stop".

PyBot starts most complex activities around a chest. There are two types:

  • For an activity that doesn't need a specific direction, like farming an area, it's just a chest. Material (e.g. seeds) and resources (e.g. wheat) will be taken from or, after collecting them, placed into that chest.
  • For activities that do have a direction (e.g. dig a tunnel in a specific direction), starting point is a chest and the direction is indicated by placing a torch on the ground directly next to the chest.

For these activities, have the bot come next to the chest and once it is there tell it to "farm" or "mine 3x3".

Farming

To start, place a chest in the area you want to farm and start with "farm". The bot will take seeds from the cest, and plant them in any nearby farmland that it can reach. If there are fully grown crops, the pot will harvest them and place them and any extra seeds in the chest. Chat "stop" to stop the bot. Right now, only Wheat is in the code, but other crops are easy to add.

Chop Wood

Right now only works with mega spruce trees as they are the most efficient. Plant 2x2 saplings and get a tree with up to 100 blocks of wood. Place a chest within 25 blocks from the tree, place a few stone axes and bread as food in the chest and start with "chop". The bot will do a spiral cut up the trunk and then cut down. It will continue to chop down trees as long as it finds them and deposit the wood into the chest.

Right now, this activity can't be aborted with stop.

Mining

Supports:

  • Use "mine fast" to start strip mining. By default it will clear a 11 wide and 9 high area of all valuable blocks (it can see through walls to find it)
  • Mine large corridors, try "mine 3x3" or "mine 5x5"
  • The bot will looking for valuable ores off corridors, usually with a default distance of 5
  • The bot will also look in ceilings and the floor up to 2 deep
  • Try "boxmine" to mine out large areas for underground rooms
  • The bot will automatically bridge across chasms/lava
  • It will not defend itself yet, but it will run away when taking damage and ninja-log when below 50%
  • It will light up tunnels
  • If you put a wall sign close to the chest, the bot will record its progress on that sign (e.g. length of tunnel, dangers etc.)

If there is a chest-in-a-minecart next to the starting chest, the bot will deposit into the minecart, and restock from the chest. That makes it easy to keep it supplied with tools while hauling away resources automatically

Movement

Try "come" to make the bot come to the player

Building

Still early, but if you add a blueprint to blueprint_list.py, the bot can build it. Starting point is a chest with a torch. The bot can build a full sorting system with "build sorter".

minebot's People

Contributors

appenz avatar yokoo-arch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

minebot's Issues

Possible bugs? (and a recommendation)

I think there might be sone bugs to check out. If i run a command (ot push the button) like "chop tree"or mine ####, (at almost every chest required task) sometimes there is in the command line a chest open timeout.
Also i recognized he gets very often stuck on doing tasks (like at chop trees he gets stuck at searching trees) (or he gets stuck after restocking (in the GUI there stays the restocking task, and the bit does nothing))

I play on 1.16.5

I have also a recommendation. Try to add to account-sample.py a server port option.
And in pybot.py the following line of code to createbot:
'port' : self.account['port'],

Because i got a server that does nit have the standard port (i checked this and it worked fine for me.

Add port to server configuration

I have also a recommendation. Try to add to account-sample.py a server port option.
And in pybot.py the following line of code to createbot:
'port' : self.account['port'],

Question: Mojang account authentication

Is there a way we can add like Cracked or offline Accounts with the code?

and which file do i need to start with? am pretty much newbie in selecting files...

Support Cracked Accounts

Is it possible to support logging in to cracked accounts instead of just Mojang accounts? Also, could you also try to make it where you can run more then one bot at once without them interfering with each other

Mineflayer

Make your own package. Minecraft multiplayer based on socket. You can get socket packets in mineflayer code. Now it lookl ike shitcode. Im not learned python, but code very scared me.

Question: Error: Invalid Credentials

I tried running the pybot.py, and when I do, it keeps giving me Error: Invalid credentials. Invalid username or password. Yet, it still says it connects to the server, but on the server hosting page, it says that there are no users. On the sample, it says to use a email, or do you use the username? I find this project amazing, and I would love for this to work. Any help would be appreciated, and if this is just me being dumb, my apologies. (I did try the credentials many ways, even using my main account, but it's still not working.)

Full error:
Screenshot 2022-02-05 12 42 32 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.