packet

package
v0.0.0-...-b730334 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameToUUID

func NameToUUID(name string) uuid.UUID

NameToUUID return the UUID from player name in offline mode TODO: implement yggdrasil authentication

func ReadBytes

func ReadBytes(r Reader, n int) (bs []byte, err error)

Types

type Angle

type Angle int8

func (Angle) Encode

func (a Angle) Encode() []byte

type Boolean

type Boolean bool

func (*Boolean) Decode

func (b *Boolean) Decode(r Reader) error

func (Boolean) Encode

func (b Boolean) Encode() []byte

type Byte

type Byte int8

func (*Byte) Decode

func (b *Byte) Decode(r Reader) error

func (Byte) Encode

func (b Byte) Encode() []byte

type ByteArray

type ByteArray []byte

func (*ByteArray) Decode

func (b *ByteArray) Decode(r Reader) error

func (ByteArray) Encode

func (b ByteArray) Encode() []byte

type Chat

type Chat = String

type Decodable

type Decodable interface {
	Decode(r Reader) error
}

type Double

type Double float64

func (*Double) Decode

func (d *Double) Decode(r Reader) error

func (Double) Encode

func (d Double) Encode() (bs []byte)

type Encodable

type Encodable interface {
	Encode() []byte
}

type Field

type Field interface {
	Encodable
	Decodable
}

Field represents a field in a packet. Can be Encoded & Decoded

type Float

type Float float32

func (*Float) Decode

func (f *Float) Decode(r Reader) error

func (Float) Encode

func (f Float) Encode() (bs []byte)

type Identifier

type Identifier = String

type Int

type Int int32

func (*Int) Decode

func (n *Int) Decode(r Reader) error

func (Int) Encode

func (n Int) Encode() (bs []byte)

type Long

type Long int64

func (*Long) Decode

func (n *Long) Decode(r Reader) error

func (Long) Encode

func (n Long) Encode() (bs []byte)

type NBT

type NBT struct {
	V interface{}
}

func (*NBT) Decode

func (n *NBT) Decode(r Reader) error

func (NBT) Encode

func (n NBT) Encode() []byte

type Packet

type Packet struct {
	ID   int32
	Data []byte
}

func Decode

func Decode(r Reader) (Packet, error)

Decode will create a Packet from the given reader

func Marshal

func Marshal(id int32, fields ...Encodable) (p Packet)

Marshal creates a Packet from the given id and fields

func (Packet) Encode

func (p Packet) Encode() (bi []byte)

Encode will format the Packet into the byte array to be sent

func (Packet) Unmarshal

func (p Packet) Unmarshal(fields ...Decodable) error

Unmarshal fills the fields from the Packet Data

type Position

type Position struct {
	X, Y, Z int32
}

func (*Position) Decode

func (p *Position) Decode(r Reader) error

func (Position) Encode

func (p Position) Encode() (bs []byte)

type Reader

type Reader interface {
	io.ByteReader
	io.Reader
}

Reader is used for decoding Fields

type Short

type Short int16

func (*Short) Decode

func (s *Short) Decode(r Reader) error

func (Short) Encode

func (s Short) Encode() (bs []byte)

type Slot

type Slot struct {
	Present   Boolean
	ItemID    VarInt
	ItemCount Byte
	NBT       NBT
}

func (*Slot) Decode

func (s *Slot) Decode(r Reader) error

func (Slot) Encode

func (s Slot) Encode() []byte

type String

type String string

func (*String) Decode

func (s *String) Decode(r Reader) error

func (String) Encode

func (s String) Encode() []byte

type UByte

type UByte uint8

func (*UByte) Decode

func (ub *UByte) Decode(r Reader) error

func (UByte) Encode

func (ub UByte) Encode() []byte

type UShort

type UShort uint16

func (*UShort) Decode

func (us *UShort) Decode(r Reader) error

func (UShort) Encode

func (us UShort) Encode() (bs []byte)

type UUID

type UUID uuid.UUID

func (*UUID) Decode

func (u *UUID) Decode(r Reader) error

func (UUID) Encode

func (u UUID) Encode() []byte

type VarInt

type VarInt int32

func (*VarInt) Decode

func (v *VarInt) Decode(r Reader) error

func (VarInt) Encode

func (v VarInt) Encode() (vs []byte)

type VarLong

type VarLong int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL