legacypacket

package
v0.0.0-...-4c637a3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InventoryTransactionTypeNormal = iota
	InventoryTransactionTypeMismatch
	InventoryTransactionTypeUseItem
	InventoryTransactionTypeUseItemOnEntity
	InventoryTransactionTypeReleaseItem
)
View Source
const (
	MoveModeNormal = iota
	MoveModeReset
	MoveModeTeleport
	MoveModeRotation
)
View Source
const (
	TeleportCauseUnknown = iota
	TeleportCauseProjectile
	TeleportCauseChorusFruit
	TeleportCauseCommand
	TeleportCauseBehaviour
)
View Source
const (
	PlayerActionStartBreak = iota
	PlayerActionAbortBreak
	PlayerActionStopBreak
	PlayerActionGetUpdatedBlock
	PlayerActionDropItem
	PlayerActionStartSleeping
	PlayerActionStopSleeping
	PlayerActionRespawn
	PlayerActionJump
	PlayerActionStartSprint
	PlayerActionStopSprint
	PlayerActionStartSneak
	PlayerActionStopSneak
	PlayerActionDimensionChangeRequest
	PlayerActionDimensionChangeDone
	PlayerActionStartGlide
	PlayerActionStopGlide
	PlayerActionBuildDenied
	PlayerActionContinueBreak

	PlayerActionSetEnchantmentSeed
	PlayerActionStartSwimming
	PlayerActionStopSwimming
	PlayerActionStartSpinAttack
	PlayerActionStopSpinAttack
)
View Source
const (
	PlayerListActionAdd = iota
	PlayerListActionRemove
)
View Source
const (
	TextTypeRaw = iota
	TextTypeChat
	TextTypeTranslation
	TextTypePopup
	TextTypeJukeboxPopup
	TextTypeTip
	TextTypeSystem
	TextTypeWhisper
	TextTypeAnnouncement
	TextTypeJSON
)

Variables

This section is empty.

Functions

func PlayerListRemoveEntry

func PlayerListRemoveEntry(r protocol.IO, x *PlayerListEntry)

PlayerListRemoveEntry encodes/decodes a PlayerListEntry for removal from the list.

Types

type ActorPickRequest

type ActorPickRequest struct {
	// EntityUniqueID is the unique ID of the entity that was attempted to be picked. The server must find the
	// type of that entity and provide the correct spawn egg to the player.
	EntityUniqueID int64
	// HotBarSlot is the held hot bar slot of the player at the time of trying to pick the entity. If empty,
	// the resulting spawn egg should be put into this slot.
	HotBarSlot byte
}

ActorPickRequest is sent by the client when it tries to pick an entity, so that it gets a spawn egg which can spawn that entity.

func (*ActorPickRequest) ID

func (*ActorPickRequest) ID() uint32

ID ...

func (*ActorPickRequest) Marshal

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

Marshal ...

type AddActor

type AddActor struct {
	// EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across
	// different sessions of the same world, but most servers simply fill the runtime ID of the entity out for
	// this field.
	EntityUniqueID int64
	// EntityNetworkID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// EntityType is the string entity type of the entity, for example 'minecraft:skeleton'. A list of these
	// entities may be found online.
	EntityType string
	// Position is the position to spawn the entity on. If the entity is on a distance that the player cannot
	// see it, the entity will still show up if the player moves closer.
	Position mgl32.Vec3
	// Velocity is the initial velocity the entity spawns with. This velocity will initiate client side
	// movement of the entity.
	Velocity mgl32.Vec3
	// Pitch is the vertical rotation of the entity. Facing straight forward yields a pitch of 0. Pitch is
	// measured in degrees.
	Pitch float32
	// Yaw is the horizontal rotation of the entity. Yaw is also measured in degrees.
	Yaw float32
	// HeadYaw is the same as Yaw, except that it applies specifically to the head of the entity. A different
	// value for HeadYaw than Yaw means that the entity will have its head turned.
	HeadYaw float32
	// Attributes is a slice of attributes that the entity has. It includes attributes such as its health,
	// movement speed, etc.
	Attributes []legacyprotocol.Attribute
	// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
	// particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'.
	// The metadata values are indexed by their property key.
	EntityMetadata map[uint32]any
	// EntityLinks is a list of entity links that are currently active on the entity. These links alter the
	// way the entity shows up when first spawned in terms of it shown as riding an entity. Setting these
	// links is important for new viewers to see the entity is riding another entity.
	EntityLinks []legacyprotocol.EntityLink
}

AddActor is sent by the server to the client to spawn an entity to the player. It is used for every entity except other players, for which the AddPlayer packet is used.

func (*AddActor) ID

func (*AddActor) ID() uint32

ID ...

func (*AddActor) Marshal

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

Marshal ...

type AddItemActor

type AddItemActor struct {
	// EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across
	// different sessions of the same world, but most servers simply fill the runtime ID of the entity out for
	// this field.
	EntityUniqueID int64
	// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// Item is the item that is spawned. It must have a valid ID for it to show up client-side. If it is not
	// a valid item, the client will crash when coming near.
	Item legacyprotocol.ItemStack
	// Position is the position to spawn the entity on. If the entity is on a distance that the player cannot
	// see it, the entity will still show up if the player moves closer.
	Position mgl32.Vec3
	// Velocity is the initial velocity the entity spawns with. This velocity will initiate client side
	// movement of the entity.
	Velocity mgl32.Vec3
	// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
	// particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'.
	// The metadata values are indexed by their property key.
	EntityMetadata map[uint32]any
	// FromFishing specifies if the item was obtained by fishing it up using a fishing rod. It is not clear
	// why the client needs to know this.
	FromFishing bool
}

AddItemActor is sent by the server to the client to make an item entity show up. It is one of the few entities that cannot be sent using the AddActor packet

func (*AddItemActor) ID

func (*AddItemActor) ID() uint32

ID ...

func (*AddItemActor) Marshal

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

Marshal ...

type AddPlayer

type AddPlayer struct {
	// UUID is the UUID of the player. It is the same UUID that the client sent in the Login packet at the
	// start of the session. A player with this UUID must exist in the player list (built up using the
	// PlayerList packet), for it to show up in-game.
	UUID uuid.UUID
	// Username is the name of the player. This username is the username that will be set as the initial
	// name tag of the player.
	Username string
	// EntityUniqueID is the unique ID of the player. The unique ID is a value that remains consistent across
	// different sessions of the same world, but most servers simply fill the runtime ID of the player out for
	// this field.
	EntityUniqueID int64
	// EntityNetworkID is the runtime ID of the player. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for
	// Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to
	// chat with each other.
	PlatformChatID string
	// Position is the position to spawn the player on. If the player is on a distance that the viewer cannot
	// see it, the player will still show up if the viewer moves closer.
	Position mgl32.Vec3
	// Velocity is the initial velocity the player spawns with. This velocity will initiate client side
	// movement of the player.
	Velocity mgl32.Vec3
	// Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is
	// measured in degrees.
	Pitch float32
	// Yaw is the horizontal rotation of the player. Yaw is also measured in degrees.
	Yaw float32
	// HeadYaw is the same as Yaw, except that it applies specifically to the head of the player. A different
	// value for HeadYaw than Yaw means that the player will have its head turned.
	HeadYaw float32
	// HeldItem is the item that the player is holding. The item is shown to the viewer as soon as the player
	// itself shows up. Needless to say that this field is rather pointless, as additional packets still must
	// be sent for armour to show up.
	HeldItem legacyprotocol.ItemStack
	// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
	// particular the way the player looks. Flags include ones such as 'on fire' and 'sprinting'.
	// The metadata values are indexed by their property key.
	EntityMetadata map[uint32]any
	// Flags is a set of flags that specify certain properties of the player, such as whether or not it can
	// fly and/or move through blocks.
	Flags uint32
	// CommandPermissionLevel is a set of permissions that specify what commands a player is allowed to execute.
	CommandPermissionLevel uint32
	// ActionPermissions is, much like Flags, a set of flags that specify actions that the player is allowed
	// to undertake, such as whether it is allowed to edit blocks, open doors etc.
	ActionPermissions uint32
	// PermissionLevel is the permission level of the player as it shows up in the player list built up using
	// the PlayerList packet.
	PermissionLevel uint32
	// CustomStoredPermissions ...
	CustomStoredPermissions uint32
	// PlayerUniqueID is a unique identifier of the player. It appears it is not required to fill this field
	// out with a correct value. Simply writing 0 seems to work.
	PlayerUniqueID int64
	// EntityLinks is a list of entity links that are currently active on the player. These links alter the
	// way the player shows up when first spawned in terms of it shown as riding an entity. Setting these
	// links is important for new viewers to see the player is riding another entity.
	EntityLinks []legacyprotocol.EntityLink
	// DeviceID is the device ID set in one of the files found in the storage of the device of the player. It
	// may be changed freely, so it should not be relied on for anything.
	DeviceID string
}

AddPlayer is sent by the server to the client to make a player entity show up client-side. It is one of the few entities that cannot be sent using the AddActor packet.

func (*AddPlayer) ID

func (*AddPlayer) ID() uint32

ID ...

func (*AddPlayer) Marshal

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

Marshal ...

type AvailableCommands

type AvailableCommands struct {
	// Commands is a list of all commands that the client should show client-side. The AvailableCommands
	// packet replaces any commands sent before. It does not only add the commands that are sent in it.
	Commands []legacyprotocol.Command
}

AvailableCommands is sent by the server to send a list of all commands that the player is able to use on the server. This packet holds all the arguments of each commands as well, making it possible for the client to provide auto-completion and command usages.

func (*AvailableCommands) ID

func (*AvailableCommands) ID() uint32

ID ...

func (*AvailableCommands) Marshal

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

type CommandRequest

type CommandRequest struct {
	// CommandLine is the raw entered command line. The client does no parsing of the command line by itself
	// (unlike it did in the early stages), but lets the server do that.
	CommandLine string
	// CommandOrigin is the data specifying the origin of the command. In other words, the source that the
	// command was from, such as the player itself or a websocket server.
	CommandOrigin protocol.CommandOrigin
	// Internal specifies if the command request internal. Setting it to false seems to work and the usage of
	// this field is not known.
	Internal bool
}

CommandRequest is sent by the client to request the execution of a server-side command. Although some servers support sending commands using the Text packet, this packet is guaranteed to have the correct result.

func (*CommandRequest) ID

func (*CommandRequest) ID() uint32

ID ...

func (*CommandRequest) Marshal

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

Marshal ...

type ContainerClose

type ContainerClose struct {
	// WindowID is the ID representing the window of the container that should be closed. It must be equal to
	// the one sent in the ContainerOpen packet to close the designated window.
	WindowID byte
}

ContainerClose is sent by the server to close a container the player currently has opened, which was opened using the ContainerOpen packet, or by the client to tell the server it closed a particular container, such as the crafting grid.

func (*ContainerClose) ID

func (*ContainerClose) ID() uint32

ID ...

func (*ContainerClose) Marshal

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

Marshal ...

type Disconnect

type Disconnect struct {
	// HideDisconnectionScreen specifies if the disconnection screen should be hidden when the client is
	// disconnected, meaning it will be sent directly to the main menu.
	HideDisconnectionScreen bool
	// Message is an optional message to show when disconnected. This message is only written if the
	// HideDisconnectionScreen field is set to true.
	Message string
}

Disconnect may be sent by the server to disconnect the client using an optional message to send as the disconnect screen.

func (*Disconnect) ID

func (*Disconnect) ID() uint32

ID ...

func (*Disconnect) Marshal

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

type GameRulesChanged

type GameRulesChanged struct {
	// GameRules defines game rules currently active with their respective values. The value of these game
	// rules may be either 'bool', 'int32' or 'float32'. Some game rules are server side only, and don't
	// necessarily need to be sent to the client.
	GameRules map[string]any
}

GameRulesChanged is sent by the server to the client to update client-side game rules, such as game rules like the 'showCoordinates' game rule.

func (*GameRulesChanged) ID

func (*GameRulesChanged) ID() uint32

ID ...

func (*GameRulesChanged) Marshal

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

Marshal ...

type InventoryContent

type InventoryContent struct {
	// WindowID is the ID that identifies one of the windows that the client currently has opened, or one of
	// the consistent windows such as the main inventory.
	WindowID uint32
	// Content is the new content of the inventory. The length of this slice must be equal to the full size of
	// the inventory window updated.
	Content []legacyprotocol.ItemStack
}

InventoryContent is sent by the server to update the full content of a particular inventory. It is usually sent for the main inventory of the player, but also works for other inventories that are currently opened by the player.

func (*InventoryContent) ID

func (*InventoryContent) ID() uint32

ID ...

func (*InventoryContent) Marshal

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

Marshal ...

type InventorySlot

type InventorySlot struct {
	// WindowID is the ID of the window that the packet modifies. It must point to one of the windows that the
	// client currently has opened.
	WindowID uint32
	// Slot is the index of the slot that the packet modifies. The new item will be set to the slot at this
	// index.
	Slot uint32
	// NewItem is the item to be put in the slot at Slot. It will overwrite any item that may currently
	// be present in that slot.
	NewItem legacyprotocol.ItemStack
}

InventorySlot is sent by the server to update a single slot in one of the inventory windows that the client currently has opened. Usually this is the main inventory, but it may also be the off hand or, for example, a chest inventory.

func (*InventorySlot) ID

func (*InventorySlot) ID() uint32

ID ...

func (*InventorySlot) Marshal

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

Marshal ...

type InventoryTransaction

type InventoryTransaction struct {
	// Actions is a list of actions that took place, that form the inventory transaction together. Each of
	// these actions hold one slot in which one item was changed to another. In general, the combination of
	// all of these actions results in a balanced inventory transaction. This should be checked to ensure that
	// no items are cheated into the inventory.
	Actions []legacyprotocol.InventoryAction
	// TransactionData is a data object that holds data specific to the type of transaction that the
	// TransactionPacket held. Its concrete type must be one of NormalTransactionData, MismatchTransactionData
	// UseItemTransactionData, UseItemOnEntityTransactionData or ReleaseItemTransactionData. If nil is set,
	// the transaction will be assumed to of type InventoryTransactionTypeNormal.
	TransactionData legacyprotocol.InventoryTransactionData
}

InventoryTransaction is a packet sent by the client. It essentially exists out of multiple sub-packets, each of which have something to do with the inventory in one way or another. Some of these sub-packets directly relate to the inventory, others relate to interaction with the world, that could potentially result in a change in the inventory.

func (*InventoryTransaction) ID

ID ...

func (*InventoryTransaction) Marshal

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

Marshal ...

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
	// 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 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)

Marshal ...

type MobArmourEquipment

type MobArmourEquipment struct {
	// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// Helmet is the equipped helmet of the entity. Items that are not wearable on the head will not be
	// rendered by the client. Unlike in Java Edition, blocks cannot be worn.
	Helmet legacyprotocol.ItemStack
	// Chestplate is the chestplate of the entity. Items that are not wearable as chestplate will not be
	// rendered.
	Chestplate legacyprotocol.ItemStack
	// Leggings is the item worn as leggings by the entity. Items not wearable as leggings will not be
	// rendered client-side.
	Leggings legacyprotocol.ItemStack
	// Boots is the item worn as boots by the entity. Items not wearable as boots will not be rendered.
	Boots legacyprotocol.ItemStack
}

