MCPcopy Index your code
hub / github.com/Tnze/go-mc

github.com/Tnze/go-mc @v1.20.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.20.2 ↗ · + Follow
3,534 symbols 6,990 edges 296 files 248 documented · 7% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Go-MC

Version Go Reference Go Report Card Discord

教程 · Tutorial

文档 · Documents

Require Go version: 1.20

There's some library in Go support you to create your Minecraft client or server.
这是一些Golang库,用于帮助你编写自己的Minecraft客户端或服务器。

  • [x] 👍 Minecraft network protocol
  • [x] 👍 Robot framework
  • [x] 👍 Server framework
  • [x] 👍 Dual role RCON protocol (Server & Client)
  • [x] 👍 Chat Message (Support both Json and old § format)
  • [x] 👍 NBT (Based on reflection)
  • [x] 👌 SNBT ⇋ NBT
  • [x] 👍 Regions & Chunks & Blocks
  • [x] ⌛ Yggdrasil (Mojang login)
  • [x] ⌛ Realms Server

We don't promise that API is 100% backward compatible.

Getting start

Go-MC tag the old version after new version released. For example, if 1.19.4 is the latest Minecraft version, the newest go-mc tag will be v1.19.3. To get the latest Go-MC that support 1.19.4, usually you must use go get -u github.com/Tnze/go-mc@master. Special cases are version like 1.19, the Go-MC support it is tagged v1.19.0 to avoid automatically upgrade.

Examples:
To get the latest version: go get github.com/Tnze/go-mc@master
To get old versions (e.g. 1.18.2): go get github.com/Tnze/go-mc@v1.18.2 To get the first of each primary version: go get github.com/Tnze/go-mc@v1.19.0

Run Examples

  • Run go run github.com/Tnze/go-mc/examples/mcping localhost to ping and list the localhost mc server.
  • Run go run github.com/Tnze/go-mc/examples/daze to join the local server at localhost:25565 as player named Daze on the offline mode.

Extension points exported contracts — how you extend this code

Entity (Interface)
go:generate go run ./generator/blockentities/main.go [41 implementers]
level/block/blockentity.go
LoginHandler (Interface)
LoginHandler is used to handle player login process, that is, from clientbound "LoginStart" packet to serverbound "Login [2 …
server/login.go
Writer (Interface)
(no doc) [3 implementers]
net/interface.go
Unmarshaler (Interface)
(no doc) [2 implementers]
nbt/interface.go
RCONServerConn (Interface)
RCONServerConn is the connection in the server side.
net/rcon.go
MCDialer (Interface)
MCDialer provide DialMCContext method, can be used to dial a minecraft server. [Dialer] is its default implementation, a
net/conn.go
Field (Interface)
A Field is both FieldEncoder and FieldDecoder
net/packet/types.go
ListPingHandler (Interface)
ListPingHandler collect server running status info which is used to handle client ping and list progress.
server/ping.go

Core symbols most depended-on inside this repo

SetLanguage
called by 140
chat/message.go
Write
called by 80
net/packet/types.go
Close
called by 52
net/queue/queue.go
Scan
called by 48
net/packet/packet.go
ID
called by 42
level/block/block.go
Decode
called by 40
nbt/decode.go
Set
called by 32
nbt/dynbt/update.go
Error
called by 32
nbt/dynbt/decode.go

Shape

Method 1,676
Struct 1,233
Function 514
TypeAlias 80
Interface 27
Class 2
FuncType 2

Languages

Go100%
Java1%

Modules by API surface

level/block/blocks.go2,006 symbols
level/block/properties_enum.go92 symbols
net/packet/types.go82 symbols
level/block/blockentities.go82 symbols
level/palette.go48 symbols
level/block/blockentity.go47 symbols
level/chunk.go31 symbols
nbt/snbt_scanner.go30 symbols
nbt/dynbt/types.go29 symbols
server/command/builders.go27 symbols
server/internal/bvh/vector.go23 symbols
net/rcon.go21 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add go-mc \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact