2020-05-24 13:10:16 +08:00
2019-12-23 13:25:59 +08:00
2020-05-24 12:40:01 +08:00
2020-04-26 13:06:42 +08:00
2020-01-25 16:13:12 +08:00
2019-07-29 10:47:33 +08:00
2020-03-06 10:32:36 +08:00
2019-09-10 09:33:32 +08:00
2019-09-10 09:06:56 +08:00
2020-05-24 13:10:16 +08:00

Go-MC

Version Protocol GoDoc Go Report Card Build Status

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

  • Chat
  • NBT
  • Yggdrasil
  • Realms Server
  • RCON protocol
  • Saves decoding /encoding
  • Minecraft network protocol
  • Simple MC robot lib

bot:

  • Swing arm
  • Get inventory
  • Pick item
  • Drop item
  • Swap item in hands
  • Use item
  • Use entity
  • Attack entity
  • Use/Place block
  • Mine block
  • Custom packets
  • Record entities

由于仍在开发中部分API在未来版本中可能会变动

Some examples are at /cmd folder.
有一些例子在cmd目录下

1.13.2 version is at gomcbot.

Getting start

After you install golang tools:
To get latest version: go get github.com/Tnze/go-mc@master
To get old versions (eg. 1.14.3): go get github.com/Tnze/go-mc@v1.14.3

First of all, you might have a try of the simple examples. It's a good start.

Run Examples

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

Basic Useage

One of the most useful functions of this lib is that it implements the network communication protocol of minecraft. It allows you to construct, send, receive, and parse network packets. All of them are encapsulated in go-mc/net and go-mc/net/packet.

import "github.com/Tnze/go-mc/net"
import pk "github.com/Tnze/go-mc/net/packet"

It's very easy to create a packet. For example, after any client connected the server, it sends a Handshake Packet. You can create this package with the following code:

p := pk.Marshal(
    0x00,                       // Handshake packet ID
    pk.VarInt(ProtocolVersion), // Protocol version
    pk.String("localhost"),     // Server's address
    pk.UnsignedShort(25565),    // Server's port
    pk.Byte(1),                 // 1 for status ping, 2 for login
)

Then send it to server using conn.WritePacket(p). conn is a net.Conn returned by net.Dial()

Description
No description provided
Readme MIT 126 MiB
Languages
Go 98.1%
Java 1.9%