using McProtoNet;
using McProtoNet.Protocol;
using HandshakeSb = McProtoNet.Protocol.Packets.Handshaking.Serverbound;
using LoginSb = McProtoNet.Protocol.Packets.Login.Serverbound;
const int Pv = 772; // 1.21.8
await using var client = new MinecraftClient(
new MinecraftClientOptions { Host = "127.0.0.1", Port = 25565 });
await client.ConnectAsync();
await client.SendAsync(
new HandshakeSb.SetProtocolPacket(Pv, "127.0.0.1", 25565, 2), Pv);
await client.SendAsync(
new LoginSb.LoginStartPacket("McProtoBot", V764_Last: new(Guid.NewGuid())),
Pv);
var bot = new Bot(client, Pv); // the class from First bot
await foreach (var packet in client.ReadPacketsAsync())
await bot.HandleAsync(in packet, Pv);
health 20, food 20
health 20, food 19
health 18, food 19
The step by step walkthrough is in First bot.
The protocol, not the game
Connect to a server, send and receive typed packets, turn on compression and encryption. A base for bots, custom clients and tools.
Fast transport
Compression through libdeflate, hardware AES for the cipher, parsing over Span<byte> without extra copies. NativeAOT compatible.
Offline servers
Handshake and login against servers in offline mode. The join order stays in the application code, so a non-standard server is not a dead end.
Network helpers
SRV record lookup and LAN server discovery.
One build, many versions
1.16 — 26.2
Protocols 735-776. The version is given at connection time, and nothing has to be rebuilt for it.
Packages
The library is split into five NuGet packages. Only McProtoNet is installed; the rest come with it. What is inside each one is in Installation
Where to go next
- First bot - installation, the protocol version, four phases, a bot that works.
- What the library does not do - worth reading before a bot is planned.
- Glossary - frame, phase, ordinal and other words from the API.