Documentation ¶
Overview ¶
Package protocol provides definitions for Minecraft packets as well as methods for reading and writing them
Index ¶
- Constants
- Variables
- func ReadBool(r io.Reader) (bool, error)
- func ReadByte(r io.Reader) (byte, error)
- func ReadNBT(r io.Reader) (*nbt.Compound, error)
- func ReadString(r io.Reader) (string, error)
- func WriteBool(w io.Writer, b bool) error
- func WriteByte(w io.Writer, b byte) error
- func WriteNBT(w io.Writer, n *nbt.Compound) error
- func WriteString(w io.Writer, str string) error
- func WriteVarInt(w io.Writer, i VarInt) error
- func WriteVarLong(w io.Writer, i VarLong) error
- type Animation
- type ArmSwing
- type BlockAction
- type BlockBreakAnimation
- type BlockChange
- type BlockChangeRecord
- type BossBar
- type Camera
- type ChangeGameState
- type ChatMessage
- type ChunkData
- type ChunkUnload
- type ClickWindow
- type ClientAbilities
- type ClientSettings
- type ClientStatus
- type CloseWindow
- type CollectItem
- type CombatEvent
- type ConfirmTransaction
- type ConfirmTransactionServerbound
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) EnableEncryption(key []byte) error
- func (c *Conn) LoginToServer(profile mojang.Profile) (err error)
- func (c *Conn) ReadPacket() (Packet, error)
- func (c *Conn) RequestStatus() (response StatusReply, ping time.Duration, err error)
- func (c *Conn) SetCompression(threshold int)
- func (c *Conn) WritePacket(packet Packet) error
- type CreativeInventoryAction
- type Disconnect
- type Effect
- type EnchantItem
- type EncryptionRequest
- type EncryptionResponse
- type Entity
- type EntityAction
- type EntityAttach
- type EntityDestroy
- type EntityEffect
- type EntityEquipment
- type EntityHeadLook
- type EntityLook
- type EntityLookAndMove
- type EntityMetadata
- type EntityMove
- type EntityProperties
- type EntityProperty
- type EntityRemoveEffect
- type EntityTeleport
- type EntityUsedBed
- type EntityVelocity
- type Explosion
- type ExplosionRecord
- type Handshake
- type HeldItemChange
- type ItemStack
- type JoinGame
- type KeepAliveClientbound
- type KeepAliveServerbound
- type LoginDisconnect
- type LoginStart
- type LoginSuccess
- type MapIcon
- type Maps
- type Metadata
- type MultiBlockChange
- type Packet
- type Particle
- type Player
- type PlayerAbilities
- type PlayerAction
- type PlayerBlockPlacement
- type PlayerDetail
- type PlayerDigging
- type PlayerInfo
- type PlayerListHeaderFooter
- type PlayerLook
- type PlayerPosition
- type PlayerPositionLook
- type PlayerProperty
- type PluginMessageClientbound
- type PluginMessageServerbound
- type Position
- type PropertyModifier
- type ResourcePackSend
- type ResourcePackStatus
- type Respawn
- type ScoreboardDisplay
- type ScoreboardObjective
- type Serializable
- type ServerDifficulty
- type ServerMessage
- type SetCompression
- type SetCooldown
- type SetCurrentHotbarSlot
- type SetExperience
- type SetInitialCompression
- type SetSign
- type SignEditorOpen
- type SoundEffect
- type SpawnExperienceOrb
- type SpawnGlobalEntity
- type SpawnMob
- type SpawnObject
- type SpawnPainting
- type SpawnPlayer
- type SpawnPosition
- type SpectateTeleport
- type State
- type Statistic
- type Statistics
- type StatusPing
- type StatusPlayer
- type StatusPong
- type StatusReply
- type StatusRequest
- type StatusResponse
- type SteerVehicle
- type TabComplete
- type TabCompleteReply
- type Teams
- type TeleportPlayer
- type TimeUpdate
- type Title
- type UUID
- type UpdateBlockEntity
- type UpdateHealth
- type UpdateScore
- type UpdateSign
- type UseEntity
- type UseItem
- type VarInt
- type VarLong
- type WindowClose
- type WindowItems
- type WindowOpen
- type WindowProperty
- type WindowSetSlot
- type WorldBorder
- Bugs
Constants ¶
const (
// SupportedProtocolVersion is current protocol version this package defines
SupportedProtocolVersion = 71
)
Variables ¶
var ( // ErrVarIntTooLarge is returned when a read varint was too large // (more than 5 bytes) ErrVarIntTooLarge = errors.New("VarInt too large") // ErrVarLongTooLarge is returned when a read varint was too large // (more than 10 bytes) ErrVarLongTooLarge = errors.New("VarLong too large") )
Functions ¶
func ReadByte ¶
ReadByte reads a single byte from the Reader. If the Reader is a ByteReader then that will be used instead.
func ReadString ¶
ReadString reads a VarInt prefixed utf-8 string to the reader.
func WriteByte ¶
WriteByte writes a single byte to the writer. If the Writer is a ByteWriter then that will be used instead.
func WriteNBT ¶
WriteNBT writes an nbt tag to the wrtier. nil can be used to specify that there isn't a tag.
func WriteString ¶
WriteString writes a VarInt prefixed utf-8 string to the writer.
func WriteVarInt ¶
WriteVarInt encodes the passed VarInt into the writer.
Types ¶
type Animation ¶
Animation is sent by the server to play an animation on a specific entity.
This is a Minecraft packet
type ArmSwing ¶
type ArmSwing struct {
Hand VarInt
}
ArmSwing is sent by the client when the player left clicks (to swing their arm).
This is a Minecraft packet
type BlockAction ¶
BlockAction triggers different actions depending on the target block.
This is a Minecraft packet
type BlockBreakAnimation ¶
BlockBreakAnimation is used to create and update the block breaking animation played when a player starts digging a block.
This is a Minecraft packet
type BlockChange ¶
BlockChange is used to update a single block on the client.
This is a Minecraft packet
type BlockChangeRecord ¶
BlockChangeRecord is a location/id record of a block to be updated
type BossBar ¶
type BossBar struct { UUID UUID `as:"raw"` Action VarInt Title format.AnyComponent `as:"json" if:".Action == 0 .Action == 3"` Health float32 `if:".Action == 0 .Action == 2"` Color VarInt `if:".Action == 0 .Action == 4"` Style VarInt `if:".Action == 0 .Action == 4"` Flags byte `if:".Action == 0 .Action == 5"` }
BossBar displays and/or changes a boss bar that is displayed on the top of the client's screen. This is normally used for bosses such as the ender dragon or the wither.
This is a Minecraft packet
type Camera ¶
type Camera struct {
TargetID VarInt
}
Camera causes the client to spectate the entity with the passed id. Use the player's id to de-spectate.
This is a Minecraft packet
type ChangeGameState ¶
ChangeGameState is used to modify the game's state like gamemode or weather.
This is a Minecraft packet
type ChatMessage ¶
type ChatMessage struct {
Message string
}
ChatMessage is sent by the client when it sends a chat message or executes a command (prefixed by '/').
This is a Minecraft packet
type ChunkData ¶
type ChunkData struct {
ChunkX, ChunkZ int32
New bool
BitMask VarInt
Data []byte `length:"VarInt" nolimit:"true"`
}
ChunkData sends or updates a single chunk on the client. If New is set then biome data should be sent too.
This is a Minecraft packet
type ChunkUnload ¶
ChunkUnload tells the client to unload the chunk at the specified position.
This is a Minecraft packet
type ClickWindow ¶
type ClickWindow struct { ID byte Slot int16 Button byte ActionNumber int16 Mode byte ClickedItem ItemStack `as:"raw"` }
ClickWindow is sent when the client clicks in a window.
This is a Minecraft packet
type ClientAbilities ¶
ClientAbilities is used to modify the players current abilities. Currently flying is the only one
This is a Minecraft packet
type ClientSettings ¶
type ClientSettings struct { Locale string ViewDistance byte ChatMode byte ChatColors bool DisplayedSkinParts byte MainHand VarInt }
ClientSettings is sent by the client to update its current settings.
This is a Minecraft packet
type ClientStatus ¶
type ClientStatus struct {
ActionID VarInt
}
ClientStatus is sent to update the client's status
This is a Minecraft packet
type CloseWindow ¶
type CloseWindow struct {
ID byte
}
CloseWindow is sent when the client closes a window.
This is a Minecraft packet
type CollectItem ¶
CollectItem causes the collected item to fly towards the collector. This does not destroy the entity.
This is a Minecraft packet
type CombatEvent ¶
type CombatEvent struct { Event VarInt Duration VarInt `if:".Event == 1"` PlayerID VarInt `if:".Event == 2"` EntityID int32 `if:".Event == 1 .Event == 2"` Message format.AnyComponent `as:"json" if:".Event == 2"` }
CombatEvent is used for... you know, I never checked. I have no clue.
This is a Minecraft packet
type ConfirmTransaction ¶
ConfirmTransaction notifies the client whether a transaction was successful or failed (e.g. due to lag).
This is a Minecraft packet
type ConfirmTransactionServerbound ¶
ConfirmTransactionServerbound is a reply to ConfirmTransaction.
This is a Minecraft packet
type Conn ¶
type Conn struct { State State Logger func(read bool, packet Packet) // contains filtered or unexported fields }
Conn is a connection from or to a Minecraft client.
The Minecraft protocol as multiple states that it switches between during login/status pinging, the state may be set using the State field.
func Dial ¶
Dial creates a connection to a Minecraft server at the passed address. The address is in same format as the vanilla client takes it
host:port // or host
If the port isn't provided then a SRV lookup is performed and if successful it will continue connecting using the returned address. If the lookup fails then the port is assumed to be 25565.
func (*Conn) EnableEncryption ¶
EnableEncryption enables cfb8 encryption on the protocol using the passed key.
func (*Conn) LoginToServer ¶
LoginToServer sends the necessary packets to join a server. This also authenticates the request with mojang for online mode connections. This stops before LoginSuccess (or any other preceding packets).
func (*Conn) ReadPacket ¶
ReadPacket deserializes a packet from the underlying connection, optionally decrypting and/or decompressing
func (*Conn) RequestStatus ¶
func (c *Conn) RequestStatus() (response StatusReply, ping time.Duration, err error)
RequestStatus starts a status request to the server and returns the results of the request. The connection will be closed after this request.
func (*Conn) SetCompression ¶
SetCompression changes the threshold at which packets are compressed.
func (*Conn) WritePacket ¶
WritePacket serializes the packet to the underlying connection, optionally encrypting and/or compressing
type CreativeInventoryAction ¶
CreativeInventoryAction is sent when the client clicks in the creative inventory. This is used to spawn items in creative.
This is a Minecraft packet
type Disconnect ¶
type Disconnect struct {
Reason format.AnyComponent `as:"json"`
}
Disconnect causes the client to disconnect displaying the passed reason.
This is a Minecraft packet
type Effect ¶
Effect plays a sound effect or particle at the target location with the volume (of sounds) being relative to the player's position unless DisableRelative is set to true.
This is a Minecraft packet
type EncryptionRequest ¶
type EncryptionRequest struct { // Generally empty, left in from legacy auth // but is still used by the client if provided ServerID string // A RSA Public key serialized in x.509 PRIX format PublicKey []byte `length:"VarInt"` // Token used by the server to verify encryption is working // correctly VerifyToken []byte `length:"VarInt"` }
EncryptionRequest is sent by the server if the server is in online mode. If it is not sent then its assumed the server is in offline mode.
This is a Minecraft packet
type EncryptionResponse ¶
type EncryptionResponse struct { // public key SharedSecret []byte `length:"VarInt"` // The verify token from the request encrypted with the // public key VerifyToken []byte `length:"VarInt"` }
EncryptionResponse is sent as a reply to EncryptionRequest. All packets following this one must be encrypted with AES/CFB8 encryption.
This is a Minecraft packet
type Entity ¶
type Entity struct {
EntityID VarInt
}
Entity does nothing. It is a result of subclassing used in Minecraft.
This is a Minecraft packet
type EntityAction ¶
EntityAction causes an entity to preform an action based on the passed id.
This is a Minecraft packet
type EntityAttach ¶
EntityAttach attaches to entities together, either by mounting or leashing. -1 can be used at the EntityID to deattach.
This is a Minecraft packet
type EntityDestroy ¶
type EntityDestroy struct {
EntityIDs []VarInt `length:"VarInt"`
}
EntityDestroy destroys the entities with the ids in the provided slice.
This is a Minecraft packet
type EntityEffect ¶
type EntityEffect struct { EntityID VarInt EffectID int8 Amplifier int8 Duration VarInt HideParticles bool }
EntityEffect applies a status effect to an entity for a given duration.
This is a Minecraft packet
type EntityEquipment ¶
EntityEquipment is sent to display an item on an entity, like a sword or armor. Slot 0 is the held item and slots 1 to 4 are boots, leggings chestplate and helmet respectively.
This is a Minecraft packet
type EntityHeadLook ¶
EntityHeadLook rotates an entity's head to the new angle.
This is a Minecraft packet
type EntityLook ¶
EntityLook rotates the entity to the new angles provided.
This is a Minecraft packet
type EntityLookAndMove ¶
type EntityLookAndMove struct { EntityID VarInt DeltaX, DeltaY, DeltaZ int8 Yaw, Pitch int8 OnGround bool }
EntityLookAndMove is a combination of EntityMove and EntityLook.
This is a Minecraft packet
type EntityMove ¶
EntityMove moves the entity with the id by the offsets provided.
This is a Minecraft packet
type EntityProperties ¶
type EntityProperties struct { EntityID VarInt Properties []EntityProperty `length:"int32"` }
EntityProperties updates the properties for an entity.
This is a Minecraft packet
type EntityProperty ¶
type EntityProperty struct { Key string Value float64 Modifiers []PropertyModifier `length:"VarInt"` }
EntityProperty is a key/value pair with optional modifiers. Used by EntityProperties.
type EntityRemoveEffect ¶
EntityRemoveEffect removes an effect from an entity.
This is a Minecraft packet
type EntityTeleport ¶
EntityTeleport teleports the entity to the target location. This is sent if the entity moves further than EntityMove allows.
This is a Minecraft packet
type EntityUsedBed ¶
EntityUsedBed is sent by the server when a player goes to bed.
This is a Minecraft packet
type EntityVelocity ¶
EntityVelocity sets the velocity of an entity in 1/8000 of a block per a tick.
This is a Minecraft packet
type Explosion ¶
type Explosion struct {
X, Y, Z float32
Radius float32
Records []ExplosionRecord `length:"int32"`
VelocityX, VelocityY, VelocityZ float32
}
Explosion is sent when an explosion is triggered (tnt, creeper etc). This plays the effect and removes the effected blocks.
This is a Minecraft packet
type ExplosionRecord ¶
type ExplosionRecord struct {
X, Y, Z int8
}
ExplosionRecord is used by explosion to mark an affected block.
type Handshake ¶
type Handshake struct { // The protocol version of the connecting client ProtocolVersion VarInt // The hostname the client connected to Host string // The port the client connected to Port uint16 // The next protocol state the client wants Next VarInt }
Handshake is the first packet sent in the protocol. Its used for deciding if the request is a client is requesting status information about the server (MOTD, players etc) or trying to login to the server.
The host and port fields are not used by the vanilla server but are there for virtual server hosting to be able to redirect a client to a target server with a single address + port.
Some modified servers/proxies use the handshake field differently, packing information into the field other than the hostname due to the protocol not providing any system for custom information to be transfered by the client to the server until after login.
This is a Minecraft packet
type HeldItemChange ¶
type HeldItemChange struct {
Slot int16
}
HeldItemChange is sent when the player changes the currently active hotbar slot.
This is a Minecraft packet
type ItemStack ¶
ItemStack is a stack of items of a single type that can be serilized in the protocol.
func (*ItemStack) Deserialize ¶
Deserialize reads an item stack from the reader into this item stack.
type JoinGame ¶
type JoinGame struct { // The entity id the client will be referenced by EntityID int32 // The starting gamemode of the client Gamemode byte // The dimension the client is starting in Dimension int8 // The difficuilty setting for the server Difficulty byte // The max number of players on the server MaxPlayers byte // The level type of the server LevelType string // Whether the client should reduce the amount of debug // information it displays in F3 mode ReducedDebugInfo bool }
JoinGame is sent after completing the login process. This sets the initial state for the client.
This is a Minecraft packet
type KeepAliveClientbound ¶
type KeepAliveClientbound struct {
ID VarInt
}
KeepAliveClientbound is sent by a server to check if the client is still responding and keep the connection open. The client should reply with the KeepAliveServerbound packet setting ID to the same as this one.
This is a Minecraft packet
type KeepAliveServerbound ¶
type KeepAliveServerbound struct {
ID VarInt
}
KeepAliveServerbound is sent by a client as a response to a KeepAliveClientbound. If the client doesn't reply the server may disconnect the client.
This is a Minecraft packet
type LoginDisconnect ¶
type LoginDisconnect struct {
Reason format.AnyComponent `as:"json"`
}
LoginDisconnect is sent by the server if there was any issues authenticating the player during login or the general server issues (e.g. too many players).
This is a Minecraft packet
type LoginStart ¶
type LoginStart struct {
Username string
}
LoginStart is sent immeditately after switching into the login state. The passed username is used by the server to authenticate the player in online mode.
This is a Minecraft packet
type LoginSuccess ¶
type LoginSuccess struct { // String encoding of a uuid (with hyphens) UUID string Username string }
LoginSuccess is sent by the server if the player successfully authenicates with the session servers (online mode) or straight after LoginStart (offline mode).
This is a Minecraft packet
type Maps ¶
type Maps struct { ItemDamage VarInt Scale int8 TrackingPosition bool Icons []MapIcon `length:"VarInt"` Columns byte Rows byte `if:".Columns>0"` X byte `if:".Columns>0"` Z byte `if:".Columns>0"` Data []byte `if:".Columns>0" length:"VarInt"` }
Maps updates a single map's contents
This is a Minecraft packet
type Metadata ¶
type Metadata map[int]interface{}
Metadata is a simple index -> value map used in the Minecraft protocol. A limited number of types are supported:
int8 int16 int32 float32 string ItemStack []int32 []float32 VarInt UUID format.AnyComponent
type MultiBlockChange ¶
type MultiBlockChange struct {
ChunkX, ChunkZ int32
Records []BlockChangeRecord `length:"VarInt"`
}
MultiBlockChange is used to update a batch of blocks in a single packet.
This is a Minecraft packet
type Packet ¶
type Packet interface {
// contains filtered or unexported methods
}
Packet is a structure that can be serialized or deserialized from Minecraft connection
type Particle ¶
type Particle struct { ParticleID int32 LongDistance bool X, Y, Z float32 OffsetX, OffsetY, OffsetZ float32 Speed float32 Count int32 Data []VarInt `length:"@particleDataLength"` }
Particle spawns particles at the target location with the various modifiers. Data's length depends on the particle ID.
This is a Minecraft packet
type Player ¶
type Player struct {
OnGround bool
}
Player is used to update whether the player is on the ground or not.
This is a Minecraft packet
type PlayerAbilities ¶
PlayerAbilities is used to modify the players current abilities. Flying, creative, god mode etc.
This is a Minecraft packet
type PlayerAction ¶
PlayerAction is sent when a player preforms various actions.
This is a Minecraft packet
type PlayerBlockPlacement ¶
type PlayerBlockPlacement struct { Location Position Face VarInt Hand VarInt CursorX, CursorY, CursorZ byte }
PlayerBlockPlacement is sent when the client tries to place a block.
This is a Minecraft packet
type PlayerDetail ¶
type PlayerDetail struct { UUID UUID `as:"raw"` Name string `if:"..Action==0"` Properties []PlayerProperty `length:"VarInt" if:"..Action==0"` GameMode VarInt `if:"..Action==0 ..Action == 1"` Ping VarInt `if:"..Action==0 ..Action == 2"` HasDisplay bool `if:"..Action==0 ..Action == 3"` DisplayName format.AnyComponent `as:"json" if:".HasDisplay==true"` }
PlayerDetail is used by PlayerInfo
type PlayerDigging ¶
PlayerDigging is sent when the client starts/stops digging a block. It also can be sent for droppping items and eating/shooting.
This is a Minecraft packet
type PlayerInfo ¶
type PlayerInfo struct { Action VarInt Players []PlayerDetail `length:"VarInt"` }
PlayerInfo is sent by the server for every player connected to the server to provide skin and username information as well as ping and gamemode info.
This is a Minecraft packet
type PlayerListHeaderFooter ¶
type PlayerListHeaderFooter struct {}
PlayerListHeaderFooter updates the header/footer of the player list.
This is a Minecraft packet
type PlayerPosition ¶
PlayerPosition is used to update the player's position.
This is a Minecraft packet
type PlayerPositionLook ¶
PlayerPositionLook is a combination of PlayerPosition and PlayerLook.
This is a Minecraft packet
type PlayerProperty ¶
type PlayerProperty struct { Name string Value string IsSigned bool Signature string `if:".IsSigned==true"` }
PlayerProperty is used by PlayerDetail
type PluginMessageClientbound ¶
PluginMessageClientbound is used for custom messages between the client and server. This is mainly for plugins/mods but vanilla has a few channels registered too.
This is a Minecraft packet
type PluginMessageServerbound ¶
PluginMessageServerbound is used for custom messages between the client and server. This is mainly for plugins/mods but vanilla has a few channels registered too.
This is a Minecraft packet
type Position ¶
type Position uint64
Position is a location in the world packed into a 64 bit integer
func NewPosition ¶
NewPosition creates a Position for the given location.
type PropertyModifier ¶
PropertyModifier is a modifier on a property. Used by EntityProperty.
type ResourcePackSend ¶
ResourcePackSend causes the client to check its cache for the requested resource packet and download it if its missing. Once the resource pack is obtained the client will use it.
This is a Minecraft packet
type ResourcePackStatus ¶
ResourcePackStatus informs the server of the client's current progress in activating the requested resource pack
This is a Minecraft packet
type Respawn ¶
Respawn is sent to respawn the player after death or when they move worlds.
This is a Minecraft packet
type ScoreboardDisplay ¶
ScoreboardDisplay is used to set the display position of a scoreboard.
This is a Minecraft packet
type ScoreboardObjective ¶
type ScoreboardObjective struct { Name string Mode byte Value string `if:".Mode == 0 .Mode == 2"` Type string `if:".Mode == 0 .Mode == 2"` }
ScoreboardObjective creates/updates a scoreboard objective.
This is a Minecraft packet
type Serializable ¶
Serializable is a type which can be serialized into a packet. This is used by protocol_builder when the struct tag 'as' is set to "raw".
type ServerDifficulty ¶
type ServerDifficulty struct {
Difficulty byte
}
ServerDifficulty changes the displayed difficulty in the client's menu as well as some ui changes for hardcore.
This is a Minecraft packet
type ServerMessage ¶
type ServerMessage struct { Message format.AnyComponent `as:"json"` // 0 - Chat message, 1 - System message, 2 - Action bar message Type byte }
ServerMessage is a message sent by the server. It could be from a player or just a system message. The Type field controls the location the message is displayed at and when the message is displayed.
This is a Minecraft packet
type SetCompression ¶
type SetCompression struct {
Threshold VarInt
}
SetCompression updates the compression threshold.
This is a Minecraft packet
type SetCooldown ¶
SetCooldown disables a set item (by id) for the set number of ticks
This is a Minecraft packet
type SetCurrentHotbarSlot ¶
type SetCurrentHotbarSlot struct {
Slot byte
}
SetCurrentHotbarSlot changes the player's currently selected hotbar item.
This is a Minecraft packet
type SetExperience ¶
SetExperience updates the experience bar on the client.
This is a Minecraft packet
type SetInitialCompression ¶
type SetInitialCompression struct { // Threshold where a packet should be sent compressed Threshold VarInt }
SetInitialCompression sets the compression threshold during the login state.
This is a Minecraft packet
type SignEditorOpen ¶
type SignEditorOpen struct {
Location Position
}
SignEditorOpen causes the client to open the editor for a sign so that it can write to it. Only sent in vanilla when the player places a sign.
This is a Minecraft packet
type SoundEffect ¶
SoundEffect plays the named sound at the target location.
This is a Minecraft packet
type SpawnExperienceOrb ¶
SpawnExperienceOrb spawns a single experience orb into the world when it is in range of the client. The count controls the amount of experience gained when collected.
This is a Minecraft packet
type SpawnGlobalEntity ¶
SpawnGlobalEntity spawns an entity which is visible from anywhere in the world. Currently only used for lightning.
This is a Minecraft packet
type SpawnMob ¶
type SpawnMob struct { EntityID VarInt UUID UUID `as:"raw"` Type byte X, Y, Z int32 Yaw, Pitch int8 HeadPitch int8 VelocityX, VelocityY, VelocityZ int16 Metadata Metadata }
SpawnMob is used to spawn a living entity into the world when it is in range of the client.
This is a Minecraft packet
type SpawnObject ¶
type SpawnObject struct { EntityID VarInt UUID UUID `as:"raw"` Type byte X, Y, Z int32 Pitch, Yaw int8 Data int32 VelocityX, VelocityY, VelocityZ int16 }
SpawnObject is used to spawn an object or vehicle into the world when it is in range of the client.
This is a Minecraft packet
type SpawnPainting ¶
SpawnPainting spawns a painting into the world when it is in range of the client. The title effects the size and the texture of the painting.
This is a Minecraft packet
type SpawnPlayer ¶
type SpawnPlayer struct { EntityID VarInt UUID UUID `as:"raw"` X, Y, Z int32 Yaw, Pitch int8 Metadata Metadata }
SpawnPlayer is used to spawn a player when they are in range of the client. This packet alone isn't enough to display the player as the skin and username information is in the player information packet.
This is a Minecraft packet
type SpawnPosition ¶
type SpawnPosition struct {
Location Position
}
SpawnPosition is sent to change the player's current spawn point. Currently only used by the client for the compass.
This is a Minecraft packet
type SpectateTeleport ¶
type SpectateTeleport struct {
Target UUID `as:"raw"`
}
SpectateTeleport is sent by clients in spectator mode to teleport to a player.
This is a Minecraft packet
type State ¶
type State int
State defined which state the protocol is in.
States of the protocol. Handshaking is default.
type Statistics ¶
type Statistics struct {
Statistics []Statistic `length:"VarInt"`
}
Statistics is used to update the statistics screen for the client.
This is a Minecraft packet
type StatusPing ¶
type StatusPing struct { // The time when the ping was sent Time int64 }
StatusPing is sent by the client after recieving a StatusResponse. The client uses the time from sending the ping until the time of recieving a pong to measure the latency between the client and the server.
This is a Minecraft packet
type StatusPlayer ¶
StatusPlayer is one of the sample players in a StatusReply
type StatusPong ¶
type StatusPong struct {
Time int64
}
StatusPong is sent as a reply to a StatusPing. The Time field should be exactly the same as the one sent by the client.
This is a Minecraft packet
type StatusReply ¶
type StatusReply struct { Version struct { Name string `json:"name"` Protocol int `json:"protocol"` } `json:"version"` Players struct { Max int `json:"max"` Online int `json:"online"` Sample []StatusPlayer `json:"sample,omitempty"` } `json:"players"` Description format.AnyComponent `json:"description"` Favicon string `json:"favicon"` }
StatusReply is the reply retrieved from a server when pinging it.
type StatusRequest ¶
type StatusRequest struct { }
StatusRequest is sent by the client instantly after switching to the Status protocol state and is used to signal the server to send a StatusResponse to the client
This is a Minecraft packet
type StatusResponse ¶
type StatusResponse struct {
Status StatusReply `as:"json"`
}
StatusResponse is sent as a reply to a StatusRequest. The Status should contain a json encoded structure with version information, a player sample, a description/MOTD and optionally a favicon.
The structure is as follows
{ "version": { "name": "1.8.3", "protocol": 47, }, "players": { "max": 20, "online": 1, "sample": [ {"name": "Thinkofdeath", "id": "4566e69f-c907-48ee-8d71-d7ba5aa00d20"} ] }, "description": "Hello world", "favicon": "data:image/png;base64,<data>" }
This is a Minecraft packet
type SteerVehicle ¶
SteerVehicle is sent by the client when steers or preforms an action on a vehicle.
This is a Minecraft packet
type TabComplete ¶
TabComplete is sent by the client when the client presses tab in the chat box.
This is a Minecraft packet
type TabCompleteReply ¶
type TabCompleteReply struct {
Matches []string `length:"VarInt"`
}
TabCompleteReply is sent as a reply to a tab completion request. The matches should be possible completions for the command/chat the player sent.
This is a Minecraft packet
type Teams ¶
type Teams struct { Name string Mode byte DisplayName string `if:".Mode == 0 .Mode == 2"` Prefix string `if:".Mode == 0 .Mode == 2"` Suffix string `if:".Mode == 0 .Mode == 2"` Flags byte `if:".Mode == 0 .Mode == 2"` NameTagVisibility string `if:".Mode == 0 .Mode == 2"` CollisionRule string `if:".Mode == 0 .Mode == 2"` Color byte `if:".Mode == 0 .Mode == 2"` Players []string `length:"VarInt" if:".Mode == 0 .Mode == 3 .Mode == 4"` }
Teams creates and updates teams
This is a Minecraft packet
type TeleportPlayer ¶
TeleportPlayer is sent to change the player's position. The client is expected to reply to the server with the same positions as contained in this packet otherwise will reject future packets.
This is a Minecraft packet
type TimeUpdate ¶
TimeUpdate is sent to sync the world's time to the client, the client will manually tick the time itself so this doesn't need to sent repeatedly but if the server or client has issues keeping up this can fall out of sync so it is a good idea to sent this now and again
This is a Minecraft packet
type Title ¶
type Title struct { Action VarInt Title format.AnyComponent `as:"json" if:".Action == 0"` SubTitle format.AnyComponent `as:"json" if:".Action == 1"` FadeIn int32 `if:".Action == 2"` FadeStay int32 `if:".Action == 2"` FadeOut int32 `if:".Action == 2"` }
Title configures an on-screen title.
This is a Minecraft packet
type UUID ¶
type UUID [16]byte
UUID is an unique identifier
func (*UUID) Deserialize ¶
Deserialize deserializes the uuid from the reader
type UpdateBlockEntity ¶
UpdateBlockEntity updates the nbt tag of a block entity in the world.
This is a Minecraft packet
type UpdateHealth ¶
UpdateHealth is sent by the server to update the player's health and food.
This is a Minecraft packet
type UpdateScore ¶
type UpdateScore struct { Name string Action byte ObjectName string Value VarInt `if:".Action != 1"` }
UpdateScore is used to update or remove an item from a scoreboard objective.
This is a Minecraft packet
type UpdateSign ¶
type UpdateSign struct { Location Position Line1 format.AnyComponent `as:"json"` Line2 format.AnyComponent `as:"json"` Line3 format.AnyComponent `as:"json"` Line4 format.AnyComponent `as:"json"` }
UpdateSign sets or changes the text on a sign.
This is a Minecraft packet
type UseEntity ¶
type UseEntity struct { TargetID VarInt Type VarInt TargetX float32 `if:".Type==2"` TargetY float32 `if:".Type==2"` TargetZ float32 `if:".Type==2"` Hand VarInt `if:".Type==0 .Type==2"` }
UseEntity is sent when the user interacts (right clicks) or attacks (left clicks) an entity.
This is a Minecraft packet
type UseItem ¶
type UseItem struct {
Hand VarInt
}
UseItem is sent when the client tries to use an item.
This is a Minecraft packet
type WindowClose ¶
type WindowClose struct {
ID byte
}
WindowClose forces the client to close the window with the given id, e.g. a chest getting destroyed.
This is a Minecraft packet
type WindowOpen ¶
type WindowOpen struct { ID byte Type string Title format.AnyComponent `as:"json"` SlotCount byte EntityID int32 `if:".Type == \"EntityHorse\""` }
WindowOpen tells the client to open the inventory window of the given type. The ID is used to reference the instance of the window in other packets.
This is a Minecraft packet
type WindowProperty ¶
WindowProperty changes the value of a property of a window. Properties vary depending on the window type.
This is a Minecraft packet
type WindowSetSlot ¶
WindowSetSlot changes an itemstack in one of the slots in a window.
This is a Minecraft packet
type WorldBorder ¶
type WorldBorder struct { Action VarInt OldRadius float64 `if:".Action == 3 .Action == 1"` NewRadius float64 `if:".Action == 3 .Action == 1 .Action == 0"` Speed VarLong `if:".Action == 3 .Action == 1"` X, Z float64 `if:".Action == 3 .Action == 2"` PortalBoundary VarInt `if:".Action == 3"` WarningTime VarInt `if:".Action == 3 .Action == 4"` WarningBlocks VarInt `if:".Action == 3 .Action == 5"` }
WorldBorder configures the world's border.
This is a Minecraft packet
Notes ¶
Bugs ¶
LoginToServer doesn't support offline mode. Call it a feature?
Source Files ¶
- connection.go
- crypto.go
- handshaking.go
- handshaking_proto.go
- io.go
- item.go
- login.go
- login_clientbound.go
- login_clientbound_proto.go
- login_serverbound.go
- login_serverbound_proto.go
- metadata.go
- play_clientbound.go
- play_clientbound_proto.go
- play_serverbound.go
- play_serverbound_proto.go
- state_string.go
- status.go
- status_clientbound.go
- status_clientbound_proto.go
- status_serverbound.go
- status_serverbound_proto.go
- types.go