packet

package
v0.0.0-...-93368d4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2015 License: MIT Imports: 6 Imported by: 18

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

View Source
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
)
View Source
const (
	PacketChunkData           byte = iota + 0x33
	PacketBlockChangeMulti         // 0x34
	PacketBlockChange              // 0x35
	PacketBlockAction              // 0x36
	PacketBlockBreakAnimation      // 0x37
	PacketMapChunkBulk             // 0x38
	PacketExplosion                // 0x39
	PacketSoundEffect              // 0x40
	PacketSoundEffectNamed         // 0x41
	PacketParticle                 // 0x42
)
View Source
const (
	PacketGameStateChange   byte = iota + 0x46
	PacketEntityGlobalSpawn      // 0x47
)
View Source
const (
	PacketWindowOpen              byte = iota + 0x64
	PacketWindowClose                  // 0x65
	PacketWindowClick                  // 0x66
	PacketWindowSlotSet                // 0x67
	PacketWindowSetItems               // 0x68
	PacketWindowUpdateProperty         // 0x69
	PacketConfirmTransaction           // 0x6a
	PacketCreativeInventoryAction      // 0x6b
	PacketEnchantItem                  // 0x6c
)
View Source
const (
	PacketSignUpdate       byte = iota + 0x82
	PacketItemData              // 0x83
	PacketTileEntityUpdate      // 0x84
)
View Source
const (
	PacketStatIncrement     byte = iota + 0xC8
	PacketPlayerTabListPing      // 0xc9
	PacketPlayerAbilities        // 0xca
	PacketTabComplete            // 0xcb
	PacketClientSettings         // 0xcc
	PacketClientStatuses         // 0xcd
	PacketScoreObjective         // 0xce
	PacketScoreUpdate            // 0xcf
	PacketScoreDisplay           // 0xd0
	PacketScoreTeams             // 0xd1
)
View Source
const (
	PacketEncryptionKeyResponse byte = iota + 0xFC
	PacketEncryptionKeyRequest       // 0xFD
	PacketServerListPing             // 0xFE
	PacketDisconnect                 // 0xFF
)
View Source
const PacketPluginMessage byte = 0xFA

Variables

This section is empty.

Functions

func CheckPacketId

func CheckPacketId(expected, input byte) error

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

func (Animation) Id

func (p Animation) Id() byte

func (*Animation) ReadFrom

func (p *Animation) ReadFrom(r io.Reader) (n int64, err error)

func (*Animation) WriteTo

func (p *Animation) WriteTo(w io.Writer) (n int64, err error)

type BedUse

type BedUse struct {
	Entity int32
	X      int32
	Y      int8
	Z      int32
}

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

func (BedUse) Id

func (p BedUse) Id() byte

func (*BedUse) ReadFrom

func (p *BedUse) ReadFrom(r io.Reader) (n int64, err error)

func (*BedUse) WriteTo

func (p *BedUse) WriteTo(w io.Writer) (n int64, err error)

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

func (*BlockAction) ReadFrom

func (p *BlockAction) ReadFrom(r io.Reader) (n int64, err error)

func (*BlockAction) WriteTo

func (p *BlockAction) WriteTo(w io.Writer) (n int64, err error)

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

func (*BlockBreakAnimation) ReadFrom

func (p *BlockBreakAnimation) ReadFrom(r io.Reader) (n int64, err error)

func (*BlockBreakAnimation) WriteTo

func (p *BlockBreakAnimation) WriteTo(w io.Writer) (n int64, err error)

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

func (*BlockChange) ReadFrom

func (p *BlockChange) ReadFrom(r io.Reader) (n int64, err error)

func (*BlockChange) WriteTo

func (p *BlockChange) WriteTo(w io.Writer) (n int64, err error)

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

func (*BlockChangeMulti) ReadFrom

func (p *BlockChangeMulti) ReadFrom(r io.Reader) (n int64, err error)

func (*BlockChangeMulti) WriteTo

func (p *BlockChangeMulti) WriteTo(w io.Writer) (n int64, err error)

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

func (*ChatMessage) ReadFrom

func (p *ChatMessage) ReadFrom(r io.Reader) (n int64, err error)

func (*ChatMessage) WriteTo

func (p *ChatMessage) WriteTo(w io.Writer) (n int64, err error)

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)

func (ChunkData) Id

func (p ChunkData) Id() byte

func (*ChunkData) ReadFrom

func (p *ChunkData) ReadFrom(r io.Reader) (n int64, err error)

func (*ChunkData) WriteTo

func (p *ChunkData) WriteTo(w io.Writer) (n int64, err error)

type ChunkMeta

type ChunkMeta struct {
	X, Z    int32  // The XZ coordinate of the specific chunk
	Primary uint16 // Bitmap. Specifies which sections are not empty
	Add     uint16 // Bitmap. Specifies which sections need add information because of very high block ids
}

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

func (*ClientSettings) ReadFrom

func (p *ClientSettings) ReadFrom(r io.Reader) (n int64, err error)

func (*ClientSettings) WriteTo

func (p *ClientSettings) WriteTo(w io.Writer) (n int64, err error)

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

func (*ClientStatuses) ReadFrom

func (p *ClientStatuses) ReadFrom(r io.Reader) (n int64, err error)

func (*ClientStatuses) WriteTo

func (p *ClientStatuses) WriteTo(w io.Writer) (n int64, err error)

type ConfirmTransaction

type ConfirmTransaction struct {
	WindowId int8
	Action   int16 // Unique number
	Accepted bool
}

ConfirmTransaction is a two-way packet. Total Size: 5 bytes

func (ConfirmTransaction) Id

func (p ConfirmTransaction) Id() byte

func (*ConfirmTransaction) ReadFrom

func (p *ConfirmTransaction) ReadFrom(r io.Reader) (n int64, err error)

func (*ConfirmTransaction) WriteTo

func (p *ConfirmTransaction) WriteTo(w io.Writer) (n int64, err error)

type CreativeInventoryAction

type CreativeInventoryAction struct {
	Slot int16
	Item *mct.Slot
}

CreativeInventoryAction is a two-way packet. Total Size: 3 bytes + slot data

func (CreativeInventoryAction) Id

func (*CreativeInventoryAction) ReadFrom

func (p *CreativeInventoryAction) ReadFrom(r io.Reader) (n int64, err error)

func (*CreativeInventoryAction) WriteTo

func (p *CreativeInventoryAction) WriteTo(w io.Writer) (n int64, err error)

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

func (*Disconnect) ReadFrom

func (p *Disconnect) ReadFrom(r io.Reader) (n int64, err error)

func (*Disconnect) WriteTo

func (p *Disconnect) WriteTo(w io.Writer) (n int64, err error)

type EnchantItem

type EnchantItem struct {
	WindowId int8
	Position int8 // 0~2 from top to bottom
}

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

func (*EnchantItem) ReadFrom

func (p *EnchantItem) ReadFrom(r io.Reader) (n int64, err error)

func (*EnchantItem) WriteTo

func (p *EnchantItem) WriteTo(w io.Writer) (n int64, err error)

type EncryptionKeyRequest

type EncryptionKeyRequest struct {
	ServerId         string
	PublicKey, Token []byte
}

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

func (*EncryptionKeyRequest) ReadFrom

func (p *EncryptionKeyRequest) ReadFrom(r io.Reader) (n int64, err error)

func (*EncryptionKeyRequest) WriteTo

func (p *EncryptionKeyRequest) WriteTo(w io.Writer) (n int64, err error)

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

func (*EncryptionKeyResponse) ReadFrom

func (p *EncryptionKeyResponse) ReadFrom(r io.Reader) (n int64, err error)

func (*EncryptionKeyResponse) WriteTo

func (p *EncryptionKeyResponse) WriteTo(w io.Writer) (n int64, err error)

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

func (Entity) Id

func (p Entity) Id() byte

func (*Entity) ReadFrom

func (p *Entity) ReadFrom(r io.Reader) (n int64, err error)

func (*Entity) WriteTo

func (p *Entity) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityAction) ReadFrom

func (p *EntityAction) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityAction) WriteTo

func (p *EntityAction) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityAttach) ReadFrom

func (p *EntityAttach) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityAttach) WriteTo

func (p *EntityAttach) WriteTo(w io.Writer) (n int64, err error)

type EntityDestroy

type EntityDestroy struct {
	Count    int8
	Entities []int32
}

EntityDestroy is a server to client packet. Total Size: 2 + (entity count * 4) bytes

func (EntityDestroy) Id

func (p EntityDestroy) Id() byte

func (*EntityDestroy) ReadFrom

func (p *EntityDestroy) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityDestroy) WriteTo

func (p *EntityDestroy) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityEffect) ReadFrom

