packet

package
v0.0.0-...-1cf8517 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CorrectPlayerMovePrediction

type CorrectPlayerMovePrediction struct {
	// Position is the position that the player is supposed to be at the tick written in the field below.
	// The client will change its current position based on movement after that tick starting from the
	// Position.
	Position mgl32.Vec3
	// Delta is the change in position compared to what the client sent as its position at that specific tick.
	Delta mgl32.Vec3
	// OnGround specifies if the player was on the ground at the time of the tick below.
	OnGround bool
	// Tick is the tick of the movement which was corrected by this packet.
	Tick uint64
}

CorrectPlayerMovePrediction is sent by the server if and only if StartGame.ServerAuthoritativeMovementMode is set to AuthoritativeMovementModeServerWithRewind. The packet is used to correct movement at a specific point in time.

func (*CorrectPlayerMovePrediction) ID

ID ...

func (*CorrectPlayerMovePrediction) Marshal

func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO)

type LevelChunk

type LevelChunk struct {
	// Position contains the X and Z coordinates of the chunk sent. You can convert a block coordinate to a chunk
	// coordinate by right-shifting it four bits.
	Position protocol.ChunkPos
	// HighestSubChunk is the highest sub-chunk at the position that is not all air. It is only set if the
	// SubChunkCount is set to protocol.SubChunkRequestModeLimited.
	HighestSubChunk uint16
	// SubChunkCount is the amount of sub-chunks that are part of the chunk
	// sent. Depending on if the cache is enabled, a list of blob hashes will be
	// sent, or, if disabled, the sub-chunk data. SubChunkCount may be set to
	// protocol.SubChunkRequestModeLimited or
	// protocol.SubChunkRequestModeLimitless to prompt the client to send a
	// SubChunkRequest in response. If this field is set to
	// protocol.SubChunkRequestModeLimited, HighestSubChunk is used.
	SubChunkCount uint32
	// CacheEnabled specifies if the client blob cache should be enabled. This system is based on hashes of
	// blobs which are consistent and saved by the client in combination with that blob, so that the server
	// does not have the same chunk multiple times. If the client does not yet have a blob with the hash sent,
	// it will send a ClientCacheBlobStatus packet containing the hashes is does not have the data of.
	CacheEnabled bool
	// BlobHashes is a list of all blob hashes used in the chunk. It is composed of SubChunkCount + 1 hashes,
	// with the first SubChunkCount hashes being those of the sub-chunks and the last one that of the biome
	// of the chunk.
	// If CacheEnabled is set to false, BlobHashes can be left empty.
	BlobHashes []uint64
	// RawPayload is a serialised string of chunk data. The data held depends on if CacheEnabled is set to
	// true. If set to false, the payload is composed of multiple sub-chunks, each of which carry a version
	// which indicates the way they are serialised, followed by biomes, border blocks and tile entities. If
	// CacheEnabled is true, the payload consists out of the border blocks and tile entities only.
	RawPayload []byte
}

LevelChunk is sent by the server to provide the client with a chunk of a world data (16xYx16 blocks). Typically, a certain amount of chunks is sent to the client before sending it the spawn PlayStatus packet, so that the client spawns in a loaded world.

func (*LevelChunk) ID

func (*LevelChunk) ID() uint32

ID ...

func (*LevelChunk) Marshal

func (pk *LevelChunk) Marshal(io protocol.IO)

type PlayerAuthInput

type PlayerAuthInput struct {
	// Pitch and Yaw hold the rotation that the player reports it has.
	Pitch, Yaw float32
	// Position holds the position that the player reports it has.
	Position mgl32.Vec3
	// MoveVector is a Vec2 that specifies the direction in which the player moved, as a combination of X/Z
	// values which are created using the WASD/controller stick state.
	MoveVector mgl32.Vec2
	// HeadYaw is the horizontal rotation of the head that the player reports it has.
	HeadYaw float32
	// InputData is a combination of bit flags that together specify the way the player moved last tick. It
	// is a combination of the flags above.
	InputData uint64
	// InputMode specifies the way that the client inputs data to the screen. It is one of the constants that
	// may be found above.
	InputMode uint32
	// PlayMode specifies the way that the player is playing. The values it holds, which are rather random,
	// may be found above.
	PlayMode uint32
	// InteractionModel is a constant representing the interaction model the player is using. It is one of the
	// constants that may be found above.
	InteractionModel int32
	// GazeDirection is the direction in which the player is gazing, when the PlayMode is PlayModeReality: In
	// other words, when the player is playing in virtual reality.
	GazeDirection mgl32.Vec3
	// Tick is the server tick at which the packet was sent. It is used in relation to
	// CorrectPlayerMovePrediction.
	Tick uint64
	// Delta was the delta between the old and the new position. There isn't any practical use for this field
	// as it can be calculated by the server itself.
	Delta mgl32.Vec3
	// ItemInteractionData is the transaction data if the InputData includes an item interaction.
	ItemInteractionData protocol.UseItemTransactionData
	// ItemStackRequest is sent by the client to change an item in their inventory.
	ItemStackRequest protocol.ItemStackRequest
	// BlockActions is a slice of block actions that the client has interacted with.
	BlockActions []protocol.PlayerBlockAction
	// AnalogueMoveVector is a Vec2 that specifies the direction in which the player moved, as a combination
	// of X/Z values which are created using an analogue input.
	AnalogueMoveVector mgl32.Vec2
}

PlayerAuthInput is sent by the client to allow for server authoritative movement. It is used to synchronise the player input with the position server-side. The client sends this packet when the ServerAuthoritativeMovementMode field in the StartGame packet is set to true, instead of the MovePlayer packet. The client will send this packet once every tick.

func (*PlayerAuthInput) ID

func (pk *PlayerAuthInput) ID() uint32

ID ...

func (*PlayerAuthInput) Marshal

func (pk *PlayerAuthInput) Marshal(io protocol.IO)

type PlayerList

type PlayerList struct {
	// ActionType is the action to execute upon the player list. The entries that follow specify which entries
	// are added or removed from the player list.
	ActionType byte
	// Entries is a list of all player list entries that should be added/removed from the player list,
	// depending on the ActionType set.
	Entries []types.PlayerListEntry
}

PlayerList is sent by the server to update the client-side player list in the in-game menu screen. It shows the icon of each player if the correct XUID is written in the packet. Sending the PlayerList packet is obligatory when sending an AddPlayer packet. The added player will not show up to a client if it has not been added to the player list, because several properties of the player are obtained from the player list, such as the skin.

func (*PlayerList) ID

func (*PlayerList) ID() uint32

ID ...

func (*PlayerList) Marshal

func (pk *PlayerList) Marshal(io protocol.IO)

Jump to

Keyboard shortcuts

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