Documentation ¶
Index ¶
- type ChunkData
- type ClientKeepAlive
- type ClientStatusPing
- type ClientStatusRequest
- type Direction
- type Disconnect
- type EncryptionRequest
- type EncryptionResponse
- type Handshake
- type JoinGame
- type LoginDisconnect
- type LoginStart
- type LoginSuccess
- type Packet
- type ServerKeepAlive
- type ServerPlayerPositionRotation
- type ServerStatusPong
- type ServerStatusResponse
- type SetCompression
- type State
- type UpdateViewPosition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkData ¶
type ChunkData struct { // Column is the chunk column that is being referenced. Column *protocol.Column }
ChunkData is sent by the server to update a chunk client-side
type ClientKeepAlive ¶
type ClientKeepAlive struct { // PingID is the time in Unix milliseconds that the client sent the packet. PingID int64 }
ClientKeepAlive is a packet sent by the client to the server usually every two seconds to keep the connection alive.
func (*ClientKeepAlive) Marshal ¶
func (pk *ClientKeepAlive) Marshal(w *protocol.Writer)
Marshal ...
func (*ClientKeepAlive) Unmarshal ¶
func (pk *ClientKeepAlive) Unmarshal(r *protocol.Reader)
Unmarshal ...
type ClientStatusPing ¶
type ClientStatusPing struct { // Payload a system-dependent time value which is counted in milliseconds. Payload int64 }
ClientStatusPing is sent by the client to the server to request a ServerStatusPong.
func (*ClientStatusPing) Marshal ¶
func (pk *ClientStatusPing) Marshal(w *protocol.Writer)
Marshal ...
func (*ClientStatusPing) Unmarshal ¶
func (pk *ClientStatusPing) Unmarshal(r *protocol.Reader)
Unmarshal ...
type ClientStatusRequest ¶
type ClientStatusRequest struct{}
ClientStatusRequest is sent by the client to the server to request the server status.
func (*ClientStatusRequest) Marshal ¶
func (*ClientStatusRequest) Marshal(*protocol.Writer)
Marshal ...
func (*ClientStatusRequest) Unmarshal ¶
func (*ClientStatusRequest) Unmarshal(*protocol.Reader)
Unmarshal ...
type Direction ¶
type Direction struct {
// contains filtered or unexported fields
}
Direction represents what direction a packet is going.
func DirectionClient ¶
func DirectionClient() Direction
DirectionClient is used when the packet is meant for clients.
func DirectionServer ¶
func DirectionServer() Direction
DirectionServer is used when the packet is meant for servers.
type Disconnect ¶
Disconnect is sent to the client when it's connection is closed.
type EncryptionRequest ¶
type EncryptionRequest struct { // ServerID is always empty post 1.7. ServerID string // PublicKey is the public key of the server. PublicKey rsa.PublicKey // VerifyToken is always 4 random bytes generated by the server. VerifyToken []byte }
EncryptionRequest is sent by the server to request encryption on future packets. If the client accepts, it will send back an EncryptionResponse packet.
func (*EncryptionRequest) Marshal ¶
func (pk *EncryptionRequest) Marshal(w *protocol.Writer)
Marshal ...
func (*EncryptionRequest) Unmarshal ¶
func (pk *EncryptionRequest) Unmarshal(r *protocol.Reader)
Unmarshal ...
type EncryptionResponse ¶
type EncryptionResponse struct { byte // VerifyToken is the same verify token value encrypted with the server's public key. VerifyToken []byte }SharedSecret []
EncryptionResponse is sent back by the client to agree to the encryption. Every future packet will use the agreed upon encryption.
func (*EncryptionResponse) Marshal ¶
func (pk *EncryptionResponse) Marshal(w *protocol.Writer)
Marshal ...
func (*EncryptionResponse) Unmarshal ¶
func (pk *EncryptionResponse) Unmarshal(r *protocol.Reader)
Unmarshal ...
type Handshake ¶
type Handshake struct { // Protocol is the protocol version of the player. The player is disconnected if the protocol is // incompatible with the protocol of the server. Protocol int32 // Address is the address the player used to connect to the server. Address string // Port is the port of the server that the player used to connect with. Port int16 // NextState is either one for status, or two for login. NextState int32 }
Handshake is sent when the client initially tries to join the server. It is the first packet sent and contains information specific to the player.
type JoinGame ¶
type JoinGame struct { // EntityID is the ID of the player joining the game. EntityID int32 // Hardcore is true if hardcore mode is enabled in the game. Hardcore bool // GameMode is the game mode of the game. GameMode byte // PreviousGameMode is the player's previous game mode. PreviousGameMode byte // Worlds contains all worlds on the server. Worlds []string // World is the name of the world the player is joining. World string // HashedSeed contains the first eight bytes of the world seed in an SHA-256 hash. HashedSeed int64 // MaxPlayers was once used by the client to draw the player list, but now is ignored. MaxPlayers int32 // ViewDistance is the maximum view distance the client can use. This ranges from two to thirty-two. ViewDistance int32 // ReducedDebugInfo is true if the client should reduce the amount of debug information it shows on the F3 screen. ReducedDebugInfo bool // EnableRespawnScreen is true if the client should show the respawn screen when the player dies. EnableRespawnScreen bool // Debug is true if the world is in debug mode. Debug bool // Flat is true if the world is flat. Flat bool }
JoinGame is sent by the server to the client to join a game.
type LoginDisconnect ¶
type LoginDisconnect struct { // Reason is the reason for closing the connection. Reason text.Text }
LoginDisconnect is sent to the client when it's connection is closed during login.
func (*LoginDisconnect) Marshal ¶
func (pk *LoginDisconnect) Marshal(w *protocol.Writer)
Marshal ...
func (*LoginDisconnect) Unmarshal ¶
func (pk *LoginDisconnect) Unmarshal(r *protocol.Reader)
Unmarshal ...
type LoginStart ¶
type LoginStart struct { // Username is the username of the player. Username string }
LoginStart is sent by the client to request starting a login.
type LoginSuccess ¶
type LoginSuccess struct { // UUID is the UUID of the player logging in. UUID uuid.UUID // Username is the username of the player logging in. Username string }
LoginSuccess is sent by the server to the client to notify it that it's login attempt was successful. It is the last packet of the login sequence, and is the indicator to switch to the play state.
func (*LoginSuccess) Unmarshal ¶
func (pk *LoginSuccess) Unmarshal(r *protocol.Reader)
Unmarshal ...
type Packet ¶
type Packet interface { // ID returns the ID of the packet. All of these identifiers of packets may be found in id.go. ID() int32 // Marshal encodes the packet to its binary representation into buf. Marshal(w *protocol.Writer) // Unmarshal decodes a serialised packet in buf into the Packet instance. The serialised packet passed // into Unmarshal will not have a header in it. Unmarshal(r *protocol.Reader) }
Packet represents a packet that may be sent over a Minecraft network connection.
type ServerKeepAlive ¶
type ServerKeepAlive struct { // PingID is the time in Unix milliseconds that the server sent the packet. PingID int64 }
ServerKeepAlive is a packet sent by the server to the client usually every two seconds to keep the connection alive.
func (*ServerKeepAlive) Marshal ¶
func (pk *ServerKeepAlive) Marshal(w *protocol.Writer)
Marshal ...
func (*ServerKeepAlive) Unmarshal ¶
func (pk *ServerKeepAlive) Unmarshal(r *protocol.Reader)
Unmarshal ...
type ServerPlayerPositionRotation ¶
type ServerPlayerPositionRotation struct {
// X, Y, Z are the new coordinates of the player.
X, Y, Z float64
// Yaw, Pitch are the new rotation of the player.
Yaw, Pitch float32
// Flags are the flags sent by the server in a bitfield.
Flags byte
// TeleportID is used if the position update was caused by a teleport.
TeleportID int32
// DismountVehicle is used if the player should dismount their vehicle.
DismountVehicle bool
}
ServerPlayerPositionRotation is sent by the server to update the player's position.
func (*ServerPlayerPositionRotation) Marshal ¶
func (pk *ServerPlayerPositionRotation) Marshal(w *protocol.Writer)
Marshal ...
func (*ServerPlayerPositionRotation) Unmarshal ¶
func (pk *ServerPlayerPositionRotation) Unmarshal(r *protocol.Reader)
Unmarshal ...
type ServerStatusPong ¶
type ServerStatusPong struct { // Payload is usually the same payload as the one in ClientStatusPing. Payload int64 }
ServerStatusPong is sent by the server to the client as a response to a ClientStatusPing.
func (*ServerStatusPong) Marshal ¶
func (pk *ServerStatusPong) Marshal(w *protocol.Writer)
Marshal ...
func (*ServerStatusPong) Unmarshal ¶
func (pk *ServerStatusPong) Unmarshal(r *protocol.Reader)
Unmarshal ...
type ServerStatusResponse ¶
type ServerStatusResponse struct { // Status is the JSON encoded status string. Status string }
ServerStatusResponse is a response to the ClientStatusRequest packet, with the status sent as a string encoded in JSON.
func (*ServerStatusResponse) Marshal ¶
func (pk *ServerStatusResponse) Marshal(w *protocol.Writer)
Marshal ...
func (*ServerStatusResponse) Unmarshal ¶
func (pk *ServerStatusResponse) Unmarshal(r *protocol.Reader)
Unmarshal ...
type SetCompression ¶
type SetCompression struct { // Threshold is the compression threshold to be used. Threshold int32 }
SetCompression updates the compression threshold on the client to whatever threshold the server requests. This is usually done right after encryption.
func (*SetCompression) Unmarshal ¶
func (pk *SetCompression) Unmarshal(r *protocol.Reader)
Unmarshal ...
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state the connection is on. These split up the packets that can be accessed to a specific selection based on the state.
func StateHandshaking ¶
func StateHandshaking() State
StateHandshaking represents the handshaking state.
type UpdateViewPosition ¶
type UpdateViewPosition struct {
// X, Z are the coordinates of the new chunk to be viewed.
X, Z int32
}
UpdateViewPosition is sent by the server to update the client's view position.
func (*UpdateViewPosition) Marshal ¶
func (pk *UpdateViewPosition) Marshal(w *protocol.Writer)
Marshal ...
func (*UpdateViewPosition) Unmarshal ¶
func (pk *UpdateViewPosition) Unmarshal(r *protocol.Reader)
Unmarshal ...
Source Files ¶
- bound.go
- chunk_data.go
- client_keep_alive.go
- client_status_ping.go
- client_status_request.go
- collection.go
- disconnect.go
- encryption_request.go
- encryption_response.go
- handshake.go
- join_game.go
- login_disconnect.go
- login_start.go
- login_success.go
- packet.go
- server_keep_alive.go
- server_player_position_rotation.go
- server_status_pong.go
- server_status_response.go
- set_compression.go
- state.go
- update_view_position.go