func (p *EntityEffect) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityEffect) WriteTo

func (p *EntityEffect) WriteTo(w io.Writer) (n int64, err error)

type EntityEffectRemove

type EntityEffectRemove struct {
	Entity int32
	Effect int8 // (see PotionEffect)
}

EntityEffectRemove is a server to client packet. Total Size: 6 bytes

func (EntityEffectRemove) Id

func (p EntityEffectRemove) Id() byte

func (*EntityEffectRemove) ReadFrom

func (p *EntityEffectRemove) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityEffectRemove) WriteTo

func (p *EntityEffectRemove) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityEquipment) ReadFrom

func (p *EntityEquipment) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityEquipment) WriteTo

func (p *EntityEquipment) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityGlobalSpawn) ReadFrom

func (p *EntityGlobalSpawn) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityGlobalSpawn) WriteTo

func (p *EntityGlobalSpawn) WriteTo(w io.Writer) (n int64, err error)

type EntityHeadLook

type EntityHeadLook struct {
	Entity  int32
	HeadYaw float32 // Head yaw in steps of 2p/256
}

EntityHeadLook is a server to client packet. Total Size: 6 bytes

func (EntityHeadLook) Id

func (p EntityHeadLook) Id() byte

func (*EntityHeadLook) ReadFrom

func (p *EntityHeadLook) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityHeadLook) WriteTo

func (p *EntityHeadLook) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityInteract) ReadFrom

func (p *EntityInteract) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityInteract) WriteTo

func (p *EntityInteract) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityLook) ReadFrom

func (p *EntityLook) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityLook) WriteTo

func (p *EntityLook) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityLookRelMove) ReadFrom

func (p *EntityLookRelMove) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityLookRelMove) WriteTo

func (p *EntityLookRelMove) WriteTo(w io.Writer) (n int64, err error)

type EntityMetadata

type EntityMetadata struct {
	Entity int32
	Meta   mct.Metadata // (see Entities)
}

EntityMetadata is a server to client packet. Total Size: 5 bytes + Metadata

func (EntityMetadata) Id

func (p EntityMetadata) Id() byte

func (*EntityMetadata) ReadFrom

func (p *EntityMetadata) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityMetadata) WriteTo

func (p *EntityMetadata) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityNamedSpawn) ReadFrom

func (p *EntityNamedSpawn) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityNamedSpawn) WriteTo

func (p *EntityNamedSpawn) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityRelMove) ReadFrom

func (p *EntityRelMove) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityRelMove) WriteTo

func (p *EntityRelMove) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityStatus) ReadFrom

func (p *EntityStatus) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityStatus) WriteTo

func (p *EntityStatus) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityTeleport) ReadFrom

func (p *EntityTeleport) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityTeleport) WriteTo

func (p *EntityTeleport) WriteTo(w io.Writer) (n int64, err error)

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

func (*EntityVelocity) ReadFrom

func (p *EntityVelocity) ReadFrom(r io.Reader) (n int64, err error)

func (*EntityVelocity) WriteTo

func (p *EntityVelocity) WriteTo(w io.Writer) (n int64, err error)

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

func (Explosion) Id

func (p Explosion) Id() byte

func (*Explosion) ReadFrom

func (p *Explosion) ReadFrom(r io.Reader) (n int64, err error)

func (*Explosion) WriteTo

func (p *Explosion) WriteTo(w io.Writer) (n int64, err error)

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

func (*GameStateChange) ReadFrom

func (p *GameStateChange) ReadFrom(r io.Reader) (n int64, err error)

func (*GameStateChange) WriteTo

func (p *GameStateChange) WriteTo(w io.Writer) (n int64, err error)

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

func (Handshake) Id

func (p Handshake) Id() byte

func (*Handshake) ReadFrom

func (p *Handshake) ReadFrom(r io.Reader) (n int64, err error)

func (*Handshake) WriteTo

func (p *Handshake) WriteTo(w io.Writer) (n int64, err error)

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

func (*HealthUpdate) ReadFrom

func (p *HealthUpdate) ReadFrom(r io.Reader) (n int64, err error)

func (*HealthUpdate) WriteTo

func (p *HealthUpdate) WriteTo(w io.Writer) (n int64, err error)

type Id

type Id byte

func (*Id) ReadFrom

func (i *Id) ReadFrom(r io.Reader) (n int64, err error)

func (*Id) WriteTo