MobArmourEquipment is sent by the server to the client to update the armour an entity is wearing. It is sent for both players and other entities, such as zombies.

func (*MobArmourEquipment) ID

func (*MobArmourEquipment) ID() uint32

ID ...

func (*MobArmourEquipment) Marshal

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

Marshal ...

type MobEquipment

type MobEquipment struct {
	// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// NewItem is the new item held after sending the MobEquipment packet. The entity will be shown holding
	// that item to the player it was sent to.
	NewItem legacyprotocol.ItemStack
	// InventorySlot is the slot in the inventory that was held. This is the same as HotBarSlot, and only
	// remains for backwards compatibility.
	InventorySlot byte
	// HotBarSlot is the slot in the hot bar that was held. It is the same as InventorySlot, which is only
	// there for backwards compatibility purposes.
	HotBarSlot byte
	// WindowID is the window ID of the window that had its equipped item changed. This is usually the window
	// ID of the normal inventory, but may also be something else, for example with the off hand.
	WindowID byte
}

MobEquipment is sent by the client to the server and the server to the client to make the other side aware of the new item that an entity is holding. It is used to show the item in the hand of entities such as zombies too.

func (*MobEquipment) ID

func (*MobEquipment) ID() uint32

ID ...

func (*MobEquipment) Marshal

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

Marshal ...

type ModalFormResponse

type ModalFormResponse struct {
	// FormID is the form ID of the form the client has responded to. It is the same as the ID sent in the
	// ModalFormRequest, and may be used to identify which form was submitted.
	FormID uint32
	// ResponseData is a JSON encoded value representing the response of the player. If the form was
	// cancelled, a JSON encoded 'null' is in the response. For a modal form, the response is either true or
	// false, for a menu form, the response is an integer specifying the index of the button clicked, and for
	// a custom form, the response is an array containing a value for each element.
	ResponseData []byte
}

ModalFormResponse is sent by the client in response to a ModalFormRequest, after the player has submitted the form sent. It contains the options/properties selected by the player, or a JSON encoded 'null' if the form was closed by clicking the X at the top right corner of the form.

func (*ModalFormResponse) ID

func (*ModalFormResponse) ID() uint32

ID ...

func (*ModalFormResponse) Marshal

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

Marshal ...

type MovePlayer

type MovePlayer struct {
	// EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// Position is the position to spawn the player on. If the player is on a distance that the viewer cannot
	// see it, the player will still show up if the viewer moves closer.
	Position mgl32.Vec3
	// Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is
	// measured in degrees.
	Pitch float32
	// Yaw is the horizontal rotation of the player. Yaw is also measured in degrees.
	Yaw float32
	// HeadYaw is the same as Yaw, except that it applies specifically to the head of the player. A different
	// value for HeadYaw than Yaw means that the player will have its head turned.
	HeadYaw float32
	// Mode is the mode of the movement. It specifies the way the player's movement should be shown to other
	// players. It is one of the constants above.
	Mode byte
	// OnGround specifies if the player is considered on the ground. Note that proxies or hacked clients could
	// fake this to always be true, so it should not be taken for granted.
	OnGround bool
	// RiddenEntityRuntimeID is the runtime ID of the entity that the player might currently be riding. If not
	// riding, this should be left 0.
	RiddenEntityRuntimeID uint64
	// TeleportCause is written only if Mode is MoveModeTeleport. It specifies the cause of the teleportation,
	// which is one of the constants above.
	TeleportCause int32
	// TeleportItem is the item network ID of the item type that was used to teleport. It is only non-zero if
	// the teleport cause was an item.
	TeleportItem int32
}

MovePlayer is sent by players to send their movement to the server, and by the server to update the movement of player entities to other players.

func (*MovePlayer) ID

func (*MovePlayer) ID() uint32

ID ...

func (*MovePlayer) Marshal

func (pk *MovePlayer) Marshal(r protocol.IO)

Marshal ...

type NetworkChunkPublisherUpdate

type NetworkChunkPublisherUpdate struct {
	// Position is the block position around which chunks loaded will remain shown to the client. Most servers
	// set this position to the position of the player itself.
	Position protocol.BlockPos
	// Radius is the radius in blocks around Position that chunks sent show up in and will remain loaded in.
	// Unlike the RequestChunkRadius and ChunkRadiusUpdated packets, this radius is in blocks rather than
	// chunks, so the chunk radius needs to be multiplied by 16. (Or shifted to the left by 4.)
	Radius uint32
}

NetworkChunkPublisherUpdate is sent by the server to change the point around which chunks are and remain loaded. This is useful for mini-game servers, where only one area is ever loaded, in which case the NetworkChunkPublisherUpdate packet can be sent in the middle of it, so that no chunks ever need to be additionally sent during the course of the game. In reality, the packet is not extraordinarily useful, and most servers just send it constantly at the position of the player. If the packet is not sent at all, no chunks will be shown to the player, regardless of where they are sent.

func (*NetworkChunkPublisherUpdate) ID

ID ...

func (*NetworkChunkPublisherUpdate) Marshal

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

Marshal ...

type PlayerAction

