Documentation ¶
Index ¶
- Constants
- type AddActor
- type AddPlayer
- type CameraInstruction
- type CameraPresets
- type ChangeDimension
- type CompressedBiomeDefinitionList
- type ContainerClose
- type ContainerRegistryCleanup
- type CorrectPlayerMovePrediction
- type Disconnect
- type EditorNetwork
- type Emote
- type InventoryContent
- type InventorySlot
- type ItemStackResponse
- type MobArmourEquipment
- type MobEffect
- type PlayerArmourDamage
- type PlayerAuthInput
- type ResourcePackStack
- type ResourcePacksInfo
- type SetActorLink
- type SetTitle
- type StartGame
- type StopSound
- type Text
- type Transfer
- type UpdateAttributes
- type UpdateBlockSynced
- type UpdatePlayerGameType
Constants ¶
const ( DimensionOverworld = iota DimensionNether DimensionEnd )
const ( PredictionTypePlayer = iota PredictionTypeVehicle )
const ( EmoteFlagServerSide = 1 << iota EmoteFlagMuteChat )
const ( TitleActionClear = iota TitleActionReset TitleActionSetTitle TitleActionSetSubtitle TitleActionSetActionBar TitleActionSetDurations TitleActionTitleTextObject TitleActionSubtitleTextObject TitleActionActionbarTextObject )
const ( SpawnBiomeTypeDefault = iota SpawnBiomeTypeUserDefined )
const ( ChatRestrictionLevelNone = 0 ChatRestrictionLevelDropped = 1 ChatRestrictionLevelDisabled = 2 )
const ( EditorWorldTypeNotEditor = iota EditorWorldTypeProject EditorWorldTypeTestLevel )
const ( TextTypeRaw = iota TextTypeChat TextTypeTranslation TextTypePopup TextTypeJukeboxPopup TextTypeTip TextTypeSystem TextTypeWhisper TextTypeAnnouncement TextTypeObjectWhisper TextTypeObject TextTypeObjectAnnouncement )
const ( BlockToEntityTransition = iota + 1 EntityToBlockTransition )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 // 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 // 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 // BodyYaw is the same as Yaw, except that it applies specifically to the body of the entity. A different value for // BodyYaw than HeadYaw means that the entity will have its body turned, although it is unclear what the difference // between BodyYaw and Yaw is. BodyYaw float32 // Attributes is a slice of attributes that the entity has. It includes attributes such as its health, // movement speed, etc. Attributes []protocol.AttributeValue // 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 // EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific // attributes of the entity. EntityProperties protocol.EntityProperties // 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 []types.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.
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 // 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 // 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 protocol.ItemInstance // GameType is the game type of the player. If set to GameTypeSpectator, the player will not be shown to viewers. GameType int32 // 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 // EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific // attributes of the entity. EntityProperties protocol.EntityProperties // AbilityData represents various data about the abilities of a player, such as ability layers or permissions. AbilityData protocol.AbilityData // 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 []types.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 // BuildPlatform is the build platform/device OS of the player that is about to be added, as it sent in // the Login packet when joining. BuildPlatform int32 }
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.
type CameraInstruction ¶
type CameraInstruction struct { // Set is a camera instruction that sets the camera to a specified preset. Set protocol.Optional[protocol.CameraInstructionSet] // Clear can be set to true to clear all the current camera instructions. Clear protocol.Optional[bool] // Fade is a camera instruction that fades the screen to a specified colour. Fade protocol.Optional[protocol.CameraInstructionFade] }
CameraInstruction gives a custom camera specific instructions to operate.
func (*CameraInstruction) Marshal ¶
func (pk *CameraInstruction) Marshal(io protocol.IO)
type CameraPresets ¶
type CameraPresets struct { // Presets is a list of camera presets that can be used by other cameras. The order of this list is important because // the index of presets is used as a pointer in the CameraInstruction packet. Presets []types.CameraPreset }
CameraPresets gives the client a list of custom camera presets.
func (*CameraPresets) Marshal ¶
func (pk *CameraPresets) Marshal(io protocol.IO)
type ChangeDimension ¶
type ChangeDimension struct { // Dimension is the dimension that the client should be changed to. The fog colour will change depending // on the type of dimension, which is one of the constants above. // Note that Dimension MUST be a different dimension than the one that the player is currently in. Sending // a ChangeDimension packet with a Dimension that the player is currently in will result in a never-ending // dimension change screen. Dimension int32 // Position is the position in the new dimension that the player is spawned in. Position mgl32.Vec3 // Respawn specifies if the dimension change was respawn based, meaning that the player died in one // dimension and got respawned into another. The client will send a PlayerAction packet with // PlayerActionDimensionChangeRequest if it dies in another dimension, indicating that it needs a // DimensionChange packet with Respawn set to true. Respawn bool }
ChangeDimension is sent by the server to the client to send a dimension change screen client-side. Once the screen is cleared client-side, the client will send a PlayerAction packet with PlayerActionDimensionChangeDone.
func (*ChangeDimension) Marshal ¶
func (pk *ChangeDimension) Marshal(io protocol.IO)
type CompressedBiomeDefinitionList ¶
type CompressedBiomeDefinitionList struct { // SerialisedBiomeDefinitions is a network NBT serialised compound of all definitions of biomes that are // available on the server. SerialisedBiomeDefinitions []byte }
CompressedBiomeDefinitionList is sent by the server to send a list of biomes to the client. The contents of this packet are very large, even after being compressed. This packet is only required when using client-side chunk generation.
func (*CompressedBiomeDefinitionList) Marshal ¶
func (pk *CompressedBiomeDefinitionList) Marshal(io protocol.IO)
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 // ServerSide determines whether or not the container was force-closed by the server. If this value is // not set correctly, the client may ignore the packet and respond with a PacketViolationWarning. ServerSide bool }
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) Marshal ¶
func (pk *ContainerClose) Marshal(io protocol.IO)
type ContainerRegistryCleanup ¶
type ContainerRegistryCleanup struct { // RemovedContainers is a list of protocol.FullContainerName's that should be removed from the client-side // container registry. RemovedContainers []types.FullContainerName }
ContainerRegistryCleanup is sent by the server to trigger a client-side cleanup of the dynamic container registry.
func (*ContainerRegistryCleanup) Marshal ¶
func (pk *ContainerRegistryCleanup) Marshal(io protocol.IO)
type CorrectPlayerMovePrediction ¶
type CorrectPlayerMovePrediction struct { // PredictionType is the type of prediction that was corrected. It is one of the constants above. PredictionType byte // 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) Marshal ¶
func (pk *CorrectPlayerMovePrediction) Marshal(io protocol.IO)
type Disconnect ¶
type Disconnect struct { // Reason is the reason for the disconnection. It seems as if this field has no use other than for // telemetry reasons as it does not affect the message that gets displayed on the disconnect screen. Reason int32 // 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) Marshal ¶
func (pk *Disconnect) Marshal(io protocol.IO)
type EditorNetwork ¶
type EditorNetwork struct { // Payload is a network little endian compound tag holding data relevant to the editor. Payload map[string]any }
EditorNetwork is a packet sent from the server to the client and vise-versa to communicate editor-mode related information. It carries a single compound tag containing the relevant information.
func (*EditorNetwork) Marshal ¶
func (pk *EditorNetwork) Marshal(io protocol.IO)
type Emote ¶
type Emote struct { // EntityRuntimeID is the entity that sent the emote. When a player sends this packet, it has this field // set as its own entity runtime ID. EntityRuntimeID uint64 // EmoteID is the ID of the emote to send. EmoteID string // XUID is the Xbox User ID of the player that sent the emote. It is only set when the emote is used by a player that // is authenticated with Xbox Live. XUID string // PlatformID is an identifier only set for particular platforms when using an emote (presumably only for Nintendo // Switch). It is otherwise an empty string, and is used to decide which players are able to emote with each other. PlatformID string // Flags is a combination of flags that change the way the Emote packet operates. When the server sends // this packet to other players, EmoteFlagServerSide must be present. Flags byte }
Emote is sent by both the server and the client. When the client sends an emote, it sends this packet to the server, after which the server will broadcast the packet to other players online.
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 []protocol.ItemInstance }
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) Marshal ¶
func (pk *InventoryContent) Marshal(io protocol.IO)
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 protocol.ItemInstance }
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) Marshal ¶
func (pk *InventorySlot) Marshal(io protocol.IO)
type ItemStackResponse ¶
type ItemStackResponse struct { // Responses is a list of responses to ItemStackRequests sent by the client before. Responses either // approve or reject a request from the client. // Vanilla limits the size of this slice to 4096. Responses []types.ItemStackResponse }
ItemStackResponse is sent by the server in response to an ItemStackRequest packet from the client. This packet is used to either approve or reject ItemStackRequests from the client. If a request is approved, the client will simply continue as normal. If rejected, the client will undo the actions so that the inventory should be in sync with the server again.
func (*ItemStackResponse) Marshal ¶
func (pk *ItemStackResponse) Marshal(io protocol.IO)
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 protocol.ItemInstance // Chestplate is the chestplate of the entity. Items that are not wearable as chestplate will not be // rendered. Chestplate protocol.ItemInstance // Leggings is the item worn as leggings by the entity. Items not wearable as leggings will not be // rendered client-side. Leggings protocol.ItemInstance // Boots is the item worn as boots by the entity. Items not wearable as boots will not be rendered. Boots protocol.ItemInstance }
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) Marshal ¶
func (pk *MobArmourEquipment) Marshal(io protocol.IO)
type MobEffect ¶
type MobEffect 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 // Operation is the operation of the packet. It is either MobEffectAdd, MobEffectModify or MobEffectRemove // and specifies the result of the packet client-side. Operation byte // EffectType is the ID of the effect to be added, removed or modified. It is one of the constants that // may be found above. EffectType int32 // Amplifier is the amplifier of the effect. Take note that the amplifier is not the same as the effect's // level. The level is usually one higher than the amplifier, and the amplifier can actually be negative // to reverse the behaviour effect. Amplifier int32 // Particles specifies if viewers of the entity that gets the effect shows particles around it. If set to // false, no particles are emitted around the entity. Particles bool // Duration is the duration of the effect in seconds. After the duration has elapsed, the effect will be // removed automatically client-side. Duration int32 // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. Tick uint64 }
MobEffect is sent by the server to apply an effect to the player, for example an effect like poison. It may also be used to modify existing effects, or removing them completely.
type PlayerArmourDamage ¶
type PlayerArmourDamage struct { // Bitset holds a bitset of 4 bits that indicate which pieces of armour need to have damage dealt to them. // The first bit, when toggled, is for a helmet, the second for the chestplate, the third for the leggings // and the fourth for boots. Bitset uint8 // HelmetDamage is the amount of damage that should be dealt to the helmet. HelmetDamage int32 // ChestplateDamage is the amount of damage that should be dealt to the chestplate. ChestplateDamage int32 // LeggingsDamage is the amount of damage that should be dealt to the leggings. LeggingsDamage int32 // BootsDamage is the amount of damage that should be dealt to the boots. BootsDamage int32 }
PlayerArmourDamage is sent by the server to damage the armour of a player. It is a very efficient packet, but generally it's much easier to just send a slot update for the damaged armour.
func (*PlayerArmourDamage) Marshal ¶
func (pk *PlayerArmourDamage) 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 uint32
// 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
// VehicleRotation is the rotation of the vehicle that the player is in, if any.
VehicleRotation mgl32.Vec2
// ClientPredictedVehicle is the unique ID of the vehicle that the client predicts the player to be in.
ClientPredictedVehicle int64
// 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
func (*PlayerAuthInput) Marshal ¶
func (pk *PlayerAuthInput) Marshal(io protocol.IO)
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 // BaseGameVersion is the vanilla version that the client should set its resource pack stack to. BaseGameVersion string // Experiments holds a list of experiments that are either enabled or disabled in the world that the // player spawns in. // It is not clear why experiments are sent both here and in the StartGame packet. Experiments []protocol.ExperimentData // ExperimentsPreviouslyToggled specifies if any experiments were previously toggled in this world. It is // probably used for some kind of metrics. ExperimentsPreviouslyToggled 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) Marshal ¶
func (pk *ResourcePackStack) Marshal(io protocol.IO)
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 // HasAddons specifies if any of the resource packs contain addons in them. If set to true, only clients // that support addons will be able to download them. HasAddons 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 []types.TexturePackInfo // 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 []types.TexturePackInfo // ForcingServerPacks is currently an unclear field. ForcingServerPacks bool // PackURLs is a list of URLs that the client can use to download a resource pack instead of downloading // it the usual way. PackURLs []protocol.PackURL }
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) Marshal ¶
func (pk *ResourcePacksInfo) Marshal(io protocol.IO)
type SetActorLink ¶
type SetActorLink struct { // EntityLink is the link to be set client-side. It links two entities together, so that one entity rides // another. Note that players that see those entities later will not see the link, unless it is also sent // in the AddActor and AddPlayer packets. EntityLink types.EntityLink }
SetActorLink is sent by the server to initiate an entity link client-side, meaning one entity will start riding another.
func (*SetActorLink) Marshal ¶
func (pk *SetActorLink) Marshal(io protocol.IO)
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 // 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. It is empty if the user is not logged into its XBL account. XUID string // PlatformOnlineID is either a uint64 or an empty string. PlatformOnlineID string }
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.
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. // This field may be set to 5 to make the client fall back to the game mode set in the WorldGameMode // field. 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 int64 // SpawnBiomeType specifies if the biome that the player spawns in is user defined (through behaviour // packs) or builtin. See the constants above. SpawnBiomeType int16 // UserDefinedBiomeName is a readable name of the biome that the player spawned in, such as 'plains'. This // might be a custom biome name if any custom biomes are present through behaviour packs. UserDefinedBiomeName string // 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 is shown in the // settings and is used if the PlayerGameMode is set to 5. WorldGameMode int32 // Hardcore is if the world is in hardcore mode. In hardcore mode, the player cannot respawn after dying. Hardcore bool // 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 // EditorWorldType is a value to dictate the type of editor mode, a special mode recently introduced adding // "powerful tools for editing worlds, intended for experienced creators." It is one of the constants above. EditorWorldType int32 // CreatedInEditor is a value to dictate if the world was created as a project in the editor mode. The functionality // of this field is currently unknown. CreatedInEditor bool // ExportedFromEditor is a value to dictate if the world was exported from editor mode. The functionality of this // field is currently unknown. ExportedFromEditor 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 // EducationEditionOffer is some Minecraft: Education Edition field that specifies what 'region' the world // was from, with 0 being None, 1 being RestOfWorld, and 2 being China. // The actual use of this field is unknown. EducationEditionOffer int32 // EducationFeaturesEnabled specifies if the world has education edition features enabled, such as the // blocks or entities specific to education edition. EducationFeaturesEnabled bool // EducationProductID is a UUID used to identify the education edition server instance. It is generally // unique for education edition servers. EducationProductID string // 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 []protocol.GameRule // Experiments holds a list of experiments that are either enabled or disabled in the world that the // player spawns in. Experiments []protocol.ExperimentData // ExperimentsPreviouslyToggled specifies if any experiments were previously toggled in this world. It is // probably used for some kind of metrics. ExperimentsPreviouslyToggled bool // 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 // PersonaDisabled is true if persona skins are disabled for the current game session. PersonaDisabled bool // CustomSkinsDisabled is true if custom skins are disabled for the current game session. CustomSkinsDisabled bool // EmoteChatMuted specifies if players will be sent a chat message when using certain emotes. EmoteChatMuted bool // BaseGameVersion is the version of the game from which Vanilla features will be used. The exact function // of this field isn't clear. BaseGameVersion string // LimitedWorldWidth and LimitedWorldDepth are the dimensions of the world if the world is a limited // world. For unlimited worlds, these may simply be left as 0. LimitedWorldWidth, LimitedWorldDepth int32 // NewNether specifies if the server runs with the new nether introduced in the 1.16 update. NewNether bool EducationSharedResourceURI protocol.EducationSharedResourceURI // ForceExperimentalGameplay specifies if experimental gameplay should be force enabled. For servers this // should always be set to false. ForceExperimentalGameplay protocol.Optional[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 // TemplateContentIdentity 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. TemplateContentIdentity 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 // PlayerMovementSettings ... PlayerMovementSettings protocol.PlayerMovementSettings // 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 custom blocks registered on the server. Blocks []protocol.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 []protocol.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 // ServerAuthoritativeInventory specifies if the server authoritative inventory system is enabled. This // is a new system introduced in 1.16. Backwards compatibility with the inventory transactions has to // some extent been preserved, but will eventually be removed. ServerAuthoritativeInventory bool // GameVersion is the version of the game the server is running. The exact function of this field isn't clear. GameVersion string // PropertyData contains properties that should be applied on the player. These properties are the same as the // ones that are sent in the SyncActorProperty packet. PropertyData map[string]any // ServerBlockStateChecksum is a checksum to ensure block states between the server and client match. // This can simply be left empty, and the client will avoid trying to verify it. ServerBlockStateChecksum uint64 // ClientSideGeneration is true if the client should use the features registered in the FeatureRegistry packet to // generate terrain client-side to save on bandwidth. ClientSideGeneration bool // WorldTemplateID is a UUID that identifies the template that was used to generate the world. Servers that do not // use a world based off of a template can set this to an empty UUID. WorldTemplateID uuid.UUID // ChatRestrictionLevel specifies the level of restriction on in-game chat. It is one of the constants above. ChatRestrictionLevel uint8 // DisablePlayerInteractions is true if the client should ignore other players when interacting with the world. DisablePlayerInteractions bool // UseBlockNetworkIDHashes is true if the client should use the hash of a block's name as its network ID rather than // its index in the expected block palette. This is useful for servers that wish to support multiple protocol versions // and custom blocks, but it will result in extra bytes being written for every block in a sub chunk palette. UseBlockNetworkIDHashes bool // ServerAuthoritativeSound is currently unknown as to what it does. ServerAuthoritativeSound bool }
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.
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.
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 TextTypeTranslation, 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 TextTypeTranslation, 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.
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.
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 []types.Attribute // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. Tick uint64 }
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) Marshal ¶
func (pk *UpdateAttributes) Marshal(io protocol.IO)
type UpdateBlockSynced ¶
type UpdateBlockSynced struct { // Position is the block position at which a block is updated. Position protocol.BlockPos // NewBlockRuntimeID is the runtime ID of the block that is placed at Position after sending the packet // to the client. NewBlockRuntimeID uint32 // Flags is a combination of flags that specify the way the block is updated client-side. It is a // combination of the flags above, but typically sending only the BlockUpdateNetwork flag is sufficient. Flags uint32 // Layer is the world layer on which the block is updated. For most blocks, this is the first layer, as // that layer is the default layer to place blocks on, but for blocks inside of each other, this differs. Layer uint32 // EntityUniqueID is the unique ID of the falling block entity that the block transitions to or that the // entity transitions from. // Note that for both possible values for TransitionType, the EntityUniqueID should point to the falling // block entity involved. EntityUniqueID int64 // TransitionType is the type of the transition that happened. It is either BlockToEntityTransition, when // a block placed becomes a falling entity, or EntityToBlockTransition, when a falling entity hits the // ground and becomes a solid block again. TransitionType uint64 }
UpdateBlockSynced is sent by the server to synchronise the falling of a falling block entity with the transitioning back and forth from and to a solid block. It is used to prevent the entity from flickering, and is used in places such as the pushing of blocks with pistons.
func (*UpdateBlockSynced) Marshal ¶
func (pk *UpdateBlockSynced) Marshal(io protocol.IO)
type UpdatePlayerGameType ¶
type UpdatePlayerGameType struct { // GameType is the new game type of the player. It is one of the constants that can be found in // set_player_game_type.go. Some of these game types require additional flags to be set in an // UpdateAbilities packet for the game mode to obtain its full functionality. GameType int32 // PlayerUniqueID is the entity unique ID of the player that should have its game mode updated. If this // packet is sent to other clients with the player unique ID of another player, nothing happens. PlayerUniqueID int64 }
UpdatePlayerGameType is sent by the server to change the game mode of a player. It is functionally identical to the SetPlayerGameType packet.
func (*UpdatePlayerGameType) Marshal ¶
func (pk *UpdatePlayerGameType) Marshal(io protocol.IO)
Source Files ¶
- add_actor.go
- add_player.go
- camera_instruction.go
- camera_presets.go
- change_dimension.go
- compressed_biome_definition_list.go
- container_close.go
- container_registry_cleanup.go
- correct_player_move_prediction.go
- disconnect.go
- editor_network.go
- emote.go
- inventory_content.go
- inventory_slot.go
- item_stack_response.go
- mob_armour_equipment.go
- mob_effect.go
- player_armour_damage.go
- player_auth_input.go
- resource_pack_stack.go
- resource_packs_info.go
- set_actor_link.go
- set_title.go
- start_game.go
- stop_sound.go
- text.go
- transfer.go
- update_attributes.go
- update_block_synced.go
- update_player_game_type.go