Documentation ¶
Index ¶
- Variables
- func ReadNBytes(r DecodeReader, n int) ([]byte, error)
- func ReadPacketBytes(r DecodeReader) ([]byte, error)
- func ScanFields(r DecodeReader, fields ...FieldDecoder) error
- type Boolean
- type Byte
- type ByteArray
- type Chat
- type DecodeReader
- type Field
- type FieldDecoder
- type FieldEncoder
- type Identifier
- type Long
- type OptionalByteArray
- type Packet
- type PeekReader
- type String
- type UUID
- type UnsignedShort
- type VarInt
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidPacketID = errors.New("invalid packet id")
)
Functions ¶
func ReadNBytes ¶
func ReadNBytes(r DecodeReader, n int) ([]byte, error)
ReadNBytes read N bytes from bytes.Reader
func ReadPacketBytes ¶
func ReadPacketBytes(r DecodeReader) ([]byte, error)
ReadPacketBytes decodes a byte stream and cuts the first Packet as a byte array out
func ScanFields ¶
func ScanFields(r DecodeReader, fields ...FieldDecoder) error
ScanFields decodes a byte stream into fields
Types ¶
type DecodeReader ¶
type DecodeReader interface { io.ByteReader io.Reader }
DecodeReader is both io.Reader and io.ByteReader
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 OptionalByteArray ¶
type OptionalByteArray []byte
OptionalByteArray is []byte without prefix VarInt as length
func (*OptionalByteArray) Decode ¶
func (b *OptionalByteArray) Decode(r DecodeReader) error
Decode a OptionalByteArray
func (OptionalByteArray) Encode ¶
func (b OptionalByteArray) Encode() []byte
Encode a OptionalByteArray
type Packet ¶
Packet is the raw representation of message that is send between the client and the server
func MarshalPacket ¶
func MarshalPacket(ID byte, fields ...FieldEncoder) Packet
MarshalPacket transforms an ID and Fields into a Packet
func PeekPacket ¶
func PeekPacket(p PeekReader) (Packet, error)
PeekPacket decodes and decompresses a byte stream and peeks the first Packet
func ReadPacket ¶
func ReadPacket(r DecodeReader) (Packet, error)
ReadPacket decodes and decompresses a byte stream and cuts the first Packet out
func (Packet) Scan ¶
func (pk Packet) Scan(fields ...FieldDecoder) error
Scan decodes and copies the Packet data into the fields
type UnsignedShort ¶
type UnsignedShort uint16
UnsignedShort is unsigned 16-bit integer
func (*UnsignedShort) Decode ¶
func (us *UnsignedShort) Decode(r DecodeReader) error
Decode a UnsignedShort