Documentation ¶
Overview ¶
Package packet implements all packets of Minecraft Protocol.
Many, many thanks to #mcdevs from Freenode and it's great documentation: http://wiki.vg/Protocol
Index ¶
- Constants
- func CheckPacketId(expected, input byte) error
- type Animation
- type BedUse
- type BlockAction
- type BlockBreakAnimation
- type BlockChange
- type BlockChangeMulti
- type ChatMessage
- type ChunkData
- type ChunkMeta
- type ClientSettings
- type ClientStatuses
- type ConfirmTransaction
- type CreativeInventoryAction
- type Disconnect
- type EnchantItem
- type EncryptionKeyRequest
- type EncryptionKeyResponse
- type Entity
- type EntityAction
- type EntityAttach
- type EntityDestroy
- type EntityEffect
- type EntityEffectRemove
- type EntityEquipment
- type EntityGlobalSpawn
- type EntityHeadLook
- type EntityInteract
- type EntityLook
- type EntityLookRelMove
- type EntityMetadata
- type EntityNamedSpawn
- type EntityRelMove
- type EntityStatus
- type EntityTeleport
- type EntityVelocity
- type Explosion
- type GameStateChange
- type Handshake
- type HealthUpdate
- type Id
- type ItemCollect
- type ItemData
- type ItemHeldChange
- type KeepAlive
- type LoginInfo
- type MapChunkBulk
- type MustReadWriter
- func (rw MustReadWriter) ReadBool(r io.Reader) (res bool)
- func (rw MustReadWriter) ReadMetadata(r io.Reader) (res mct.Metadata)
- func (rw MustReadWriter) ReadObjectData(r io.Reader) (res *mct.ObjectData)
- func (rw MustReadWriter) ReadSlot(r io.Reader) (res *mct.Slot)
- func (rw MustReadWriter) ReadString(r io.Reader) (res string)
- func (rw MustReadWriter) WriteBool(w io.Writer, value bool)
- func (rw MustReadWriter) WriteMetadata(w io.Writer, value mct.Metadata)
- func (rw MustReadWriter) WriteObjectData(w io.Writer, value *mct.ObjectData)
- func (rw MustReadWriter) WriteSlot(w io.Writer, value *mct.Slot)
- func (rw MustReadWriter) WriteString(w io.Writer, value string)
- type Packet
- type Particle
- type Player
- type PlayerAbilities
- type PlayerAction
- type PlayerBlockPlace
- type PlayerLook
- type PlayerPos
- type PlayerPosLook
- type PlayerTabListPing
- type PluginMessage
- type Respawn
- type ScoreDisplay
- type ScoreObjective
- type ScoreTeams
- type ScoreUpdate
- type ServerListPing
- type SetExperience
- type SignUpdate
- type SoundEffect
- type SoundEffectNamed
- type SpawnExperienceOrb
- type SpawnMob
- type SpawnObjectVehicle
- type SpawnPainting
- type SpawnPosition
- type StatIncrement
- type TabComplete
- type TileEntityUpdate
- type TimeUpdate
- type WindowClick
- type WindowClose
- type WindowOpen
- type WindowSetItems
- type WindowSlotSet
- type WindowUpdateProperty
- Bugs
Constants ¶
const ( PacketKeepAlive byte = iota PacketLoginInfo // 0x01 PacketHandshake // 0x02 PacketChatMessage // 0x03 PacketTimeUpdate // 0x04 PacketEntityEquipment // 0x05 PacketSpawnPosition // 0x06 PacketEntityInteract // 0x07 PacketHealthUpdate // 0x08 PacketRespawn // 0x09 PacketPlayer // 0x0a PacketPlayerPos // 0x0b PacketPlayerLook // 0x0c PacketPlayerPosLook // 0x0d PacketPlayerAction // 0x0e PacketPlayerBlockPlace // 0x0f PacketItemHeldChange // 0x10 PacketBedUse // 0x11 PacketAnimation // 0x12 PacketEntityAction // 0x13 PacketEntityNamedSpawn // 0x14 PacketItemCollect // 0x15 PacketSpawnObjectVehicle // 0x16 PacketSpawnMob // 0x17 PacketSpawnPainting // 0x18 PacketSpawnExperienceOrb // 0x19 PacketEntityVelocity // 0x1a PacketEntityDestroy // 0x1b PacketEntity // 0x1c PacketEntityRelMove // 0x1d PacketEntityLook // 0x1e PacketEntityLookRelMove // 0x1f PacketEntityTeleport // 0x20 PacketEntityHeadLook // 0x21 PacketEntityStatus // 0x22 PacketEntityAttach // 0x23 PacketEntityMetadata // 0x24 PacketEntityEffect // 0x25 PacketEntityEffectRemove // 0x26 PacketSetExperience // 0x27 )
const ( PacketChunkData byte = iota + 0x33 PacketBlockChangeMulti // 0x34 PacketBlockChange // 0x35 PacketBlockAction // 0x36 PacketBlockBreakAnimation // 0x37 PacketMapChunkBulk // 0x38 PacketExplosion // 0x39 PacketSoundEffect // 0x40 PacketSoundEffectNamed // 0x41 PacketParticle // 0x42 )
const ( PacketGameStateChange byte = iota + 0x46 PacketEntityGlobalSpawn // 0x47 )
const ( PacketWindowOpen byte = iota + 0x64 PacketWindowClose // 0x65 PacketWindowClick // 0x66 PacketWindowSlotSet // 0x67 PacketWindowSetItems // 0x68 PacketWindowUpdateProperty // 0x69 PacketConfirmTransaction // 0x6a PacketCreativeInventoryAction // 0x6b PacketEnchantItem // 0x6c )
const ( PacketSignUpdate byte = iota + 0x82 PacketItemData // 0x83 PacketTileEntityUpdate // 0x84 )
const ( PacketStatIncrement byte = iota + 0xC8 PacketPlayerTabListPing // 0xc9 PacketPlayerAbilities // 0xca PacketTabComplete // 0xcb PacketClientSettings // 0xcc PacketClientStatuses // 0xcd PacketScoreObjective // 0xce PacketScoreUpdate // 0xcf PacketScoreDisplay // 0xd0 PacketScoreTeams // 0xd1 )
const ( PacketEncryptionKeyResponse byte = iota + 0xFC PacketEncryptionKeyRequest // 0xFD PacketServerListPing // 0xFE PacketDisconnect // 0xFF )
const PacketPluginMessage byte = 0xFA
Variables ¶
This section is empty.
Functions ¶
func CheckPacketId ¶
Types ¶
type Animation ¶
type Animation struct { Entity int32 Animation int8 // (see proto/minecraft/constants#EntityAnimation) }
Animation is a two-way packet. Total Size: 6 bytes
type BedUse ¶
BedUse is a server to client packet.
Note: This Packet is sent to all nearby players including the one sent to bed.
Total Size: 15 bytes
type BlockAction ¶
type BlockAction struct { X int32 Y int16 Z int32 Byte1, Byte2 int8 // Varies depending on block (see Block_Actions) BlockId int16 // The block id this action is set for }
BlockAction is a server to client packet.
It is used for: - Chests opening and closing - Pistons pushing and pulling - Note blocks playing
Total Size: 15 bytes
func (BlockAction) Id ¶
func (p BlockAction) Id() byte
type BlockBreakAnimation ¶
type BlockBreakAnimation struct { Entity int32 X, Y, Z int32 // Block position Damage int8 // How far destroyed this block is }
BlockBreakAnimation is a server to client packet. Total Size: 18 bytes
func (BlockBreakAnimation) Id ¶
func (p BlockBreakAnimation) Id() byte
type BlockChange ¶
type BlockChange struct { X int32 Y byte Z int32 BlockType int16 // New block type for block BlockMeta int8 // New Metadata for block }
BlockChange is a server to client packet. Total Size: 13 bytes
func (BlockChange) Id ¶
func (p BlockChange) Id() byte
type BlockChangeMulti ¶
type BlockChangeMulti struct {
X, Z int32 // Chunk XZ Coordinate
Count int16 // len(Blocks)
Length int32 // Length of payload
Blocks []int32 // Coordinates, Type, and Metadata of blocks to change
}
BlockChangeMulti is a server to client packet. Total Size: 15 bytes + arrays
func (BlockChangeMulti) Id ¶
func (p BlockChangeMulti) Id() byte
type ChatMessage ¶
type ChatMessage struct {
Message string
}
ChatMessage is a two-way packet.
The default server will check the message to see if it begins with a '/'. If it doesn't, the username of the sender is prepended and sent to all other clients (including the original sender). If it does, the server assumes it to be a command and attempts to process it. A message longer than 100 characters will cause the server to kick the client.
Note: User input must be sanitized server-side
Total Size: 3 bytes + length of strings
func (ChatMessage) Id ¶
func (p ChatMessage) Id() byte
type ChunkData ¶
type ChunkData struct {
X, Z int32 // Chunk XZ Coordinate
AllColSections bool // true = all sections in this vertical column, where the primary bitmap specifies exactly which sections are included, and which are air.
Primary uint16 // Bitmask. 1 for every 16x16x16 section
Add uint16 // Bitmask. 1 for every 16x16x16 section ("add" on payload)
// BUG(toqueteos): type should be proto/anvil/ChunkData instead of []byte
ChunkData []byte // ZLib Deflate compressed chunk data
}
ChunkData is a server to client packet. Total Size: 18 bytes + len(ChunkData)
type ClientSettings ¶
type ClientSettings struct { Locale string ViewDistance int8 // 0-3 for "far", "normal", "short", "tiny" ChatFlags int8 // Chat settings Difficulty int8 // Client-side difficulty from options.txt ShowCape bool // Client-side "show cape" option }
ClientSettings is a client to server packet. Total Size: 7 bytes + length of string
func (ClientSettings) Id ¶
func (p ClientSettings) Id() byte
type ClientStatuses ¶
type ClientStatuses struct {
Payload int8 // Bit field. 0: Initial spawn, 1: Respawn after death
}
ClientStatuses is a client to server packet. Total Size: 2 bytes
func (ClientStatuses) Id ¶
func (p ClientStatuses) Id() byte
type ConfirmTransaction ¶
ConfirmTransaction is a two-way packet. Total Size: 5 bytes
func (ConfirmTransaction) Id ¶
func (p ConfirmTransaction) Id() byte
type CreativeInventoryAction ¶
CreativeInventoryAction is a two-way packet. Total Size: 3 bytes + slot data
func (CreativeInventoryAction) Id ¶
func (p CreativeInventoryAction) Id() byte
type Disconnect ¶
type Disconnect struct {
Reason string // Displayed to the client when the connection terminates
}
Disconnect is a two-way packet. Total Size: 3 bytes + length of strings
func (Disconnect) Id ¶
func (p Disconnect) Id() byte
type EnchantItem ¶
EnchantItem is a client to server packet.
While the user is in the standard inventory (i.e., not a crafting bench) on a creative-mode server then the server will send this packet: - If an item is dropped into the quick bar. - If an item is picked up from the quick bar (item id is -1)..
Total Size: 3 bytes
func (EnchantItem) Id ¶
func (p EnchantItem) Id() byte
type EncryptionKeyRequest ¶
EncryptionKeyRequest is a server to client packet. Total Size: 7 bytes + len(ServerId) + len(PublicKey) + len(Token)
func (EncryptionKeyRequest) Id ¶
func (p EncryptionKeyRequest) Id() byte
type EncryptionKeyResponse ¶
type EncryptionKeyResponse struct {
Secret, Token []byte
}
EncryptionKeyResponse is a two-way packet. Total Size: 5 bytes + len(Secret) + len(Token)
func (EncryptionKeyResponse) Id ¶
func (p EncryptionKeyResponse) Id() byte
type Entity ¶
type Entity struct {
Entity int32
}
Entity is a server to client packet.
Sent every game tick.
Entity did not move/look since the last PlayerPos/Look packet.
Total Size: 5 bytes
type EntityAction ¶
type EntityAction struct { Entity int32 Action int8 // (see proto/minecraft/constants#EntityAction) }
EntityAction is a client to server packet. Total Size: 6 bytes
func (EntityAction) Id ¶
func (p EntityAction) Id() byte
type EntityAttach ¶
type EntityAttach struct { Entity int32 VehicleId int32 // The vehicle entity Id attached to (-1 for unattaching) }
EntityAttach is a server to client packet.
Sent when an entity is attached to an entity (Minecart).
Total Size: 9 bytes
func (EntityAttach) Id ¶
func (p EntityAttach) Id() byte
type EntityDestroy ¶
EntityDestroy is a server to client packet. Total Size: 2 + (entity count * 4) bytes
func (EntityDestroy) Id ¶
func (p EntityDestroy) Id() byte
type EntityEffect ¶
type EntityEffect struct { Entity int32 Effect int8 // (see PotionEffect) Amplifier int8 Duration int16 }
EntityEffect is a server to client packet. Total Size: 9 bytes
func (EntityEffect) Id ¶
func (p EntityEffect) Id() byte
type EntityEffectRemove ¶
EntityEffectRemove is a server to client packet. Total Size: 6 bytes
func (EntityEffectRemove) Id ¶
func (p EntityEffectRemove) Id() byte
type EntityEquipment ¶
type EntityEquipment struct { Entity int32 Slot int16 // Equipment slot: 0=held, 1-4=armor slot Item *mct.Slot // Item in slot format }
EntityEquipment is a server to client packet. Total Size: 7 bytes + slot data
func (EntityEquipment) Id ¶
func (p EntityEquipment) Id() byte
type EntityGlobalSpawn ¶
type EntityGlobalSpawn struct { Entity int32 Type int8 // Global entity type, currently always 1 for thunderbolt. X, Y, Z int32 // Thunderbolt XYZ as Absolute Integer }
EntityGlobalSpawn is a server to client packet. Total Size: 18 bytes
func (EntityGlobalSpawn) Id ¶
func (p EntityGlobalSpawn) Id() byte
type EntityHeadLook ¶
EntityHeadLook is a server to client packet. Total Size: 6 bytes
func (EntityHeadLook) Id ¶
func (p EntityHeadLook) Id() byte
type EntityInteract ¶
type EntityInteract struct {
From, To int32
MouseButton bool // true=left click, false=right click
}
EntityInteract is a client to server packet.
Sent when an entity attacks or right-clicks another entity.
NMS: accept iff entity being attacked/used is visible without obstruction and within a 4-unit radius of the player's position.
Total Size: 10 bytes
func (EntityInteract) Id ¶
func (p EntityInteract) Id() byte
type EntityLook ¶
type EntityLook struct { Entity int32 Yaw, Pitch float32 // The X & Y Axis rotation as a fraction of 360 }
EntityLook is a server to client packet.
Sent when an entity rotates.
Total Size: 7 bytes
func (EntityLook) Id ¶
func (p EntityLook) Id() byte
type EntityLookRelMove ¶
type EntityLookRelMove struct { Entity int32 X, Y, Z int8 // Axis Relative movement as an Absolute Integer Yaw, Pitch int8 // The X & Y Axis rotation as a fraction of 360 }
EntityLookRelMove is a server to client packet.
Mix of 0x1F + 0x20.
Total Size: 10 bytes
func (EntityLookRelMove) Id ¶
func (p EntityLookRelMove) Id() byte
type EntityMetadata ¶
EntityMetadata is a server to client packet. Total Size: 5 bytes + Metadata
func (EntityMetadata) Id ¶
func (p EntityMetadata) Id() byte
type EntityNamedSpawn ¶
type EntityNamedSpawn struct { Entity int32 Name string // Max length: 16 X, Y, Z float64 // Absolute Integer Yaw, Pitch float32 // Packed float Item int16 // Item currently holding. 0: no item Metadata mct.Metadata }
EntityNamedSpawn is a server to client packet.
Note: sent when a player comes into visible range, not when it player joins.
Note: Item <= 0 crashes clients.
Total Size: 22 bytes + length of strings + metadata (at least 1)
func (EntityNamedSpawn) Id ¶
func (p EntityNamedSpawn) Id() byte
type EntityRelMove ¶
type EntityRelMove struct { Entity int32 X, Y, Z int8 // Axis Relative movement as an Absolute Integer }
EntityRelMove is a server to client packet.
Sent when an entity moves less than 4 blocks, otherwise use 0x22.
Total Size: 8 bytes
func (EntityRelMove) Id ¶
func (p EntityRelMove) Id() byte
type EntityStatus ¶
type EntityStatus struct { Entity int32 Status int8 // (see proto/minecraft/constants#EntityStatus) }
EntityStatus is a server to client packet. Total Size: 6 bytes
func (EntityStatus) Id ¶
func (p EntityStatus) Id() byte
type EntityTeleport ¶
type EntityTeleport struct { Entity int32 X, Y, Z float64 // Position as an Absolute Integer Yaw, Pitch float32 // The X & Y Axis rotation as a fraction of 360 }
EntityTeleport is a server to client packet.
Complementary of 0x1F. Sent when an entity moves more than 4 blocks.
Total Size: 19 bytes
func (EntityTeleport) Id ¶
func (p EntityTeleport) Id() byte
type EntityVelocity ¶
type EntityVelocity struct { Entity int32 VelX, VelY, VelZ int16 // (Protocol#Entity Velocity (0x1C)) }
EntityVelocity is a server to client packet.
Velocity is believed to be in units of 1/8000 of a block per server tick (50ms).
Example: -1343 would move (-1343 / 8000) = −0.167875 blocks per tick (or −3,3575 blocks per second).
Total Size: 11 bytes
func (EntityVelocity) Id ¶
func (p EntityVelocity) Id() byte
type Explosion ¶
type Explosion struct {
X, Y, Z float64
Radius float32 // NMC: Unused
Count int32
Blocks [][3]int8 // len(BlockPos) == Blocks * 3
PlayerX, PlayerY, PlayerZ float32 // XYZ velocity of the player being pushed
}
Explosion is a server to client packet. Total Size: 45 bytes + 3*(Record count) bytes
type GameStateChange ¶
type GameStateChange struct { Reason int8 GameMode int8 // Reason == 3 then 0=survival, 1=creative }
GameStateChange is a server to client packet. Total Size: 3 bytes
func (GameStateChange) Id ¶
func (p GameStateChange) Id() byte
type Handshake ¶
type Handshake struct { Version int8 Username string // Player attempting to connect Host string Port int32 }
Handshake is a client to server packet.
Total Size: 10 bytes + length of strings
type HealthUpdate ¶
type HealthUpdate struct { Health int16 // <=0: dead, 20: full HP Food int16 // 0~20 Saturation float32 // 0.0~5.0, integer increments }
HealthUpdate is a server to client packet.
Updates a player's health. Starts at 5.0.
Food won't decrease while saturation is over zero. Eating increases food and saturation.
Total Size: 9 bytes
func (HealthUpdate) Id ¶
func (p HealthUpdate) Id() byte
type ItemCollect ¶
type ItemCollect struct {
WhatId, WhoId int32
}
ItemCollect is a server to client packet.
Note: Server checks items to be picked up after each PlayerPos and PlayerPosLook packet sent.
Total Size: 9 bytes
func (ItemCollect) Id ¶
func (p ItemCollect) Id() byte
type ItemData ¶
type ItemData struct { Type int16 ItemId int16 // Damage value Length int16 // len(Text) Text []byte // ASCII text }
ItemData is a server to client packet.
Specifies complex data on an item; currently used only for maps.
Maps If the first byte of the text is 0, the next two bytes are X start and Y start and the rest of the bytes are the colors in that column.
If the first byte of the text is 1, the rest of the bytes are in groups of three: (data, x, y). The lower half of the data is the type (always 0 under vanilla) and the upper half is the direction.
Total Size: 7 bytes + Text length
type ItemHeldChange ¶
type ItemHeldChange struct {
SlotId int16 // The slot which the player has selected (0-8)
}
ItemHeldChange is a two-way packet. Total Size: 3 bytes
func (ItemHeldChange) Id ¶
func (p ItemHeldChange) Id() byte
type KeepAlive ¶
type KeepAlive struct {
RandomId int32
}
KeepAlive is a two-way packet.
The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same packet.
Total Size: 5 bytes
type LoginInfo ¶
type LoginInfo struct { Entity int32 LevelType string // level-type in server.properties GameMode int8 // 0: survival, 1: creative, 2: adventure. Bit 3 (0x8) is the hardcore flag Dimension int8 // -1: nether, 0: overworld, 1: end Difficulty int8 // 0~3 for Peaceful, Easy, Normal, Hard // _WorldHeight int8 // NMS: always 0 MaxPlayers int8 // Used by the client to draw the player list }
LoginInfo is a server to client packet.
Total Size: 12 bytes + length of strings
type MapChunkBulk ¶
type MapChunkBulk struct { // Count int16 // len(ChunkMeta) // Length int32 // len(ChunkData) SkylightSent bool // Chunk data contains a light nibble array? true for overworld, false otherwise ChunkData []byte // Compressed chunk data ChunkMeta []ChunkMeta }
MapChunkBulk is a server to client packet. Total Size: 8 + (DataLength) + 12 * (Count) bytes
func (MapChunkBulk) Id ¶
func (p MapChunkBulk) Id() byte
type MustReadWriter ¶
type MustReadWriter struct {
must.ReadWriter
}
MustReadWriter handles error handling while reading common types present in packets. It keeps a counter of bytes read and errors out on the first error.
func (MustReadWriter) ReadMetadata ¶
func (rw MustReadWriter) ReadMetadata(r io.Reader) (res mct.Metadata)
func (MustReadWriter) ReadObjectData ¶
func (rw MustReadWriter) ReadObjectData(r io.Reader) (res *mct.ObjectData)
func (MustReadWriter) ReadString ¶
func (rw MustReadWriter) ReadString(r io.Reader) (res string)
func (MustReadWriter) WriteMetadata ¶
func (rw MustReadWriter) WriteMetadata(w io.Writer, value mct.Metadata)
func (MustReadWriter) WriteObjectData ¶
func (rw MustReadWriter) WriteObjectData(w io.Writer, value *mct.ObjectData)
func (MustReadWriter) WriteString ¶
func (rw MustReadWriter) WriteString(w io.Writer, value string)
type Particle ¶
type Particle struct { Name string X, Y, Z float32 OffsetX, OffsetY, OffsetZ float32 // Added to XYZ after multiplication by random.nextGaussian() Speed float32 Number int32 }
Particle is a server to client packet. Total Size: 34 bytes + length of string
type Player ¶
type Player struct {
OnGround bool // true if the client is on the ground, false otherwise
}
Player is a client to server packet.
Fall damage is applied when this state goes from false to true and player is 4+ blocks high from ground.
Total Size: 2 bytes
type PlayerAbilities ¶
type PlayerAbilities struct {
GodMode, CanFly, Flying, Creative bool // Sent as byte
FlyingSpeed int8
WalkingSpeed int8
}
Total Size: 4 bytes
func (PlayerAbilities) Id ¶
func (p PlayerAbilities) Id() byte
type PlayerAction ¶
type PlayerAction struct { Action int8 // (see proto/minecraft/constants#PlayerAction) X int32 Y int8 Z int32 Face int8 // (see proto/minecraft/constants#BlockDirection) }
PlayerAction client to server packet.
NMS: accepts packet iff coordinates within a 6-unit radius from player's position.
Actions: 0: start dig. 1: cancel dig. 2: finish dig. 3: drop full stack (all other values set to 0). 4: drop single item from stack (all other values set to 0). 5: shoot arrow / finish eating (face: 0xff, all other values set to 0).
Total Size: 12 bytes
func (PlayerAction) Id ¶
func (p PlayerAction) Id() byte
type PlayerBlockPlace ¶
type PlayerBlockPlace struct { X int32 Y byte Z int32 Direction int8 // (see proto/minecraft/constants#BlockDirection) HeldItem *mct.Slot ChX, ChY, ChZ int8 // The position of the crosshair on the block }
PlayerBlockPlace client to server packet.
Iff XYZ + Direction == -1 currently held item should have its state updated (eating food, shooting bows, using buckets, etc...)
Note: NMC might send two packets when using buckets, first a normal and then a special case. First a normal packet is sent when you're looking at a block, it does nothing on NMS. Second packet performs the action (based on current pos/look and with a distance check, see next note).
Note: buckets can only be used within a radius of 6 units.
Total Size: 14 bytes + slot data
func (PlayerBlockPlace) Id ¶
func (p PlayerBlockPlace) Id() byte
type PlayerLook ¶
type PlayerLook struct {
Yaw, Pitch float32 // Absolute rotation on the XY Axis (degrees)
OnGround bool // Same as 0x0A
}
PlayerLook client to server packet.
Updates the direction the player is looking in.
Yaw is measured in degrees, and does not follow classical trigonometry rules. The unit circle of yaw on the xz-plane starts at (0, 1) and turns backwards towards (-1, 0), or in other words, it turns clockwise instead of counterclockwise. Additionally, yaw is not clamped to between 0 and 360 degrees; any number is valid, including negative numbers and numbers greater than 360.
Pitch is measured in degrees, where 0 is looking straight ahead, -90 is looking straight up, and 90 is looking straight down.
Total Size: 10 bytes
func (PlayerLook) Id ¶
func (p PlayerLook) Id() byte
type PlayerPos ¶
type PlayerPos struct {
X, Y, Z float64 // Absolute position
Stance float64 // Modifies players' bounding box while on stairs, crouching, etc...
OnGround bool // Same as 0x0A
}
PlayerPos client to server packet.
Updates the players XYZ position on the server.
If Stance - Y is less than 0.1 or greater than 1.65, the stance is illegal and the client will be kicked with the message “Illegal Stance”.
If the distance between the last known position of the player on the server and the new position set by this packet is greater than 100 units will result in the client being kicked for "You moved too quickly :( (Hacking?)".
Also if the absolute number of X or Z is set greater than 3.2E7D the client will be kicked for "Illegal position".
Total Size: 34 bytes
type PlayerPosLook ¶
type PlayerPosLook struct {
X, Y, Z float64 // Absolute position
Stance float64 // Modifies players' bounding box while on stairs, crouching, etc...
Yaw, Pitch float32 // Absolute rotation on the XY Axis (degrees)
OnGround bool // Same as 0x0A
}
PlayerPosLook is a two-way packet.
Note: When this packet is sent from the server, the Y and Stance fields are swapped.
Total Size: 42 bytes
func (PlayerPosLook) Id ¶
func (p PlayerPosLook) Id() byte
type PlayerTabListPing ¶
type PlayerTabListPing struct { Name string // Supports chat colouring, max 16 chars Online bool // false = client will remove user from player list Ping int16 // Ping, presumably in ms }
PlayerTabListPing is a server to client packet.
NMS: sends one packet per user per tick (amounting to 20 packets/s for 1 online user).
Total Size: 6 bytes + length of string
func (PlayerTabListPing) Id ¶
func (p PlayerTabListPing) Id() byte
type PluginMessage ¶
PluginMessage is a two-way packet. Total Size: 5 bytes + len(Name) + len(Payload)
func (PluginMessage) Id ¶
func (p PluginMessage) Id() byte
type Respawn ¶
type Respawn struct { Dimension int32 // -1: The Nether, 0: The Overworld, 1: The End Difficulty int8 // 0~3: Peaceful, Easy, Normal, Hard. GameMode int8 // 0: survival, 1: creative, 2: adventure. Hardcore flag not included WorldHeight int16 // Defaults to 256 LevelType string // See 0x01 login }
Respawn is a server to client packet.
NMC: 1 is always sent c->s
Total Size: 11 bytes + length of string
type ScoreDisplay ¶
type ScoreDisplay struct { Position int8 // 0 = list, 1 = sidebar, 2 = belowName DisplayName string // Unique name for the scoreboard to be displayed. }
ScoreDisplay is a server to client packet. Total Size: 4 bytes + length of string
func (ScoreDisplay) Id ¶
func (p ScoreDisplay) Id() byte
type ScoreObjective ¶
type ScoreObjective struct { Name string // Unique name Value string // The text to be displayed for the score Action int8 // 0 = create, 1 = remove, 2 = update display text }
ScoreObjective is a server to client packet. Total Size: 6 bytes + length of string
func (ScoreObjective) Id ¶
func (p ScoreObjective) Id() byte
type ScoreTeams ¶
type ScoreTeams struct { Name string // Unique, shared with scoreboard Mode int8 // 0: create, 1: remove, 2: update, 3: player join, 4: player leave DisplayName, Prefix, Suffix string // iff Mode == (0 | 2) FriendlyFire int8 // iff Mode == (0 | 2); 0: off, 1: on, 3: see friendly invisibles Count int16 // iff Mode == (0 | 3 | 4) Players []string // iff Mode == (0 | 3 | 4) }
ScoreTeams is a server to client packet. Total Size: Variable
func (ScoreTeams) Id ¶
func (p ScoreTeams) Id() byte
type ScoreUpdate ¶
type ScoreUpdate struct { EntityName string // Unique name to be displayed in the list. Action int8 // 0 = create/update item, 1 = remove item Objetive string // Unique name. Sent iff Action != 1 Value int32 // Sent iff Action != 1 }
ScoreUpdate is a server to client packet. Total Size: 9 bytes + length of strings
func (ScoreUpdate) Id ¶
func (p ScoreUpdate) Id() byte
type ServerListPing ¶
type ServerListPing struct {
Magic int8 // always 1
}
ServerListPing is a client to server packet. Total Size: 2 bytes
func (ServerListPing) Id ¶
func (p ServerListPing) Id() byte
type SetExperience ¶
SetExperience is a server to client packet. Total Size: 9 bytes
func (SetExperience) Id ¶
func (p SetExperience) Id() byte
type SignUpdate ¶
SignUpdate is a two-way packet.
S->C: sent whenever a sign is discovered or created. C->S: sent when the "Done" button is pushed after placing a sign.
Note: Not sent when a sign is destroyed or unloaded.
Total Size: 11 bytes + 4 strings
func (SignUpdate) Id ¶
func (p SignUpdate) Id() byte
type SoundEffect ¶
type SoundEffect struct { EffectId int32 X int32 Y int8 Z int32 Data int32 // Extra data for certain effects, see below. DisableRelVolume bool // Ignored by client for all but mob.wither.spawn (1013) }
SoundEffect is a server to client packet.
NMC: volume of sound effects is adjusted based on distance.
Total Size: 19 bytes
func (SoundEffect) Id ¶
func (p SoundEffect) Id() byte
type SoundEffectNamed ¶
type SoundEffectNamed struct { Name string // 250 X, Y, Z int32 // XYZ, multiplied by 8 Volume float32 // 1 is 100%, can be more Pitch int8 // 63 is 100%, can be more }
SoundEffectNamed is a server to client packet. Total Size: 20 bytes + length of string
func (SoundEffectNamed) Id ¶
func (p SoundEffectNamed) Id() byte
type SpawnExperienceOrb ¶
SpawnExperienceOrb is a server to client packet. Total Size: 19 bytes
func (SpawnExperienceOrb) Id ¶
func (p SpawnExperienceOrb) Id() byte
type SpawnMob ¶
type SpawnMob struct { Entity int32 Type int8 // The type of object (see Entities#Objects) X, Y, Z int32 // Absolute Integer Position of the object Pitch, HeadPitch, Yaw int8 // Yaw in steps of 2p/256 VelX, VelY, VelZ int16 Metadata mct.Metadata // Varies by mob (see Entities) }
SpawnMob is a server to client packet. Total Size: 27 bytes + Metadata (3+ bytes)
type SpawnObjectVehicle ¶
type SpawnObjectVehicle struct { Entity int32 Type int8 // The type of object (see Entities#Objects) X, Y, Z int32 // Absolute Integer Position of the object Pitch, Yaw int8 // In steps of 2p/256 ObjectData *mct.ObjectData // (see Object Data) }
SpawnObjectVehicle is a server to client packet. Total Size: 23 or 29 bytes
func (SpawnObjectVehicle) Id ¶
func (p SpawnObjectVehicle) Id() byte
type SpawnPainting ¶
type SpawnPainting struct { Entity int32 Title string X, Y, Z int32 Direction int32 // Direction the painting faces (0: -z, 1: -x, 2: +z, 3: +x) }
SpawnPainting is a server to client packet.
Note: Title's max length is 13.
Total Size: 23 bytes + length of string
func (SpawnPainting) Id ¶
func (p SpawnPainting) Id() byte
type SpawnPosition ¶
type SpawnPosition struct {
X, Y, Z int32 // Spawn X, Y, Z in block coordinates
}
SpawnPosition is a server to client packet.
Sent by the server after login to specify the coordinates of the spawn point. It can be sent at any time to update the point compasses point at.
Total Size: 13 bytes
func (SpawnPosition) Id ¶
func (p SpawnPosition) Id() byte
type StatIncrement ¶
StatIncrement is a server to client packet. Total Size: 6 bytes
func (StatIncrement) Id ¶
func (p StatIncrement) Id() byte
type TabComplete ¶
type TabComplete struct {
Text string
}
TabComplete is a two-way packet. Total Size: 3 bytes + length of string
func (TabComplete) Id ¶
func (p TabComplete) Id() byte
type TileEntityUpdate ¶
type TileEntityUpdate struct { X int32 Y int16 Z int32 Action int8 // 1: set mob displayed inside mob spawner // Length int16 // Hidden in slice Data []byte // NBT Byte Array; iff Length > 0 }
TileEntityUpdate is a server to client packet. Total Size: 12 + itemstack bytes
func (TileEntityUpdate) Id ¶
func (p TileEntityUpdate) Id() byte
type TimeUpdate ¶
type TimeUpdate struct {
WorldAge, Time int64
}
TimeUpdate is a server to client packet.
Time is based on ticks, exactly 20 ticks per second. There are 24000 ticks in a day, making Minecraft days exactly 20 minutes long.
NOTES: Time = Time + 20 % 24000
Total Size: 17 Bytes
func (TimeUpdate) Id ¶
func (p TimeUpdate) Id() byte
type WindowClick ¶
type WindowClick struct { WindowId int8 // 0: inventory Slot int16 // Button int8 // 0: left, 1: right, 3: middle ("Mode" set to 3) Action int16 // Unique number for the action, used for transaction handling Mode int8 // 0: regular, 1: shift + click, 5: "painting" mode, 6: double-click Item *mct.Slot // Clicked item }
WindowClick is a client to server packet. Total Size: 8 bytes + slot data
func (WindowClick) Id ¶
func (p WindowClick) Id() byte
type WindowClose ¶
type WindowClose struct {
WindowId int8 // 0 = inventory
}
WindowClose is a two-way packet. Total Size: 2 bytes
func (WindowClose) Id ¶
func (p WindowClose) Id() byte
type WindowOpen ¶
type WindowOpen struct { WindowId int8 // Unique Window Id number. NMS: counter, starting at 1. InventoryType int8 // The window type to use for display. Check below WindowTitle string // The title of the window. Slots int8 // Slots in window excluding player inventory slots UseProvidedTitle bool // true: client uses what the server provides, false: client will look up a string }
WindowOpen is a server to client packet.
Sent when NMC should open an inventory (chest, workbench, furnace, etc...). Not sent when client opens his inventory.
Total Size: 7 bytes + length of string
func (WindowOpen) Id ¶
func (p WindowOpen) Id() byte
type WindowSetItems ¶
WindowSetItems is a server to client packet. Total Size: 4 bytes + size of slot data array
func (WindowSetItems) Id ¶
func (p WindowSetItems) Id() byte
type WindowSlotSet ¶
WindowSlotSet is a server to client packet. Total Size: 4 bytes + slot data
func (WindowSlotSet) Id ¶
func (p WindowSlotSet) Id() byte
type WindowUpdateProperty ¶
WindowUpdateProperty is a server to client packet. Total Size: 6 bytes
func (WindowUpdateProperty) Id ¶
func (p WindowUpdateProperty) Id() byte
Notes ¶
Bugs ¶
type should be proto/anvil/ChunkData instead of []byte