Documentation ¶
Index ¶
- Variables
- func Supported(protocol Protocol) bool
- type Direction
- type Packet
- type PacketContext
- type PacketId
- type PacketType
- type Protocol
- func (p Protocol) Greater(then *Version) bool
- func (p Protocol) GreaterEqual(then *Version) bool
- func (p Protocol) Legacy() bool
- func (p Protocol) Lower(then *Version) bool
- func (p Protocol) LowerEqual(then *Version) bool
- func (p Protocol) String() string
- func (p Protocol) Supported() bool
- func (p Protocol) Unknown() bool
- func (p Protocol) Version() *Version
- type State
- type Version
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Unknown = &Version{-1, "Unknown"} Legacy = &Version{-2, "Legacy"} Minecraft_1_7_2 = &Version{4, "1.7.2"} Minecraft_1_7_6 = &Version{5, "1.7.6"} Minecraft_1_8 = &Version{47, "1.8"} Minecraft_1_9 = &Version{107, "1.9"} Minecraft_1_9_1 = &Version{108, "1.9.1"} Minecraft_1_9_4 = &Version{110, "1.9.4"} Minecraft_1_11 = &Version{315, "1.11"} Minecraft_1_12 = &Version{335, "1.12"} Minecraft_1_12_1 = &Version{338, "1.12.1"} Minecraft_1_12_2 = &Version{340, "1.12.2"} Minecraft_1_13 = &Version{393, "1.13"} Minecraft_1_13_2 = &Version{404, "1.13.2"} Minecraft_1_14 = &Version{477, "1.14"} Minecraft_1_15 = &Version{573, "1.15"} Minecraft_1_16 = &Version{735, "1.16"} Minecraft_1_16_1 = &Version{736, "1.16.1"} Minecraft_1_16_2 = &Version{751, "1.16.2"} // Versions ordered from lowest to highest Versions = []*Version{ Unknown, Legacy, Minecraft_1_7_2, Minecraft_1_7_6, Minecraft_1_8, Minecraft_1_9, Minecraft_1_9_1, Minecraft_1_9_4, Minecraft_1_11, Minecraft_1_12, Minecraft_1_12_1, Minecraft_1_12_2, Minecraft_1_13, Minecraft_1_13_2, Minecraft_1_14, Minecraft_1_15, Minecraft_1_16, Minecraft_1_16_1, Minecraft_1_16_2, } )
View Source
var ( IdToVersion = func() map[Protocol]*Version { m := make(map[Protocol]*Version, len(Versions)) for _, v := range Versions { m[v.Protocol] = v } return m }() SupportedVersions = func() (v []*Version) { for _, ver := range Versions { if !ver.Unknown() && !ver.Legacy() { v = append(v, ver) } } return }() )
View Source
var ( // The lowest supported version. MinimumVersion = SupportedVersions[0] // The highest supported version. MaximumVersion = SupportedVersions[len(SupportedVersions)-1] // The supported versions range as a string. SupportedVersionsString = fmt.Sprintf("%s-%s", MinimumVersion, MaximumVersion) )
Functions ¶
Types ¶
type Direction ¶
type Direction uint8
Direction is the direction a packet is meant to go to/come from.
type Packet ¶
type Packet interface { Encode(c *PacketContext, wr io.Writer) error // Encodes the packet into the writer Decode(c *PacketContext, rd io.Reader) (err error) // Decodes a packet by reading from the reader }
Packet should be implemented by any Minecraft protocol packet. It is the layer of the protocol packet's data.
type PacketContext ¶
type PacketContext struct { Direction Direction // The direction the packet was bound to. Protocol Protocol // The protocol version of the packet. KnownPacket bool // If false Packet field is nil. PacketId PacketId // Is always set. Packet Packet // The decoded packet. // The unencrypted and uncompressed form of packet id + data. // It contains the actual received payload (may be longer than what the Packet's Decode read). // This can be used to skip encoding Packet. Payload []byte // Empty when encoding. }
type PacketType ¶
PacketType helps to instantiate a new packet of it's reflect type.
func TypeOf ¶
func TypeOf(p Packet) PacketType
TypeOf is a helper func to make sure the reflect.Type of p implements Packet and returns a non-pointer type.
Click to show internal directories.
Click to hide internal directories.