Documentation ¶
Index ¶
- func Compress(data []byte) []byte
- func ReadNBytes(r DecodeReader, n int) (bs []byte, err error)
- type Angle
- type Ary
- type Boolean
- type Byte
- type ByteArray
- type Chat
- type DecodeReader
- type Double
- type Field
- type FieldDecoder
- type FieldEncoder
- type Float
- type Identifier
- type Int
- type Long
- type NBT
- type Opt
- type Packet
- type Position
- type Short
- type String
- type UUID
- type UnsignedByte
- type UnsignedShort
- type VarInt
- type VarLong
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadNBytes ¶
func ReadNBytes(r DecodeReader, n int) (bs []byte, err error)
ReadNBytes read N bytes from bytes.Reader
Types ¶
type Ary ¶
type Ary struct { Len Field Ary interface{} }
func (Ary) Decode ¶
func (a Ary) Decode(r DecodeReader) error
type DecodeReader ¶
type DecodeReader interface { io.ByteReader io.Reader }
DecodeReader is both io.Reader and io.ByteReader
type Double ¶
type Double float64
A Double is a double-precision 64-bit IEEE 754 floating point number
type Field ¶
type Field interface { FieldEncoder FieldDecoder }
A Field is both FieldEncoder and FieldDecoder
type FieldDecoder ¶
type FieldDecoder interface {
Decode(r DecodeReader) error
}
A FieldDecoder can Decode from minecraft protocol
type FieldEncoder ¶
type FieldEncoder interface {
Encode() []byte
}
A FieldEncoder can be encode as minecraft protocol used.
type Identifier ¶
type Identifier = String
Identifier is encoded as a String with max length of 32767.
type Opt ¶
type Opt struct { Has func() bool Field interface{} }
func (Opt) Decode ¶
func (o Opt) Decode(r DecodeReader) error
type Packet ¶
Packet define a net data package
func Marshal ¶
func Marshal(id data.PktID, fields ...FieldEncoder) (pk Packet)
Marshal generate Packet with the ID and Fields
func RecvPacket ¶
func RecvPacket(r DecodeReader, useZlib bool) (*Packet, error)
RecvPacket receive a packet from server
func (Packet) Scan ¶
func (p Packet) Scan(fields ...FieldDecoder) error
Scan decode the packet and fill data into fields
type Position ¶
type Position struct {
X, Y, Z int
}
Position x as a 26-bit integer, followed by y as a 12-bit integer, followed by z as a 26-bit integer (all signed, two's complement)
type UnsignedByte ¶
type UnsignedByte uint8
UnsignedByte is unsigned 8-bit integer
func (*UnsignedByte) Decode ¶
func (ub *UnsignedByte) Decode(r DecodeReader) error
Decode a UnsignedByte
type UnsignedShort ¶
type UnsignedShort uint16
UnsignedShort is unsigned 16-bit integer
func (*UnsignedShort) Decode ¶
func (us *UnsignedShort) Decode(r DecodeReader) error
Decode a UnsignedShort