Minecraft
An easy to understand minecraft botting guide for beginners [MINEFLAYER]
Submitted by poggers11111, 05-05-2021, 02:47 PM, Thread ID: 205622
Thread Closed
05-05-2021, 02:47 PM
#1 Mineflayer is a popular minecraft botting tool used to automate boring tasks and such. I'm making this tutorial because the original mineflayer documentation is a lot of reading and a lot of the stuff they show in the examples is outdated and depracated.
I know some people would rather use OQMinebot because it lets you just drag the elements for the macro instead of actually having to code the macro yourself. Despite that I still think mineflayer is more customizable and you have better control of what it's doing.
Requirements:
- nodejs (https://nodejs.org)
- the mineflayer package (npm install mineflayer)
- basic knowledge of javascript
- a minecraft server for testing (https://www.minecraft.net/en-us/download/server)
- some of the imports from the examples below
In this tutorial:
- how to make a bot join a server and send a chat message (& respond to your messages)
- examples of common things you might want the bot to do (digging, clicking an item in an inventory, right clicking a compass etc.)
- how to host a webserver that will let you view the POV of the bot
- how to use multiple accounts at once
Your first bot
Let's start with a simple bot that joins the specified server and sends a message. Here's the example code with explainations:https://www.skidbin.net/paste?t=MXgrEpAY
To run it, open a terminal and type "node botfilename.js". It should then join the local offline testing server and say "I spawned".
If it doesn't say the message or doesn't join at all, you should try searching for a solution on https://mineflayer.prismarine.js.org[url=https://mineflayer.prismarine.js.org][/url]
Viewing the bot's POV
To view your bot's POV you will need to download and import the "prismarine-viewer" project. (npm install prismarine-viewer)
After you've done that, just paste these 5 lines on the bottom of your script: https://www.skidbin.net/paste?t=HG96mNDq
The only con in this is that you cannot view the bot's opened inventories or their own inventory using this.
Making your bot respond to you and dig down
This one is pretty simple and let's you do a lot of things, here's the final code:https://www.skidbin.net/paste?t=fI0SOo56
To make your bot dig down you actually have to add a lot of code. It's hard to explain what and where I added so I'll just post the code and you can check it yourself: https://www.skidbin.net/paste?t=u8jozmgU
Using multiple bot accounts
This is an official example of how to load and use multiple bot accounts at once: https://github.com/PrismarineJS/mineflay...om_file.js
It's well explained and I use it myself though it's one of the most complicated things explained here.
Some useful functions you might be looking for
bot.activateItem() - activates the item in the bots hand (used for right clicking compass and such)
bot.dig() - you need "prismarine-block" for some of it to function correctly
bot.clickWindow(slot, type, mode) both type and mode are explained here: https://wiki.vg/Protocol#Click_Window - clicks a slot in an inventory to switch lobby etc.
https://github.com/PrismarineJS/mineflay...r/examples - official examples you might find useful
bot.setControlState('state') - allows you to control the bots state like shifting sprinting or going forward
bot.setQuickBarSlot('slot 0-8') - selects a hotbar slot
That's all. I hope this will help atleast one person fix their bot or remove confusion. If you have any questions please look through the official examples and the official API documentation: https://mineflayer.prismarine.js.org/#/api
I know some people would rather use OQMinebot because it lets you just drag the elements for the macro instead of actually having to code the macro yourself. Despite that I still think mineflayer is more customizable and you have better control of what it's doing.
Requirements:
- nodejs (https://nodejs.org)
- the mineflayer package (npm install mineflayer)
- basic knowledge of javascript
- a minecraft server for testing (https://www.minecraft.net/en-us/download/server)
- some of the imports from the examples below
In this tutorial:
- how to make a bot join a server and send a chat message (& respond to your messages)
- examples of common things you might want the bot to do (digging, clicking an item in an inventory, right clicking a compass etc.)
- how to host a webserver that will let you view the POV of the bot
- how to use multiple accounts at once
Your first bot
Let's start with a simple bot that joins the specified server and sends a message. Here's the example code with explainations:https://www.skidbin.net/paste?t=MXgrEpAY
To run it, open a terminal and type "node botfilename.js". It should then join the local offline testing server and say "I spawned".
If it doesn't say the message or doesn't join at all, you should try searching for a solution on https://mineflayer.prismarine.js.org[url=https://mineflayer.prismarine.js.org][/url]
Viewing the bot's POV
To view your bot's POV you will need to download and import the "prismarine-viewer" project. (npm install prismarine-viewer)
After you've done that, just paste these 5 lines on the bottom of your script: https://www.skidbin.net/paste?t=HG96mNDq
The only con in this is that you cannot view the bot's opened inventories or their own inventory using this.
Making your bot respond to you and dig down
This one is pretty simple and let's you do a lot of things, here's the final code:https://www.skidbin.net/paste?t=fI0SOo56
To make your bot dig down you actually have to add a lot of code. It's hard to explain what and where I added so I'll just post the code and you can check it yourself: https://www.skidbin.net/paste?t=u8jozmgU
Using multiple bot accounts
This is an official example of how to load and use multiple bot accounts at once: https://github.com/PrismarineJS/mineflay...om_file.js
It's well explained and I use it myself though it's one of the most complicated things explained here.
Some useful functions you might be looking for
bot.activateItem() - activates the item in the bots hand (used for right clicking compass and such)
bot.dig() - you need "prismarine-block" for some of it to function correctly
bot.clickWindow(slot, type, mode) both type and mode are explained here: https://wiki.vg/Protocol#Click_Window - clicks a slot in an inventory to switch lobby etc.
https://github.com/PrismarineJS/mineflay...r/examples - official examples you might find useful
bot.setControlState('state') - allows you to control the bots state like shifting sprinting or going forward
bot.setQuickBarSlot('slot 0-8') - selects a hotbar slot
That's all. I hope this will help atleast one person fix their bot or remove confusion. If you have any questions please look through the official examples and the official API documentation: https://mineflayer.prismarine.js.org/#/api
Users browsing this thread: 1 Guest(s)