func (i *Id) WriteTo(w io.Writer) (n int64, err error)

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

func (*ItemCollect) ReadFrom

func (p *ItemCollect) ReadFrom(r io.Reader) (n int64, err error)

func (*ItemCollect) WriteTo

func (p *ItemCollect) WriteTo(w io.Writer) (n int64, err error)

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

func (ItemData) Id

func (p ItemData) Id() byte

func (*ItemData) ReadFrom

func (p *ItemData) ReadFrom(r io.Reader) (n int64, err error)

func (*ItemData) WriteTo

func (p *ItemData) WriteTo(w io.Writer) (n int64, err error)

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

func (*ItemHeldChange) ReadFrom

func (p *ItemHeldChange) ReadFrom(r io.Reader) (n int64, err error)

func (*ItemHeldChange) WriteTo

func (p *ItemHeldChange) WriteTo(w io.Writer) (n int64, err error)

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

func (KeepAlive) Id

func (p KeepAlive) Id() byte

func (*KeepAlive) ReadFrom

func (p *KeepAlive) ReadFrom(r io.Reader) (n int64, err error)

func (*KeepAlive) WriteTo

func (p *KeepAlive) WriteTo(w io.Writer) (n int64, err error)

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

func (LoginInfo) Id

func (p LoginInfo) Id() byte

func (*LoginInfo) ReadFrom

func (p *LoginInfo) ReadFrom(r io.Reader) (n int64, err error)

func (*LoginInfo) WriteTo

func (p *LoginInfo) WriteTo(w io.Writer) (n int64, err error)

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

func (*MapChunkBulk) ReadFrom

func (p *MapChunkBulk) ReadFrom(r io.Reader) (n int64, err error)

func (*MapChunkBulk) WriteTo

func (p *MapChunkBulk) WriteTo(w io.Writer) (n int64, err error)

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

func (rw MustReadWriter) ReadBool(r io.Reader) (res bool)

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

func (rw MustReadWriter) ReadSlot(r io.Reader) (res *mct.Slot)

func (MustReadWriter) ReadString

func (rw MustReadWriter) ReadString(r io.Reader) (res string)

func (MustReadWriter) WriteBool

func (rw MustReadWriter) WriteBool(w io.Writer, value bool)

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

func (rw MustReadWriter) WriteSlot(w io.Writer, value *mct.Slot)

func (MustReadWriter) WriteString

func (rw MustReadWriter) WriteString(w io.Writer, value string)

type Packet

type Packet interface {
	Id() byte
	io.ReaderFrom
	io.WriterTo
}

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

func (Particle) Id

func (p Particle) Id() byte

func (*Particle) ReadFrom

func (p *Particle) ReadFrom(r io.Reader) (n int64, err error)

func (*Particle) WriteTo

func (p *Particle) WriteTo(w io.Writer) (n int64, err error)

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

func (Player) Id

func (p Player) Id() byte

func (*Player) ReadFrom

func (p *Player) ReadFrom(r io.Reader) (n int64, err error)

func (*Player) WriteTo

func (p *Player) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerAbilities) ReadFrom

func (p *PlayerAbilities) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerAbilities) WriteTo

func (p *PlayerAbilities) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerAction) ReadFrom

func (p *PlayerAction) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerAction) WriteTo

func (p *PlayerAction) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerBlockPlace) ReadFrom

func (p *PlayerBlockPlace) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerBlockPlace) WriteTo

func (p *PlayerBlockPlace) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerLook) ReadFrom

func (p *PlayerLook) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerLook) WriteTo

func (p *PlayerLook) WriteTo(w io.Writer) (n int64, err error)

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

func (PlayerPos) Id

func (p PlayerPos) Id() byte

func (*PlayerPos) ReadFrom

func (p *PlayerPos) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerPos) WriteTo

func (p *PlayerPos) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerPosLook) ReadFrom

func (p *PlayerPosLook) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerPosLook) WriteTo

func (p *PlayerPosLook) WriteTo(w io.Writer) (n int64, err error)

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

func (*PlayerTabListPing) ReadFrom

func (p *PlayerTabListPing) ReadFrom(r io.Reader) (n int64, err error)

func (*PlayerTabListPing) WriteTo

func (p *PlayerTabListPing) WriteTo(w io.Writer) (n int64, err error)

type PluginMessage

type PluginMessage struct {
	Name string
	// Length  int16 // len(Payload)
	Payload []byte
}