type PlayerAction struct {
	// EntityNetworkID is the runtime ID of the player. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// ActionType is the ID of the action that was executed by the player. It is one of the constants that may
	// be found above.
	ActionType int32
	// BlockPosition is the position of the target block, if the action with the ActionType set concerned a
	// block. If that is not the case, the block position will be zero.
	BlockPosition protocol.BlockPos
	// BlockFace is the face of the target block that was touched. If the action with the ActionType set
	// concerned a block. If not, the face is always 0.
	BlockFace int32
}

PlayerAction is sent by the client when it executes any action, for example starting to sprint, swim, starting the breaking of a block, dropping an item, etc.

func (*PlayerAction) ID

func (*PlayerAction) ID() uint32

ID ...

func (*PlayerAction) Marshal

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

Marshal ...

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 []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)

Marshal ...

type PlayerListEntry

type PlayerListEntry struct {
	// UUID is the UUID of the player as sent in the Login packet when the client joined the server. It must
	// match this UUID exactly for the correct XBOX Live icon to show up in the list.
	UUID uuid.UUID
	// EntityUniqueID is the unique entity ID of the player. This ID typically stays consistent during the
	// lifetime of a world, but servers often send the runtime ID for this.
	EntityUniqueID int64
	// Username is the username that is shown in the player list of the player that obtains a PlayerList
	// packet with this entry. It does not have to be the same as the actual username of the player.
	Username string
	// SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex'
	// for the default Alex skin.
	SkinID string
	// SkinData is a byte slice of 64*32*4, 64*64*4 or 128*128*4 bytes. It is a RGBA ordered byte
	// representation of the skin colours.
	SkinData []byte
	// CapeData is a byte slice of 64*32*4 bytes. It is a RGBA ordered byte representation of the cape
	// colours, much like the SkinData.
	CapeData []byte
	// SkinGeometryName is the geometry name of the skin geometry above. This name must be equal to one of the
	// outer names found in the SkinGeometry, so that the client can find the correct geometry data.
	SkinGeometryName string
	// SkinGeometry is a base64 JSON encoded structure of the geometry data of a skin, containing properties
	// such as bones, uv, pivot etc.
	SkinGeometry []byte
	// XUID is the XBOX Live user ID of the player, which will remain consistent as long as the player is
	// logged in with the XBOX Live account.
	XUID string
	// PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for
	// Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to
	// chat with each other.
	PlatformChatID string
}

PlayerListEntry is an entry found in the PlayerList packet. It represents a single player using the UUID found in the entry, and contains several properties such as the skin.

func (*PlayerListEntry) Marshal

func (x *PlayerListEntry) Marshal(r protocol.IO)

Marshal encodes/decodes a PlayerListEntry.

type PlayerSkin

type PlayerSkin struct {
	// UUID is the UUID of the player as sent in the Login packet when the client joined the server. It must
	// match this UUID exactly for the skin to show up on the player.
	UUID uuid.UUID
	// SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex'
	// for the default Alex skin.
	SkinID string
	// NewSkinName no longer has a function: The field can be left empty at all times.
	NewSkinName string
	// OldSkinName no longer has a function: The field can be left empty at all times.
	OldSkinName string
	// SkinData is a byte slice of 64*32*4, 64*64*4 or 128*128*4 bytes. It is a RGBA ordered byte
	// representation of the skin colours.
	SkinData []byte
	// CapeData is a byte slice of 64*32*4 bytes. It is a RGBA ordered byte representation of the cape
	// colours, much like the SkinData.
	CapeData []byte
	// SkinGeometryName is the geometry name of the skin geometry above. This name must be equal to one of the
	// outer names found in the SkinGeometry, so that the client can find the correct geometry data.
	SkinGeometryName string
	// SkinGeometry is a base64 JSON encoded structure of the geometry data of a skin, containing properties
	// such as bones, uv, pivot etc.
	SkinGeometry []byte
	// PremiumSkin specifies if the skin equipped was a premium skin, meaning a payment was required in the
	// marketplace to get access to it.
	PremiumSkin bool
}

PlayerSkin is sent by the client to the server when it updates its own skin using the in-game skin picker. It is relayed by the server, or sent if the server changes the skin of a player on its own accord. Note that the packet can only be sent for players that are in the player list at the time of sending.

func (*PlayerSkin) ID

func (*PlayerSkin) ID() uint32

ID ...

func (*PlayerSkin) Marshal

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

Marshal ...

type RequestChunkRadius

type RequestChunkRadius struct {
	// ChunkRadius is the requested chunk radius. This value is always the value set in the settings of the
	// player.
	ChunkRadius int32
}

RequestChunkRadius is sent by the client to the server to update the server on the chunk view radius that it has set in the settings. The server may respond with a ChunkRadiusUpdated packet with either the chunk radius requested, or a different chunk radius if the server chooses so.

func (*RequestChunkRadius) ID

func (*RequestChunkRadius) ID() uint32

ID ...

func (*RequestChunkRadius) Marshal

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

type ResourcePackChunkData

type ResourcePackChunkData struct {
	// UUID is the unique ID of the resource pack that the chunk of data is taken out of.
	UUID string
	// ChunkIndex is the current chunk index of the chunk. It is a number that starts at 0 and is incremented
	// for each resource pack data chunk sent to the client.
	ChunkIndex uint32
	// DataOffset is the current progress in bytes or offset in the data that the resource pack data chunk is
	// taken from.
	DataOffset uint64
	// RawPayload is a byte slice containing a chunk of data from the resource pack. It must be of the same size or
	// less than the DataChunkSize set in the ResourcePackDataInfo packet.
	Data []byte
}

