Skip to content

MrJulus/MinecraftBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bot Features Documentation

This document outlines the key functionalities of the Minecraft bot.

Config

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.

Chat Commands

a. Hello Command

If the bot receives the message hi or hello, it replies with a greeting message.

Example:

if (message === 'hi' || message === 'hello') {
    bot.chat(`Hi ${username} !`);
}

b. Whisper Command

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>

c. Follow Command

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
}

d. Drop Item Command

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
}

e. Found Wood Command

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
}

f. Equip Armor Command

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
}

g. Teleport Command

The bot can teleport to a player or coordinates using the tp <player> or tp <x> <y> <z> command.

Examples:

tp <player_name>
tp <x> <y> <z>

3. Health and Food Management

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();
    }
});

4. Item Collection on Drop

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`);
    }
});

5. Player Joined

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} !`);
});

6. Bot Respawn

When the bot dies, it automatically respawns and sends a death message.

bot.on('death', function () {
    bot.emit("respawn");
    bot.chat('I am dead');
});

7. Error Handling

The bot logs any errors or issues encountered during its operation.

bot.on('error', function (err) {
    console.error("Bot error: ", err);
});

8. Bot Kick Handling

If the bot is kicked from the server, it logs the reason.

bot.on('kicked', function (reason) {
    console.log("Kicked for: ", reason);
});

9. Bot End Handling

When the bot disconnects, it logs the event.

bot.on('end', function () {
    console.log("Bot has ended");
});

❤️ Contributors

  • Mr_Julus (@MrJulus)

💡 Feel free to contribute by opening an issue or a pull request!

About

A simple Minecraft Bot with some features

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published