PluginMessage is a two-way packet. Total Size: 5 bytes + len(Name) + len(Payload)

func (PluginMessage) Id

func (p PluginMessage) Id() byte

func (*PluginMessage) ReadFrom

func (p *PluginMessage) ReadFrom(r io.Reader) (n int64, err error)

func (*PluginMessage) WriteTo

func (p *PluginMessage) WriteTo(w io.Writer) (n int64, err error)

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

func (Respawn) Id

func (p Respawn) Id() byte

func (*Respawn) ReadFrom

func (p *Respawn) ReadFrom(r io.Reader) (n int64, err error)

func (*Respawn) WriteTo

func (p *Respawn) WriteTo(w io.Writer) (n int64, err error)

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

func (*ScoreDisplay) ReadFrom

func (p *ScoreDisplay) ReadFrom(r io.Reader) (n int64, err error)

func (*ScoreDisplay) WriteTo

func (p *ScoreDisplay) WriteTo(w io.Writer) (n int64, err error)

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

func (*ScoreObjective) ReadFrom

func (p *ScoreObjective) ReadFrom(r io.Reader) (n int64, err error)

func (*ScoreObjective) WriteTo

func (p *ScoreObjective) WriteTo(w io.Writer) (n int64, err error)

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

func (*ScoreTeams) ReadFrom

func (p *ScoreTeams) ReadFrom(r io.Reader) (n int64, err error)

func (*ScoreTeams) WriteTo

func (p *ScoreTeams) WriteTo(w io.Writer) (n int64, err error)

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

func (*ScoreUpdate) ReadFrom

func (p *ScoreUpdate) ReadFrom(r io.Reader) (n int64, err error)

func (*ScoreUpdate) WriteTo

func (p *ScoreUpdate) WriteTo(w io.Writer) (n int64, err error)

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

func (*ServerListPing) ReadFrom

func (p *ServerListPing) ReadFrom(r io.Reader) (n int64, err error)

func (*ServerListPing) WriteTo

func (p *ServerListPing) WriteTo(w io.Writer) (n int64, err error)

type SetExperience

type SetExperience struct {
	Xp      float32
	Level   int16
	TotalXp int16
}

SetExperience is a server to client packet. Total Size: 9 bytes

func (SetExperience) Id

func (p SetExperience) Id() byte

func (*SetExperience) ReadFrom

func (p *SetExperience) ReadFrom(r io.Reader) (n int64, err error)

func (*SetExperience) WriteTo

func (p *SetExperience) WriteTo(w io.Writer) (n int64, err error)

type SignUpdate

type SignUpdate struct {
	X     int32
	Y     int16
	Z     int32
	Lines [4]string
}

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

func (*SignUpdate) ReadFrom

func (p *SignUpdate) ReadFrom(r io.Reader) (n int64, err error)

func (*SignUpdate) WriteTo

func (p *SignUpdate) WriteTo(w io.Writer) (n int64, err error)

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

func (*SoundEffect) ReadFrom

func (p *SoundEffect) ReadFrom(r io.Reader) (n int64, err error)

func (*SoundEffect) WriteTo

func (p *SoundEffect) WriteTo(w io.Writer) (n int64, err error)

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

func (*SoundEffectNamed) ReadFrom

func (p *SoundEffectNamed) ReadFrom(r io.Reader) (n int64, err error)

func (*SoundEffectNamed) WriteTo

func (p *SoundEffectNamed) WriteTo(w io.Writer) (n int64, err error)

type SpawnExperienceOrb

type SpawnExperienceOrb struct {
	Entity  int32
	X, Y, Z int32 // Absolute
	Count   int16
}

SpawnExperienceOrb is a server to client packet. Total Size: 19 bytes

func (SpawnExperienceOrb) Id

func (p SpawnExperienceOrb) Id() byte

func (*SpawnExperienceOrb) ReadFrom

func (p *SpawnExperienceOrb) ReadFrom(r io.Reader) (n int64, err error)

func (*SpawnExperienceOrb) WriteTo

func (p *SpawnExperienceOrb) WriteTo(w io.Writer) (n int64, err error)

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)

func (SpawnMob) Id

func (p SpawnMob) Id() byte

func (*SpawnMob) ReadFrom

func (p *SpawnMob) ReadFrom(r io.Reader) (n int64, err error)

func (*SpawnMob) WriteTo

func (p *SpawnMob) WriteTo(w io.Writer) (n int64, err error)

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