ResourcePackChunkData is sent to the client so that the client can download the resource pack. Each packet holds a chunk of the compressed resource pack, of which the size is defined in the ResourcePackDataInfo packet sent before.

func (*ResourcePackChunkData) ID

ID ...

func (*ResourcePackChunkData) Marshal

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

Marshal ...

type ResourcePackStack

type ResourcePackStack struct {
	// TexturePackRequired specifies if the client must accept the texture packs the server has in order to
	// join the server. If set to true, the client gets the option to either download the resource packs and
	// join, or quit entirely. Behaviour packs never have to be downloaded.
	TexturePackRequired bool
	// BehaviourPack is a list of behaviour packs that the client needs to download before joining the server.
	// All of these behaviour packs will be applied together, and the order does not necessarily matter.
	BehaviourPacks []protocol.StackResourcePack
	// TexturePacks is a list of texture packs that the client needs to download before joining the server.
	// The order of these texture packs specifies the order that they are applied in on the client side. The
	// first in the list will be applied first.
	TexturePacks []protocol.StackResourcePack
	// Experimental specifies if the resource packs in the stack are experimental. This is internal and should
	// always be set to false.
	Experimental bool
}

ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs should be applied (and downloaded) by the client.

func (*ResourcePackStack) ID

func (*ResourcePackStack) ID() uint32

ID ...

func (*ResourcePackStack) Marshal

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

Marshal ...

type ResourcePacksInfo

type ResourcePacksInfo struct {
	// TexturePackRequired specifies if the client must accept the texture packs the server has in order to
	// join the server. If set to true, the client gets the option to either download the resource packs and
	// join, or quit entirely. Behaviour packs never have to be downloaded.
	TexturePackRequired bool
	// HasScripts specifies if any of the resource packs contain scripts in them. If set to true, only clients
	// that support scripts will be able to download them.
	HasScripts bool
	// BehaviourPack is a list of behaviour packs that the client needs to download before joining the server.
	// All of these behaviour packs will be applied together.
	BehaviourPacks []legacyprotocol.ResourcePackInfo
	// TexturePacks is a list of texture packs that the client needs to download before joining the server.
	// The order of these texture packs is not relevant in this packet. It is however important in the
	// ResourcePackStack packet.
	TexturePacks []legacyprotocol.ResourcePackInfo
}

ResourcePacksInfo is sent by the server to inform the client on what resource packs the server has. It sends a list of the resource packs it has and basic information on them like the version and description.

func (*ResourcePacksInfo) ID

func (*ResourcePacksInfo) ID() uint32

ID ...

func (*ResourcePacksInfo) Marshal

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

Marshal ...

type SetActorData

type SetActorData struct {
	// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in
	// particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'.
	// The metadata values are indexed by their property key.
	EntityMetadata map[uint32]any
}

SetActorData is sent by the server to update the entity metadata of an entity. It includes flags such as if the entity is on fire, but also properties such as the air it has left until it starts drowning.

func (*SetActorData) ID

func (*SetActorData) ID() uint32

ID ...

func (*SetActorData) Marshal

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

Marshal ...

type SetTitle

type SetTitle struct {
	// ActionType is the type of the action that should be executed upon the title of a player. It is one of
	// the constants above and specifies the response of the client to the packet.
	ActionType int32
	// Text is the text of the title, which has a different meaning depending on the ActionType that the
	// packet has. The text is the text of a title, subtitle or action bar, depending on the type set.
	Text string
	// FadeInDuration is the duration that the title takes to fade in on the screen of the player. It is
	// measured in 20ths of a second (AKA in ticks).
	FadeInDuration int32
	// RemainDuration is the duration that the title remains on the screen of the player. It is measured in
	// 20ths of a second (AKA in ticks).
	RemainDuration int32
	// FadeOutDuration is the duration that the title takes to fade out of the screen of the player. It is
	// measured in 20ths of a second (AKA in ticks).
	FadeOutDuration int32
}

SetTitle is sent by the server to make a title, subtitle or action bar shown to a player. It has several fields that allow setting the duration of the titles.

func (*SetTitle) ID

func (*SetTitle) ID() uint32

ID ...

func (*SetTitle) Marshal

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

type StartGame

