Bots

2figures
3min read
Sheet 6 of 47 · Bots

A bot is a player the tool plays. Bots are MCProtocolLib clients that run as threads inside the tool, so they cannot outlive it. They chat, open and click menus, read dialogs, walk with real physics and pathfinding, dig, place, fight, craft, and reconnect on their own.

A bot joins with an offline name, or with a saved premium account for online-mode servers.

The Bots page with eight bots online and one picked.
The Bots page: the bot list with status, position and ping, the picked bot's keys, and its packet log

Adding a bot

In the window the Bots header asks for the server, how to join and a name, then Add bot. Swarm adds many at once and asks who joins, how many, when and where. Over the API the same choices are query parameters on /join and /swarm:

ParameterWhat it does
name=TestBotOffline bot, on a server with online-mode=false
account=<name or uuid>Premium bot from a saved account. See Premium Accounts
count=20&pattern=Test_{n}Swarm: spawns Test_1 to Test_20, staggered
accounts=allSwarm: one bot per saved account
reconnect=1Rejoins after a kick or a dropped connection
version=1.21.8Picks the protocol. Without it the bot asks the server with a status ping

The example assumes the tool runs with --api-port 8767. The default port is 8766.

curl "localhost:8767/join?name=TestBot"

What a bot can do

Every action a bot can do is listed at GET /actions and on the API screen, generated from the live registry. The groups are chat, inventory, world, entities, dialogs, movement, connection, info and packets.

On the Bots page the Actions tab is the same list to search, with one form per action and a named field for every parameter. The answer lands on a screen next to it.

Actions on a bot: pick one, fill in its fields, Run.
The Actions tab of a bot: a searchable list of actions on the left and the chat action's fields c, wait and until with a Run key

Server versions

Bots always speak 1.21.11 (protocol 774), the version MCProtocolLib ships. For any other server the tool puts ViaVersion and ViaBackwards (through ViaLoader) into the bot's own netty pipeline, between the compression and packet codecs. Via rewrites every packet both ways, so chunks, block states, items and windows arrive with 1.21.11 ids and the bot code needs nothing per version. The server needs no plugin.

TopicHow it works
DetectionBefore a bot connects, the tool sends a status ping and takes the protocol the server reports. Results are cached for 30 seconds per host and port, so a swarm pings once
Overrideversion= on /join and /swarm, or "Bot Minecraft version" in Settings. Takes a release (1.21.8), a range name (1.21.7-1.21.8) or a protocol number (772). auto or empty means detect. A bot keeps its version for reconnects
Checked live1.21.4, 1.21.5, 1.21.6, 1.21.8, 1.21.10 and 1.21.11, offline and in online mode with a premium account, and 26.2 on Folia with no Via plugin on the server. Join, chat, commands, /win on menus, block reads and inventory
First joinVia loads its mappings the first time a bot joins a server that is not on 1.21.11, which takes about a second. Its configs live in via/ViaLoader in the data dir
Seeing it/stats shows the version a bot talks to as serverVersion

Staying connected

A bot answers the server's keep-alive and ping packets itself, in every connection state. The protocol library's own handler only answers while the bot is in game, so a proxy server switch could leave keep-alives unanswered and get the bot dropped; anticheats that send ping packets get their answer too. During a takeover the real client answers them.

A bot that is kicked or loses the connection comes back with reconnect=1. The first try waits reconnectDelaySeconds (5 s), each failed try doubles the wait, up to reconnectMaxDelaySeconds (60 s). Both are on Settings > Bots.

Loading the index

Enter openUp Down moveEsc close