func (*SpawnObjectVehicle) ReadFrom

func (p *SpawnObjectVehicle) ReadFrom(r io.Reader) (n int64, err error)

func (*SpawnObjectVehicle) WriteTo

func (p *SpawnObjectVehicle) WriteTo(w io.Writer) (n int64, err error)

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

func (*SpawnPainting) ReadFrom

func (p *SpawnPainting) ReadFrom(r io.Reader) (n int64, err error)

func (*SpawnPainting) WriteTo

func (p *SpawnPainting) WriteTo(w io.Writer) (n int64, err error)

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

func (*SpawnPosition) ReadFrom

func (p *SpawnPosition) ReadFrom(r io.Reader) (n int64, err error)

func (*SpawnPosition) WriteTo

func (p *SpawnPosition) WriteTo(w io.Writer) (n int64, err error)

type StatIncrement

type StatIncrement struct {
	StatId int32
	Amount int8
}

StatIncrement is a server to client packet. Total Size: 6 bytes

func (StatIncrement) Id

func (p StatIncrement) Id() byte

func (*StatIncrement) ReadFrom

func (p *StatIncrement) ReadFrom(r io.Reader) (n int64, err error)

func (*StatIncrement) WriteTo

func (p *StatIncrement) WriteTo(w io.Writer) (n int64, err error)

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

func (*TabComplete) ReadFrom

func (p *TabComplete) ReadFrom(r io.Reader) (n int64, err error)

func (*TabComplete) WriteTo

func (p *TabComplete) WriteTo(w io.Writer) (n int64, err error)

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

func (*TileEntityUpdate) ReadFrom

func (p *TileEntityUpdate) ReadFrom(r io.Reader) (n int64, err error)

func (*TileEntityUpdate) WriteTo

func (p *TileEntityUpdate) WriteTo(w io.Writer) (n int64, err error)

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

func (*TimeUpdate) ReadFrom

func (p *TimeUpdate) ReadFrom(r io.Reader) (n int64, err error)

func (*TimeUpdate) WriteTo

func (p *TimeUpdate) WriteTo(w io.Writer) (n int64, err error)

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

func (*WindowClick) ReadFrom

func (p *WindowClick) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowClick) WriteTo

func (p *WindowClick) WriteTo(w io.Writer) (n int64, err error)

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

func (*WindowClose) ReadFrom

func (p *WindowClose) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowClose) WriteTo

func (p *WindowClose) WriteTo(w io.Writer) (n int64, err error)

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

func (*WindowOpen) ReadFrom

func (p *WindowOpen) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowOpen) WriteTo

func (p *WindowOpen) WriteTo(w io.Writer) (n int64, err error)

type WindowSetItems

type WindowSetItems struct {
	WindowId int8 // 0 = inventory
	Count    int16
	SlotData []*mct.Slot
}

WindowSetItems is a server to client packet. Total Size: 4 bytes + size of slot data array

func (WindowSetItems) Id

func (p WindowSetItems) Id() byte

func (*WindowSetItems) ReadFrom

func (p *WindowSetItems) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowSetItems) WriteTo

func (p *WindowSetItems) WriteTo(w io.Writer) (n int64, err error)

type WindowSlotSet

type WindowSlotSet struct {
	WindowId int8 // 0 = inventory
	Slot     int16
	Data     *mct.Slot
}

WindowSlotSet is a server to client packet. Total Size: 4 bytes + slot data

func (WindowSlotSet) Id

func (p WindowSlotSet) Id() byte

func (*WindowSlotSet) ReadFrom

func (p *WindowSlotSet) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowSlotSet) WriteTo

func (p *WindowSlotSet) WriteTo(w io.Writer) (n int64, err error)

type WindowUpdateProperty

type WindowUpdateProperty struct {
	WindowId int8 // 0 = inventory
	Property int16
	Value    int16
}

WindowUpdateProperty is a server to client packet. Total Size: 6 bytes

func (WindowUpdateProperty) Id

func (p WindowUpdateProperty) Id() byte

func (*WindowUpdateProperty) ReadFrom

func (p *WindowUpdateProperty) ReadFrom(r io.Reader) (n int64, err error)

func (*WindowUpdateProperty) WriteTo

func (p *WindowUpdateProperty) WriteTo(w io.Writer) (n int64, err error)

Notes

Bugs

  • type should be proto/anvil/ChunkData instead of []byte

Jump to

Keyboard shortcuts

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