type StartGame struct {
	// EntityUniqueID is the unique ID of the player. The unique ID is a value that remains consistent across
	// different sessions of the same world, but most servers simply fill the runtime ID of the entity out for
	// this field.
	EntityUniqueID int64
	// EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// PlayerGameMode is the game mode the player currently has. It is a value from 0-4, with 0 being
	// survival mode, 1 being creative mode, 2 being adventure mode, 3 being survival spectator and 4 being
	// creative spectator.
	PlayerGameMode int32
	// PlayerPosition is the spawn position of the player in the world. In servers this is often the same as
	// the world's spawn position found below.
	PlayerPosition mgl32.Vec3
	// Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is
	// measured in degrees.
	Pitch float32
	// Yaw is the horizontal rotation of the player. Yaw is also measured in degrees.
	Yaw float32
	// WorldSeed is the seed used to generate the world. Unlike in PC edition, the seed is a 32bit integer
	// here.
	WorldSeed int32
	// Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2, with 0 being
	// the overworld, 1 being the nether and 2 being the end.
	Dimension int32
	// Generator is the generator used for the world. It is a value from 0-4, with 0 being old limited worlds,
	// 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and 4 being end worlds. A value of
	// 0 will actually make the client stop rendering chunks you send beyond the world limit.
	Generator int32
	// WorldGameMode is the game mode that a player gets when it first spawns in the world. It has no effect
	// on the actual game mode the player spawns with. See PlayerGameMode for that.
	WorldGameMode int32
	// Difficulty is the difficulty of the world. It is a value from 0-3, with 0 being peaceful, 1 being easy,
	// 2 being normal and 3 being hard.
	Difficulty int32
	// WorldSpawn is the block on which the world spawn of the world. This coordinate has no effect on the
	// place that the client spawns, but it does have an effect on the direction that a compass points.
	WorldSpawn protocol.BlockPos
	// AchievementsDisabled defines if achievements are disabled in the world. The client crashes if this
	// value is set to true while the player's or the world's game mode is creative, and it's recommended to
	// simply always set this to false as a server.
	AchievementsDisabled bool
	// DayCycleLockTime is the time at which the day cycle was locked if the day cycle is disabled using the
	// respective game rule. The client will maintain this time as long as the day cycle is disabled.
	DayCycleLockTime int32
	// EducationMode specifies if the world is specifically for education edition clients. Setting this to
	// true for normal editions actually temporarily 'transforms' the client into Education Edition, with even
	// the ability to see that title on the home screen.
	EducationMode bool
	// EducationFeaturesEnabled specifies if the world has education edition features enabled, such as the
	// blocks or entities specific to education edition.
	EducationFeaturesEnabled bool
	// RainLevel is the level specifying the intensity of the rain falling. When set to 0, no rain falls at
	// all.
	RainLevel float32
	// LightningLevel is the level specifying the intensity of the thunder. This may actually be set
	// independently from the RainLevel, meaning dark clouds can be produced without rain.
	LightningLevel float32
	// ConfirmedPlatformLockedContent ...
	ConfirmedPlatformLockedContent bool
	// MultiPlayerGame specifies if the world is a multi-player game. This should always be set to true for
	// servers.
	MultiPlayerGame bool
	// LANBroadcastEnabled specifies if LAN broadcast was intended to be enabled for the world.
	LANBroadcastEnabled bool
	// XBLBroadcastMode is the mode used to broadcast the joined game across XBOX Live.
	XBLBroadcastMode int32
	// PlatformBroadcastMode is the mode used to broadcast the joined game across the platform.
	PlatformBroadcastMode int32
	// CommandsEnabled specifies if commands are enabled for the player. It is recommended to always set this
	// to true on the server, as setting it to false means the player cannot, under any circumstance, use a
	// command.
	CommandsEnabled bool
	// TexturePackRequired specifies if the texture pack the world might hold is required, meaning the client
	// was forced to download it before joining.
	TexturePackRequired bool
	// GameRules defines game rules currently active with their respective values. The value of these game
	// rules may be either 'bool', 'int32' or 'float32'. Some game rules are server side only, and don't
	// necessarily need to be sent to the client.
	GameRules map[string]any
	// BonusChestEnabled specifies if the world had the bonus map setting enabled when generating it. It does
	// not have any effect client-side.
	BonusChestEnabled bool
	// StartWithMapEnabled specifies if the world has the start with map setting enabled, meaning each joining
	// player obtains a map. This should always be set to false, because the client obtains a map all on its
	// own accord if this is set to true.
	StartWithMapEnabled bool
	// PlayerPermissions is the permission level of the player. It is a value from 0-3, with 0 being visitor,
	// 1 being member, 2 being operator and 3 being custom.
	PlayerPermissions int32
	// ServerChunkTickRadius is the radius around the player in which chunks are ticked. Most servers set this
	// value to a fixed number, as it does not necessarily affect anything client-side.
	ServerChunkTickRadius int32
	// HasLockedBehaviourPack specifies if the behaviour pack of the world is locked, meaning it cannot be
	// disabled from the world. This is typically set for worlds on the marketplace that have a dedicated
	// behaviour pack.
	HasLockedBehaviourPack bool
	// HasLockedTexturePack specifies if the texture pack of the world is locked, meaning it cannot be
	// disabled from the world. This is typically set for worlds on the marketplace that have a dedicated
	// texture pack.
	HasLockedTexturePack bool
	// FromLockedWorldTemplate specifies if the world from the server was from a locked world template. For
	// servers this should always be set to false.
	FromLockedWorldTemplate bool
	// MSAGamerTagsOnly ..
	MSAGamerTagsOnly bool
	// FromWorldTemplate specifies if the world from the server was from a world template. For servers this
	// should always be set to false.
	FromWorldTemplate bool
	// WorldTemplateSettingsLocked specifies if the world was a template that locks all settings that change
	// properties above in the settings GUI. It is recommended to set this to true for servers that do not
	// allow things such as setting game rules through the GUI.
	WorldTemplateSettingsLocked bool
	// OnlySpawnV1Villagers is a hack that Mojang put in place to preserve backwards compatibility with old
	// villagers. The bool is never actually read though, so it has no functionality.
	OnlySpawnV1Villagers bool
	// LevelID is a base64 encoded world ID that is used to identify the world.
	LevelID string
	// WorldName is the name of the world that the player is joining. Note that this field shows up above the
	// player list for the rest of the game session, and cannot be changed. Setting the server name to this
	// field is recommended.
	WorldName string
	// PremiumWorldTemplateID is a UUID specific to the premium world template that might have been used to
	// generate the world. Servers should always fill out an empty string for this.
	PremiumWorldTemplateID string
	// Trial specifies if the world was a trial world, meaning features are limited and there is a time limit
	// on the world.
	Trial bool
	// Time is the total time that has elapsed since the start of the world.
	Time int64
	// EnchantmentSeed is the seed used to seed the random used to produce enchantments in the enchantment
	// table. Note that the exact correct random implementation must be used to produce the correct results
	// both client- and server-side.
	EnchantmentSeed int32
	// Blocks is a list of all blocks and variants existing in the game. Failing to send any of the blocks
	// that are in the game, including any specific variants of that block, will crash mobile clients. It
	// seems Windows 10 games do not crash.
	Blocks []legacymappings.BlockEntry
	// Items is a list of all items with their legacy IDs which are available in the game. Failing to send any
	// of the items that are in the game will crash mobile clients.
	Items []legacymappings.ItemEntry
	// MultiPlayerCorrelationID is a unique ID specifying the multi-player session of the player. A random
	// UUID should be filled out for this field.
	MultiPlayerCorrelationID string
}

