This document outlines the key functionalities of the Minecraft bot.
Config your bot with the config.json file.
When the bot is in AFK mode, it will continuously move forward for 5 seconds and then stop.
If the bot receives the message hi
or hello
, it replies with a greeting message.
if (message === 'hi' || message === 'hello') {
bot.chat(`Hi ${username} !`);
}
The bot can whisper a message to another player using the whisper <player> <message>
command. It supports whispering a message to a player with the following format:
whisper <player_name> <message>
The bot can follow a player with the follow <player_name>
command. If the player is me
, the bot will follow the player who issued the command. The bot will stop following with the stopFollow
command.
if (message.startsWith('follow ')) {
// Follow player logic here
}
The bot can drop a specified quantity of an item with the drop <item_name> <quantity>
command. If the bot has enough of the item, it will drop the specified amount.
if (message.startsWith('drop ')) {
// Drop item logic here
}
The bot will find and collect a specified amount of wood with the found wood <quantity>
command. It will drop the wood at the player who requested it.
if (message.startsWith('found wood')) {
// Find and collect wood logic here
}
The bot will equip armor if available. The equip armor
command makes the bot equip the armor items in its inventory.
if (message === 'equip armor') {
// Equip armor logic here
}
The bot can teleport to a player or coordinates using the tp <player>
or tp <x> <y> <z>
command.
tp <player_name>
tp <x> <y> <z>
If the bot's health falls below 2 hearts or if its food level is below 6, the bot will request food and attempt to eat if possible.
bot.on('health', () => {
if (bot.health <= 4) {
bot.chat('I\'m in danger! I have less than 2 hearts!');
}
if (bot.food < 6 && !isEating) {
bot.chat('I\'m hungry! I need food.');
eatFood();
}
});
The bot collects dropped items and adds them to its inventory.
bot.on('drop', (entity) => {
if (entity && entity.item) {
bot.collectBlock.collect(entity);
bot.chat(`Item ${entity.item.name} picked up`);
}
});
The bot greets new players when they join the server.
bot.on('playerJoined', (player) => {
console.log(`${player.username} has joined the server`);
bot.chat(`Hello ${player.username} !`);
});
When the bot dies, it automatically respawns and sends a death message.
bot.on('death', function () {
bot.emit("respawn");
bot.chat('I am dead');
});
The bot logs any errors or issues encountered during its operation.
bot.on('error', function (err) {
console.error("Bot error: ", err);
});
If the bot is kicked from the server, it logs the reason.
bot.on('kicked', function (reason) {
console.log("Kicked for: ", reason);
});
When the bot disconnects, it logs the event.
bot.on('end', function () {
console.log("Bot has ended");
});
- Mr_Julus (@MrJulus)
💡 Feel free to contribute by opening an issue or a pull request!