Documentation
¶
Index ¶
- Constants
- Variables
- func ChainErr(err ...error) error
- type AddEntity
- type AddItemEntity
- type AddPainting
- type AddPlayer
- type BlockEntry
- type BlockEvent
- type ChunkRadiusUpdated
- type ClientToServerHandshake
- type Decoder
- type Disconnect
- type Encoder
- type Explode
- type FullChunkData
- type Header
- type LevelEvent
- type Login
- type ModalFormRequest
- type ModalFormResponse
- type MoveEntityAbsolute
- type MovePlayer
- type Packet
- type PlayStatus
- type Pool
- type RemoveEntity
- type RequestChunkRadius
- type ResourcePack
- type ResourcePackChunkData
- type ResourcePackChunkRequest
- type ResourcePackClientResponse
- type ResourcePackDataInfo
- type ResourcePackStack
- type ResourcePacksInfo
- type RiderJump
- type ServerSettingsRequest
- type ServerSettingsResponse
- type ServerToClientHandshake
- type SetLocalPlayerAsInitialised
- type SetTime
- type StartGame
- type TakeItemEntity
- type Text
- type Transfer
- type Unknown
- type UpdateBlock
Constants ¶
const ( IDLogin = iota + 0x01 IDPlayStatus IDServerToClientHandshake IDClientToServerHandshake IDDisconnect IDResourcePacksInfo IDResourcePackStack IDResourcePackClientResponse IDText IDSetTime IDStartGame IDAddPlayer IDAddEntity IDRemoveEntity IDAddItemEntity IDTakeItemEntity IDMoveEntityAbsolute IDMovePlayer IDRiderJump IDUpdateBlock IDAddPainting IDExplode IDLevelEvent IDBlockEvent )
const ( IDRequestChunkRadius = iota + 0x45 IDChunkRadiusUpdated )
...
const ( IDResourcePackDataInfo = iota + 0x52 IDResourcePackChunkData IDResourcePackChunkRequest IDTransfer )
...
const ( IDModalFormRequest = iota + 0x64 IDModalFormResponse IDServerSettingsRequest IDServerSettingsResponse )
...
const ( EventSoundClick = 1000 EventSoundClickFail = 1001 EventSoundShoot = 1002 EventSoundDoor = 1003 EventSoundFizz = 1004 EventSoundIgnite = 1005 EventSoundGhast = 1007 EventSoundGhastShoot = 1008 EventSoundBlazeShoot = 1009 EventSoundDoorBump = 1010 EventSoundDoorCrash = 1012 EventSoundEndermanTeleport = 1018 EventSoundAnvilBreak = 1020 EventSoundAnvilUse = 1021 EventSoundAnvilFall = 1022 EventSoundPop = 1030 EventSoundPortal = 1032 EventSoundItemFrameAddItem = 1040 EventSoundItemFrameBreak = 1041 EventSoundItemFramePlace = 1042 EventSoundItemFrameRemoveItem = 1043 EventSoundItemFrameRotateItem = 1044 EventSoundCamera = 1050 EventSoundOrb = 1051 EventSoundTotem = 1052 EventSoundArmourStandBreak = 1060 EventSoundArmourStandHit = 1061 EventSoundArmourStandFall = 1062 EventSoundArmourStandPlace = 1063 EventParticleShoot = 2000 EventParticleDestroy = 2001 EventParticleSplash = 2002 EventParticleEyeDespawn = 2003 EventParticleSpawn = 2004 EventGuardianCurse = 2006 EventParticleBlockForceField = 2008 EventParticleProjectileHit = 2009 EventParticleDragonEggTeleport = 2010 EventParticleEndermanTeleport = 2013 EventParticlePunchBlock = 2014 EventStartRain = 3001 EventStartThunder = 3002 EventStopRain = 3003 EventStopThunder = 3004 EventPauseGame = 3005 EventRedstoneTrigger = 3500 EventCauldronExplode = 3501 EventCauldronDyeArmour = 3502 EventCauldronCleanArmour = 3503 EventCauldronFillPotion = 3504 EventCauldronTakePotion = 3505 EventCauldronFillWater = 3506 EventCauldronTakeWater = 3507 EventCauldronAddDye = 3508 EventCauldronCleanBanner = 3509 EventBlockStartBreak = 3600 EventBlockStopBreak = 3601 EventSetData = 4000 EventPlayersSleeping = 9800 EventAddParticleMask = 0x4000 )
const ( MoveFlagOnGround = 1 << iota MoveFlagTeleport )
const ( MoveModeNormal = iota MoveModeReset MoveModeTeleport MoveModeRotation )
const ( TeleportCauseUnknown = iota TeleportCauseProjectile TeleportCauseChorusFruit TeleportCauseCommand TeleportCauseBehaviour )
const ( PlayStatusLoginSuccess int32 = iota PlayStatusLoginFailedClient PlayStatusLoginFailedServer PlayStatusPlayerSpawn PlayStatusLoginFailedInvalidTenant PlayStatusLoginFailedVanillaEdu PlayStatusLoginFailedEduVanilla PlayStatusLoginFailedServerFull )
const ( PackResponseRefused = iota + 1 PackResponseSendPacks PackResponseAllPacksDownloaded PackResponseCompleted )
const ( TextTypeRaw = iota TextTypeChat TextTypeTranslation TextTypePopup TextTypeJukeboxPopup TextTypeTip TextTypeSystem TextTypeWhisper TextTypeAnnouncement TextTypeJSON )
const ( BlockUpdateNeighbours = 1 << iota BlockUpdateNetwork BlockUpdateNoGraphics BlockUpdatePriority )
const (
BlockEventChangeChestState = 1
)
const (
IDFullChunkData = iota + 0x3a
)
...
const (
IDSetLocalPlayerAsInitialised = iota + 0x71
)
...
Variables ¶
var PacketsByName = map[string]func() Packet{}
PacketsByName is a map holding a function to create a new packet for each packet registered in Pool. These functions are indexed using the exact packet name they return.
Functions ¶
Types ¶
type AddEntity ¶
type AddEntity 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 // Attributes is a slice of attributes that the entity has. It includes attributes such as its health, // movement speed, etc. Attributes []protocol.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]interface{} // 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 []protocol.EntityLink }
AddEntity 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 AddItemEntity ¶ added in v0.3.0
type AddItemEntity 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 protocol.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]interface{} // 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 }
AddItemEntity 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 AddEntity packet
func (*AddItemEntity) Marshal ¶ added in v0.3.0
func (pk *AddItemEntity) Marshal(buf *bytes.Buffer)
Marshal ...
type AddPainting ¶
type AddPainting 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 // 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 protocol.BlockPos // Direction is the facing direction of the painting. Direction int32 // Title is the title of the painting. It specifies the motive of the painting. The title of the painting // must be valid. Title string }
AddPainting is sent by the server to the client to make a painting entity show up. It is one of the few entities that cannot be sent using the AddEntity packet.
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 // 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.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]interface{} // 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 // CommandPermissions is a set of permissions that specify what commands a player is allowed to execute. CommandPermissions 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 // PlayerID 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. PlayerID 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 []protocol.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 AddEntity packet.
type BlockEntry ¶ added in v0.1.0
type BlockEntry struct { // Name is the name of the block. It looks like 'minecraft:stone'. Name string // Data is the metadata value of the block. A lot of blocks only have 0 as data value, but some blocks // carry specific variants or properties encoded in the metadata. Data int16 }
BlockEntry is a block sent in the StartGame packet block runtime ID table. It holds a name and a metadata value of a block.
type BlockEvent ¶
type BlockEvent struct { // Position is the position of the block that an event occurred at. Position protocol.BlockPos // EventType is the type of the block event. The event type decides the way the event data that follows // is used. It is one of the constants found above. EventType int32 // EventData holds event type specific data. For chests for example, opening the chest means the data must // hold 1, whereas closing it should hold 0. EventData int32 }
BlockEvent is sent by the server to initiate a certain event that has something to do with blocks in specific, for example opening a chest.
type ChunkRadiusUpdated ¶
type ChunkRadiusUpdated struct { // ChunkRadius is the final chunk radius that the client will adapt when it receives the packet. It does // not have to be the same as the requested chunk radius. ChunkRadius int32 }
ChunkRadiusUpdated is sent by the server in response to a RequestChunkRadius packet. It defines the chunk radius that the server allows the client to have. This may be lower than the chunk radius requested by the client in the RequestChunkRadius packet.
func (*ChunkRadiusUpdated) Marshal ¶
func (pk *ChunkRadiusUpdated) Marshal(buf *bytes.Buffer)
Marshal ...
type ClientToServerHandshake ¶
type ClientToServerHandshake struct { }
ClientToServerHandshake is sent by the client in response to a ServerToClientHandshake packet sent by the server. It is the first encrypted packet in the login handshake and serves as a confirmation that encryption is correctly initialised client side.
func (*ClientToServerHandshake) Marshal ¶
func (*ClientToServerHandshake) Marshal(buf *bytes.Buffer)
Marshal ...
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder handles the decoding of Minecraft packets sent through an io.Reader. These packets in turn contain multiple zlib compressed packets.
func NewDecoder ¶
NewDecoder returns a new decoder decoding data from the reader passed. One read call from the reader is assumed to consume an entire packet.
func (*Decoder) Decode ¶
Decode decodes one 'packet' from the reader passed in NewDecoder(), producing a slice of packets that it held and an error if not successful.
func (*Decoder) EnableEncryption ¶
EnableEncryption enables encryption for the Decoder using the secret key bytes passed. Each packet received will be decrypted.
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.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder handles the encoding of Minecraft packets that are sent to an io.Writer. The packets are compressed and optionally encoded before they are sent to the io.Writer.
func NewEncoder ¶
NewEncoder returns a new Encoder for the io.Writer passed. Each final packet produced by the Encoder is sent with a single call to io.Writer.Write().
func (*Encoder) EnableEncryption ¶
EnableEncryption enables encryption for the Encoder using the secret key bytes passed. Each packet sent after encryption is enabled will be encrypted.
type Explode ¶ added in v0.3.0
type Explode struct { // Position is the centre position of the explosion that is taking place. It has no effect on the blocks // broken client-side, and seems to have no other functionality. Position mgl32.Vec3 // Radius is the radius of the explosion. It seems to have no functionality. Radius float32 // BlocksBroken is a list of all block positions that are to be destroyed by the explosion. This is the // only field that has functionality in the packet. BlocksBroken []protocol.BlockPos }
Explode is sent by the server to make an explosion happen. The explosion will break all blocks in the packet client-side.
type FullChunkData ¶ added in v0.2.0
type FullChunkData struct { // ChunkX is the X coordinate of the chunk sent. (To translate a block's X to a chunk's X: x >> 4) ChunkX int32 // ChunkZ is the Z coordinate of the chunk sent. (To translate a block's Z to a chunk's Z: z >> 4) ChunkZ int32 // Data is a serialised string of chunk data. The chunk data is composed of multiple sub-chunks, each of // which carry a version which indicates the way they are serialised. Data string }
FullChunkData 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 (*FullChunkData) Marshal ¶ added in v0.2.0
func (pk *FullChunkData) Marshal(buf *bytes.Buffer)
Marshal ...
type Header ¶
Header is the header of a packet. It exists out of a single varuint32 which is composed of a packet ID and a sender and target sub client ID. These IDs are used for split screen functionality.
type LevelEvent ¶
type LevelEvent struct { // EventID is the ID of the event that is being 'called'. It is one of the events found in the constants // above. EventID int32 // Position is the position of the level event. Practically every event requires this Vec3 set for it, as // particles, sounds and block editing relies on it. Position mgl32.Vec3 // EventData is an integer holding additional data of the event. The type of data held depends on the // EventID. EventData int32 }
LevelEvent is sent by the server to make a certain event in the level occur. It ranges from particles, to sounds, and other events such as starting rain and block breaking.
type Login ¶
type Login struct { // ClientProtocol is the protocol version of the player. The player is disconnected if the protocol is // incompatible with the protocol of the server. ClientProtocol int32 // ConnectionRequest is a string containing information about the player and JWTs that may be used to // verify if the player is connected to XBOX Live. The connection request also contains the necessary // client public key to initiate encryption. ConnectionRequest string }
Login is sent when the client initially tries to join the server. It is the first packet sent and contains information specific to the player.
type ModalFormRequest ¶
type ModalFormRequest struct { // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player // submits the form, so that the server can identify which form was submitted. FormID uint32 // FormData is a JSON encoded object of form data. The content of the object differs, depending on the // type of the form sent, which is also set in the JSON. FormData string }
ModalFormRequest is sent by the server to make the client open a form. This form may be either a modal form which has two options, a menu form for a selection of options and a custom form for properties.
func (*ModalFormRequest) Marshal ¶
func (pk *ModalFormRequest) Marshal(buf *bytes.Buffer)
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 string }
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) Marshal ¶
func (pk *ModalFormResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type MoveEntityAbsolute ¶ added in v0.3.0
type MoveEntityAbsolute 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 // Flags is a combination of flags that specify details of the movement. It is a combination of the flags // above. Flags byte // 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 // Rotation is a Vec3 holding the X, Y and Z rotation of the entity after the movement. This is a Vec3 for // the reason that projectiles like arrows don't have yaw/pitch, but do have roll. Rotation mgl32.Vec3 }
MoveEntityAbsolute is sent by the server to move an entity to an absolute position. It is typically used for movements where high accuracy isn't needed, such as for long range teleporting.
func (*MoveEntityAbsolute) Marshal ¶ added in v0.3.0
func (pk *MoveEntityAbsolute) Marshal(buf *bytes.Buffer)
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.
type Packet ¶
type Packet interface { // ID returns the ID of the packet. All of these identifiers of packets may be found in id.go. ID() uint32 // Marshal encodes the packet to its binary representation into buf. Marshal(buf *bytes.Buffer) // Unmarshal decodes a serialised packet in buf into the Packet instance. The serialised packet passed // into Unmarshal will not have a header in it. Unmarshal(buf *bytes.Buffer) error }
Packet represents a packet that may be sent over a Minecraft network connection. The packet needs to hold a method to encode itself to binary and decode itself from binary.
type PlayStatus ¶
type PlayStatus struct { // Status is the status of the packet. It is one of the constants found above. Status int32 }
PlayStatus is sent by the server to update a player on the play status. This includes failed statuses due to a mismatched version, but also success statuses.
type RemoveEntity ¶
type RemoveEntity struct { // EntityUniqueID is the unique ID of the entity to be removed. 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 }
RemoveEntity is sent by the server to remove an entity that currently exists in the world from the client- side. Sending this packet if the client cannot already see this entity will have no effect.
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) Marshal ¶
func (pk *RequestChunkRadius) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePack ¶ added in v0.1.0
type ResourcePack struct { // UUID is the UUID of the resource pack. Each resource pack downloaded must have a different UUID in // order for the client to be able to handle them properly. UUID string // Version is the version of the resource pack. The client will cache resource packs sent by the server as // long as they carry the same version. Sending a resource pack with a different version than previously // will force the client to re-download it. Version string // Size is the total size in bytes that the resource pack occupies. This is the size of the compressed // archive (zip) of the resource pack. Size int64 // ContentKey is the key used to decrypt the resource pack if it is encrypted. This is generally the case // for marketplace resource packs. ContentKey string // SubPackName ... SubPackName string // ContentIdentity ... ContentIdentity string // HasScripts specifies if the resource packs has any scripts in it. A client will only download the // resource pack if it supports scripts, which, up to 1.11, only includes Windows 10. HasScripts bool }
ResourcePack represents a resource pack sent over network. It holds information about the resource pack such as its name, description and version.
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 int32 // DataOffset is the current progress in bytes or offset in the data that the resource pack data chunk is // taken from. DataOffset int64 // Data 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) Marshal ¶
func (pk *ResourcePackChunkData) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackChunkRequest ¶
type ResourcePackChunkRequest struct { // UUID is the unique ID of the resource pack that the chunk of data is requested from. UUID string // ChunkIndex is the requested chunk index of the chunk. It is a number that starts at 0 and is // incremented for each resource pack data chunk requested. ChunkIndex int32 }
ResourcePackChunkRequest is sent by the client to request a chunk of data from a particular resource pack, that it has obtained information about in a ResourcePackDataInfo packet.
func (*ResourcePackChunkRequest) Marshal ¶
func (pk *ResourcePackChunkRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackClientResponse ¶
type ResourcePackClientResponse struct { // Response is the response type of the response. It is one of the constants found above. Response byte // PacksToDownload is a list of resource pack UUIDs combined with their version that need to be downloaded // (for example SomePack_1.0.0), if the Response field is PackResponseSendPacks. PacksToDownload []string }
ResourcePackClientResponse is sent by the client in response to resource packets sent by the server. It is used to let the server know what action needs to be taken for the client to have all resource packs ready and set.
func (*ResourcePackClientResponse) Marshal ¶
func (pk *ResourcePackClientResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackDataInfo ¶
type ResourcePackDataInfo struct { // UUID is the unique ID of the resource pack that the info concerns. UUID string // DataChunkSize is the maximum size in bytes of the chunks in which the total size of the resource pack // to be sent will be divided. A size of 1MB (1024*1024) means that a resource pack of 15.5MB will be // split into 16 data chunks. DataChunkSize int32 // ChunkCount is the total amount of data chunks that the sent resource pack will exist out of. It is the // total size of the resource pack divided by the DataChunkSize field. ChunkCount int32 // Size is the total size in bytes that the resource pack occupies. This is the size of the compressed // archive (zip) of the resource pack. Size int64 // Hash is a SHA256 hash of the content of the resource pack. Hash string }
ResourcePackDataInfo is sent by the server to the client to inform the client about the data contained in one of the resource packs that are about to be sent.
func (*ResourcePackDataInfo) Marshal ¶
func (pk *ResourcePackDataInfo) Marshal(buf *bytes.Buffer)
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 []ResourcePack // 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 []ResourcePack // 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) Marshal ¶
func (pk *ResourcePackStack) Marshal(buf *bytes.Buffer)
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 []ResourcePack // 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 []ResourcePack }
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(buf *bytes.Buffer)
Marshal ...
type RiderJump ¶ added in v0.3.0
type RiderJump struct { // JumpStrength is the strength of the jump, depending on how long the rider has held the jump button. JumpStrength int32 }
RiderJump is sent by the client to the server when it jumps while riding an entity that has the WASDControlled entity flag set, for example when riding a horse.
type ServerSettingsRequest ¶
type ServerSettingsRequest struct { }
ServerSettingsRequest is sent by the client to request the settings specific to the server. These settings are shown in a separate tab client-side, and have the same structure as a custom form.
func (*ServerSettingsRequest) Marshal ¶
func (*ServerSettingsRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type ServerSettingsResponse ¶
type ServerSettingsResponse struct { // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player // submits the form, so that the server can identify which form was submitted. FormID uint32 // FormData is a JSON encoded object of form data. The content of the object differs, depending on the // type of the form sent, which is also set in the JSON. FormData string }
ServerSettingsResponse is optionally sent by the server in response to a ServerSettingsRequest from the client. It is structured the same as a ModalFormRequest packet, and if filled out correctly, will show a specific tab for the server in the settings of the client. A ModalFormResponse packet is sent by the client in response to a ServerSettingsResponse, when the client fills out the settings and closes the settings again.
func (*ServerSettingsResponse) Marshal ¶
func (pk *ServerSettingsResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type ServerToClientHandshake ¶
type ServerToClientHandshake struct { // JWT is a raw JWT token containing data such as the public key from the server, the algorithm used and // the server's token. It is used for the client to produce a shared secret. JWT string }
ServerToClientHandshake is sent by the server to the client to complete the key exchange in order to initialise encryption on client and server side. It is followed up by a ClientToServerHandshake packet from the client.
func (*ServerToClientHandshake) Marshal ¶
func (pk *ServerToClientHandshake) Marshal(buf *bytes.Buffer)
Marshal ...
type SetLocalPlayerAsInitialised ¶
type SetLocalPlayerAsInitialised struct { // EntityRuntimeID is the entity runtime ID the player was assigned earlier in the login sequence in the // StartGame packet. EntityRuntimeID uint64 }
SetLocalPlayerAsInitialised is sent by the client in response to a PlayStatus packet with the status set to 3. The packet marks the moment at which the client is fully initialised and can receive any packet without discarding it.
func (*SetLocalPlayerAsInitialised) Marshal ¶
func (pk *SetLocalPlayerAsInitialised) Marshal(buf *bytes.Buffer)
Marshal ...
type SetTime ¶
type SetTime struct { // Time is the current time. The time is not limited to 24000 (time of day), but continues progressing // after that. Time int32 }
SetTime is sent by the server to update the current time client-side. The client actually advances time client-side by itself, so this packet does not need to be sent each tick. It is merely a means of synchronising time between server and client.
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]interface{} // 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 // 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 []BlockEntry // 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.
type TakeItemEntity ¶ added in v0.3.0
type TakeItemEntity struct { // ItemEntityRuntimeID is the entity runtime ID of the item that is being taken by another entity. It will // disappear to viewers after showing the pick-up animation. ItemEntityRuntimeID uint64 // TakerEntityRuntimeID is the runtime ID of the entity that took the item, which is usually a player, but // could be another entity like a zombie too. TakerEntityRuntimeID uint64 }
TakeItemEntity is sent by the server when a player picks up an item entity. It makes the item entity disappear to viewers and shows the pick-up animation.
func (*TakeItemEntity) Marshal ¶ added in v0.3.0
func (pk *TakeItemEntity) Marshal(buf *bytes.Buffer)
Marshal ...
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.
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 Unknown ¶
type Unknown struct { // PacketID is the packet ID of the packet. PacketID uint32 // Payload is the raw payload of the packet. Payload []byte }
Unknown is an implementation of the Packet interface for unknown/unimplemented packets. It holds the packet ID and the raw payload. It serves as a way to read raw unknown packets and forward them to another connection, without necessarily implementing them.
type UpdateBlock ¶
type UpdateBlock 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. The runtime ID must point to a block sent in the list in the StartGame packet. 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 }
UpdateBlock is sent by the server to update a block client-side, without resending the entire chunk that the block is located in. It is particularly useful for small modifications like block breaking/placing.
Source Files
¶
- add_entity.go
- add_item_entity.go
- add_painting.go
- add_player.go
- block_event.go
- chunk_radius_updated.go
- client_to_server_handshake.go
- decoder.go
- disconnect.go
- encoder.go
- encryption.go
- explode.go
- full_chunk_data.go
- id.go
- level_event.go
- login.go
- modal_form_request.go
- modal_form_response.go
- move_entity_absolute.go
- move_player.go
- packet.go
- play_status.go
- pool.go
- remove_entity.go
- request_chunk_radius.go
- resource_pack_chunk_data.go
- resource_pack_chunk_request.go
- resource_pack_client_response.go
- resource_pack_data_info.go
- resource_pack_stack.go
- resource_packs_info.go
- rider_jump.go
- server_settings_request.go
- server_settings_response.go
- server_to_client_handshake.go
- set_local_player_as_initialised.go
- set_time.go
- start_game.go
- take_item_entity.go
- text.go
- transfer.go
- unknown.go
- update_block.go
- util.go