StartGame is sent by the server to send information about the world the player will be spawned in. It contains information about the position the player spawns in, and information about the world in general such as its game rules.

func (*StartGame) ID

func (*StartGame) ID() uint32

ID ...

func (*StartGame) Marshal

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

Marshal ...

type StopSound

type StopSound struct {
	// SoundName is the name of the sound that should be stopped from playing. If no sound with this name is
	// currently active, the packet is ignored.
	SoundName string
	// StopAll specifies if all sounds currently playing to the player should be stopped. If set to true, the
	// SoundName field may be left empty.
	StopAll bool
}

StopSound is sent by the server to stop a sound playing to the player, such as a playing music disk track or other long-lasting sounds.

func (*StopSound) ID

func (*StopSound) ID() uint32

ID ...

func (*StopSound) Marshal

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

type Text

type Text struct {
	// TextType is the type of the text sent. When a client sends this to the server, it should always be
	// TextTypeChat. If the server sends it, it may be one of the other text types above.
	TextType byte
	// NeedsTranslation specifies if any of the messages need to be translated. It seems that where % is found
	// in translatable text types, these are translated regardless of this bool. Translatable text types
	// include TextTypeTip, TextTypePopup and TextTypeJukeboxPopup.
	NeedsTranslation bool
	// SourceName is the name of the source of the messages. This source is displayed in text types such as
	// the TextTypeChat and TextTypeWhisper, where typically the username is shown.
	SourceName string
	// Message is the message of the packet. This field is set for each TextType and is the main component of
	// the packet.
	Message string
	// Parameters is a list of parameters that should be filled into the message. These parameters are only
	// written if the type of the packet is TextTypeTip, TextTypePopup or TextTypeJukeboxPopup.
	Parameters []string
	// XUID is the XBOX Live user ID of the player that sent the message. It is only set for packets of
	// TextTypeChat. When sent to a player, the player will only be shown the chat message if a player with
	// this XUID is present in the player list and not muted, or if the XUID is empty.
	XUID string
	// PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for
	// Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to
	// chat with each other.
	PlatformChatID string
}

Text is sent by the client to the server to send chat messages, and by the server to the client to forward or send messages, which may be chat, popups, tips etc.

func (*Text) ID

func (*Text) ID() uint32

ID ...

func (*Text) Marshal

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

Marshal ...

type Transfer

type Transfer struct {
	// Address is the address of the new server, which might be either a hostname or an actual IP address.
	Address string
	// Port is the UDP port of the new server.
	Port uint16
}

Transfer is sent by the server to transfer a player from the current server to another. Doing so will fully disconnect the client, bring it back to the main menu and make it connect to the next server.

func (*Transfer) ID

func (*Transfer) ID() uint32

ID ...

func (*Transfer) Marshal

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

Marshal ...

type UpdateAttributes

type UpdateAttributes struct {
	// EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and
	// entities are generally identified in packets using this runtime ID.
	EntityRuntimeID uint64
	// Attributes is a slice of new attributes that the entity gets. It includes attributes such as its
	// health, movement speed, etc. Note that only changed attributes have to be sent in this packet. It is
	// not required to send attributes that did not have their values changed.
	Attributes []legacyprotocol.Attribute
}

UpdateAttributes is sent by the server to update an amount of attributes of any entity in the world. These attributes include ones such as the health or the movement speed of the entity.

func (*UpdateAttributes) ID

func (*UpdateAttributes) ID() uint32

ID ...

func (*UpdateAttributes) Marshal

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

Marshal ...

Jump to

Keyboard shortcuts

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