commit e40ed2e534c3e8ca5a4edd0bf0443aa6ca3e2041 Author: 蒟蒻 Date: Thu Jun 19 15:01:07 2025 +0800 Initialize Commit diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..9e055f2 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,16 @@ +{ + "permissions": { + "allow": [ + "Bash(./packetizer)", + "Bash(packetizer)", + "Bash(find:*)", + "Bash(grep:*)", + "Bash(rg:*)", + "Bash(go:*)", + "*", + "Bash(./gen-packet.sh:*)", + "Bash(chmod:*)" + ], + "deny": [] + } +} \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..1c2fda5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..4561c4d --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/graphql-settings.xml b/.idea/graphql-settings.xml new file mode 100644 index 0000000..7493d06 --- /dev/null +++ b/.idea/graphql-settings.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/minego.iml b/.idea/minego.iml new file mode 100644 index 0000000..338a266 --- /dev/null +++ b/.idea/minego.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0b29c7f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..70e51d7 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,114 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +MinEGO is a Go-based Minecraft protocol implementation that generates packet codecs and data components for Minecraft Java Edition protocol version 1.21.6 (protocol 771). The project uses code generation to create serialization/deserialization code for Minecraft network packets and item components. + +## Architecture + +The project follows a modular architecture centered around code generation: + +- **`codec/data/component/`** - Contains Go structs for all Minecraft item components (e.g., damage, enchantments, custom_name). Each component implements the `slot.Component` interface with Type() and ID() methods. +- **`codec/data/packet/game/`** - Contains client and server packet definitions following the Minecraft protocol specification +- **`codec/data/slot/`** - Core slot/item stack implementation and component registration system +- **`net/`** - Network layer implementation (currently empty) +- **Protocol Reference** - `codec/data/packet/protocol.wiki` contains the complete Minecraft protocol specification from wiki.vg + +## Code Generation System + +The project uses a custom code generator called `packetizer` that processes Go structs marked with `//codec:gen` comments. This generates the necessary ReadFrom/WriteTo methods for network serialization. + +Key patterns: +- Structs marked with `//codec:gen` will have codecs auto-generated +- Structs marked with `//codec:ignore` are excluded from generation +- Components must implement `Type() slot.ComponentID` and `ID() string` methods +- Components are registered in `codec/data/component/components.go` using `slot.RegisterComponent()` + +## Development Commands + +### Code Generation +```bash +# Generate packet codecs (run from project root) +./gen-packet.sh +# This runs: packetizer ./codec +``` + +### Standard Go Commands +```bash +# Build the project +go build + +# Run tests (if any exist) +go test ./... + +# Format code +go fmt ./... + +# Get dependencies +go mod tidy +``` + +## Dependencies + +- **github.com/Tnze/go-mc** - Core Minecraft protocol library (uses forked version) +- **packetizer** - Custom code generation tool (available at /root/go/bin/packetizer) + +## Working with Components + +When adding new Minecraft item components: +1. Create the struct in `codec/data/component/` following existing patterns +2. Add `//codec:gen` comment above the struct +3. Implement `Type()` and `ID()` methods with correct component ID and namespace +4. Register the component in `components.go` init() function +5. Run `./gen-packet.sh` to generate codecs + +## Working with Packets + +When adding new packet types: +1. Define the packet struct in appropriate `client/` or `server/` directory +2. Add `//codec:gen` comment for auto-generation +3. Register the packet in the appropriate packets map +4. Run `./gen-packet.sh` to generate codecs + +## Module Path + +The project uses `git.konjactw.dev/patyhank/minego` as its module path and includes a replace directive for the go-mc dependency pointing to a custom fork. + +## Code Generation Tasks + +- **Java to Go Packet Conversion**: + * Task to implement Game State packets by converting Java code from `~/GoProjects/mc-network-source/network/protocol/game` to Go structs + * Focus on maintaining the same read/write logic during translation + * Ensure packet structures match the original Java implementation + * Use packetizer for automatic codec generation + +## Reference Notes + +- PacketID Reference: + * In `/root/go/pkg/mod/git.konjactw.dev/patyhank/go-mc@v1.20.3-0.20250618004758-a3d57fde34e8/data/packetid/packetid.go`, you can find all packet IDs (excluding handshake stage) + +## Packet Serialization Techniques + +- 對於Optional封包資料 簡易的格式可以使用pk.Option[XXX,*XXX] 的方法 比較複雜的需要自己實作一個ReadFrom&WriteTo 並且移除codec:gen的標記 + +### Example + +```go +// ExampleTypeFull full example for codec generator +// +//codec:gen +type ExampleTypeFull struct { + PlayerID int32 `mc:"VarInt"` + PlayerName string + UUID uuid.UUID `mc:"UUID"` + ResourceLocation string `mc:"Identifier"` + Data nbt.RawMessage `mc:"NBT"` + ByteData []byte `mc:"ByteArray"` + Health float32 + Balance float64 + Message chat.Message + SentMessages []chat.Message +} +``` \ No newline at end of file diff --git a/codec/component/attribute_modifiers.go b/codec/component/attribute_modifiers.go new file mode 100644 index 0000000..1e8f3f3 --- /dev/null +++ b/codec/component/attribute_modifiers.go @@ -0,0 +1,28 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type AttributeModifiers struct { + Modifiers []AttributeModifier +} + +//codec:gen +type AttributeModifier struct { + AttributeID int32 `mc:"VarInt"` + ModifierID pk.Identifier + Value float64 + Operation int32 `mc:"VarInt"` // 0=Add, 1=Multiply base, 2=Multiply total + Slot int32 `mc:"VarInt"` // 0=Any, 1=Main hand, 2=Off hand, etc. +} + +func (*AttributeModifiers) Type() slot.ComponentID { + return 13 +} + +func (*AttributeModifiers) ID() string { + return "minecraft:attribute_modifiers" +} diff --git a/codec/component/axolotl_variant.go b/codec/component/axolotl_variant.go new file mode 100644 index 0000000..cb734d6 --- /dev/null +++ b/codec/component/axolotl_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type AxolotlVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*AxolotlVariant) Type() slot.ComponentID { + return 91 +} + +func (*AxolotlVariant) ID() string { + return "minecraft:axolotl/variant" +} diff --git a/codec/component/banner_patterns.go b/codec/component/banner_patterns.go new file mode 100644 index 0000000..e89600f --- /dev/null +++ b/codec/component/banner_patterns.go @@ -0,0 +1,33 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type BannerPatterns struct { + Layers []BannerLayer +} + +//codec:gen +type BannerLayer struct { + PatternType int32 `mc:"VarInt"` + AssetID pk.Option[packet.Identifier, *packet.Identifier] + TranslationKey pk.Option[pk.String, *pk.String] + Color DyeColor +} + +//codec:gen +type DyeColor struct { + ColorID int32 `mc:"VarInt"` +} + +func (*BannerPatterns) Type() slot.ComponentID { + return 63 +} + +func (*BannerPatterns) ID() string { + return "minecraft:banner_patterns" +} diff --git a/codec/component/base_color.go b/codec/component/base_color.go new file mode 100644 index 0000000..6872d2d --- /dev/null +++ b/codec/component/base_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type BaseColor struct { + Color DyeColor +} + +func (*BaseColor) Type() slot.ComponentID { + return 64 +} + +func (*BaseColor) ID() string { + return "minecraft:base_color" +} diff --git a/codec/component/bees.go b/codec/component/bees.go new file mode 100644 index 0000000..9c48617 --- /dev/null +++ b/codec/component/bees.go @@ -0,0 +1,26 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type Bees struct { + Bees []Bee +} + +//codec:gen +type Bee struct { + EntityData nbt.RawMessage `mc:"NBT"` + TicksInHive int32 `mc:"VarInt"` + MinTicksInHive int32 `mc:"VarInt"` +} + +func (*Bees) Type() slot.ComponentID { + return 68 +} + +func (*Bees) ID() string { + return "minecraft:bees" +} diff --git a/codec/component/block_entity_data.go b/codec/component/block_entity_data.go new file mode 100644 index 0000000..0661d7b --- /dev/null +++ b/codec/component/block_entity_data.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type BlockEntityData struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*BlockEntityData) Type() slot.ComponentID { + return 51 +} + +func (*BlockEntityData) ID() string { + return "minecraft:block_entity_data" +} diff --git a/codec/component/block_state.go b/codec/component/block_state.go new file mode 100644 index 0000000..b3d61ad --- /dev/null +++ b/codec/component/block_state.go @@ -0,0 +1,22 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type BlockState struct { + Properties []BlockStateProperty +} + +//codec:gen +type BlockStateProperty struct { + Name string + Value string +} + +func (*BlockState) Type() slot.ComponentID { + return 67 +} + +func (*BlockState) ID() string { + return "minecraft:block_state" +} diff --git a/codec/component/blocks_attacks.go b/codec/component/blocks_attacks.go new file mode 100644 index 0000000..03b7ac6 --- /dev/null +++ b/codec/component/blocks_attacks.go @@ -0,0 +1,35 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type BlocksAttacks struct { + BlockDelaySeconds float32 + DisableCooldownScale float32 + DamageReductions []DamageReduction + ItemDamageThreshold float32 + ItemDamageBase float32 + ItemDamageFactor float32 + BypassedBy pk.Option[pk.Identifier, *pk.Identifier] + BlockSound pk.Option[SoundEvent, *SoundEvent] + DisableSound pk.Option[SoundEvent, *SoundEvent] +} + +//codec:gen +type DamageReduction struct { + HorizontalBlockingAngle float32 + Type pk.Option[pk.IDSet, *pk.IDSet] + Base float32 + Factor float32 +} + +func (*BlocksAttacks) Type() slot.ComponentID { + return 33 +} + +func (*BlocksAttacks) ID() string { + return "minecraft:blocks_attacks" +} diff --git a/codec/component/break_sound.go b/codec/component/break_sound.go new file mode 100644 index 0000000..5e3ba8e --- /dev/null +++ b/codec/component/break_sound.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type BreakSound struct { + SoundData packet.OptID[SoundEvent, *SoundEvent] +} + +func (*BreakSound) Type() slot.ComponentID { + return 71 +} + +func (*BreakSound) ID() string { + return "minecraft:break_sound" +} diff --git a/codec/component/bucket_entity_data.go b/codec/component/bucket_entity_data.go new file mode 100644 index 0000000..d3b75d5 --- /dev/null +++ b/codec/component/bucket_entity_data.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type BucketEntityData struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*BucketEntityData) Type() slot.ComponentID { + return 50 +} + +func (*BucketEntityData) ID() string { + return "minecraft:bucket_entity_data" +} diff --git a/codec/component/bundle_contents.go b/codec/component/bundle_contents.go new file mode 100644 index 0000000..bdafbfd --- /dev/null +++ b/codec/component/bundle_contents.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type BundleContents struct { + Items []slot.Slot +} + +func (*BundleContents) Type() slot.ComponentID { + return 41 +} + +func (*BundleContents) ID() string { + return "minecraft:bundle_contents" +} diff --git a/codec/component/can_break.go b/codec/component/can_break.go new file mode 100644 index 0000000..f454187 --- /dev/null +++ b/codec/component/can_break.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CanBreak struct { + BlockPredicates []BlockPredicate +} + +func (*CanBreak) Type() slot.ComponentID { + return 12 +} + +func (*CanBreak) ID() string { + return "minecraft:can_break" +} diff --git a/codec/component/can_place_on.go b/codec/component/can_place_on.go new file mode 100644 index 0000000..05d6cf1 --- /dev/null +++ b/codec/component/can_place_on.go @@ -0,0 +1,62 @@ +package component + +import ( + "io" + + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type CanPlaceOn struct { + BlockPredicates []BlockPredicate +} + +//codec:gen +type BlockPredicate struct { + Blocks pk.Option[pk.IDSet, *pk.IDSet] + Properties pk.Option[Properties, *Properties] + NBT pk.Option[pk.NBTField, *pk.NBTField] + DataComponents []ExactDataComponentMatcher + PartialDataComponentPredicates []PartialDataComponentMatcher +} + +type Properties []Property + +func (p Properties) WriteTo(w io.Writer) (n int64, err error) { + return pk.Array(p).WriteTo(w) +} + +func (p *Properties) ReadFrom(r io.Reader) (n int64, err error) { + return pk.Array(p).ReadFrom(r) +} + +//codec:gen +type Property struct { + Name string + IsExactMatch bool + ExactValue pk.Option[pk.String, *pk.String] + MinValue pk.Option[pk.String, *pk.String] + MaxValue pk.Option[pk.String, *pk.String] +} + +//codec:gen +type ExactDataComponentMatcher struct { + Type int32 `mc:"VarInt"` + Value nbt.RawMessage `mc:"NBT"` +} + +//codec:gen +type PartialDataComponentMatcher struct { + Type int32 `mc:"VarInt"` + Predicate nbt.RawMessage `mc:"NBT"` +} + +func (*CanPlaceOn) Type() slot.ComponentID { + return 11 +} + +func (*CanPlaceOn) ID() string { + return "minecraft:can_place_on" +} diff --git a/codec/component/cat_collar.go b/codec/component/cat_collar.go new file mode 100644 index 0000000..453f753 --- /dev/null +++ b/codec/component/cat_collar.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CatCollar struct { + Color DyeColor +} + +func (*CatCollar) Type() slot.ComponentID { + return 93 +} + +func (*CatCollar) ID() string { + return "minecraft:cat/collar" +} diff --git a/codec/component/cat_variant.go b/codec/component/cat_variant.go new file mode 100644 index 0000000..2c05ee8 --- /dev/null +++ b/codec/component/cat_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CatVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*CatVariant) Type() slot.ComponentID { + return 92 +} + +func (*CatVariant) ID() string { + return "minecraft:cat/variant" +} diff --git a/codec/component/charged_projectiles.go b/codec/component/charged_projectiles.go new file mode 100644 index 0000000..4a3e3cf --- /dev/null +++ b/codec/component/charged_projectiles.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type ChargedProjectiles struct { + Projectiles []slot.Slot +} + +func (*ChargedProjectiles) Type() slot.ComponentID { + return 40 +} + +func (*ChargedProjectiles) ID() string { + return "minecraft:charged_projectiles" +} diff --git a/codec/component/chicken_variant.go b/codec/component/chicken_variant.go new file mode 100644 index 0000000..814cc02 --- /dev/null +++ b/codec/component/chicken_variant.go @@ -0,0 +1,58 @@ +package component + +import ( + "io" + + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +type ChickenVariant struct { + Mode int8 + VariantName packet.Identifier + VariantID int32 +} + +func (c *ChickenVariant) ReadFrom(r io.Reader) (n int64, err error) { + n1, err := (*packet.Byte)(&c.Mode).ReadFrom(r) + if err != nil { + return n1, err + } + if c.Mode == 0 { + n2, err := c.VariantName.ReadFrom(r) + return n1 + n2, err + } + + if c.Mode == 1 { + n2, err := (*packet.VarInt)(&c.VariantID).ReadFrom(r) + return n1 + n2, err + } + + return n1, err +} + +func (c ChickenVariant) WriteTo(w io.Writer) (int64, error) { + n1, err := (*packet.Byte)(&c.Mode).WriteTo(w) + if err != nil { + return n1, err + } + + if c.Mode == 0 { + n2, err := c.VariantName.WriteTo(w) + return n1 + n2, err + } + + if c.Mode == 1 { + n2, err := (*packet.VarInt)(&c.VariantID).WriteTo(w) + return n1 + n2, err + } + return n1, err +} + +func (*ChickenVariant) Type() slot.ComponentID { + return 86 +} + +func (*ChickenVariant) ID() string { + return "minecraft:chicken/variant" +} diff --git a/codec/component/codecs.go b/codec/component/codecs.go new file mode 100644 index 0000000..dbb8cea --- /dev/null +++ b/codec/component/codecs.go @@ -0,0 +1,3949 @@ +// Code generated by packetizer.go; DO NOT EDIT. + +package component + +import ( + "io" + + pk "github.com/Tnze/go-mc/net/packet" +) + +func (c *AttributeModifiers) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Modifiers).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c AttributeModifiers) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Modifiers).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *AttributeModifier) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.AttributeID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ModifierID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Operation).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Slot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c AttributeModifier) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.AttributeID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ModifierID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Operation).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Slot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *AxolotlVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c AxolotlVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BannerPatterns) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Layers).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BannerPatterns) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Layers).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BannerLayer) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PatternType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AssetID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.TranslationKey).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BannerLayer) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PatternType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AssetID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.TranslationKey).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DyeColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ColorID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DyeColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ColorID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BaseColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BaseColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Bees) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Bees).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Bees) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Bees).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Bee) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.EntityData).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.TicksInHive).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.MinTicksInHive).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Bee) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.EntityData).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.TicksInHive).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.MinTicksInHive).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockEntityData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockEntityData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockState) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Properties).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockState) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Properties).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockStateProperty) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockStateProperty) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlocksAttacks) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.BlockDelaySeconds).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DisableCooldownScale).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.DamageReductions).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageThreshold).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageBase).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageFactor).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BypassedBy).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BlockSound).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.DisableSound).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlocksAttacks) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.BlockDelaySeconds).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DisableCooldownScale).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.DamageReductions).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageThreshold).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageBase).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.ItemDamageFactor).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BypassedBy).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BlockSound).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.DisableSound).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DamageReduction) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.HorizontalBlockingAngle).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Base).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Factor).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DamageReduction) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.HorizontalBlockingAngle).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Base).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Factor).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BreakSound) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundData).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BreakSound) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundData).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BucketEntityData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BucketEntityData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BundleContents) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Items).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BundleContents) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Items).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CanBreak) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.BlockPredicates).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CanBreak) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.BlockPredicates).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CanPlaceOn) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.BlockPredicates).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CanPlaceOn) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.BlockPredicates).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockPredicate) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Blocks).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Properties).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.NBT).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.DataComponents).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.PartialDataComponentPredicates).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockPredicate) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Blocks).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Properties).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.NBT).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.DataComponents).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.PartialDataComponentPredicates).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Property) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsExactMatch).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ExactValue).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.MinValue).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.MaxValue).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Property) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsExactMatch).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ExactValue).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.MinValue).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.MaxValue).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ExactDataComponentMatcher) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ExactDataComponentMatcher) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PartialDataComponentMatcher) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Predicate).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PartialDataComponentMatcher) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Predicate).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CatCollar) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CatCollar) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CatVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CatVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ChargedProjectiles) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Projectiles).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ChargedProjectiles) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Projectiles).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Consumable) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.ConsumeSeconds).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Animation).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Sound).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasConsumeParticles).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Effects).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Consumable) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.ConsumeSeconds).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Animation).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Sound).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasConsumeParticles).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Effects).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SoundEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEventID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FixedRange).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SoundEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEventID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FixedRange).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ConsumeEffect) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ConsumeEffect) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Container) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Items).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Container) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Items).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ContainerLoot) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ContainerLoot) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CowVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CowVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CreativeSlotLock) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c CreativeSlotLock) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *CustomData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CustomData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CustomModelData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Floats).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Flags).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Strings).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Colors).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CustomModelData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Floats).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Flags).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Strings).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Colors).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CustomName) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CustomName) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Damage) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Damage).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Damage) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Damage).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DamageResistant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Types).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DamageResistant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Types).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DeathProtection) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Effects).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DeathProtection) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Effects).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DebugStickState) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DebugStickState) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DyedColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DyedColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Enchantable) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Enchantable) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *EnchantmentGlintOverride) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasGlint).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c EnchantmentGlintOverride) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasGlint).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Enchantments) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Enchantments).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Enchantments) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Enchantments).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *EntityData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c EntityData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Equippable) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Slot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.EquipSound).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasModel).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Model).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCameraOverlay).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CameraOverlay).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasAllowedEntities).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AllowedEntities).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Dispensable).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Swappable).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.DamageOnHurt).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Equippable) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Slot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.EquipSound).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasModel).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Model).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCameraOverlay).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CameraOverlay).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasAllowedEntities).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AllowedEntities).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Dispensable).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Swappable).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.DamageOnHurt).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *FireworkExplosion) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Explosion).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c FireworkExplosion) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Explosion).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *FireworkExplosionData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Shape).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Colors).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.FadeColors).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasTrail).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasTwinkle).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c FireworkExplosionData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Shape).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Colors).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.FadeColors).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasTrail).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasTwinkle).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Fireworks) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.FlightDuration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Explosions).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Fireworks) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.FlightDuration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Explosions).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Food) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Nutrition).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.SaturationModifier).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.CanAlwaysEat).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Food) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Nutrition).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.SaturationModifier).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.CanAlwaysEat).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *FoxVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c FoxVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *FrogVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c FrogVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Glider) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c Glider) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *HorseVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c HorseVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Instrument) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Instrument).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Instrument) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Instrument).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *InstrumentData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEvent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.SoundRange).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Range).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c InstrumentData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEvent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.SoundRange).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Range).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *IntangibleProjectile) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Empty).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c IntangibleProjectile) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Empty).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ItemModel) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Model).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ItemModel) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Model).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ItemName) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ItemName) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *JukeboxSongData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEvent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Duration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Output).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c JukeboxSongData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.SoundEvent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Duration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Output).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *LlamaVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c LlamaVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Lock) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Key).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Lock) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Key).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *LodestoneTracker) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasGlobalPosition).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Dimension).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Position).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Tracked).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c LodestoneTracker) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasGlobalPosition).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Dimension).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Position).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Tracked).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Lore) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Lines).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Lore) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Lines).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MapColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MapColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MapDecorations) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MapDecorations) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MapID) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.MapID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MapID) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.MapID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MapPostProcessing) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PostProcessingType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MapPostProcessing) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PostProcessingType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MaxDamage) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Damage).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MaxDamage) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Damage).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MaxStackSize) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Size).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MaxStackSize) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Size).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *MooshroomVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c MooshroomVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *NoteBlockSound) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Sound).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c NoteBlockSound) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Sound).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *OminousBottleAmplifier) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Amplifier).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c OminousBottleAmplifier) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Amplifier).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PaintingVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Width).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Height).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AssetID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Title).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Author).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PaintingVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Width).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Height).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.AssetID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Title).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Author).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ParrotVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ParrotVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PigVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PigVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PotDecorations) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Decorations).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PotDecorations) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Decorations).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PotionContents) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasPotionID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.PotionID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCustomColor).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.CustomColor).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.CustomEffects).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.CustomName).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PotionContents) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasPotionID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.PotionID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCustomColor).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.CustomColor).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.CustomEffects).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.CustomName).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PotionEffect) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.TypeID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Amplifier).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Ambient).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowParticles).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowIcon).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasHiddenEffect).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.HiddenEffect).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PotionEffect) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.TypeID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Amplifier).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Ambient).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowParticles).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowIcon).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasHiddenEffect).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.HiddenEffect).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PotionEffectExtraDetails) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Amplifier).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Ambient).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowParticles).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowIcon).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasHiddenEffect).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PotionEffectExtraDetails) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Amplifier).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Ambient).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowParticles).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowIcon).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasHiddenEffect).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PotionDurationScale) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.EffectMultiplier).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PotionDurationScale) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.EffectMultiplier).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Profile) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasName).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasUniqueID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.UniqueID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Properties).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Profile) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HasName).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasUniqueID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.UniqueID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Properties).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ProfileProperty) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasSignature).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Signature).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ProfileProperty) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Name).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasSignature).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Signature).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ProvidesBannerPatterns) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Key).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ProvidesBannerPatterns) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Key).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *RabbitVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c RabbitVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Rarity) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Rarity).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Rarity) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Rarity).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Recipes) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Recipes) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *RepairCost) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Cost).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c RepairCost) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Cost).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Repairable) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Items).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Repairable) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Items).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SalmonSize) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.SizeType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SalmonSize) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.SizeType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SheepColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SheepColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ShulkerColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ShulkerColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *StoredEnchantments) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Enchantments).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c StoredEnchantments) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Enchantments).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SuspiciousStewEffects) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Effects).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SuspiciousStewEffects) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Effects).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SuspiciousStewEffect) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.TypeID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SuspiciousStewEffect) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.TypeID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Tool) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Rules).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DefaultMiningSpeed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.DamagePerBlock).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Tool) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Rules).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DefaultMiningSpeed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.DamagePerBlock).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ToolRule) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Blocks).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasSpeed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Speed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCorrectDropForBlocks).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CorrectDropForBlocks).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ToolRule) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Blocks).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasSpeed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Speed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasCorrectDropForBlocks).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CorrectDropForBlocks).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TooltipDisplay) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HideTooltip).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.HiddenComponents).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TooltipDisplay) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.HideTooltip).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.HiddenComponents).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TooltipStyle) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Style).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TooltipStyle) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Style).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Trim) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.TrimMaterial).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.TrimPattern).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Trim) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.TrimMaterial).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.TrimPattern).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TrimMaterial) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Suffix).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Overrides).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TrimMaterial) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Suffix).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Overrides).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TrimPattern) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.AssetName).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.TemplateItem).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Decal).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TrimPattern) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.AssetName).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.TemplateItem).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Description).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Decal).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TropicalFishBaseColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TropicalFishBaseColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TropicalFishPattern) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Pattern).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TropicalFishPattern) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Pattern).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TropicalFishPatternColor) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TropicalFishPatternColor) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Unbreakable) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c Unbreakable) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *UseCooldown) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.Seconds).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CooldownGroup).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c UseCooldown) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.Seconds).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CooldownGroup).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *UseRemainder) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Remainder).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c UseRemainder) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Remainder).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *VillagerVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c VillagerVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Weapon) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.DamagePerAttack).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DisableBlockingFor).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Weapon) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.DamagePerAttack).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.DisableBlockingFor).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WolfCollar) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WolfCollar) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WolfSoundVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WolfSoundVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WolfVariant) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WolfVariant) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Variant).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WritableBookContent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Pages).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WritableBookContent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Pages).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WritableBookPage) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.RawContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WritableBookPage) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.RawContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WrittenBookContent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.RawTitle).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredTitle).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredTitle).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Author).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Generation).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Pages).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WrittenBookContent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.RawTitle).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredTitle).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredTitle).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.String)(&c.Author).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Generation).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Pages).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *WrittenBookPage) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.RawContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredContent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c WrittenBookPage) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.RawContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.HasFilteredContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.FilteredContent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} diff --git a/codec/component/components.go b/codec/component/components.go new file mode 100644 index 0000000..38d7e34 --- /dev/null +++ b/codec/component/components.go @@ -0,0 +1,102 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +func init() { + slot.RegisterComponent(&CustomData{}) + slot.RegisterComponent(&MaxStackSize{}) + slot.RegisterComponent(&MaxDamage{}) + slot.RegisterComponent(&Damage{}) + slot.RegisterComponent(&Unbreakable{}) + slot.RegisterComponent(&CustomName{}) + slot.RegisterComponent(&ItemName{}) + slot.RegisterComponent(&ItemModel{}) + slot.RegisterComponent(&Lore{}) + slot.RegisterComponent(&Rarity{}) + slot.RegisterComponent(&Enchantments{}) + slot.RegisterComponent(&CanPlaceOn{}) + slot.RegisterComponent(&CanBreak{}) + slot.RegisterComponent(&AttributeModifiers{}) + slot.RegisterComponent(&CustomModelData{}) + slot.RegisterComponent(&TooltipDisplay{}) + slot.RegisterComponent(&RepairCost{}) + slot.RegisterComponent(&CreativeSlotLock{}) + slot.RegisterComponent(&EnchantmentGlintOverride{}) + slot.RegisterComponent(&IntangibleProjectile{}) + slot.RegisterComponent(&Food{}) + slot.RegisterComponent(&Consumable{}) + slot.RegisterComponent(&UseRemainder{}) + slot.RegisterComponent(&UseCooldown{}) + slot.RegisterComponent(&DamageResistant{}) + slot.RegisterComponent(&Tool{}) + slot.RegisterComponent(&Weapon{}) + slot.RegisterComponent(&Enchantable{}) + slot.RegisterComponent(&Equippable{}) + slot.RegisterComponent(&Repairable{}) + slot.RegisterComponent(&Glider{}) + slot.RegisterComponent(&TooltipStyle{}) + slot.RegisterComponent(&DeathProtection{}) + slot.RegisterComponent(&BlocksAttacks{}) + slot.RegisterComponent(&StoredEnchantments{}) + slot.RegisterComponent(&DyedColor{}) + slot.RegisterComponent(&MapColor{}) + slot.RegisterComponent(&MapID{}) + slot.RegisterComponent(&MapDecorations{}) + slot.RegisterComponent(&MapPostProcessing{}) + slot.RegisterComponent(&ChargedProjectiles{}) + slot.RegisterComponent(&BundleContents{}) + slot.RegisterComponent(&PotionContents{}) + slot.RegisterComponent(&PotionDurationScale{}) + slot.RegisterComponent(&SuspiciousStewEffects{}) + slot.RegisterComponent(&WritableBookContent{}) + slot.RegisterComponent(&WrittenBookContent{}) + slot.RegisterComponent(&Trim{}) + slot.RegisterComponent(&DebugStickState{}) + slot.RegisterComponent(&EntityData{}) + slot.RegisterComponent(&BucketEntityData{}) + slot.RegisterComponent(&BlockEntityData{}) + slot.RegisterComponent(&Instrument{}) + slot.RegisterComponent(&ProvidesTrimMaterial{}) + slot.RegisterComponent(&OminousBottleAmplifier{}) + slot.RegisterComponent(&JukeboxPlayable{}) + slot.RegisterComponent(&ProvidesBannerPatterns{}) + slot.RegisterComponent(&Recipes{}) + slot.RegisterComponent(&LodestoneTracker{}) + slot.RegisterComponent(&FireworkExplosion{}) + slot.RegisterComponent(&Fireworks{}) + slot.RegisterComponent(&Profile{}) + slot.RegisterComponent(&NoteBlockSound{}) + slot.RegisterComponent(&BannerPatterns{}) + slot.RegisterComponent(&BaseColor{}) + slot.RegisterComponent(&PotDecorations{}) + slot.RegisterComponent(&Container{}) + slot.RegisterComponent(&BlockState{}) + slot.RegisterComponent(&Bees{}) + slot.RegisterComponent(&Lock{}) + slot.RegisterComponent(&ContainerLoot{}) + slot.RegisterComponent(&BreakSound{}) + slot.RegisterComponent(&VillagerVariant{}) + slot.RegisterComponent(&WolfVariant{}) + slot.RegisterComponent(&WolfSoundVariant{}) + slot.RegisterComponent(&WolfCollar{}) + slot.RegisterComponent(&FoxVariant{}) + slot.RegisterComponent(&SalmonSize{}) + slot.RegisterComponent(&ParrotVariant{}) + slot.RegisterComponent(&TropicalFishPattern{}) + slot.RegisterComponent(&TropicalFishBaseColor{}) + slot.RegisterComponent(&TropicalFishPatternColor{}) + slot.RegisterComponent(&MooshroomVariant{}) + slot.RegisterComponent(&RabbitVariant{}) + slot.RegisterComponent(&PigVariant{}) + slot.RegisterComponent(&CowVariant{}) + slot.RegisterComponent(&ChickenVariant{}) + slot.RegisterComponent(&FrogVariant{}) + slot.RegisterComponent(&HorseVariant{}) + slot.RegisterComponent(&PaintingVariant{}) + slot.RegisterComponent(&LlamaVariant{}) + slot.RegisterComponent(&AxolotlVariant{}) + slot.RegisterComponent(&CatVariant{}) + slot.RegisterComponent(&CatCollar{}) + slot.RegisterComponent(&SheepColor{}) + slot.RegisterComponent(&ShulkerColor{}) +} diff --git a/codec/component/consumable.go b/codec/component/consumable.go new file mode 100644 index 0000000..8069dd2 --- /dev/null +++ b/codec/component/consumable.go @@ -0,0 +1,35 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Consumable struct { + ConsumeSeconds float32 + Animation int32 `mc:"VarInt"` // 0=none, 1=eat, 2=drink, etc. + Sound SoundEvent + HasConsumeParticles bool + Effects []ConsumeEffect +} + +//codec:gen +type SoundEvent struct { + SoundEventID packet.Identifier + FixedRange packet.Option[packet.Float, *packet.Float] +} + +//codec:gen +type ConsumeEffect struct { + Type int32 `mc:"VarInt"` + // Data varies by type - would need custom handling +} + +func (*Consumable) Type() slot.ComponentID { + return 21 +} + +func (*Consumable) ID() string { + return "minecraft:consumable" +} diff --git a/codec/component/container.go b/codec/component/container.go new file mode 100644 index 0000000..c5a2e4d --- /dev/null +++ b/codec/component/container.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Container struct { + Items []slot.Slot +} + +func (*Container) Type() slot.ComponentID { + return 66 +} + +func (*Container) ID() string { + return "minecraft:container" +} diff --git a/codec/component/container_loot.go b/codec/component/container_loot.go new file mode 100644 index 0000000..4b0da21 --- /dev/null +++ b/codec/component/container_loot.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type ContainerLoot struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*ContainerLoot) Type() slot.ComponentID { + return 70 +} + +func (*ContainerLoot) ID() string { + return "minecraft:container_loot" +} diff --git a/codec/component/cow_variant.go b/codec/component/cow_variant.go new file mode 100644 index 0000000..f51161f --- /dev/null +++ b/codec/component/cow_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CowVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*CowVariant) Type() slot.ComponentID { + return 85 +} + +func (*CowVariant) ID() string { + return "minecraft:cow/variant" +} diff --git a/codec/component/creative_slot_lock.go b/codec/component/creative_slot_lock.go new file mode 100644 index 0000000..88bb0fa --- /dev/null +++ b/codec/component/creative_slot_lock.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CreativeSlotLock struct { + // no fields +} + +func (*CreativeSlotLock) Type() slot.ComponentID { + return 17 +} + +func (*CreativeSlotLock) ID() string { + return "minecraft:creative_slot_lock" +} diff --git a/codec/component/custom_data.go b/codec/component/custom_data.go new file mode 100644 index 0000000..aed9374 --- /dev/null +++ b/codec/component/custom_data.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type CustomData struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*CustomData) Type() slot.ComponentID { + return 0 +} + +func (*CustomData) ID() string { + return "minecraft:custom_data" +} diff --git a/codec/component/custom_model_data.go b/codec/component/custom_model_data.go new file mode 100644 index 0000000..636615e --- /dev/null +++ b/codec/component/custom_model_data.go @@ -0,0 +1,19 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type CustomModelData struct { + Floats []float32 + Flags []bool + Strings []string + Colors []int32 `mc:"VarInt"` +} + +func (*CustomModelData) Type() slot.ComponentID { + return 14 +} + +func (*CustomModelData) ID() string { + return "minecraft:custom_model_data" +} diff --git a/codec/component/custom_name.go b/codec/component/custom_name.go new file mode 100644 index 0000000..b21d12d --- /dev/null +++ b/codec/component/custom_name.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" +) + +//codec:gen +type CustomName struct { + Name chat.Message +} + +func (*CustomName) Type() slot.ComponentID { + return 5 +} + +func (*CustomName) ID() string { + return "minecraft:custom_name" +} diff --git a/codec/component/damage.go b/codec/component/damage.go new file mode 100644 index 0000000..742f1af --- /dev/null +++ b/codec/component/damage.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Damage struct { + Damage int32 `mc:"VarInt"` +} + +func (*Damage) Type() slot.ComponentID { + return 3 +} + +func (*Damage) ID() string { + return "minecraft:damage" +} diff --git a/codec/component/damage_resistant.go b/codec/component/damage_resistant.go new file mode 100644 index 0000000..22117f6 --- /dev/null +++ b/codec/component/damage_resistant.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type DamageResistant struct { + Types pk.Identifier // Tag specifying damage types +} + +func (*DamageResistant) Type() slot.ComponentID { + return 24 +} + +func (*DamageResistant) ID() string { + return "minecraft:damage_resistant" +} diff --git a/codec/component/death_protection.go b/codec/component/death_protection.go new file mode 100644 index 0000000..4a6a523 --- /dev/null +++ b/codec/component/death_protection.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type DeathProtection struct { + Effects []ConsumeEffect +} + +func (*DeathProtection) Type() slot.ComponentID { + return 32 +} + +func (*DeathProtection) ID() string { + return "minecraft:death_protection" +} diff --git a/codec/component/debug_stick_state.go b/codec/component/debug_stick_state.go new file mode 100644 index 0000000..d14d5a4 --- /dev/null +++ b/codec/component/debug_stick_state.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type DebugStickState struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*DebugStickState) Type() slot.ComponentID { + return 48 +} + +func (*DebugStickState) ID() string { + return "minecraft:debug_stick_state" +} diff --git a/codec/component/dyed_color.go b/codec/component/dyed_color.go new file mode 100644 index 0000000..a62f6da --- /dev/null +++ b/codec/component/dyed_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type DyedColor struct { + Color int32 `mc:"Int"` // RGB components encoded as integer +} + +func (*DyedColor) Type() slot.ComponentID { + return 35 +} + +func (*DyedColor) ID() string { + return "minecraft:dyed_color" +} diff --git a/codec/component/enchantable.go b/codec/component/enchantable.go new file mode 100644 index 0000000..f19de60 --- /dev/null +++ b/codec/component/enchantable.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Enchantable struct { + Value int32 `mc:"VarInt"` +} + +func (*Enchantable) Type() slot.ComponentID { + return 27 +} + +func (*Enchantable) ID() string { + return "minecraft:enchantable" +} diff --git a/codec/component/enchantment_glint_override.go b/codec/component/enchantment_glint_override.go new file mode 100644 index 0000000..2f3629c --- /dev/null +++ b/codec/component/enchantment_glint_override.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type EnchantmentGlintOverride struct { + HasGlint bool +} + +func (*EnchantmentGlintOverride) Type() slot.ComponentID { + return 18 +} + +func (*EnchantmentGlintOverride) ID() string { + return "minecraft:enchantment_glint_override" +} diff --git a/codec/component/enchantments.go b/codec/component/enchantments.go new file mode 100644 index 0000000..109f0d5 --- /dev/null +++ b/codec/component/enchantments.go @@ -0,0 +1,21 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Enchantments struct { + Enchantments []Enchantment +} + +type Enchantment struct { + TypeID int32 `mc:"VarInt"` + Level int32 `mc:"VarInt"` +} + +func (*Enchantments) Type() slot.ComponentID { + return 10 +} + +func (*Enchantments) ID() string { + return "minecraft:enchantments" +} diff --git a/codec/component/entity_data.go b/codec/component/entity_data.go new file mode 100644 index 0000000..a488da5 --- /dev/null +++ b/codec/component/entity_data.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type EntityData struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*EntityData) Type() slot.ComponentID { + return 49 +} + +func (*EntityData) ID() string { + return "minecraft:entity_data" +} diff --git a/codec/component/equippable.go b/codec/component/equippable.go new file mode 100644 index 0000000..f561958 --- /dev/null +++ b/codec/component/equippable.go @@ -0,0 +1,29 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Equippable struct { + Slot int32 `mc:"VarInt"` // 0=mainhand, 1=feet, 2=legs, etc. + EquipSound SoundEvent + HasModel bool + Model pk.Option[pk.Identifier, *pk.Identifier] + HasCameraOverlay bool + CameraOverlay pk.Option[pk.Identifier, *pk.Identifier] + HasAllowedEntities bool + AllowedEntities pk.Option[pk.IDSet, *pk.IDSet] + Dispensable bool + Swappable bool + DamageOnHurt bool +} + +func (*Equippable) Type() slot.ComponentID { + return 28 +} + +func (*Equippable) ID() string { + return "minecraft:equippable" +} diff --git a/codec/component/firework_explosion.go b/codec/component/firework_explosion.go new file mode 100644 index 0000000..9c92811 --- /dev/null +++ b/codec/component/firework_explosion.go @@ -0,0 +1,25 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type FireworkExplosion struct { + Explosion FireworkExplosionData +} + +//codec:gen +type FireworkExplosionData struct { + Shape int32 `mc:"VarInt"` + Colors []int32 `mc:"PrefixedArray"` + FadeColors []int32 `mc:"PrefixedArray"` + HasTrail bool + HasTwinkle bool +} + +func (*FireworkExplosion) Type() slot.ComponentID { + return 59 +} + +func (*FireworkExplosion) ID() string { + return "minecraft:firework_explosion" +} diff --git a/codec/component/fireworks.go b/codec/component/fireworks.go new file mode 100644 index 0000000..dd18938 --- /dev/null +++ b/codec/component/fireworks.go @@ -0,0 +1,17 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Fireworks struct { + FlightDuration int32 `mc:"VarInt"` + Explosions []FireworkExplosionData +} + +func (*Fireworks) Type() slot.ComponentID { + return 60 +} + +func (*Fireworks) ID() string { + return "minecraft:fireworks" +} diff --git a/codec/component/food.go b/codec/component/food.go new file mode 100644 index 0000000..8f07ae3 --- /dev/null +++ b/codec/component/food.go @@ -0,0 +1,18 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Food struct { + Nutrition int32 `mc:"VarInt"` + SaturationModifier float32 + CanAlwaysEat bool +} + +func (*Food) Type() slot.ComponentID { + return 20 +} + +func (*Food) ID() string { + return "minecraft:food" +} diff --git a/codec/component/fox_variant.go b/codec/component/fox_variant.go new file mode 100644 index 0000000..45c9405 --- /dev/null +++ b/codec/component/fox_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type FoxVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*FoxVariant) Type() slot.ComponentID { + return 76 +} + +func (*FoxVariant) ID() string { + return "minecraft:fox/variant" +} diff --git a/codec/component/frog_variant.go b/codec/component/frog_variant.go new file mode 100644 index 0000000..a226f46 --- /dev/null +++ b/codec/component/frog_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type FrogVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*FrogVariant) Type() slot.ComponentID { + return 87 +} + +func (*FrogVariant) ID() string { + return "minecraft:frog/variant" +} diff --git a/codec/component/glider.go b/codec/component/glider.go new file mode 100644 index 0000000..a495a38 --- /dev/null +++ b/codec/component/glider.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Glider struct { + // no fields +} + +func (*Glider) Type() slot.ComponentID { + return 30 +} + +func (*Glider) ID() string { + return "minecraft:glider" +} diff --git a/codec/component/horse_variant.go b/codec/component/horse_variant.go new file mode 100644 index 0000000..e33feb2 --- /dev/null +++ b/codec/component/horse_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type HorseVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*HorseVariant) Type() slot.ComponentID { + return 88 +} + +func (*HorseVariant) ID() string { + return "minecraft:horse/variant" +} diff --git a/codec/component/instrument.go b/codec/component/instrument.go new file mode 100644 index 0000000..657fc2c --- /dev/null +++ b/codec/component/instrument.go @@ -0,0 +1,28 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Instrument struct { + Instrument packet.OptID[InstrumentData, *InstrumentData] +} + +//codec:gen +type InstrumentData struct { + SoundEvent packet.OptID[SoundEvent, *SoundEvent] + SoundRange float32 + Range float32 + Description chat.Message +} + +func (*Instrument) Type() slot.ComponentID { + return 52 +} + +func (*Instrument) ID() string { + return "minecraft:instrument" +} diff --git a/codec/component/intangible_projectile.go b/codec/component/intangible_projectile.go new file mode 100644 index 0000000..3a0132c --- /dev/null +++ b/codec/component/intangible_projectile.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type IntangibleProjectile struct { + Empty nbt.RawMessage `mc:"NBT"` // Always empty compound tag +} + +func (*IntangibleProjectile) Type() slot.ComponentID { + return 19 +} + +func (*IntangibleProjectile) ID() string { + return "minecraft:intangible_projectile" +} diff --git a/codec/component/item_model.go b/codec/component/item_model.go new file mode 100644 index 0000000..2383330 --- /dev/null +++ b/codec/component/item_model.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type ItemModel struct { + Model packet.Identifier +} + +func (*ItemModel) Type() slot.ComponentID { + return 7 +} + +func (*ItemModel) ID() string { + return "minecraft:item_model" +} diff --git a/codec/component/item_name.go b/codec/component/item_name.go new file mode 100644 index 0000000..ac209dd --- /dev/null +++ b/codec/component/item_name.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" +) + +//codec:gen +type ItemName struct { + Name chat.Message +} + +func (*ItemName) Type() slot.ComponentID { + return 6 +} + +func (*ItemName) ID() string { + return "minecraft:item_name" +} diff --git a/codec/component/jukebox_playable.go b/codec/component/jukebox_playable.go new file mode 100644 index 0000000..091e5d1 --- /dev/null +++ b/codec/component/jukebox_playable.go @@ -0,0 +1,67 @@ +package component + +import ( + "io" + + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" + "github.com/Tnze/go-mc/net/packet" +) + +type JukeboxPlayable struct { + Mode int8 + Name packet.Identifier + SongData packet.OptID[JukeboxSongData, *JukeboxSongData] +} + +func (p *JukeboxPlayable) ReadFrom(r io.Reader) (n int64, err error) { + n1, err := (*packet.Byte)(&p.Mode).ReadFrom(r) + if err != nil { + return n1, err + } + if p.Mode == 0 { + n2, err := p.Name.ReadFrom(r) + return n1 + n2, err + } + + if p.Mode == 1 { + n2, err := p.SongData.ReadFrom(r) + return n1 + n2, err + } + + return n1, err +} + +func (p JukeboxPlayable) WriteTo(w io.Writer) (int64, error) { + n1, err := (*packet.Byte)(&p.Mode).WriteTo(w) + if err != nil { + return n1, err + } + + if p.Mode == 0 { + n2, err := p.Name.WriteTo(w) + return n1 + n2, err + } + + if p.Mode == 1 { + n2, err := p.SongData.WriteTo(w) + return n1 + n2, err + } + return n1, err +} + +//codec:gen +type JukeboxSongData struct { + SoundEvent packet.OptID[SoundEvent, *SoundEvent] + Description chat.Message + Duration float32 + Output int32 `mc:"VarInt"` +} + +func (*JukeboxPlayable) Type() slot.ComponentID { + return 55 +} + +func (*JukeboxPlayable) ID() string { + return "minecraft:jukebox_playable" +} diff --git a/codec/component/llama_variant.go b/codec/component/llama_variant.go new file mode 100644 index 0000000..da3d1b1 --- /dev/null +++ b/codec/component/llama_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type LlamaVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*LlamaVariant) Type() slot.ComponentID { + return 90 +} + +func (*LlamaVariant) ID() string { + return "minecraft:llama/variant" +} diff --git a/codec/component/lock.go b/codec/component/lock.go new file mode 100644 index 0000000..7994c89 --- /dev/null +++ b/codec/component/lock.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type Lock struct { + Key nbt.RawMessage `mc:"NBT"` +} + +func (*Lock) Type() slot.ComponentID { + return 69 +} + +func (*Lock) ID() string { + return "minecraft:lock" +} diff --git a/codec/component/lodestone_tracker.go b/codec/component/lodestone_tracker.go new file mode 100644 index 0000000..ae1f660 --- /dev/null +++ b/codec/component/lodestone_tracker.go @@ -0,0 +1,23 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type LodestoneTracker struct { + HasGlobalPosition bool + Dimension pk.Option[packet.Identifier, *packet.Identifier] + Position pk.Option[pk.Position, *pk.Position] + Tracked bool +} + +func (*LodestoneTracker) Type() slot.ComponentID { + return 58 +} + +func (*LodestoneTracker) ID() string { + return "minecraft:lodestone_tracker" +} diff --git a/codec/component/lore.go b/codec/component/lore.go new file mode 100644 index 0000000..e30d649 --- /dev/null +++ b/codec/component/lore.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" +) + +//codec:gen +type Lore struct { + Lines []chat.Message +} + +func (*Lore) Type() slot.ComponentID { + return 8 +} + +func (*Lore) ID() string { + return "minecraft:lore" +} diff --git a/codec/component/map_color.go b/codec/component/map_color.go new file mode 100644 index 0000000..bdeeb2a --- /dev/null +++ b/codec/component/map_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MapColor struct { + Color int32 `mc:"Int"` // RGB components encoded as integer +} + +func (*MapColor) Type() slot.ComponentID { + return 36 +} + +func (*MapColor) ID() string { + return "minecraft:map_color" +} diff --git a/codec/component/map_decorations.go b/codec/component/map_decorations.go new file mode 100644 index 0000000..d42c4d4 --- /dev/null +++ b/codec/component/map_decorations.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type MapDecorations struct { + Data nbt.RawMessage `mc:"NBT"` // Always a Compound Tag +} + +func (*MapDecorations) Type() slot.ComponentID { + return 38 +} + +func (*MapDecorations) ID() string { + return "minecraft:map_decorations" +} diff --git a/codec/component/map_id.go b/codec/component/map_id.go new file mode 100644 index 0000000..80fd245 --- /dev/null +++ b/codec/component/map_id.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MapID struct { + MapID int32 `mc:"VarInt"` +} + +func (*MapID) Type() slot.ComponentID { + return 37 +} + +func (*MapID) ID() string { + return "minecraft:map_id" +} diff --git a/codec/component/map_post_processing.go b/codec/component/map_post_processing.go new file mode 100644 index 0000000..bde7dcc --- /dev/null +++ b/codec/component/map_post_processing.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MapPostProcessing struct { + PostProcessingType int32 `mc:"VarInt"` // 0=Lock, 1=Scale +} + +func (*MapPostProcessing) Type() slot.ComponentID { + return 39 +} + +func (*MapPostProcessing) ID() string { + return "minecraft:map_post_processing" +} diff --git a/codec/component/max_damage.go b/codec/component/max_damage.go new file mode 100644 index 0000000..6087b21 --- /dev/null +++ b/codec/component/max_damage.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MaxDamage struct { + Damage int32 `mc:"VarInt"` +} + +func (*MaxDamage) Type() slot.ComponentID { + return 2 +} + +func (*MaxDamage) ID() string { + return "minecraft:max_damage" +} diff --git a/codec/component/max_stack_size.go b/codec/component/max_stack_size.go new file mode 100644 index 0000000..e739d3b --- /dev/null +++ b/codec/component/max_stack_size.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MaxStackSize struct { + Size int32 `mc:"VarInt"` +} + +func (*MaxStackSize) Type() slot.ComponentID { + return 1 +} + +func (*MaxStackSize) ID() string { + return "minecraft:max_stack_size" +} diff --git a/codec/component/mooshroom_variant.go b/codec/component/mooshroom_variant.go new file mode 100644 index 0000000..08e6321 --- /dev/null +++ b/codec/component/mooshroom_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type MooshroomVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*MooshroomVariant) Type() slot.ComponentID { + return 82 +} + +func (*MooshroomVariant) ID() string { + return "minecraft:mooshroom/variant" +} diff --git a/codec/component/note_block_sound.go b/codec/component/note_block_sound.go new file mode 100644 index 0000000..ccc52bb --- /dev/null +++ b/codec/component/note_block_sound.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type NoteBlockSound struct { + Sound packet.Identifier +} + +func (*NoteBlockSound) Type() slot.ComponentID { + return 62 +} + +func (*NoteBlockSound) ID() string { + return "minecraft:note_block_sound" +} diff --git a/codec/component/ominous_bottle_amplifier.go b/codec/component/ominous_bottle_amplifier.go new file mode 100644 index 0000000..1beec52 --- /dev/null +++ b/codec/component/ominous_bottle_amplifier.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type OminousBottleAmplifier struct { + Amplifier int32 `mc:"VarInt"` +} + +func (*OminousBottleAmplifier) Type() slot.ComponentID { + return 54 +} + +func (*OminousBottleAmplifier) ID() string { + return "minecraft:ominous_bottle_amplifier" +} diff --git a/codec/component/painting_variant.go b/codec/component/painting_variant.go new file mode 100644 index 0000000..bcd18fb --- /dev/null +++ b/codec/component/painting_variant.go @@ -0,0 +1,24 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type PaintingVariant struct { + Width int32 + Height int32 + AssetID pk.Identifier + Title pk.Option[chat.Message, *chat.Message] + Author pk.Option[chat.Message, *chat.Message] +} + +func (*PaintingVariant) Type() slot.ComponentID { + return 89 +} + +func (*PaintingVariant) ID() string { + return "minecraft:painting/variant" +} diff --git a/codec/component/parrot_variant.go b/codec/component/parrot_variant.go new file mode 100644 index 0000000..8883b2f --- /dev/null +++ b/codec/component/parrot_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type ParrotVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*ParrotVariant) Type() slot.ComponentID { + return 78 +} + +func (*ParrotVariant) ID() string { + return "minecraft:parrot/variant" +} diff --git a/codec/component/pig_variant.go b/codec/component/pig_variant.go new file mode 100644 index 0000000..7f56467 --- /dev/null +++ b/codec/component/pig_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type PigVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*PigVariant) Type() slot.ComponentID { + return 84 +} + +func (*PigVariant) ID() string { + return "minecraft:pig/variant" +} diff --git a/codec/component/pot_decorations.go b/codec/component/pot_decorations.go new file mode 100644 index 0000000..c80b503 --- /dev/null +++ b/codec/component/pot_decorations.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type PotDecorations struct { + Decorations []int32 `mc:"PrefixedArray"` +} + +func (*PotDecorations) Type() slot.ComponentID { + return 65 +} + +func (*PotDecorations) ID() string { + return "minecraft:pot_decorations" +} diff --git a/codec/component/potion_contents.go b/codec/component/potion_contents.go new file mode 100644 index 0000000..0bcfcb2 --- /dev/null +++ b/codec/component/potion_contents.go @@ -0,0 +1,47 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type PotionContents struct { + HasPotionID bool + PotionID int32 `mc:"VarInt"` + HasCustomColor bool + CustomColor int32 `mc:"Int"` + CustomEffects []PotionEffect + CustomName string +} + +//codec:gen +type PotionEffect struct { + TypeID int32 `mc:"VarInt"` + + Amplifier int32 `mc:"VarInt"` + Duration int32 `mc:"VarInt"` + Ambient bool + ShowParticles bool + ShowIcon bool + HasHiddenEffect bool + HiddenEffect pk.Option[PotionEffectExtraDetails, *PotionEffectExtraDetails] +} + +//codec:gen +type PotionEffectExtraDetails struct { + Amplifier int32 `mc:"VarInt"` + Duration int32 `mc:"VarInt"` + Ambient bool + ShowParticles bool + ShowIcon bool + HasHiddenEffect bool +} + +func (*PotionContents) Type() slot.ComponentID { + return 42 +} + +func (*PotionContents) ID() string { + return "minecraft:potion_contents" +} diff --git a/codec/component/potion_duration_scale.go b/codec/component/potion_duration_scale.go new file mode 100644 index 0000000..b381d75 --- /dev/null +++ b/codec/component/potion_duration_scale.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type PotionDurationScale struct { + EffectMultiplier float32 +} + +func (*PotionDurationScale) Type() slot.ComponentID { + return 43 +} + +func (*PotionDurationScale) ID() string { + return "minecraft:potion_duration_scale" +} diff --git a/codec/component/profile.go b/codec/component/profile.go new file mode 100644 index 0000000..5a6bb36 --- /dev/null +++ b/codec/component/profile.go @@ -0,0 +1,31 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Profile struct { + HasName bool + Name pk.Option[pk.String, *pk.String] + HasUniqueID bool + UniqueID pk.Option[pk.UUID, *pk.UUID] + Properties []ProfileProperty +} + +//codec:gen +type ProfileProperty struct { + Name string `mc:"String"` + Value string `mc:"String"` + HasSignature bool + Signature pk.Option[pk.String, *pk.String] +} + +func (*Profile) Type() slot.ComponentID { + return 61 +} + +func (*Profile) ID() string { + return "minecraft:profile" +} diff --git a/codec/component/provides_banner_patterns.go b/codec/component/provides_banner_patterns.go new file mode 100644 index 0000000..e2f1656 --- /dev/null +++ b/codec/component/provides_banner_patterns.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type ProvidesBannerPatterns struct { + Key packet.Identifier +} + +func (*ProvidesBannerPatterns) Type() slot.ComponentID { + return 56 +} + +func (*ProvidesBannerPatterns) ID() string { + return "minecraft:provides_banner_patterns" +} diff --git a/codec/component/provides_trim_material.go b/codec/component/provides_trim_material.go new file mode 100644 index 0000000..e2cc4ec --- /dev/null +++ b/codec/component/provides_trim_material.go @@ -0,0 +1,58 @@ +package component + +import ( + "io" + + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/net/packet" +) + +type ProvidesTrimMaterial struct { + Mode int8 + Name packet.Identifier + Material packet.OptID[TrimMaterial, *TrimMaterial] +} + +func (p *ProvidesTrimMaterial) ReadFrom(r io.Reader) (n int64, err error) { + n1, err := (*packet.Byte)(&p.Mode).ReadFrom(r) + if err != nil { + return n1, err + } + if p.Mode == 0 { + n2, err := p.Name.ReadFrom(r) + return n1 + n2, err + } + + if p.Mode == 1 { + n2, err := p.Material.ReadFrom(r) + return n1 + n2, err + } + + return n1, err +} + +func (p ProvidesTrimMaterial) WriteTo(w io.Writer) (int64, error) { + n1, err := (*packet.Byte)(&p.Mode).WriteTo(w) + if err != nil { + return n1, err + } + + if p.Mode == 0 { + n2, err := p.Name.WriteTo(w) + return n1 + n2, err + } + + if p.Mode == 1 { + n2, err := p.Material.WriteTo(w) + return n1 + n2, err + } + return n1, err +} + +func (*ProvidesTrimMaterial) Type() slot.ComponentID { + return 53 +} + +func (*ProvidesTrimMaterial) ID() string { + return "minecraft:provides_trim_material" +} diff --git a/codec/component/rabbit_variant.go b/codec/component/rabbit_variant.go new file mode 100644 index 0000000..83cb8e7 --- /dev/null +++ b/codec/component/rabbit_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type RabbitVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*RabbitVariant) Type() slot.ComponentID { + return 83 +} + +func (*RabbitVariant) ID() string { + return "minecraft:rabbit/variant" +} diff --git a/codec/component/rarity.go b/codec/component/rarity.go new file mode 100644 index 0000000..37966d5 --- /dev/null +++ b/codec/component/rarity.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Rarity struct { + Rarity int32 `mc:"VarInt"` // 0=Common, 1=Uncommon, 2=Rare, 3=Epic +} + +func (*Rarity) Type() slot.ComponentID { + return 9 +} + +func (*Rarity) ID() string { + return "minecraft:rarity" +} diff --git a/codec/component/recipes.go b/codec/component/recipes.go new file mode 100644 index 0000000..2adaded --- /dev/null +++ b/codec/component/recipes.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/nbt" +) + +//codec:gen +type Recipes struct { + Data nbt.RawMessage `mc:"NBT"` +} + +func (*Recipes) Type() slot.ComponentID { + return 57 +} + +func (*Recipes) ID() string { + return "minecraft:recipes" +} diff --git a/codec/component/repair_cost.go b/codec/component/repair_cost.go new file mode 100644 index 0000000..e827057 --- /dev/null +++ b/codec/component/repair_cost.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type RepairCost struct { + Cost int32 `mc:"VarInt"` +} + +func (*RepairCost) Type() slot.ComponentID { + return 16 +} + +func (*RepairCost) ID() string { + return "minecraft:repair_cost" +} diff --git a/codec/component/repairable.go b/codec/component/repairable.go new file mode 100644 index 0000000..eeccb57 --- /dev/null +++ b/codec/component/repairable.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Repairable struct { + Items pk.IDSet +} + +func (*Repairable) Type() slot.ComponentID { + return 29 +} + +func (*Repairable) ID() string { + return "minecraft:repairable" +} diff --git a/codec/component/salmon_size.go b/codec/component/salmon_size.go new file mode 100644 index 0000000..5c12458 --- /dev/null +++ b/codec/component/salmon_size.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type SalmonSize struct { + SizeType int32 `mc:"VarInt"` +} + +func (*SalmonSize) Type() slot.ComponentID { + return 77 +} + +func (*SalmonSize) ID() string { + return "minecraft:salmon/size" +} diff --git a/codec/component/sheep_color.go b/codec/component/sheep_color.go new file mode 100644 index 0000000..84a683c --- /dev/null +++ b/codec/component/sheep_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type SheepColor struct { + Color DyeColor +} + +func (*SheepColor) Type() slot.ComponentID { + return 94 +} + +func (*SheepColor) ID() string { + return "minecraft:sheep/color" +} diff --git a/codec/component/shulker_color.go b/codec/component/shulker_color.go new file mode 100644 index 0000000..c2d63a6 --- /dev/null +++ b/codec/component/shulker_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type ShulkerColor struct { + Color DyeColor +} + +func (*ShulkerColor) Type() slot.ComponentID { + return 95 +} + +func (*ShulkerColor) ID() string { + return "minecraft:shulker/color" +} diff --git a/codec/component/stored_enchantments.go b/codec/component/stored_enchantments.go new file mode 100644 index 0000000..839636f --- /dev/null +++ b/codec/component/stored_enchantments.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type StoredEnchantments struct { + Enchantments []Enchantment +} + +func (*StoredEnchantments) Type() slot.ComponentID { + return 34 +} + +func (*StoredEnchantments) ID() string { + return "minecraft:stored_enchantments" +} diff --git a/codec/component/suspicious_stew_effects.go b/codec/component/suspicious_stew_effects.go new file mode 100644 index 0000000..7d4dc89 --- /dev/null +++ b/codec/component/suspicious_stew_effects.go @@ -0,0 +1,22 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type SuspiciousStewEffects struct { + Effects []SuspiciousStewEffect +} + +//codec:gen +type SuspiciousStewEffect struct { + TypeID int32 `mc:"VarInt"` + Duration int32 `mc:"VarInt"` +} + +func (*SuspiciousStewEffects) Type() slot.ComponentID { + return 44 +} + +func (*SuspiciousStewEffects) ID() string { + return "minecraft:suspicious_stew_effects" +} diff --git a/codec/component/tool.go b/codec/component/tool.go new file mode 100644 index 0000000..d6dd0d3 --- /dev/null +++ b/codec/component/tool.go @@ -0,0 +1,30 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Tool struct { + Rules []ToolRule + DefaultMiningSpeed float32 + DamagePerBlock int32 `mc:"VarInt"` +} + +//codec:gen +type ToolRule struct { + Blocks pk.IDSet + HasSpeed bool + Speed pk.Option[pk.Float, *pk.Float] + HasCorrectDropForBlocks bool + CorrectDropForBlocks pk.Option[pk.Boolean, *pk.Boolean] +} + +func (*Tool) Type() slot.ComponentID { + return 25 +} + +func (*Tool) ID() string { + return "minecraft:tool" +} diff --git a/codec/component/tooltip_display.go b/codec/component/tooltip_display.go new file mode 100644 index 0000000..d58f322 --- /dev/null +++ b/codec/component/tooltip_display.go @@ -0,0 +1,17 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type TooltipDisplay struct { + HideTooltip bool + HiddenComponents []int32 `mc:"VarInt"` +} + +func (*TooltipDisplay) Type() slot.ComponentID { + return 15 +} + +func (*TooltipDisplay) ID() string { + return "minecraft:tooltip_display" +} diff --git a/codec/component/tooltip_style.go b/codec/component/tooltip_style.go new file mode 100644 index 0000000..cdc3bfa --- /dev/null +++ b/codec/component/tooltip_style.go @@ -0,0 +1,19 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type TooltipStyle struct { + Style pk.Identifier +} + +func (*TooltipStyle) Type() slot.ComponentID { + return 31 +} + +func (*TooltipStyle) ID() string { + return "minecraft:tooltip_style" +} diff --git a/codec/component/trim.go b/codec/component/trim.go new file mode 100644 index 0000000..9648808 --- /dev/null +++ b/codec/component/trim.go @@ -0,0 +1,41 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type Trim struct { + TrimMaterial TrimMaterial + TrimPattern TrimPattern +} + +//codec:gen +type TrimMaterial struct { + Suffix string + Overrides []TrimOverride + Description chat.Message +} + +type TrimOverride struct { + MaterialType pk.Identifier + OverrideAssetName string +} + +//codec:gen +type TrimPattern struct { + AssetName string + TemplateItem int32 `mc:"VarInt"` + Description chat.Message + Decal bool +} + +func (*Trim) Type() slot.ComponentID { + return 47 +} + +func (*Trim) ID() string { + return "minecraft:trim" +} diff --git a/codec/component/tropical_fish_base_color.go b/codec/component/tropical_fish_base_color.go new file mode 100644 index 0000000..93f84da --- /dev/null +++ b/codec/component/tropical_fish_base_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type TropicalFishBaseColor struct { + Color DyeColor +} + +func (*TropicalFishBaseColor) Type() slot.ComponentID { + return 80 +} + +func (*TropicalFishBaseColor) ID() string { + return "minecraft:tropical_fish/base_color" +} diff --git a/codec/component/tropical_fish_pattern.go b/codec/component/tropical_fish_pattern.go new file mode 100644 index 0000000..fe8bfc9 --- /dev/null +++ b/codec/component/tropical_fish_pattern.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type TropicalFishPattern struct { + Pattern int32 `mc:"VarInt"` +} + +func (*TropicalFishPattern) Type() slot.ComponentID { + return 79 +} + +func (*TropicalFishPattern) ID() string { + return "minecraft:tropical_fish/pattern" +} diff --git a/codec/component/tropical_fish_pattern_color.go b/codec/component/tropical_fish_pattern_color.go new file mode 100644 index 0000000..e14b2c1 --- /dev/null +++ b/codec/component/tropical_fish_pattern_color.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type TropicalFishPatternColor struct { + Color DyeColor +} + +func (*TropicalFishPatternColor) Type() slot.ComponentID { + return 81 +} + +func (*TropicalFishPatternColor) ID() string { + return "minecraft:tropical_fish/pattern_color" +} diff --git a/codec/component/unbreakable.go b/codec/component/unbreakable.go new file mode 100644 index 0000000..3bde2f3 --- /dev/null +++ b/codec/component/unbreakable.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Unbreakable struct { + // no fields +} + +func (*Unbreakable) Type() slot.ComponentID { + return 4 +} + +func (*Unbreakable) ID() string { + return "minecraft:unbreakable" +} diff --git a/codec/component/use_cooldown.go b/codec/component/use_cooldown.go new file mode 100644 index 0000000..70468bc --- /dev/null +++ b/codec/component/use_cooldown.go @@ -0,0 +1,20 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type UseCooldown struct { + Seconds float32 + CooldownGroup pk.Option[pk.Identifier, *pk.Identifier] +} + +func (*UseCooldown) Type() slot.ComponentID { + return 23 +} + +func (*UseCooldown) ID() string { + return "minecraft:use_cooldown" +} diff --git a/codec/component/use_remainder.go b/codec/component/use_remainder.go new file mode 100644 index 0000000..c6efe73 --- /dev/null +++ b/codec/component/use_remainder.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type UseRemainder struct { + Remainder slot.Slot +} + +func (*UseRemainder) Type() slot.ComponentID { + return 22 +} + +func (*UseRemainder) ID() string { + return "minecraft:use_remainder" +} diff --git a/codec/component/villager_variant.go b/codec/component/villager_variant.go new file mode 100644 index 0000000..2dac2d5 --- /dev/null +++ b/codec/component/villager_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type VillagerVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*VillagerVariant) Type() slot.ComponentID { + return 72 +} + +func (*VillagerVariant) ID() string { + return "minecraft:villager/variant" +} diff --git a/codec/component/weapon.go b/codec/component/weapon.go new file mode 100644 index 0000000..d809104 --- /dev/null +++ b/codec/component/weapon.go @@ -0,0 +1,17 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type Weapon struct { + DamagePerAttack int32 `mc:"VarInt"` + DisableBlockingFor float32 // In seconds +} + +func (*Weapon) Type() slot.ComponentID { + return 26 +} + +func (*Weapon) ID() string { + return "minecraft:weapon" +} diff --git a/codec/component/wolf_collar.go b/codec/component/wolf_collar.go new file mode 100644 index 0000000..47fb441 --- /dev/null +++ b/codec/component/wolf_collar.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type WolfCollar struct { + Color DyeColor +} + +func (*WolfCollar) Type() slot.ComponentID { + return 75 +} + +func (*WolfCollar) ID() string { + return "minecraft:wolf/collar" +} diff --git a/codec/component/wolf_sound_variant.go b/codec/component/wolf_sound_variant.go new file mode 100644 index 0000000..3c32f7e --- /dev/null +++ b/codec/component/wolf_sound_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type WolfSoundVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*WolfSoundVariant) Type() slot.ComponentID { + return 74 +} + +func (*WolfSoundVariant) ID() string { + return "minecraft:wolf/sound_variant" +} diff --git a/codec/component/wolf_variant.go b/codec/component/wolf_variant.go new file mode 100644 index 0000000..8a00da1 --- /dev/null +++ b/codec/component/wolf_variant.go @@ -0,0 +1,16 @@ +package component + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type WolfVariant struct { + Variant int32 `mc:"VarInt"` +} + +func (*WolfVariant) Type() slot.ComponentID { + return 73 +} + +func (*WolfVariant) ID() string { + return "minecraft:wolf/variant" +} diff --git a/codec/component/writable_book_content.go b/codec/component/writable_book_content.go new file mode 100644 index 0000000..da92f55 --- /dev/null +++ b/codec/component/writable_book_content.go @@ -0,0 +1,26 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type WritableBookContent struct { + Pages []WritableBookPage +} + +//codec:gen +type WritableBookPage struct { + RawContent string `mc:"String"` + HasFilteredContent bool + FilteredContent pk.Option[pk.String, *pk.String] +} + +func (*WritableBookContent) Type() slot.ComponentID { + return 45 +} + +func (*WritableBookContent) ID() string { + return "minecraft:writable_book_content" +} diff --git a/codec/component/written_book_content.go b/codec/component/written_book_content.go new file mode 100644 index 0000000..1f19496 --- /dev/null +++ b/codec/component/written_book_content.go @@ -0,0 +1,32 @@ +package component + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type WrittenBookContent struct { + RawTitle string `mc:"String"` + HasFilteredTitle bool + FilteredTitle pk.Option[pk.String, *pk.String] + Author string `mc:"String"` + Generation int32 `mc:"VarInt"` + Pages []WrittenBookPage +} + +//codec:gen +type WrittenBookPage struct { + RawContent chat.Message + HasFilteredContent bool + FilteredContent pk.Option[chat.Message, *chat.Message] +} + +func (*WrittenBookContent) Type() slot.ComponentID { + return 46 +} + +func (*WrittenBookContent) ID() string { + return "minecraft:written_book_content" +} diff --git a/codec/packet/game/client/add_entity.go b/codec/packet/game/client/add_entity.go new file mode 100644 index 0000000..18fdaab --- /dev/null +++ b/codec/packet/game/client/add_entity.go @@ -0,0 +1,26 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" + "github.com/google/uuid" +) + +var _ ClientboundPacket = (*AddEntity)(nil) +var _ packet.Field = (*AddEntity)(nil) + +// AddEntityPacket +// codec:gen +type AddEntity struct { + ID int32 `mc:"VarInt"` + UUID uuid.UUID `mc:"UUID"` + Type int32 `mc:"VarInt"` + X, Y, Z float64 + XRot, YRot, YHeadRot int8 + Data int32 `mc:"VarInt"` + VelocityX, VelocityY, VelocityZ int16 +} + +func (AddEntity) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundAddEntity +} diff --git a/codec/packet/game/client/animate.go b/codec/packet/game/client/animate.go new file mode 100644 index 0000000..cb4652d --- /dev/null +++ b/codec/packet/game/client/animate.go @@ -0,0 +1,20 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*Animate)(nil) +var _ packet.Field = (*Animate)(nil) + +// AnimatePacket +// codec:gen +type Animate struct { + EntityID int32 `mc:"VarInt"` + Action uint8 +} + +func (Animate) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundAnimate +} diff --git a/codec/packet/game/client/award_stats.go b/codec/packet/game/client/award_stats.go new file mode 100644 index 0000000..4532bcb --- /dev/null +++ b/codec/packet/game/client/award_stats.go @@ -0,0 +1,25 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +// codec:gen +type StatsData struct { + CategoryID int32 `mc:"VarInt"` + StatID int32 `mc:"VarInt"` + Value int32 `mc:"VarInt"` +} + +var _ ClientboundPacket = (*AwardStats)(nil) +var _ packet.Field = (*AwardStats)(nil) + +// codec:gen +type AwardStats struct { + Stats []StatsData +} + +func (AwardStats) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundAwardStats +} diff --git a/codec/packet/game/client/block_changed_ack.go b/codec/packet/game/client/block_changed_ack.go new file mode 100644 index 0000000..d76c52b --- /dev/null +++ b/codec/packet/game/client/block_changed_ack.go @@ -0,0 +1,16 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*BlockChangedAck)(nil) + +// codec:gen +type BlockChangedAck struct { + Sequence int32 `mc:"VarInt"` +} + +func (BlockChangedAck) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundBlockChangedAck +} diff --git a/codec/packet/game/client/block_destruction.go b/codec/packet/game/client/block_destruction.go new file mode 100644 index 0000000..85d57a3 --- /dev/null +++ b/codec/packet/game/client/block_destruction.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*BlockDestruction)(nil) + +// codec:gen +type BlockDestruction struct { + ID int32 `mc:"VarInt"` + Position packet.Position + Progress uint8 +} + +func (BlockDestruction) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundBlockDestruction +} diff --git a/codec/packet/game/client/block_entity_data.go b/codec/packet/game/client/block_entity_data.go new file mode 100644 index 0000000..44dae37 --- /dev/null +++ b/codec/packet/game/client/block_entity_data.go @@ -0,0 +1,13 @@ +package client + +import ( + "github.com/Tnze/go-mc/nbt" + "github.com/Tnze/go-mc/net/packet" +) + +// codec:gen +type BlockEntityData struct { + Position packet.Position + Type int32 `mc:"VarInt"` + Data nbt.RawMessage `mc:"NBT"` +} diff --git a/codec/packet/game/client/block_event.go b/codec/packet/game/client/block_event.go new file mode 100644 index 0000000..81f2cfb --- /dev/null +++ b/codec/packet/game/client/block_event.go @@ -0,0 +1,18 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +// codec:gen +type BlockEvent struct { + Position packet.Position + EventType uint8 + Data uint8 + Block int32 `mc:"VarInt"` +} + +func (BlockEvent) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundBlockEvent +} diff --git a/codec/packet/game/client/block_update.go b/codec/packet/game/client/block_update.go new file mode 100644 index 0000000..ca6429c --- /dev/null +++ b/codec/packet/game/client/block_update.go @@ -0,0 +1,16 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +// codec:gen +type BlockUpdate struct { + Position packet.Position + BlockState int32 `mc:"VarInt"` +} + +func (BlockUpdate) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundBlockUpdate +} diff --git a/codec/packet/game/client/boss_event.go b/codec/packet/game/client/boss_event.go new file mode 100644 index 0000000..4345d5a --- /dev/null +++ b/codec/packet/game/client/boss_event.go @@ -0,0 +1,163 @@ +package client + +import ( + "io" + + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" + "github.com/google/uuid" +) + +// codec:gen +type BossEvent struct { + UUID uuid.UUID `mc:"UUID"` + BossEventOp BossEventOperation +} + +// codec:gen +type BossEventOpAdd struct { + Message chat.Message + Progress float32 + Color int32 `mc:"VarInt"` + Overlay int32 `mc:"VarInt"` + Flags uint8 +} + +// codec:gen +type BossEventOpRemove struct { +} + +// codec:gen +type BossEventOpUpdate struct { + Progress float32 +} + +// codec:gen +type BossEventOpUpdateName struct { + Message chat.Message +} + +// codec:gen +type BossEventOpUpdateStyle struct { + Color int32 `mc:"VarInt"` + Overlay int32 `mc:"VarInt"` +} + +// codec:gen +type BossEventOpUpdateProperties struct { + Flags uint8 +} + +type BossEventOperation struct { + Operation int32 `mc:"VarInt"` + OpData any +} + +func (c *BossEventOperation) ReadFrom(r io.Reader) (int64, error) { + o, err := (*pk.VarInt)(&c.Operation).ReadFrom(r) + if err != nil { + return o, err + } + var i int64 + + switch c.Operation { + case 0: + var op BossEventOpAdd + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + case 1: + var op BossEventOpRemove + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + case 2: + var op BossEventOpUpdate + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + case 3: + var op BossEventOpUpdateName + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + case 4: + var op BossEventOpUpdateStyle + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + case 5: + var op BossEventOpUpdateProperties + i, err = op.ReadFrom(r) + if err != nil { + return i, err + } + c.OpData = &op + } + + return o + i, nil +} + +func (c *BossEventOperation) WriteTo(w io.Writer) (int64, error) { + o, err := (*pk.VarInt)(&c.Operation).WriteTo(w) + if err != nil { + return o, err + } + + switch c.Operation { + case 0: + op := c.OpData.(*BossEventOpAdd) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + case 1: + op := c.OpData.(*BossEventOpRemove) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + case 2: + op := c.OpData.(*BossEventOpUpdate) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + case 3: + op := c.OpData.(*BossEventOpUpdateName) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + case 4: + op := c.OpData.(*BossEventOpUpdateStyle) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + case 5: + op := c.OpData.(*BossEventOpUpdateProperties) + i, err := op.WriteTo(w) + if err != nil { + return o + i, err + } + return o + i, nil + } + + return o, nil +} diff --git a/codec/packet/game/client/bundle_delimiter.go b/codec/packet/game/client/bundle_delimiter.go new file mode 100644 index 0000000..035466c --- /dev/null +++ b/codec/packet/game/client/bundle_delimiter.go @@ -0,0 +1,7 @@ +package client + +// BundleDelimiter +// +// codec:gen +type BundleDelimiter struct { +} diff --git a/codec/packet/game/client/change_difficulty.go b/codec/packet/game/client/change_difficulty.go new file mode 100644 index 0000000..1d7adc0 --- /dev/null +++ b/codec/packet/game/client/change_difficulty.go @@ -0,0 +1,7 @@ +package client + +// codec:gen +type ChangeDifficulty struct { + Difficulty []int8 + Locked bool +} diff --git a/codec/packet/game/client/chunk_batch_finished.go b/codec/packet/game/client/chunk_batch_finished.go new file mode 100644 index 0000000..264c607 --- /dev/null +++ b/codec/packet/game/client/chunk_batch_finished.go @@ -0,0 +1,6 @@ +package client + +// codec:gen +type ChunkBatchFinished struct { + BatchSize int32 `mc:"VarInt"` +} diff --git a/codec/packet/game/client/chunk_batch_start.go b/codec/packet/game/client/chunk_batch_start.go new file mode 100644 index 0000000..3794f8c --- /dev/null +++ b/codec/packet/game/client/chunk_batch_start.go @@ -0,0 +1,7 @@ +package client + +// ChunkBatchStartPacket +// +// codec:gen +type ChunkBatchStart struct { +} diff --git a/codec/packet/game/client/chunk_biomes.go b/codec/packet/game/client/chunk_biomes.go new file mode 100644 index 0000000..7dc3826 --- /dev/null +++ b/codec/packet/game/client/chunk_biomes.go @@ -0,0 +1,8 @@ +package client + +//codec:gen +type ChunkBiomes struct { + ChunkX int32 + ChunkZ int32 + Data []byte `mc:"ByteArray"` +} diff --git a/codec/packet/game/client/clear_titles.go b/codec/packet/game/client/clear_titles.go new file mode 100644 index 0000000..8f007bc --- /dev/null +++ b/codec/packet/game/client/clear_titles.go @@ -0,0 +1,6 @@ +package client + +//codec:gen +type ClearTitles struct { + Reset bool +} diff --git a/codec/packet/game/client/close_container.go b/codec/packet/game/client/close_container.go new file mode 100644 index 0000000..d143de2 --- /dev/null +++ b/codec/packet/game/client/close_container.go @@ -0,0 +1,6 @@ +package client + +//codec:gen +type CloseContainer struct { + WindowID int32 `mc:"VarInt"` +} diff --git a/codec/packet/game/client/codecs.go b/codec/packet/game/client/codecs.go new file mode 100644 index 0000000..f903127 --- /dev/null +++ b/codec/packet/game/client/codecs.go @@ -0,0 +1,2429 @@ +// Code generated by packetizer.go; DO NOT EDIT. + +package client + +import ( + "io" + + pk "github.com/Tnze/go-mc/net/packet" +) + +func (c *AddEntity) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UUID)(&c.UUID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.XRot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.YRot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.YHeadRot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityX).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityY).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityZ).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c AddEntity) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UUID)(&c.UUID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.XRot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.YRot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.YHeadRot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityX).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityY).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.VelocityZ).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Animate) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Action).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Animate) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Action).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *StatsData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.CategoryID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StatID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c StatsData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.CategoryID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StatID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *AwardStats) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Stats).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c AwardStats) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Stats).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockChangedAck) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Sequence).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockChangedAck) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Sequence).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockDestruction) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Position).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Progress).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockDestruction) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Position).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Progress).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockEntityData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockEntityData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.NBT(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.EventType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Block).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.EventType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Block).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BlockUpdate) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.BlockState).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BlockUpdate) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Position).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.BlockState).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UUID)(&c.UUID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BossEventOp).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UUID)(&c.UUID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.BossEventOp).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEventOpAdd) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Progress).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Overlay).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Flags).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEventOpAdd) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Progress).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Overlay).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Flags).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEventOpRemove) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c BossEventOpRemove) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *BossEventOpUpdate) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.Progress).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEventOpUpdate) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Float)(&c.Progress).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEventOpUpdateName) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEventOpUpdateName) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEventOpUpdateStyle) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Color).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Overlay).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEventOpUpdateStyle) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Color).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Overlay).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BossEventOpUpdateProperties) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Flags).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c BossEventOpUpdateProperties) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Flags).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *BundleDelimiter) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c BundleDelimiter) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *ChangeDifficulty) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Difficulty).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Locked).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ChangeDifficulty) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Difficulty).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Locked).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ChunkBatchFinished) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.BatchSize).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ChunkBatchFinished) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.BatchSize).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ChunkBatchStart) ReadFrom(r io.Reader) (int64, error) { + return 0, nil +} + +func (c ChunkBatchStart) WriteTo(w io.Writer) (int64, error) { + return 0, nil +} + +func (c *ChunkBiomes) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.ChunkX).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.ChunkZ).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ChunkBiomes) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.ChunkX).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.ChunkZ).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ClearTitles) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.Reset).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ClearTitles) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Boolean)(&c.Reset).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CloseContainer) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CloseContainer) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CommandSuggestionsMatch) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Match).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Tooltip).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CommandSuggestionsMatch) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.String)(&c.Match).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Tooltip).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CommandSuggestions) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Start).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Length).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Matches).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CommandSuggestions) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Start).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Length).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Matches).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Commands) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Nodes).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.RootIndex).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Commands) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Nodes).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.RootIndex).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *SetContainerContent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StateID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Slots).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CarriedItem).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c SetContainerContent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StateID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Slots).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CarriedItem).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ContainerSetData) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Byte)(&c.ContainerID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.ID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.Value).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ContainerSetData) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Byte)(&c.ContainerID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.ID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.Value).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ContainerSetSlot) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ContainerID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StateID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.Slot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ItemStack).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ContainerSetSlot) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ContainerID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.StateID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Short)(&c.Slot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.ItemStack).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CookieRequest) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Key).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CookieRequest) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Key).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Cooldown) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Identifier)(&c.CooldownGroup).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Cooldown) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Identifier)(&c.CooldownGroup).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.Duration).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CustomChatCompletions) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Action).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Entries).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CustomChatCompletions) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.Action).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Entries).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CustomPayload) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Channel).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CustomPayload) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Channel).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DamageEventPos) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DamageEventPos) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DamageEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceCauseID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceDirectID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.SourcePos).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DamageEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceCauseID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SourceDirectID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.SourcePos).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DebugSample) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Sample).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.DebugSampleType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DebugSample) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = pk.Array(&c.Sample).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.DebugSampleType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DeleteChat) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.ByteArray)(&c.MessageSignature).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DeleteChat) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.ByteArray)(&c.MessageSignature).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Disconnect) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Reason).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Disconnect) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Reason).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *DisguisedChat) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.ChatType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c DisguisedChat) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Message).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.ByteArray)(&c.ChatType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *EntityEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.EventID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c EntityEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.EventID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *TeleportEntity) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityX).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityY).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityZ).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Yaw).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Pitch).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.OnGround).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c TeleportEntity) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityX).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityY).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.VelocityZ).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Yaw).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Pitch).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.OnGround).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Vec3) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Vec3) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Explode) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.CenterX).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.CenterY).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.CenterZ).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.PlayerKnockbackVelocity).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Explode) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.CenterX).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.CenterY).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.CenterZ).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.PlayerKnockbackVelocity).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ChunkPos) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ChunkPos) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *ForgetLevelChunk) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Pos).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c ForgetLevelChunk) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.Pos).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *GameEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Event).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Param).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c GameEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Event).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Param).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *OpenHorseScreen) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.InventoryColumnsSize).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c OpenHorseScreen) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.WindowID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.InventoryColumnsSize).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *HurtAnimation) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Yaw).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c HurtAnimation) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.EntityID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.Yaw).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *LevelChunkWithLight) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c LevelChunkWithLight) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *LevelEvent) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Type).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Pos).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Data).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.GlobalEvent).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c LevelEvent) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Int)(&c.Type).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Pos).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Int)(&c.Data).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.GlobalEvent).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *GlobalPos) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Identifier)(&c.Dimension).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Pos).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c GlobalPos) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Identifier)(&c.Dimension).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Pos).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *CommonPlayerSpawnInfo) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.DimensionType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Identifier)(&c.Dimension).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Long)(&c.Seed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.GameType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.PreviousGameType).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsDebug).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsFlat).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.LastDeathLocation).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.PortalCooldown).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SeaLevel).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c CommonPlayerSpawnInfo) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.DimensionType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Identifier)(&c.Dimension).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Long)(&c.Seed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.GameType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Byte)(&c.PreviousGameType).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsDebug).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.IsFlat).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.LastDeathLocation).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.PortalCooldown).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SeaLevel).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Login) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PlayerID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Hardcore).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Levels).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.MaxPlayers).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.ChunkRadius).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SimulationDistance).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ReducedDebugInfo).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowDeathScreen).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.DoLimitedCrafting).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CommonPlayerSpawnInfo).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.EnforcesSecureChat).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Login) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.PlayerID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.Hardcore).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = pk.Array(&c.Levels).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.MaxPlayers).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.ChunkRadius).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.VarInt)(&c.SimulationDistance).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ReducedDebugInfo).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.ShowDeathScreen).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.DoLimitedCrafting).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.CommonPlayerSpawnInfo).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Boolean)(&c.EnforcesSecureChat).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PlayerAbilities) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Flags).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.FlyingSpeed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.WalkingSpeed).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PlayerAbilities) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.UnsignedByte)(&c.Flags).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.FlyingSpeed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.WalkingSpeed).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PositionMoveRotation) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.YRot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.XRot).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PositionMoveRotation) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.Double)(&c.X).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Y).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Double)(&c.Z).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.YRot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.Float)(&c.XRot).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *PlayerPosition) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Change).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Relatives).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c PlayerPosition) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (*pk.VarInt)(&c.ID).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (&c.Change).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.Relatives).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c *Respawn) ReadFrom(r io.Reader) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.CommonPlayerSpawnInfo).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.DataToKeep).ReadFrom(r) + n += temp + if err != nil { + return n, err + } + return n, err +} + +func (c Respawn) WriteTo(w io.Writer) (int64, error) { + var n int64 + var err error + var temp int64 + temp, err = (&c.CommonPlayerSpawnInfo).WriteTo(w) + n += temp + if err != nil { + return n, err + } + temp, err = (*pk.UnsignedByte)(&c.DataToKeep).WriteTo(w) + n += temp + if err != nil { + return n, err + } + return n, err +} diff --git a/codec/packet/game/client/command_suggestions.go b/codec/packet/game/client/command_suggestions.go new file mode 100644 index 0000000..1c88877 --- /dev/null +++ b/codec/packet/game/client/command_suggestions.go @@ -0,0 +1,20 @@ +package client + +import ( + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type CommandSuggestionsMatch struct { + Match string + Tooltip pk.Option[chat.Message, *chat.Message] +} + +//codec:gen +type CommandSuggestions struct { + ID int32 `mc:"VarInt"` + Start int32 `mc:"VarInt"` + Length int32 `mc:"VarInt"` + Matches []CommandSuggestionsMatch +} diff --git a/codec/packet/game/client/commands.go b/codec/packet/game/client/commands.go new file mode 100644 index 0000000..fd9d36f --- /dev/null +++ b/codec/packet/game/client/commands.go @@ -0,0 +1,9 @@ +package client + +import "github.com/Tnze/go-mc/server/command" + +//codec:gen +type Commands struct { + Nodes []command.Node + RootIndex int32 `mc:"VarInt"` +} diff --git a/codec/packet/game/client/container_set_content.go b/codec/packet/game/client/container_set_content.go new file mode 100644 index 0000000..4175c86 --- /dev/null +++ b/codec/packet/game/client/container_set_content.go @@ -0,0 +1,11 @@ +package client + +import "git.konjactw.dev/patyhank/minego/codec/data/slot" + +//codec:gen +type SetContainerContent struct { + WindowID int32 `mc:"VarInt"` + StateID int32 `mc:"VarInt"` + Slots []slot.Slot + CarriedItem slot.Slot +} diff --git a/codec/packet/game/client/container_set_data.go b/codec/packet/game/client/container_set_data.go new file mode 100644 index 0000000..6991b96 --- /dev/null +++ b/codec/packet/game/client/container_set_data.go @@ -0,0 +1,22 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*ContainerSetData)(nil) +var _ packet.Field = (*ContainerSetData)(nil) + +// ContainerSetDataPacket +// +//codec:gen +type ContainerSetData struct { + ContainerID int8 + ID int16 + Value int16 +} + +func (ContainerSetData) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundContainerSetData +} diff --git a/codec/packet/game/client/container_set_slot.go b/codec/packet/game/client/container_set_slot.go new file mode 100644 index 0000000..9e6e4d4 --- /dev/null +++ b/codec/packet/game/client/container_set_slot.go @@ -0,0 +1,24 @@ +package client + +import ( + "git.konjactw.dev/patyhank/minego/codec/data/slot" + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*ContainerSetSlot)(nil) +var _ packet.Field = (*ContainerSetSlot)(nil) + +// ContainerSetSlotPacket +// +//codec:gen +type ContainerSetSlot struct { + ContainerID int32 `mc:"VarInt"` + StateID int32 `mc:"VarInt"` + Slot int16 + ItemStack slot.Slot +} + +func (ContainerSetSlot) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundContainerSetSlot +} diff --git a/codec/packet/game/client/cookie_request.go b/codec/packet/game/client/cookie_request.go new file mode 100644 index 0000000..113c1c8 --- /dev/null +++ b/codec/packet/game/client/cookie_request.go @@ -0,0 +1,8 @@ +package client + +import pk "github.com/Tnze/go-mc/net/packet" + +//codec:gen +type CookieRequest struct { + Key pk.Identifier +} diff --git a/codec/packet/game/client/cooldown.go b/codec/packet/game/client/cooldown.go new file mode 100644 index 0000000..3d66bb4 --- /dev/null +++ b/codec/packet/game/client/cooldown.go @@ -0,0 +1,21 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + pk "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*Cooldown)(nil) +var _ pk.Field = (*Cooldown)(nil) + +// CooldownPacket +// +//codec:gen +type Cooldown struct { + CooldownGroup pk.Identifier `mc:"Identifier"` + Duration int32 `mc:"VarInt"` +} + +func (Cooldown) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundCooldown +} diff --git a/codec/packet/game/client/custom_chat_completions.go b/codec/packet/game/client/custom_chat_completions.go new file mode 100644 index 0000000..401380e --- /dev/null +++ b/codec/packet/game/client/custom_chat_completions.go @@ -0,0 +1,21 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*CustomChatCompletions)(nil) +var _ packet.Field = (*CustomChatCompletions)(nil) + +// CustomChatCompletionsPacket +// +//codec:gen +type CustomChatCompletions struct { + Action int32 `mc:"VarInt"` + Entries []string +} + +func (CustomChatCompletions) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundCustomChatCompletions +} diff --git a/codec/packet/game/client/custom_payload.go b/codec/packet/game/client/custom_payload.go new file mode 100644 index 0000000..8493b93 --- /dev/null +++ b/codec/packet/game/client/custom_payload.go @@ -0,0 +1,9 @@ +package client + +import pk "github.com/Tnze/go-mc/net/packet" + +//codec:gen +type CustomPayload struct { + Channel pk.Identifier + Data []byte `mc:"ByteArray"` +} diff --git a/codec/packet/game/client/damage_event.go b/codec/packet/game/client/damage_event.go new file mode 100644 index 0000000..64f2591 --- /dev/null +++ b/codec/packet/game/client/damage_event.go @@ -0,0 +1,29 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + pk "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*DamageEvent)(nil) +var _ pk.Field = (*DamageEvent)(nil) + +//codec:gen +type DamageEventPos struct { + X, Y, Z float64 +} + +// DamageEventPacket +// +//codec:gen +type DamageEvent struct { + EntityID int32 `mc:"VarInt"` + SourceType int32 `mc:"VarInt"` + SourceCauseID int32 `mc:"VarInt"` + SourceDirectID int32 `mc:"VarInt"` + SourcePos pk.Option[DamageEventPos, *DamageEventPos] +} + +func (DamageEvent) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundDamageEvent +} diff --git a/codec/packet/game/client/debug_sample.go b/codec/packet/game/client/debug_sample.go new file mode 100644 index 0000000..a4766b3 --- /dev/null +++ b/codec/packet/game/client/debug_sample.go @@ -0,0 +1,21 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*DebugSample)(nil) +var _ packet.Field = (*DebugSample)(nil) + +// DebugSamplePacket +// +//codec:gen +type DebugSample struct { + Sample []int64 + DebugSampleType int32 `mc:"VarInt"` +} + +func (DebugSample) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundDebugSample +} diff --git a/codec/packet/game/client/delete_chat.go b/codec/packet/game/client/delete_chat.go new file mode 100644 index 0000000..05c3968 --- /dev/null +++ b/codec/packet/game/client/delete_chat.go @@ -0,0 +1,20 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*DeleteChat)(nil) +var _ packet.Field = (*DeleteChat)(nil) + +// DeleteChatPacket +// +//codec:gen +type DeleteChat struct { + MessageSignature []byte `mc:"ByteArray"` +} + +func (DeleteChat) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundDeleteChat +} diff --git a/codec/packet/game/client/disconnect.go b/codec/packet/game/client/disconnect.go new file mode 100644 index 0000000..67f5c69 --- /dev/null +++ b/codec/packet/game/client/disconnect.go @@ -0,0 +1,8 @@ +package client + +import "github.com/Tnze/go-mc/chat" + +//codec:gen +type Disconnect struct { + Reason chat.Message +} diff --git a/codec/packet/game/client/disguised_chat.go b/codec/packet/game/client/disguised_chat.go new file mode 100644 index 0000000..791dd34 --- /dev/null +++ b/codec/packet/game/client/disguised_chat.go @@ -0,0 +1,22 @@ +package client + +import ( + "github.com/Tnze/go-mc/chat" + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*DisguisedChat)(nil) +var _ packet.Field = (*DisguisedChat)(nil) + +// DisguisedChatPacket +// +//codec:gen +type DisguisedChat struct { + Message chat.Message + ChatType []byte `mc:"ByteArray"` +} + +func (DisguisedChat) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundDisguisedChat +} diff --git a/codec/packet/game/client/entity_event.go b/codec/packet/game/client/entity_event.go new file mode 100644 index 0000000..49e5b61 --- /dev/null +++ b/codec/packet/game/client/entity_event.go @@ -0,0 +1,21 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*EntityEvent)(nil) +var _ packet.Field = (*EntityEvent)(nil) + +// EntityEventPacket +// +//codec:gen +type EntityEvent struct { + EntityID int32 + EventID int8 +} + +func (EntityEvent) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundEntityEvent +} diff --git a/codec/packet/game/client/entity_position_sync.go b/codec/packet/game/client/entity_position_sync.go new file mode 100644 index 0000000..0674e10 --- /dev/null +++ b/codec/packet/game/client/entity_position_sync.go @@ -0,0 +1,10 @@ +package client + +//codec:gen +type TeleportEntity struct { + EntityID int32 `mc:"VarInt"` + X, Y, Z float64 + VelocityX, VelocityY, VelocityZ float64 + Yaw, Pitch float32 + OnGround bool +} diff --git a/codec/packet/game/client/explode.go b/codec/packet/game/client/explode.go new file mode 100644 index 0000000..96bd64e --- /dev/null +++ b/codec/packet/game/client/explode.go @@ -0,0 +1,25 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + pk "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*Explode)(nil) + +//codec:gen +type Vec3 struct { + X, Y, Z float64 +} + +//codec:gen +type Explode struct { + CenterX float64 + CenterY float64 + CenterZ float64 + PlayerKnockbackVelocity pk.Option[Vec3, *Vec3] +} + +func (Explode) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundExplode +} diff --git a/codec/packet/game/client/forget_level_chunk.go b/codec/packet/game/client/forget_level_chunk.go new file mode 100644 index 0000000..cf909cd --- /dev/null +++ b/codec/packet/game/client/forget_level_chunk.go @@ -0,0 +1,21 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*ForgetLevelChunk)(nil) + +//codec:gen +type ChunkPos struct { + X, Z int32 +} + +//codec:gen +type ForgetLevelChunk struct { + Pos ChunkPos +} + +func (ForgetLevelChunk) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundForgetLevelChunk +} diff --git a/codec/packet/game/client/game_event.go b/codec/packet/game/client/game_event.go new file mode 100644 index 0000000..90bc7fd --- /dev/null +++ b/codec/packet/game/client/game_event.go @@ -0,0 +1,17 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*GameEvent)(nil) + +//codec:gen +type GameEvent struct { + Event uint8 + Param float32 +} + +func (GameEvent) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundGameEvent +} diff --git a/codec/packet/game/client/horse_screen_open.go b/codec/packet/game/client/horse_screen_open.go new file mode 100644 index 0000000..2e0ac93 --- /dev/null +++ b/codec/packet/game/client/horse_screen_open.go @@ -0,0 +1,8 @@ +package client + +//codec:gen +type OpenHorseScreen struct { + WindowID int32 `mc:"VarInt"` + InventoryColumnsSize int32 `mc:"VarInt"` + EntityID int32 +} diff --git a/codec/packet/game/client/hurt_animation.go b/codec/packet/game/client/hurt_animation.go new file mode 100644 index 0000000..047d03a --- /dev/null +++ b/codec/packet/game/client/hurt_animation.go @@ -0,0 +1,7 @@ +package client + +//codec:gen +type HurtAnimation struct { + EntityID int32 `mc:"VarInt"` + Yaw float32 +} diff --git a/codec/packet/game/client/initialize_border.go b/codec/packet/game/client/initialize_border.go new file mode 100644 index 0000000..572997d --- /dev/null +++ b/codec/packet/game/client/initialize_border.go @@ -0,0 +1,11 @@ +package client + +//codec:gen +type InitializeWorldBorder struct { + X, Z float64 + OldDiameter, NewDiameter float64 + Speed int64 `mc:"VarLong"` + PortalTeleportBoundary int32 `mc:"VarInt"` + WarningBlocks int32 `mc:"VarInt"` + WarningTime int32 `mc:"VarInt"` +} diff --git a/codec/packet/game/client/keep_alive.go b/codec/packet/game/client/keep_alive.go new file mode 100644 index 0000000..aa69b05 --- /dev/null +++ b/codec/packet/game/client/keep_alive.go @@ -0,0 +1,6 @@ +package client + +//codec:gen +type KeepAlive struct { + ID int64 +} diff --git a/codec/packet/game/client/level_chunk_with_light.go b/codec/packet/game/client/level_chunk_with_light.go new file mode 100644 index 0000000..589b755 --- /dev/null +++ b/codec/packet/game/client/level_chunk_with_light.go @@ -0,0 +1,12 @@ +package client + +import "github.com/Tnze/go-mc/level" + +var _ ClientboundPacket = (*LevelChunkWithLight)(nil) + +//codec:gen +type LevelChunkWithLight struct { + X int32 + Z int32 + Data level.Chunk +} diff --git a/codec/packet/game/client/level_event.go b/codec/packet/game/client/level_event.go new file mode 100644 index 0000000..08d4ddd --- /dev/null +++ b/codec/packet/game/client/level_event.go @@ -0,0 +1,20 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + pk "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*LevelEvent)(nil) + +//codec:gen +type LevelEvent struct { + Type int32 + Pos pk.Position + Data int32 + GlobalEvent bool +} + +func (LevelEvent) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundLevelEvent +} diff --git a/codec/packet/game/client/login.go b/codec/packet/game/client/login.go new file mode 100644 index 0000000..afd34e0 --- /dev/null +++ b/codec/packet/game/client/login.go @@ -0,0 +1,47 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + pk "github.com/Tnze/go-mc/net/packet" +) + +var _ ClientboundPacket = (*Login)(nil) + +//codec:gen +type GlobalPos struct { + Dimension string `mc:"Identifier"` + Pos pk.Position +} + +//codec:gen +type CommonPlayerSpawnInfo struct { + DimensionType int32 `mc:"VarInt"` + Dimension string `mc:"Identifier"` + Seed int64 + GameType uint8 + PreviousGameType int8 + IsDebug bool + IsFlat bool + LastDeathLocation pk.Option[GlobalPos, *GlobalPos] + PortalCooldown int32 `mc:"VarInt"` + SeaLevel int32 `mc:"VarInt"` +} + +//codec:gen +type Login struct { + PlayerID int32 `mc:"VarInt"` + Hardcore bool + Levels []string `mc:"Identifier"` + MaxPlayers int32 `mc:"VarInt"` + ChunkRadius int32 `mc:"VarInt"` + SimulationDistance int32 `mc:"VarInt"` + ReducedDebugInfo bool + ShowDeathScreen bool + DoLimitedCrafting bool + CommonPlayerSpawnInfo CommonPlayerSpawnInfo + EnforcesSecureChat bool +} + +func (Login) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundLogin +} diff --git a/codec/packet/game/client/map_data.go b/codec/packet/game/client/map_data.go new file mode 100644 index 0000000..80b418a --- /dev/null +++ b/codec/packet/game/client/map_data.go @@ -0,0 +1,57 @@ +package client + +import ( + "io" + + "github.com/Tnze/go-mc/chat" + pk "github.com/Tnze/go-mc/net/packet" +) + +//codec:gen +type MapIcon struct { + Type int32 `mc:"VarInt"` + X, Z int8 + Direction int8 + DisplayName pk.Option[chat.Message, *chat.Message] +} + +type MapColorPatch struct { + Columns uint8 + Rows uint8 + X, Z uint8 + Data []pk.UnsignedByte +} + +func (c *MapColorPatch) ReadFrom(r io.Reader) (n int64, err error) { + t, err := (*pk.UnsignedByte)(&c.Columns).ReadFrom(r) + if err != nil { + return t, err + } + if c.Columns <= 0 { + return t, err + } + a, err := (*pk.UnsignedByte)(&c.Rows).ReadFrom(r) + b, err := (*pk.UnsignedByte)(&c.X).ReadFrom(r) + d, err := (*pk.UnsignedByte)(&c.Z).ReadFrom(r) + e, err := pk.Array(&c.Data).ReadFrom(r) + return t + a + b + d + e, err +} + +func (c MapColorPatch) WriteTo(w io.Writer) (n int64, err error) { + n, err = pk.UnsignedByte(c.Columns).WriteTo(w) + if c.Columns <= 0 { + return n, err + } + n, err = pk.UnsignedByte(c.Rows).WriteTo(w) + n, err = pk.UnsignedByte(c.X).WriteTo(w) + n, err = pk.UnsignedByte(c.Z).WriteTo(w) + n, err = pk.Array(&c.Data).WriteTo(w) + return n, err +} + +//codec:gen +type MapData struct { + MapID int32 `mc:"VarInt"` + Scale int8 + Locked bool +} diff --git a/codec/packet/game/client/merchant_offers.go b/codec/packet/game/client/merchant_offers.go new file mode 100644 index 0000000..da13c8e --- /dev/null +++ b/codec/packet/game/client/merchant_offers.go @@ -0,0 +1 @@ +package client diff --git a/codec/packet/game/client/packet.go b/codec/packet/game/client/packet.go new file mode 100644 index 0000000..604fc85 --- /dev/null +++ b/codec/packet/game/client/packet.go @@ -0,0 +1,42 @@ +//codec:ignore +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" + "github.com/Tnze/go-mc/net/packet" +) + +type ClientboundPacket interface { + packet.Field +} + +var ClientboundPackets = make(map[packetid.ClientboundPacketID]ClientboundPacket) + +func init() { + ClientboundPackets[packetid.ClientboundAddEntity] = &AddEntity{} + ClientboundPackets[packetid.ClientboundAnimate] = &Animate{} + ClientboundPackets[packetid.ClientboundAwardStats] = &AwardStats{} + ClientboundPackets[packetid.ClientboundBlockChangedAck] = &BlockChangedAck{} + ClientboundPackets[packetid.ClientboundBlockDestruction] = &BlockDestruction{} + ClientboundPackets[packetid.ClientboundBlockEntityData] = &BlockEntityData{} + ClientboundPackets[packetid.ClientboundBlockEvent] = &BlockEvent{} + ClientboundPackets[packetid.ClientboundBlockUpdate] = &BlockUpdate{} + ClientboundPackets[packetid.ClientboundBossEvent] = &BossEvent{} + ClientboundPackets[packetid.ClientboundChangeDifficulty] = &ChangeDifficulty{} + ClientboundPackets[packetid.ClientboundChunkBatchFinished] = &ChunkBatchFinished{} + ClientboundPackets[packetid.ClientboundChunkBatchStart] = &ChunkBatchStart{} + ClientboundPackets[packetid.ClientboundChunksBiomes] = &ChunkBiomes{} + ClientboundPackets[packetid.ClientboundClearTitles] = &ClearTitles{} + ClientboundPackets[packetid.ClientboundContainerClose] = &CloseContainer{} + ClientboundPackets[packetid.ClientboundCommandSuggestions] = &CommandSuggestions{} + ClientboundPackets[packetid.ClientboundCommands] = &Commands{} + ClientboundPackets[packetid.ClientboundContainerSetData] = &ContainerSetData{} + ClientboundPackets[packetid.ClientboundContainerSetSlot] = &ContainerSetSlot{} + ClientboundPackets[packetid.ClientboundCooldown] = &Cooldown{} + ClientboundPackets[packetid.ClientboundCustomChatCompletions] = &CustomChatCompletions{} + ClientboundPackets[packetid.ClientboundDamageEvent] = &DamageEvent{} + ClientboundPackets[packetid.ClientboundDebugSample] = &DebugSample{} + ClientboundPackets[packetid.ClientboundDeleteChat] = &DeleteChat{} + ClientboundPackets[packetid.ClientboundDisguisedChat] = &DisguisedChat{} + ClientboundPackets[packetid.ClientboundEntityEvent] = &EntityEvent{} +} diff --git a/codec/packet/game/client/player_abilities.go b/codec/packet/game/client/player_abilities.go new file mode 100644 index 0000000..b84c041 --- /dev/null +++ b/codec/packet/game/client/player_abilities.go @@ -0,0 +1,18 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*PlayerAbilities)(nil) + +//codec:gen +type PlayerAbilities struct { + Flags uint8 + FlyingSpeed float32 + WalkingSpeed float32 +} + +func (PlayerAbilities) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundPlayerAbilities +} diff --git a/codec/packet/game/client/player_position.go b/codec/packet/game/client/player_position.go new file mode 100644 index 0000000..2d9784d --- /dev/null +++ b/codec/packet/game/client/player_position.go @@ -0,0 +1,24 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*PlayerPosition)(nil) + +//codec:gen +type PositionMoveRotation struct { + X, Y, Z float64 + YRot, XRot float32 +} + +//codec:gen +type PlayerPosition struct { + ID int32 `mc:"VarInt"` + Change PositionMoveRotation + Relatives uint8 +} + +func (PlayerPosition) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundPlayerPosition +} diff --git a/codec/packet/game/client/respawn.go b/codec/packet/game/client/respawn.go new file mode 100644 index 0000000..5e14e75 --- /dev/null +++ b/codec/packet/game/client/respawn.go @@ -0,0 +1,17 @@ +package client + +import ( + "github.com/Tnze/go-mc/data/packetid" +) + +var _ ClientboundPacket = (*Respawn)(nil) + +//codec:gen +type Respawn struct { + CommonPlayerSpawnInfo CommonPlayerSpawnInfo + DataToKeep uint8 +} + +func (Respawn) ClientboundPacketID() packetid.ClientboundPacketID { + return packetid.ClientboundRespawn +} diff --git a/codec/packet/game/client/update_light.go b/codec/packet/game/client/update_light.go new file mode 100644 index 0000000..61e2c13 --- /dev/null +++ b/codec/packet/game/client/update_light.go @@ -0,0 +1,9 @@ +package client + +import "github.com/Tnze/go-mc/level" + +//codec:gen +type UpdateLight struct { + ChunkX, ChunkZ int32 `mc:"VarInt"` + Data level.LightData +} diff --git a/codec/packet/game/server/packet.go b/codec/packet/game/server/packet.go new file mode 100644 index 0000000..2af70c4 --- /dev/null +++ b/codec/packet/game/server/packet.go @@ -0,0 +1,10 @@ +//codec:ignore +package server + +import "github.com/Tnze/go-mc/data/packetid" + +type ServerboundPacket interface { + ServerboundPacketID() packetid.ServerboundPacketID +} + +var ServerboundPackets = make(map[packetid.ServerboundPacketID]ServerboundPacket) diff --git a/codec/packet/protocol.wiki b/codec/packet/protocol.wiki new file mode 100644 index 0000000..a876748 --- /dev/null +++ b/codec/packet/protocol.wiki @@ -0,0 +1,9897 @@ +{{DISPLAYTITLE:''Java Edition'' protocol/Packets}} +{{about|the protocol for a stable release of {{JE}}|the protocol used in development versions of {{JE}}|Java Edition protocol/Development version|the protocol used in {{BE}}|Bedrock Edition protocol|the protocol used in old ''[[Pocket Edition]]'' versions|Pocket Edition protocol}} +{{See also|Java Edition protocol/FAQ|title1=Protocol FAQ}} +{{exclusive|java}} +{{Info|While you may use the contents of this page without restriction to create servers, clients, bots, etc; keep in mind that the contents of this page are distributed under the terms of [https://creativecommons.org/licenses/by-sa/3.0/ CC BY-SA 3.0 Unported]. Reproductions and derivative works must be distributed accordingly.}} + +This article presents a dissection of the current {{JE}} '''protocol''' for [[Minecraft Wiki:Projects/wiki.vg merge/Protocol version numbers|1.21.6, protocol 771]]. + +The changes between versions may be viewed at [[Minecraft Wiki:Projects/wiki.vg merge/Protocol History|Protocol History]]. + +== Definitions == + +The Minecraft server accepts connections from TCP clients and communicates with them using ''packets''. A packet is a sequence of bytes sent over the TCP connection. The meaning of a packet depends both on its packet ID and the current state of the connection. The initial state of each connection is [[#Handshaking|Handshaking]], and state is switched using the packets [[#Handshake|Handshake]] and [[#Login Success|Login Success]]. + +=== Data types === + +{{:Java Edition protocol/Data types}} + +=== Other definitions === + +{| class="wikitable" + |- + ! Term + ! Definition + |- + | Player + | When used in the singular, Player always refers to the client connected to the server. + |- + | Entity + | Entity refers to any item, player, mob, minecart or boat etc. See [[Entity|the Minecraft Wiki article]] for a full list. + |- + | EID + | An EID — or Entity ID — is a 4-byte sequence used to identify a specific entity. An entity's EID is unique on the entire server. + |- + | XYZ + | In this document, the axis names are the same as those shown in the debug screen (F3). Y points upwards, X points east, and Z points south. + |- + | Meter + | The meter is Minecraft's base unit of length, equal to the length of a vertex of a solid block. The term “block” may be used to mean “meter” or “cubic meter”. + |- + | Registry + | A table describing static, gameplay-related objects of some kind, such as the types of entities, block states or biomes. The entries of a registry are typically associated with textual or numeric identifiers, or both. + +Minecraft has a unified registry system used to implement most of the registries, including blocks, items, entities, biomes and dimensions. These "ordinary" registries associate entries with both namespaced textual identifiers (see [[#Identifier]]), and signed (positive) 32-bit numeric identifiers. There is also a registry of registries listing all of the registries in the registry system. Some other registries, most notably the [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Block state registry|block state registry]], are however implemented in a more ad-hoc fashion. + +Some registries, such as biomes and dimensions, can be customized at runtime by the server (see [[Minecraft Wiki:Projects/wiki.vg merge/Registry Data|Registry Data]]), while others, such as blocks, items and entities, are hardcoded. The contents of the hardcoded registries can be extracted via the built-in [[Minecraft Wiki:Projects/wiki.vg merge/Data Generators|Data Generators]] system. + |- + | Block state + | Each block in Minecraft has 0 or more properties, which in turn may have any number of possible values. These represent, for example, the orientations of blocks, poweredness states of redstone components, and so on. Each of the possible permutations of property values for a block is a distinct block state. The block state registry assigns a numeric identifier to every block state of every block. + +A current list of properties and state ID ranges is found on [https://pokechu22.github.io/Burger/1.21.html burger]. + +Alternatively, the vanilla server now includes an option to export the current block state ID mapping, by running java -DbundlerMainClass=net.minecraft.data.Main -jar minecraft_server.jar --reports. See [[Minecraft Wiki:Projects/wiki.vg merge/Data Generators|Data Generators]] for more information. + |- + | Vanilla + | The official implementation of Minecraft as developed and released by Mojang. + |- + | Sequence + | The action number counter for local block changes, incremented by one when clicking a block with a hand, right clicking an item, or starting or finishing digging a block. Counter handles latency to avoid applying outdated block changes to the local world. Also is used to revert ghost blocks created when placing blocks, using buckets, or breaking blocks. + |} + +== Packet format == + +Packets cannot be larger than 221 − 1 or 2097151 bytes (the maximum that can be sent in a 3-byte {{Type|VarInt}}). Moreover, the length field must not be longer than 3 bytes, even if the encoded value is within the limit. Unnecessarily long encodings at 3 bytes or below are still allowed. For compressed packets, this applies to the Packet Length field, i.e. the compressed length. + +=== Without compression === + +{| class="wikitable" + ! Field Name + ! Field Type + ! Notes + |- + | Length + | {{Type|VarInt}} + | Length of Packet ID + Data + |- + | Packet ID + | {{Type|VarInt}} + | Corresponds to protocol_id from [[Minecraft Wiki:Projects/wiki.vg merge/Data Generators#Packets report|the server's packet report]] + |- + | Data + | {{Type|Byte Array}} + | Depends on the connection state and packet ID, see the sections below + |} + +=== With compression === + +Once a [[#Set Compression|Set Compression]] packet (with a non-negative threshold) is sent, [[wikipedia:Zlib|zlib]] compression is enabled for all following packets. The format of a packet changes slightly to include the size of the uncompressed packet. + +{| class=wikitable + ! Present? + ! Compressed? + ! Field Name + ! Field Type + ! Notes + |- + | always + | No + | Packet Length + | {{Type|VarInt}} + | Length of (Data Length) + length of compressed (Packet ID + Data) + |- + | rowspan="3"| if size >= threshold + | No + | Data Length + | {{Type|VarInt}} + | Length of uncompressed (Packet ID + Data) + |- + | rowspan="2"| Yes + | Packet ID + | {{Type|VarInt}} + | zlib compressed packet ID (see the sections below) + |- + | Data + | {{Type|Byte Array}} + | zlib compressed packet data (see the sections below) + |- + | rowspan="3"| if size < threshold + | rowspan="3"| No + | Data Length + | {{Type|VarInt}} + | 0 to indicate uncompressed + |- + | Packet ID + | {{Type|VarInt}} + | packet ID (see the sections below) + |- + | Data + | {{Type|Byte Array}} + | packet data (see the sections below) + |} + +For serverbound packets, the uncompressed length of (Packet ID + Data) must not be greater than 223 or 8388608 bytes. Note that a length equal to 223 is permitted, which differs from the compressed length limit. The vanilla client, on the other hand, has no limit for the uncompressed length of incoming compressed packets. + +If the size of the buffer containing the packet data and ID (as a {{Type|VarInt}}) is smaller than the threshold specified in the packet [[#Set Compression|Set Compression]]. It will be sent as uncompressed. This is done by setting the data length as 0. (Comparable to sending a non-compressed format with an extra 0 between the length, and packet data). + +If it's larger than or equal to the threshold, then it follows the regular compressed protocol format. + +The vanilla server (but not client) rejects compressed packets smaller than the threshold. Uncompressed packets exceeding the threshold, however, are accepted. + +Compression can be disabled by sending the packet [[#Set Compression|Set Compression]] with a negative Threshold, or not sending the Set Compression packet at all. + +== Handshaking == + +=== Clientbound === + +There are no clientbound packets in the Handshaking state, since the protocol immediately switches to a different state after the client sends the first packet. + +=== Serverbound === + +==== Handshake ==== + +This packet causes the server to switch into the target state. It should be sent right after opening the TCP connection to prevent the server from disconnecting. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x00

''resource:''
intention + | rowspan="4"| Handshaking + | rowspan="4"| Server + | Protocol Version + | {{Type|VarInt}} + | See [[Minecraft Wiki:Projects/wiki.vg merge/Protocol version numbers|protocol version numbers]] (currently 770 in Minecraft 1.21.5). + |- + | Server Address + | {{Type|String}} (255) + | Hostname or IP, e.g. localhost or 127.0.0.1, that was used to connect. The vanilla server does not use this information. Note that SRV records are a simple redirect, e.g. if _minecraft._tcp.example.com points to mc.example.org, users connecting to example.com will provide example.org as server address in addition to connecting to it. + |- + | Server Port + | {{Type|Unsigned Short}} + | Default is 25565. The vanilla server does not use this information. + |- + | Intent + | {{Type|VarInt}} {{Type|Enum}} + | 1 for [[#Status|Status]], 2 for [[#Login|Login]], 3 for [[#Login|Transfer]]. + |} + +==== Legacy Server List Ping ==== + +{{Warning|This packet uses a nonstandard format. It is never length-prefixed, and the packet ID is an {{Type|Unsigned Byte}} instead of a {{Type|VarInt}}.}} + +While not technically part of the current protocol, (legacy) clients may send this packet to initiate [[Minecraft Wiki:Projects/wiki.vg merge/Server List Ping|Server List Ping]], and modern servers should handle it correctly. +The format of this packet is a remnant of the pre-Netty age, before the switch to Netty in 1.7 brought the standard format that is recognized now. This packet merely exists to inform legacy clients that they can't join our modern server. + +Modern clients (tested with 1.21.5 + 1.21.4) also send this packet when the server does not send any response within a 30 seconds time window or when the connection is immediately closed. +{{Warning|The client does not close the connection with the legacy packet on its own! +It only gets closed when the Minecraft client is closed.}} +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | 0xFE + | Handshaking + | Server + | Payload + | {{Type|Unsigned Byte}} + | always 1 (0x01). + |} + +See [[Minecraft Wiki:Projects/wiki.vg merge/Server List Ping#1.6|Server List Ping#1.6]] for the details of the protocol that follows this packet. +== Status == +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Server List Ping}} + +=== Clientbound === + +==== Status Response ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x00

''resource:''
status_response + | Status + | Client + | JSON Response + | {{Type|String}} (32767) + | See [[Minecraft Wiki:Projects/wiki.vg merge/Server List Ping#Status Response|Server List Ping#Status Response]]; as with all strings this is prefixed by its length as a {{Type|VarInt}}. + |} + +==== Pong Response (status) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x01

''resource:''
pong_response + | Status + | Client + | Timestamp + | {{Type|Long}} + | Should match the one sent by the client. + |} + +=== Serverbound === + +==== Status Request ==== + +The status can only be requested once immediately after the handshake, before any ping. The server won't respond otherwise. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x00

''resource:''
status_request + | Status + | Server + | colspan="3"| ''no fields'' + |} + +==== Ping Request (status) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x01

''resource:''
ping_request + | Status + | Server + | Timestamp + | {{Type|Long}} + | May be any number, but vanilla clients will always use the timestamp in milliseconds. + |} + +== Login == + +The login process is as follows: + +# C→S: [[#Handshake|Handshake]] with intent set to 2 (login) +# C→S: [[#Login Start|Login Start]] +# S→C: [[#Encryption Request|Encryption Request]] +# Client auth (if enabled) +# C→S: [[#Encryption Response|Encryption Response]] +# Server auth (if enabled) +# Both enable encryption +# S→C: [[#Set Compression|Set Compression]] (optional) +# S→C: [[#Login Success|Login Success]] +# C→S: [[#Login Acknowledged|Login Acknowledged]] + +Set Compression, if present, must be sent before Login Success. Note that anything sent after Set Compression must use the [[#With compression|Post Compression packet format]]. + +Three modes of operation are possible depending on how the packets are sent: +* Online-mode with encryption +* Offline-mode with encryption +* Offline-mode without encryption + +For online-mode servers (the ones with authentication enabled), encryption is always mandatory, and the entire process described above needs to be followed. + +For offline-mode servers (the ones with authentication disabled), encryption is optional, and part of the process can be skipped. In that case [[#Login Start|Login Start]] is directly followed by [[#Login Success|Login Success]]. The vanilla server only uses UUID v3 for offline player UUIDs, deriving it from the string OfflinePlayer: For example, Notch’s offline UUID would be chosen from the string OfflinePlayer:Notch. This is not a requirement however, the UUID can be set to anything. + +As of 1.21, the vanilla server never uses encryption in offline mode. + +See [[protocol encryption]] for details. + +=== Clientbound === + +==== Disconnect (login) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x00

''resource:''
login_disconnect + | Login + | Client + | Reason + | {{Type|JSON Text Component}} + | The reason why the player was disconnected. + |} + +==== Encryption Request ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x01

''resource:''
hello + | rowspan="4"| Login + | rowspan="4"| Client + | Server ID + | {{Type|String}} (20) + | Always empty when sent by the vanilla server. + |- + | Public Key + | {{Type|Prefixed Array}} of {{Type|Byte}} + | The server's public key, in bytes. + |- + | Verify Token + | {{Type|Prefixed Array}} of {{Type|Byte}} + | A sequence of random bytes generated by the server. + |- + | Should authenticate + | {{Type|Boolean}} + | Whether the client should attempt to [[Minecraft Wiki:Projects/wiki.vg merge/Protocol_Encryption#Authentication|authenticate through mojang servers]]. + |} + +See [[protocol encryption]] for details. + +==== Login Success ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x02

''resource:''
login_finished + | rowspan="5"| Login + | rowspan="5"| Client + | colspan="2"| UUID + | colspan="2"| {{Type|UUID}} + | colspan="2"| + |- + | colspan="2"| Username + | colspan="2"| {{Type|String}} (16) + | colspan="2"| + |- + | rowspan="3"| Property + | Name + | rowspan="3"| {{Type|Prefixed Array}} (16) + | {{Type|String}} (64) + | colspan="2"| + |- + | Value + | {{Type|String}} (32767) + | colspan="1"| + |- + | Signature + | {{Type|Prefixed Optional}} {{Type|String}} (1024) + | + |} + +The Property field looks like response of [[Minecraft Wiki:Projects/wiki.vg merge/Mojang API#UUID to Profile and Skin/Cape|Mojang API#UUID to Profile and Skin/Cape]], except using the protocol format instead of JSON. That is, each player will usually have one property with Name being “textures” and Value being a base64-encoded JSON string, as documented at [[Minecraft Wiki:Projects/wiki.vg merge/Mojang API#UUID to Profile and Skin/Cape|Mojang API#UUID to Profile and Skin/Cape]]. An empty properties array is also acceptable, and will cause clients to display the player with one of the two default skins depending their UUID (again, see the Mojang API page). + +==== Set Compression ==== + +Enables compression. If compression is enabled, all following packets are encoded in the [[#With compression|compressed packet format]]. Negative values will disable compression, meaning the packet format should remain in the [[#Without compression|uncompressed packet format]]. However, this packet is entirely optional, and if not sent, compression will also not be enabled (the vanilla server does not send the packet when compression is disabled). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x03

''resource:''
login_compression + | Login + | Client + | Threshold + | {{Type|VarInt}} + | Maximum size of a packet before it is compressed. + |} + +==== Login Plugin Request ==== + +Used to implement a custom handshaking flow together with [[#Login Plugin Response|Login Plugin Response]]. + +Unlike plugin messages in "play" mode, these messages follow a lock-step request/response scheme, where the client is expected to respond to a request indicating whether it understood. The vanilla client always responds that it hasn't understood, and sends an empty payload. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x04

''resource:''
custom_query + | rowspan="3"| Login + | rowspan="3"| Client + | Message ID + | {{Type|VarInt}} + | Generated by the server - should be unique to the connection. + |- + | Channel + | {{Type|Identifier}} + | Name of the [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channel]] used to send the data. + |- + | Data + | {{Type|Byte Array}} (1048576) + | Any data, depending on the channel. The length of this array must be inferred from the packet length. + |} + +==== Cookie Request (login) ==== + +Requests a cookie that was previously stored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x05

''resource:''
cookie_request + | rowspan="1"| Login + | rowspan="1"| Client + | colspan="2"| Key + | colspan="2"| {{Type|Identifier}} + | The identifier of the cookie. + |} + +=== Serverbound === + +==== Login Start ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x00

''resource:''
hello + | rowspan="2"| Login + | rowspan="2"| Server + | Name + | {{Type|String}} (16) + | Player's Username. + |- + | Player UUID + | {{Type|UUID}} + | The {{Type|UUID}} of the player logging in. Unused by the vanilla server. + |} + +==== Encryption Response ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x01

''resource:''
key + | rowspan="2"| Login + | rowspan="2"| Server + | Shared Secret + | {{Type|Prefixed Array}} of {{Type|Byte}} + | Shared Secret value, encrypted with the server's public key. + |- + | Verify Token + | {{Type|Prefixed Array}} of {{Type|Byte}} + | Verify Token value, encrypted with the same public key as the shared secret. + |} + +See [[protocol encryption]] for details. + +==== Login Plugin Response ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x02

''resource:''
custom_query_answer + | rowspan="2"| Login + | rowspan="2"| Server + | Message ID + | {{Type|VarInt}} + | Should match ID from server. + |- + | Data + | {{Type|Prefixed Optional}} {{Type|Byte Array}} (1048576) + | Any data, depending on the channel. The length of this array must be inferred from the packet length. Only present if the client understood the request. + |} + +==== Login Acknowledged ==== + +Acknowledgement to the [[Java Edition protocol#Login_Success|Login Success]] packet sent by the server. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x03

''resource:''
login_acknowledged + | Login + | Server + | colspan="3"| ''no fields'' + |} + +This packet switches the connection state to [[#Configuration|configuration]]. + +==== Cookie Response (login) ==== + +Response to a [[#Cookie_Request_(login)|Cookie Request (login)]] from the server. The vanilla server only accepts responses of up to 5 kiB in size. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x04

''resource:''
cookie_response + | rowspan="2"| Login + | rowspan="2"| Server + | Key + | {{Type|Identifier}} + | The identifier of the cookie. + |- + | Payload + | {{Type|Prefixed Optional}} {{Type|Prefixed Array}} (5120) of {{Type|Byte}} + | The data of the cookie. + |} + +== Configuration == + +=== Clientbound === + +==== Cookie Request (configuration) ==== + +Requests a cookie that was previously stored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x00

''resource:''
cookie_request + | rowspan="1"| Configuration + | rowspan="1"| Client + | colspan="2"| Key + | colspan="2"| {{Type|Identifier}} + | The identifier of the cookie. + |} + +==== Clientbound Plugin Message (configuration) ==== + +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Plugin channels}} + +Mods and plugins can use this to send their data. Minecraft itself uses several [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channels]]. These internal channels are in the minecraft namespace. + +More information on how it works on [https://web.archive.org/web/20220831140929/https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/ Dinnerbone's blog]. More documentation about internal and popular registered channels are [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|here]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x01

''resource:''
custom_payload + | rowspan="2"| Configuration + | rowspan="2"| Client + | Channel + | {{Type|Identifier}} + | Name of the [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channel]] used to send the data. + |- + | Data + | {{Type|Byte Array}} (1048576) + | Any data. The length of this array must be inferred from the packet length. + |} + +In vanilla clients, the maximum data length is 1048576 bytes. + +==== Disconnect (configuration) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x02

''resource:''
disconnect + | Configuration + | Client + | Reason + | {{Type|Text Component}} + | The reason why the player was disconnected. + |} + +==== Finish Configuration ==== + +Sent by the server to notify the client that the configuration process has finished. The client answers with [[#Acknowledge_Finish_Configuration|Acknowledge Finish Configuration]] whenever it is ready to continue. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x03

''resource:''
finish_configuration + | rowspan="1"| Configuration + | rowspan="1"| Client + | colspan="3"| ''no fields'' + |} + +This packet switches the connection state to [[#Play|play]]. + +==== Clientbound Keep Alive (configuration) ==== + +The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same payload (see [[#Serverbound Keep Alive (configuration)|Serverbound Keep Alive]]). If the client does not respond to a Keep Alive packet within 15 seconds after it was sent, the server kicks the client. Vice versa, if the server does not send any keep-alives for 20 seconds, the client will disconnect and yields a "Timed out" exception. + +The vanilla server uses a system-dependent time in milliseconds to generate the keep alive ID value. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x04

''resource:''
keep_alive + | Configuration + | Client + | Keep Alive ID + | {{Type|Long}} + | + |} + +==== Ping (configuration) ==== + +Packet is not used by the vanilla server. When sent to the client, client responds with a [[#Pong (configuration)|Pong]] packet with the same id. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x05

''resource:''
ping + | Configuration + | Client + | ID + | {{Type|Int}} + | + |} + +==== Reset Chat ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x06

''resource:''
reset_chat + | Configuration + | Client + | colspan="3"| ''no fields'' + |} + +==== Registry Data ==== + +Represents certain registries that are sent from the server and are applied on the client. + +See [[Minecraft Wiki:Projects/wiki.vg merge/Registry_Data|Registry Data]] for details. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x07

''resource:''
registry_data + | rowspan="3"| Configuration + | rowspan="3"| Client + | colspan="2"| Registry ID + | colspan="2"| {{Type|Identifier}} + | + |- + | rowspan="2"| Entries + | Entry ID + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | + |- + | Data + | {{Type|Prefixed Optional}} {{Type|NBT}} + | Entry data. + |} + +==== Remove Resource Pack (configuration) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x08

''resource:''
resource_pack_pop + | rowspan="1"| Configuration + | rowspan="1"| Client + | UUID + | {{Type|Prefixed Optional}} {{Type|UUID}} + | The {{Type|UUID}} of the resource pack to be removed. If not present every resource pack will be removed. + |} + +==== Add Resource Pack (configuration) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x09

''resource:''
resource_pack_push + | rowspan="5"| Configuration + | rowspan="5"| Client + | UUID + | {{Type|UUID}} + | The unique identifier of the resource pack. + |- + | URL + | {{Type|String}} (32767) + | The URL to the resource pack. + |- + | Hash + | {{Type|String}} (40) + | A 40 character hexadecimal, case-insensitive [[wikipedia:SHA-1|SHA-1]] hash of the resource pack file.
If it's not a 40 character hexadecimal string, the client will not use it for hash verification and likely waste bandwidth. + |- + | Forced + | {{Type|Boolean}} + | The vanilla client will be forced to use the resource pack from the server. If they decline they will be kicked from the server. + |- + | Prompt Message + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | This is shown in the prompt making the client accept or decline the resource pack (only if present). + |} + +==== Store Cookie (configuration) ==== + +Stores some arbitrary data on the client, which persists between server transfers. The vanilla client only accepts cookies of up to 5 kiB in size. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0A

''resource:''
store_cookie + | rowspan="2"| Configuration + | rowspan="2"| Client + | colspan="2"| Key + | colspan="2"| {{Type|Identifier}} + | The identifier of the cookie. + |- + | colspan="2"| Payload + | colspan="2"| {{Type|Prefixed Array}} (5120) of {{Type|Byte}} + | The data of the cookie. + |} + +==== Transfer (configuration) ==== + +Notifies the client that it should transfer to the given server. Cookies previously stored are preserved between server transfers. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0B

''resource:''
transfer + | rowspan="2"| Configuration + | rowspan="2"| Client + | colspan="2"| Host + | colspan="2"| {{Type|String}} (32767) + | The hostname or IP of the server. + |- + | colspan="2"| Port + | colspan="2"| {{Type|VarInt}} + | The port of the server. + |} + +==== Feature Flags ==== + +Used to enable and disable features, generally experimental ones, on the client. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0C

''resource:''
update_enabled_features + | rowspan="1"| Configuration + | rowspan="1"| Client + | Feature Flags + | {{Type|Prefixed Array}} of {{Type|Identifier}} + | + |} + +There is one special feature flag, which is in most versions: +* minecraft:vanilla - enables vanilla features + +For the other feature flags, which may change between versions, see [[Experiments#Java_Edition]]. + +==== Update Tags (configuration) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0D

''resource:''
update_tags + | rowspan="2"| Configuration + | rowspan="2"| Client + | rowspan="2"| Array of tags + | Registry + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | Registry identifier (Vanilla expects tags for the registries minecraft:block, minecraft:item, minecraft:fluid, minecraft:entity_type, and minecraft:game_event) + |- + | Array of Tag + | (See below) + | + |} + +Tag arrays look like: + +{| class="wikitable" + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| Tags + | Tag name + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | + |- + | Entries + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | Numeric IDs of the given type (block, item, etc.). This list replaces the previous list of IDs for the given tag. If some preexisting tags are left unmentioned, a warning is printed. + |} + +See [[Tag]] on the Minecraft Wiki for more information, including a list of vanilla tags. + +==== Clientbound Known Packs ==== + +Informs the client of which data packs are present on the server. +The client is expected to respond with its own [[#Serverbound_Known_Packs|Serverbound Known Packs]] packet. +The vanilla server does not continue with Configuration until it receives a response. + +The vanilla client requires the minecraft:core pack with version 1.21.5 for a normal login sequence. This packet must be sent before the Registry Data packets. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x0E

''resource:''
select_known_packs + | rowspan="3"| Configuration + | rowspan="3"| Client + | rowspan="3"| Known Packs + | Namespace + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|String}} (32767) + | + |- + | ID + | {{Type|String}} (32767) + | + |- + | Version + | {{Type|String}} (32767) + | + |} + +==== Custom Report Details (configuration) ==== + +Contains a list of key-value text entries that are included in any crash or disconnection report generated during connection to the server. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0F

''resource:''
custom_report_details + | rowspan="2"| Configuration + | rowspan="2"| Client + | rowspan="2"| Details + | Title + | rowspan="2"| {{Type|Prefixed Array}} (32) + | {{Type|String}} (128) + | + |- + | Description + | {{Type|String}} (4096) + | +|} + +==== Server Links (configuration) ==== + +This packet contains a list of links that the vanilla client will display in the menu available from the pause menu. Link labels can be built-in or custom (i.e., any text). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x10

''resource:''
server_links + | rowspan="2"| Configuration + | rowspan="2"| Client + | rowspan="2"| Links + | Label + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|VarInt}} {{Type|Enum}} {{Type|or}} {{Type|Text Component}} + | Enums are used for built-in labels (see below), text components for custom labels. + |- + | URL + | {{Type|String}} + | Valid URL. +|} + + +{| class="wikitable" + ! ID + ! Name + ! Notes + |- + | 0 + | Bug Report + | Displayed on connection error screen; included as a comment in the disconnection report. + |- + | 1 + | Community Guidelines + | + |- + | 2 + | Support + | + |- + | 3 + | Status + | + |- + | 4 + | Feedback + | + |- + | 5 + | Community + | + |- + | 6 + | Website + | + |- + | 7 + | Forums + | + |- + | 8 + | News + | + |- + | 9 + | Announcements + | + |- + |} + +==== Clear Dialog (configuration) ==== + +If we're currently in a dialog screen, then this removes the current screen and switches back to the previous one. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x11

''resource:''
clear_dialog + | Configuration + | Client + | colspan="3"| ''no fields'' + |} + +==== Show Dialog (configuration) ==== + +Show a custom dialog screen to the client. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x12

''resource:''
show_dialog + | Configuration + | Client + | Dialog + | {{Type|ID or}} {{Type|NBT}} + | ID in the minecraft:dialog registry, or an inline definition as described at [[Java_Edition_protocol/Registry_data#Dialog|Registry_data#Dialog]]. + |} + +=== Serverbound === + +==== Client Information (configuration) ==== + +Sent when the player connects, or when settings are changed. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x00

''resource:''
client_information + | rowspan="9"| Configuration + | rowspan="9"| Server + | Locale + | {{Type|String}} (16) + | e.g. en_GB. + |- + | View Distance + | {{Type|Byte}} + | Client-side render distance, in chunks. + |- + | Chat Mode + | {{Type|VarInt}} {{Type|Enum}} + | 0: enabled, 1: commands only, 2: hidden. See [[Minecraft Wiki:Projects/wiki.vg merge/Chat#Client chat mode|Chat#Client chat mode]] for more information. + |- + | Chat Colors + | {{Type|Boolean}} + | “Colors” multiplayer setting. The vanilla server stores this value but does nothing with it (see [https://bugs.mojang.com/browse/MC-64867 MC-64867]). Third-party servers such as Hypixel disable all coloring in chat and system messages when it is false. + |- + | Displayed Skin Parts + | {{Type|Unsigned Byte}} + | Bit mask, see below. + |- + | Main Hand + | {{Type|VarInt}} {{Type|Enum}} + | 0: Left, 1: Right. + |- + | Enable text filtering + | {{Type|Boolean}} + | Enables filtering of text on signs and written book titles. The vanilla client sets this according to the profanityFilterPreferences.profanityFilterOn account attribute indicated by the [[Minecraft Wiki:Projects/wiki.vg merge/Mojang API#Player Attributes|/player/attributes Mojang API endpoint]]. In offline mode it is always false. + |- + | Allow server listings + | {{Type|Boolean}} + | Servers usually list online players, this option should let you not show up in that list. + |- + | Particle Status + | {{Type|VarInt}} {{Type|Enum}} + | 0: all, 1: decreased, 2: minimal + |} + +''Displayed Skin Parts'' flags: + +* Bit 0 (0x01): Cape enabled +* Bit 1 (0x02): Jacket enabled +* Bit 2 (0x04): Left Sleeve enabled +* Bit 3 (0x08): Right Sleeve enabled +* Bit 4 (0x10): Left Pants Leg enabled +* Bit 5 (0x20): Right Pants Leg enabled +* Bit 6 (0x40): Hat enabled + +The most significant bit (bit 7, 0x80) appears to be unused. + +==== Cookie Response (configuration) ==== + +Response to a [[#Cookie_Request_(configuration)|Cookie Request (configuration)]] from the server. The vanilla server only accepts responses of up to 5 kiB in size. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x01

''resource:''
cookie_response + | rowspan="2"| Configuration + | rowspan="2"| Server + | Key + | {{Type|Identifier}} + | The identifier of the cookie. + |- + | Payload + | {{Type|Prefixed Optional}} {{Type|Prefixed Array}} (5120) of {{Type|Byte}} + | The data of the cookie. + |} + +==== Serverbound Plugin Message (configuration) ==== + +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Plugin channels}} + +Mods and plugins can use this to send their data. Minecraft itself uses some [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channels]]. These internal channels are in the minecraft namespace. + +More documentation on this: [https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/ https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/] + +Note that the length of Data is known only from the packet length, since the packet has no length field of any kind. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x02

''resource:''
custom_payload + | rowspan="2"| Configuration + | rowspan="2"| Server + | Channel + | {{Type|Identifier}} + | Name of the [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channel]] used to send the data. + |- + | Data + | {{Type|Byte Array}} (32767) + | Any data, depending on the channel. minecraft: channels are documented [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|here]]. The length of this array must be inferred from the packet length. + |} + +In vanilla server, the maximum data length is 32767 bytes. + +==== Acknowledge Finish Configuration ==== + +Sent by the client to notify the server that the configuration process has finished. It is sent in response to the server's [[#Finish_Configuration|Finish Configuration]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x03

''resource:''
finish_configuration + | rowspan="1"| Configuration + | rowspan="1"| Server + | colspan="3"| ''no fields'' + |} + +This packet switches the connection state to [[#Play|play]]. + +==== Serverbound Keep Alive (configuration) ==== + +The server will frequently send out a keep-alive (see [[#Clientbound Keep Alive (configuration)|Clientbound Keep Alive]]), each containing a random ID. The client must respond with the same packet. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x04

''resource:''
keep_alive + | Configuration + | Server + | Keep Alive ID + | {{Type|Long}} + | + |} + +==== Pong (configuration) ==== + +Response to the clientbound packet ([[#Ping (configuration)|Ping]]) with the same id. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x05

''resource:''
pong + | Configuration + | Server + | ID + | {{Type|Int}} + | + |} + +==== Resource Pack Response (configuration) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2" | ''protocol:''
0x06

''resource:''
resource_pack + | rowspan="2" | Configuration + | rowspan="2" | Server + | UUID + | {{Type|UUID}} + | The unique identifier of the resource pack received in the [[#Add_Resource_Pack_(configuration)|Add Resource Pack (configuration)]] request. + |- + | Result + | {{Type|VarInt}} {{Type|Enum}} + | Result ID (see below). + |} + +Result can be one of the following values: + +{| class="wikitable" + ! ID + ! Result + |- + | 0 + | Successfully downloaded + |- + | 1 + | Declined + |- + | 2 + | Failed to download + |- + | 3 + | Accepted + |- + | 4 + | Downloaded + |- + | 5 + | Invalid URL + |- + | 6 + | Failed to reload + |- + | 7 + | Discarded + |} + +==== Serverbound Known Packs ==== + +Informs the server of which data packs are present on the client. The client sends this in response to [[#Clientbound_Known_Packs|Clientbound Known Packs]]. + +If the client specifies a pack in this packet, the server should omit its contained data from the [[#Registry_Data_2|Registry Data]] packet. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x07

''resource:''
select_known_packs + | rowspan="3"| Configuration + | rowspan="3"| Server + | rowspan="3"| Known Packs + | Namespace + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|String}} + | + |- + | ID + | {{Type|String}} + | + |- + | Version + | {{Type|String}} + | + |} + +==== Custom Click Action (configuration) ==== + +Sent when the client clicks a {{Type|Text Component}} with the minecraft:custom click action. This is meant as an alternative to running a command, but will not have any effect on vanilla servers. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x08

''resource:''
custom_click_action + | rowspan="2"| Configuration + | rowspan="2"| Server + | ID + | {{Type|Identifier}} + | The identifier for the click action. + |- + | Payload + | {{Type|NBT}} + | The data to send with the click action. May be a TAG_END (0). + |} + +== Play == + +=== Clientbound === + +==== Bundle Delimiter ==== + +The delimiter for a bundle of packets. When received, the client should store every subsequent packet it receives, and wait until another delimiter is received. Once that happens, the client is guaranteed to process every packet in the bundle on the same tick, and the client should stop storing packets. + +As of 1.20.6, the vanilla server only uses this to ensure [[#Spawn_Entity|Spawn Entity]] and associated packets used to configure the entity happen on the same tick. Each entity gets a separate bundle. + +The vanilla client doesn't allow more than 4096 packets in the same bundle. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x00

''resource:''
bundle_delimiter + | Play + | Client + | colspan="3"| ''no fields'' + |} + +==== Spawn Entity ==== + +Sent by the server when an entity (aside from [[#Spawn_Experience_Orb|Experience Orb]]) is created. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="13"| ''protocol:''
0x01

''resource:''
add_entity + | rowspan="13"| Play + | rowspan="13"| Client + | Entity ID + | {{Type|VarInt}} + | A unique integer ID mostly used in the protocol to identify the entity. + |- + | Entity UUID + | {{Type|UUID}} + | A unique identifier that is mostly used in persistence and places where the uniqueness matters more. + |- + | Type + | {{Type|VarInt}} + | ID in the minecraft:entity_type registry (see "type" field in [[Java Edition protocol/Entity metadata#Entities|Entity metadata#Entities]]). + |- + | X + | {{Type|Double}} + | + |- + | Y + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |- + | Pitch + | {{Type|Angle}} + | To get the real pitch, you must divide this by (256.0F / 360.0F) + |- + | Yaw + | {{Type|Angle}} + | To get the real yaw, you must divide this by (256.0F / 360.0F) + |- + | Head Yaw + | {{Type|Angle}} + | Only used by living entities, where the head of the entity may differ from the general body rotation. + |- + | Data + | {{Type|VarInt}} + | Meaning dependent on the value of the Type field, see [[Minecraft Wiki:Projects/wiki.vg merge/Object Data|Object Data]] for details. + |- + | Velocity X + | {{Type|Short}} + | rowspan="3"| Same units as [[#Set Entity Velocity|Set Entity Velocity]]. + |- + | Velocity Y + | {{Type|Short}} + |- + | Velocity Z + | {{Type|Short}} + |} + +{{warning|The points listed below should be considered when this packet is used to spawn a player entity.}} +When in [[Server.properties#online-mode|online mode]], the UUIDs must be valid and have valid skin blobs. +In offline mode, the vanilla server uses [[Wikipedia:Universally unique identifier#Versions 3 and 5 (namespace name-based)|UUID v3]] and chooses the player's UUID by using the String OfflinePlayer:<player name>, encoding it in UTF-8 (and case-sensitive), then processes it with [https://github.com/AdoptOpenJDK/openjdk-jdk8u/blob/9a91972c76ddda5c1ce28b50ca38cbd8a30b7a72/jdk/src/share/classes/java/util/UUID.java#L153-L175 UUID.nameUUIDFromBytes]. + +For NPCs UUID v2 should be used. Note: + + <+Grum> i will never confirm this as a feature you know that :) + +In an example UUID, xxxxxxxx-xxxx-Yxxx-xxxx-xxxxxxxxxxxx, the UUID version is specified by Y. So, for UUID v3, Y will always be 3, and for UUID v2, Y will always be 2. + +==== Entity Animation ==== + +Sent whenever an entity should change animation. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x02

''resource:''
animate + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | Player ID. + |- + | Animation + | {{Type|Unsigned Byte}} + | Animation ID (see below). + |} + +Animation can be one of the following values: + +{| class="wikitable" + ! ID + ! Animation + |- + | 0 + | Swing main arm + |- + | 2 + | Leave bed + |- + | 3 + | Swing offhand + |- + | 4 + | Critical effect + |- + | 5 + | Magic critical effect + |} + +==== Award Statistics ==== + +Sent as a response to [[#Client Status|Client Status]] (id 1). Will only send the changed values if previously requested. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x03

''resource:''
award_stats + | rowspan="3"| Play + | rowspan="3"| Client + | rowspan="3"| Statistics + | Category ID + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|VarInt}} + | See below. + |- + | Statistic ID + | {{Type|VarInt}} + | See below. + |- + | Value + | {{Type|VarInt}} + | The amount to set it to. + |} + +Categories (these are namespaced, but with : replaced with .): + +{| class="wikitable" + ! Name + ! ID + ! Registry + |- + | minecraft.mined + | 0 + | Blocks + |- + | minecraft.crafted + | 1 + | Items + |- + | minecraft.used + | 2 + | Items + |- + | minecraft.broken + | 3 + | Items + |- + | minecraft.picked_up + | 4 + | Items + |- + | minecraft.dropped + | 5 + | Items + |- + | minecraft.killed + | 6 + | Entities + |- + | minecraft.killed_by + | 7 + | Entities + |- + | minecraft.custom + | 8 + | Custom + |} + +Blocks, Items, and Entities use block (not block state), item, and entity ids. + +Custom has the following (unit only matters for clients): + +{| class="wikitable" + ! Name + ! ID + ! Unit + |- + | minecraft.leave_game + | 0 + | None + |- + | minecraft.play_time + | 1 + | Time + |- + | minecraft.total_world_time + | 2 + | Time + |- + | minecraft.time_since_death + | 3 + | Time + |- + | minecraft.time_since_rest + | 4 + | Time + |- + | minecraft.sneak_time + | 5 + | Time + |- + | minecraft.walk_one_cm + | 6 + | Distance + |- + | minecraft.crouch_one_cm + | 7 + | Distance + |- + | minecraft.sprint_one_cm + | 8 + | Distance + |- + | minecraft.walk_on_water_one_cm + | 9 + | Distance + |- + | minecraft.fall_one_cm + | 10 + | Distance + |- + | minecraft.climb_one_cm + | 11 + | Distance + |- + | minecraft.fly_one_cm + | 12 + | Distance + |- + | minecraft.walk_under_water_one_cm + | 13 + | Distance + |- + | minecraft.minecart_one_cm + | 14 + | Distance + |- + | minecraft.boat_one_cm + | 15 + | Distance + |- + | minecraft.pig_one_cm + | 16 + | Distance + |- + | minecraft.horse_one_cm + | 17 + | Distance + |- + | minecraft.aviate_one_cm + | 18 + | Distance + |- + | minecraft.swim_one_cm + | 19 + | Distance + |- + | minecraft.strider_one_cm + | 20 + | Distance + |- + | minecraft.jump + | 21 + | None + |- + | minecraft.drop + | 22 + | None + |- + | minecraft.damage_dealt + | 23 + | Damage + |- + | minecraft.damage_dealt_absorbed + | 24 + | Damage + |- + | minecraft.damage_dealt_resisted + | 25 + | Damage + |- + | minecraft.damage_taken + | 26 + | Damage + |- + | minecraft.damage_blocked_by_shield + | 27 + | Damage + |- + | minecraft.damage_absorbed + | 28 + | Damage + |- + | minecraft.damage_resisted + | 29 + | Damage + |- + | minecraft.deaths + | 30 + | None + |- + | minecraft.mob_kills + | 31 + | None + |- + | minecraft.animals_bred + | 32 + | None + |- + | minecraft.player_kills + | 33 + | None + |- + | minecraft.fish_caught + | 34 + | None + |- + | minecraft.talked_to_villager + | 35 + | None + |- + | minecraft.traded_with_villager + | 36 + | None + |- + | minecraft.eat_cake_slice + | 37 + | None + |- + | minecraft.fill_cauldron + | 38 + | None + |- + | minecraft.use_cauldron + | 39 + | None + |- + | minecraft.clean_armor + | 40 + | None + |- + | minecraft.clean_banner + | 41 + | None + |- + | minecraft.clean_shulker_box + | 42 + | None + |- + | minecraft.interact_with_brewingstand + | 43 + | None + |- + | minecraft.interact_with_beacon + | 44 + | None + |- + | minecraft.inspect_dropper + | 45 + | None + |- + | minecraft.inspect_hopper + | 46 + | None + |- + | minecraft.inspect_dispenser + | 47 + | None + |- + | minecraft.play_noteblock + | 48 + | None + |- + | minecraft.tune_noteblock + | 49 + | None + |- + | minecraft.pot_flower + | 50 + | None + |- + | minecraft.trigger_trapped_chest + | 51 + | None + |- + | minecraft.open_enderchest + | 52 + | None + |- + | minecraft.enchant_item + | 53 + | None + |- + | minecraft.play_record + | 54 + | None + |- + | minecraft.interact_with_furnace + | 55 + | None + |- + | minecraft.interact_with_crafting_table + | 56 + | None + |- + | minecraft.open_chest + | 57 + | None + |- + | minecraft.sleep_in_bed + | 58 + | None + |- + | minecraft.open_shulker_box + | 59 + | None + |- + | minecraft.open_barrel + | 60 + | None + |- + | minecraft.interact_with_blast_furnace + | 61 + | None + |- + | minecraft.interact_with_smoker + | 62 + | None + |- + | minecraft.interact_with_lectern + | 63 + | None + |- + | minecraft.interact_with_campfire + | 64 + | None + |- + | minecraft.interact_with_cartography_table + | 65 + | None + |- + | minecraft.interact_with_loom + | 66 + | None + |- + | minecraft.interact_with_stonecutter + | 67 + | None + |- + | minecraft.bell_ring + | 68 + | None + |- + | minecraft.raid_trigger + | 69 + | None + |- + | minecraft.raid_win + | 70 + | None + |- + | minecraft.interact_with_anvil + | 71 + | None + |- + | minecraft.interact_with_grindstone + | 72 + | None + |- + | minecraft.target_hit + | 73 + | None + |- + | minecraft.interact_with_smithing_table + | 74 + | None + |} + +Units: + +* None: just a normal number (formatted with 0 decimal places) +* Damage: value is 10 times the normal amount +* Distance: a distance in centimeters (hundredths of blocks) +* Time: a time span in ticks + +==== Acknowledge Block Change ==== + +Acknowledges a user-initiated block change. After receiving this packet, the client will display the block state sent by the server instead of the one predicted by the client. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x04

''resource:''
block_changed_ack + | rowspan="1"| Play + | rowspan="1"| Client + | Sequence ID + | {{Type|VarInt}} + | Represents the sequence to acknowledge, this is used for properly syncing block changes to the client after interactions. + |} + +==== Set Block Destroy Stage ==== + +0–9 are the displayable destroy stages and each other number means that there is no animation on this coordinate. + +Block break animations can still be applied on air; the animation will remain visible although there is no block being broken. However, if this is applied to a transparent block, odd graphical effects may happen, including water losing its transparency. (An effect similar to this can be seen in normal gameplay when breaking ice blocks) + +If you need to display several break animations at the same time you have to give each of them a unique Entity ID. The entity ID does not need to correspond to an actual entity on the client. It is valid to use a randomly generated number. + +When removing break animation, you must use the ID of the entity that set it. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x05

''resource:''
block_destruction + | rowspan="3"| Play + | rowspan="3"| Client + | Entity ID + | {{Type|VarInt}} + | The ID of the entity breaking the block. + |- + | Location + | {{Type|Position}} + | Block Position. + |- + | Destroy Stage + | {{Type|Unsigned Byte}} + | 0–9 to set it, any other value to remove it. + |} + +==== Block Entity Data ==== + +Sets the block entity associated with the block at the given location. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x06

''resource:''
block_entity_data + | rowspan="3"| Play + | rowspan="3"| Client + | Location + | {{Type|Position}} + | + |- + | Type + | {{Type|VarInt}} + | ID in the minecraft:block_entity_type registry + |- + | NBT Data + | {{Type|NBT}} + | Data to set. + |} + +==== Block Action ==== + +This packet is used for a number of actions and animations performed by blocks, usually non-persistent. The client ignores the provided block type and instead uses the block state in their world. + +See [[Minecraft Wiki:Projects/wiki.vg merge/Block Actions|Block Actions]] for a list of values. + +{{warning|This packet uses a block ID from the minecraft:block registry, not a block state.}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x07

''resource:''
block_event + | rowspan="4"| Play + | rowspan="4"| Client + | Location + | {{Type|Position}} + | Block coordinates. + |- + | Action ID (Byte 1) + | {{Type|Unsigned Byte}} + | Varies depending on block — see [[Minecraft Wiki:Projects/wiki.vg merge/Block Actions|Block Actions]]. + |- + | Action Parameter (Byte 2) + | {{Type|Unsigned Byte}} + | Varies depending on block — see [[Minecraft Wiki:Projects/wiki.vg merge/Block Actions|Block Actions]]. + |- + | Block Type + | {{Type|VarInt}} + | ID in the minecraft:block registry. This value is unused by the vanilla client, as it will infer the type of block based on the given position. + |} + +==== Block Update ==== + +Fired whenever a block is changed within the render distance. + +{{warning|Changing a block in a chunk that is not loaded is not a stable action. The vanilla client currently uses a ''shared'' empty chunk which is modified for all block changes in unloaded chunks; while in 1.9 this chunk never renders in older versions the changed block will appear in all copies of the empty chunk. Servers should avoid sending block changes in unloaded chunks and clients should ignore such packets.}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x08

''resource:''
block_update + | rowspan="2"| Play + | rowspan="2"| Client + | Location + | {{Type|Position}} + | Block Coordinates. + |- + | Block ID + | {{Type|VarInt}} + | The new block state ID for the block as given in the [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Block state registry|block state registry]]. + |} + +==== Boss Bar ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="14"| ''protocol:''
0x09

''resource:''
boss_event + | rowspan="14"| Play + | rowspan="14"| Client + | colspan="2"| UUID + | {{Type|UUID}} + | Unique ID for this bar. + |- + | colspan="2"| Action + | {{Type|VarInt}} {{Type|Enum}} + | Determines the layout of the remaining packet. + |- + ! Action + ! Field Name + ! + ! + |- + | rowspan="5"| 0: add + | Title + | {{Type|Text Component}} + | + |- + | Health + | {{Type|Float}} + | From 0 to 1. Values greater than 1 do not crash a vanilla client, and start [https://i.johni0702.de/nA.png rendering part of a second health bar] at around 1.5. + |- + | Color + | {{Type|VarInt}} {{Type|Enum}} + | Color ID (see below). + |- + | Division + | {{Type|VarInt}} {{Type|Enum}} + | Type of division (see below). + |- + | Flags + | {{Type|Unsigned Byte}} + | Bit mask. 0x01: should darken sky, 0x02: is dragon bar (used to play end music), 0x04: create fog (previously was also controlled by 0x02). + |- + | 1: remove + | ''no fields'' + | ''no fields'' + | Removes this boss bar. + |- + | 2: update health + | Health + | {{Type|Float}} + | ''as above'' + |- + | 3: update title + | Title + | {{Type|Text Component}} + | + |- + | rowspan="2"| 4: update style + | Color + | {{Type|VarInt}} {{Type|Enum}} + | Color ID (see below). + |- + | Dividers + | {{Type|VarInt}} {{Type|Enum}} + | ''as above'' + |- + | 5: update flags + | Flags + | {{Type|Unsigned Byte}} + | ''as above'' + |} + +{| class="wikitable" + ! ID + ! Color + |- + | 0 + | Pink + |- + | 1 + | Blue + |- + | 2 + | Red + |- + | 3 + | Green + |- + | 4 + | Yellow + |- + | 5 + | Purple + |- + | 6 + | White + |} + +{| class="wikitable" + ! ID + ! Type of division + |- + | 0 + | No division + |- + | 1 + | 6 notches + |- + | 2 + | 10 notches + |- + | 3 + | 12 notches + |- + | 4 + | 20 notches + |} + +==== Change Difficulty ==== + +Changes the difficulty setting in the client's option menu + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0A

''resource:''
change_difficulty + | rowspan="2"| Play + | rowspan="2"| Client + | Difficulty + | {{Type|Unsigned Byte}} {{Type|Enum}} + | 0: peaceful, 1: easy, 2: normal, 3: hard. + |- + | Difficulty locked? + | {{Type|Boolean}} + | + |} + +==== Chunk Batch Finished ==== + +Marks the end of a chunk batch. The vanilla client marks the time it receives this packet and calculates the elapsed duration since the [[#Chunk Batch Start|beginning of the chunk batch]]. The server uses this duration and the batch size received in this packet to estimate the number of milliseconds elapsed per chunk received. This value is then used to calculate the desired number of chunks per tick through the formula 25 / millisPerChunk, which is reported to the server through [[#Chunk Batch Received|Chunk Batch Received]]. This likely uses 25 instead of the normal tick duration of 50 so chunk processing will only use half of the client's and network's bandwidth. + +The vanilla client uses the samples from the latest 15 batches to estimate the milliseconds per chunk number. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0B

''resource:''
chunk_batch_finished + | rowspan="1"| Play + | rowspan="1"| Client + | Batch size + | {{Type|VarInt}} + | Number of chunks. + |} + +==== Chunk Batch Start ==== + +Marks the start of a chunk batch. The vanilla client marks and stores the time it receives this packet. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x0C

''resource:''
chunk_batch_start + | Play + | Client + | colspan="3"| ''no fields'' + |} + +==== Chunk Biomes ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x0D

''resource:''
chunks_biomes + | rowspan="3"| Play + | rowspan="3"| Client + | rowspan="3"| Chunk biome data + | Chunk Z + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|Int}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Chunk X + | {{Type|Int}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Data + | {{Type|Prefixed Array}} of {{Type|Byte}} + | Chunk [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Data structure|data structure]], with [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Chunk_Section|sections]] containing only the Biomes field + |} + +Note: The order of X and Z is inverted, because the client reads them as one big-endian {{Type|Long}}, with Z being the upper 32 bits. + +==== Clear Titles ==== + +Clear the client's current title information, with the option to also reset it. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0E

''resource:''
clear_titles + | rowspan="1"| Play + | rowspan="1"| Client + | Reset + | {{Type|Boolean}} + | + |} + +==== Command Suggestions Response ==== + +The server responds with a list of auto-completions of the last word sent to it. In the case of regular chat, this is a player username. Command names and parameters are also supported. The client sorts these alphabetically before listing them. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x0F

''resource:''
command_suggestions + | rowspan="5"| Play + | rowspan="5"| Client + | colspan="2"| ID + | colspan="2"| {{Type|VarInt}} + | Transaction ID. + |- + | colspan="2"| Start + | colspan="2"| {{Type|VarInt}} + | Start of the text to replace. + |- + | colspan="2"| Length + | colspan="2"| {{Type|VarInt}} + | Length of the text to replace. + |- + | rowspan="2"| Matches + | Match + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|String}} (32767) + | One eligible value to insert, note that each command is sent separately instead of in a single string, hence the need for Count. Note that for instance this doesn't include a leading / on commands. + |- + | Tooltip + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | Tooltip to display. + |} + +==== Commands ==== + +Lists all of the commands on the server, and how they are parsed. + +This is a directed graph, with one root node. Each redirect or child node must refer only to nodes that have already been declared. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x10

''resource:''
commands + | rowspan="2"| Play + | rowspan="2"| Client + | Nodes + | {{Type|Prefixed Array}} of [[Minecraft Wiki:Projects/wiki.vg merge/Command Data#Node Format|Node]] + | An array of nodes. + |- + | Root index + | {{Type|VarInt}} + | Index of the root node in the previous array. + |} + +For more information on this packet, see the [[Minecraft Wiki:Projects/wiki.vg merge/Command Data|Command Data]] article. + +==== Close Container ==== + +This packet is sent from the server to the client when a window is forcibly closed, such as when a chest is destroyed while it's open. The vanilla client disregards the provided window ID and closes any active window. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x11

''resource:''
container_close + | Play + | Client + | Window ID + | {{Type|VarInt}} + | This is the ID of the window that was closed. 0 for inventory. + |} + +==== Set Container Content ==== + +[[File:Inventory-slots.png|thumb|The inventory slots]] + +Replaces the contents of a container window. Sent by the server upon initialization of a container window or the player's inventory, and in response to state ID mismatches (see [[#Click Container]]). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x12

''resource:''
container_set_content + | rowspan="4"| Play + | rowspan="4"| Client + | Window ID + | {{Type|VarInt}} + | The ID of window which items are being sent for. 0 for player inventory. The client ignores any packets targeting a Window ID other than the current one. However, an exception is made for the player inventory, which may be targeted at any time. (The vanilla server does not appear to utilize this special case.) + |- + | State ID + | {{Type|VarInt}} + | A server-managed sequence number used to avoid desynchronization; see [[#Click Container]]. + |- + | Slot Data + | {{Type|Prefixed Array}} of {{Type|Slot}} + |- + | Carried Item + | {{Type|Slot}} + | Item being dragged with the mouse. + |} + +See [[Minecraft Wiki:Projects/wiki.vg merge/Inventory#Windows|inventory windows]] for further information about how slots are indexed. +Use [[#Open Screen|Open Screen]] to open the container on the client. + +==== Set Container Property ==== + +This packet is used to inform the client that part of a GUI window should be updated. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x13

''resource:''
container_set_data + | rowspan="3"| Play + | rowspan="3"| Client + | Window ID + | {{Type|VarInt}} + | + |- + | Property + | {{Type|Short}} + | The property to be updated, see below. + |- + | Value + | {{Type|Short}} + | The new value for the property, see below. + |} + +The meaning of the Property field depends on the type of the window. The following table shows the known combinations of window type and property, and how the value is to be interpreted. + +{| class="wikitable" + |- + ! Window type + ! Property + ! Value + |- + | rowspan="4"| Furnace + | 0: Fire icon (fuel left) + | counting from fuel burn time down to 0 (in-game ticks) + |- + | 1: Maximum fuel burn time + | fuel burn time or 0 (in-game ticks) + |- + | 2: Progress arrow + | counting from 0 to maximum progress (in-game ticks) + |- + | 3: Maximum progress + | always 200 on the vanilla server + |- + | rowspan="10"| Enchantment Table + | 0: Level requirement for top enchantment slot + | rowspan="3"| The enchantment's xp level requirement + |- + | 1: Level requirement for middle enchantment slot + |- + | 2: Level requirement for bottom enchantment slot + |- + | 3: The enchantment seed + | Used for drawing the enchantment names (in [[Wikipedia:Standard Galactic Alphabet|SGA]]) clientside. The same seed ''is'' used to calculate enchantments, but some of the data isn't sent to the client to prevent easily guessing the entire list (the seed value here is the regular seed bitwise and 0xFFFFFFF0). + |- + | 4: Enchantment ID shown on mouse hover over top enchantment slot + | rowspan="3"| The enchantment id (set to -1 to hide it), see below for values + |- + | 5: Enchantment ID shown on mouse hover over middle enchantment slot + |- + | 6: Enchantment ID shown on mouse hover over bottom enchantment slot + |- + | 7: Enchantment level shown on mouse hover over the top slot + | rowspan="3"| The enchantment level (1 = I, 2 = II, 6 = VI, etc.), or -1 if no enchant + |- + | 8: Enchantment level shown on mouse hover over the middle slot + |- + | 9: Enchantment level shown on mouse hover over the bottom slot + |- + | rowspan="3"| Beacon + | 0: Power level + | 0-4, controls what effect buttons are enabled + |- + | 1: First potion effect + | [[Data values#Status effects|Potion effect ID]] for the first effect, or -1 if no effect + |- + | 2: Second potion effect + | [[Data values#Status effects|Potion effect ID]] for the second effect, or -1 if no effect + |- + | Anvil + | 0: Repair cost + | The repair's cost in xp levels + |- + | rowspan="2"| Brewing Stand + | 0: Brew time + | 0 – 400, with 400 making the arrow empty, and 0 making the arrow full + |- + | 1: Fuel time + | 0 - 20, with 0 making the arrow empty, and 20 making the arrow full + |- + | Stonecutter + | 0: Selected recipe + | The index of the selected recipe. -1 means none is selected. + |- + | Loom + | 0: Selected pattern + | The index of the selected pattern. 0 means none is selected, 0 is also the internal id of the "base" pattern. + |- + | Lectern + | 0: Page number + | The current page number, starting from 0. + |- + | Smithing Table + | 0: Has recipe error + | True if greater than zero. + |} + +For an enchanting table, the following numerical IDs are used: + +{| class="wikitable" + ! Numerical ID + ! Enchantment ID + ! Enchantment Name + |- + | 0 + | minecraft:protection + | Protection + |- + | 1 + | minecraft:fire_protection + | Fire Protection + |- + | 2 + | minecraft:feather_falling + | Feather Falling + |- + | 3 + | minecraft:blast_protection + | Blast Protection + |- + | 4 + | minecraft:projectile_protection + | Projectile Protection + |- + | 5 + | minecraft:respiration + | Respiration + |- + | 6 + | minecraft:aqua_affinity + | Aqua Affinity + |- + | 7 + | minecraft:thorns + | Thorns + |- + | 8 + | minecraft:depth_strider + | Depth Strider + |- + | 9 + | minecraft:frost_walker + | Frost Walker + |- + | 10 + | minecraft:binding_curse + | Curse of Binding + |- + | 11 + | minecraft:soul_speed + | Soul Speed + |- + | 12 + | minecraft:swift_sneak + | Swift Sneak + |- + | 13 + | minecraft:sharpness + | Sharpness + |- + | 14 + | minecraft:smite + | Smite + |- + | 15 + | minecraft:bane_of_arthropods + | Bane of Arthropods + |- + | 16 + | minecraft:knockback + | Knockback + |- + | 17 + | minecraft:fire_aspect + | Fire Aspect + |- + | 18 + | minecraft:looting + | Looting + |- + | 19 + | minecraft:sweeping_edge + | Sweeping Edge + |- + | 20 + | minecraft:efficiency + | Efficiency + |- + | 21 + | minecraft:silk_touch + | Silk Touch + |- + | 22 + | minecraft:unbreaking + | Unbreaking + |- + | 23 + | minecraft:fortune + | Fortune + |- + | 24 + | minecraft:power + | Power + |- + | 25 + | minecraft:punch + | Punch + |- + | 26 + | minecraft:flame + | Flame + |- + | 27 + | minecraft:infinity + | Infinity + |- + | 28 + | minecraft:luck_of_the_sea + | Luck of the Sea + |- + | 29 + | minecraft:lure + | Lure + |- + | 30 + | minecraft:loyalty + | Loyalty + |- + | 31 + | minecraft:impaling + | Impaling + |- + | 32 + | minecraft:riptide + | Riptide + |- + | 33 + | minecraft:channeling + | Channeling + |- + | 34 + | minecraft:multishot + | Multishot + |- + | 35 + | minecraft:quick_charge + | Quick Charge + |- + | 36 + | minecraft:piercing + | Piercing + |- + | 37 + | minecraft:density + | Density + |- + | 38 + | minecraft:breach + | Breach + |- + | 39 + | minecraft:wind_burst + | Wind Burst + |- + | 40 + | minecraft:mending + | Mending + |- + | 41 + | minecraft:vanishing_curse + | Curse of Vanishing + |} + +==== Set Container Slot ==== + +Sent by the server when an item in a slot (in a window) is added/removed. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x14

''resource:''
container_set_slot + | rowspan="4"| Play + | rowspan="4"| Client + | Window ID + | {{Type|VarInt}} + | The window which is being updated. 0 for player inventory. The client ignores any packets targeting a Window ID other than the current one; see below for exceptions. + |- + | State ID + | {{Type|VarInt}} + | A server-managed sequence number used to avoid desynchronization; see [[#Click Container]]. + |- + | Slot + | {{Type|Short}} + | The slot that should be updated. + |- + | Slot Data + | {{Type|Slot}} + | + |} + +If Window ID is 0, the hotbar and offhand slots (slots 36 through 45) may be updated even when a different container window is open. (The vanilla server does not appear to utilize this special case.) Updates are also restricted to those slots when the player is looking at a creative inventory tab other than the survival inventory. (The vanilla server does ''not'' handle this restriction in any way, leading to [https://bugs.mojang.com/browse/MC-242392 MC-242392].) + +If Window ID is -1, the item being dragged with the mouse is set. In this case, State ID and Slot are ignored. + +If Window ID is -2, any slot in the player's inventory can be updated irrespective of the current container window. In this case, State ID is ignored, and the vanilla server uses a bogus value of 0. Used by the vanilla server to implement the [[#Pick Item]] functionality. + +When a container window is open, the server never sends updates targeting Window ID 0—all of the [[Minecraft Wiki:Projects/wiki.vg merge/Inventory|window types]] include slots for the player inventory. The client must automatically apply changes targeting the inventory portion of a container window to the main inventory; the server does not resend them for ID 0 when the window is closed. However, since the armor and offhand slots are only present on ID 0, updates to those slots occurring while a window is open must be deferred by the server until the window's closure. + +==== Cookie Request (play) ==== + +Requests a cookie that was previously stored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x15

''resource:''
cookie_request + | rowspan="1"| Play + | rowspan="1"| Client + | colspan="2"| Key + | colspan="2"| {{Type|Identifier}} + | The identifier of the cookie. + |} + +==== Set Cooldown ==== + +Applies a cooldown period to all items with the given type. Used by the vanilla server with enderpearls. This packet should be sent when the cooldown starts and also when the cooldown ends (to compensate for lag), although the client will end the cooldown automatically. Can be applied to any item, note that interactions still get sent to the server with the item but the client does not play the animation nor attempt to predict results (i.e block placing). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x16

''resource:''
cooldown + | rowspan="2"| Play + | rowspan="2"| Client + | Cooldown Group + | {{Type|Identifier}} + | Identifier of the item (minecraft:stone) or the cooldown group ("use_cooldown" item component) + |- + | Cooldown Ticks + | {{Type|VarInt}} + | Number of ticks to apply a cooldown for, or 0 to clear the cooldown. + |} + +==== Chat Suggestions ==== + +Unused by the vanilla server. Likely provided for custom servers to send chat message completions to clients. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x17

''resource:''
custom_chat_completions + | rowspan="2"| Play + | rowspan="2"| Client + | Action + | {{Type|VarInt}} {{Type|Enum}} + | 0: Add, 1: Remove, 2: Set + |- + | Entries + | {{Type|Prefixed Array}} of {{Type|String}} (32767) + | + |} + +==== Clientbound Plugin Message (play) ==== + +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Plugin channels}} + +Mods and plugins can use this to send their data. Minecraft itself uses several [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channels]]. These internal channels are in the minecraft namespace. + +More information on how it works on [https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/ Dinnerbone's blog]. More documentation about internal and popular registered channels are [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|here]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x18

''resource:''
custom_payload + | rowspan="2"| Play + | rowspan="2"| Client + | Channel + | {{Type|Identifier}} + | Name of the [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channel]] used to send the data. + |- + | Data + | {{Type|Byte Array}} (1048576) + | Any data. The length of this array must be inferred from the packet length. + |} + +In vanilla clients, the maximum data length is 1048576 bytes. + +==== Damage Event ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x19

''resource:''
damage_event + | rowspan="8"| Play + | rowspan="8"| Client + |- + | colspan="2"| Entity ID + | colspan="2"| {{Type|VarInt}} + | The ID of the entity taking damage + |- + | colspan="2"| Source Type ID + | colspan="2"| {{Type|VarInt}} + | The type of damage in the minecraft:damage_type registry, defined by the [[Java Edition protocol#Registry_Data|Registry Data]] packet. + |- + | colspan="2"| Source Cause ID + | colspan="2"| {{Type|VarInt}} + | The ID + 1 of the entity responsible for the damage, if present. If not present, the value is 0 + |- + | colspan="2"| Source Direct ID + | colspan="2"| {{Type|VarInt}} + | The ID + 1 of the entity that directly dealt the damage, if present. If not present, the value is 0. If this field is present: +* and damage was dealt indirectly, such as by the use of a projectile, this field will contain the ID of such projectile; +* and damage was dealt dirctly, such as by manually attacking, this field will contain the same value as Source Cause ID. + |- + | rowspan="3"| Source Position + | X + | rowspan="3"| {{Type|Prefixed Optional}} + | {{Type|Double}} + | rowspan="3"| The vanilla server sends the Source Position when the damage was dealt by the /damage command and a position was specified + |- + | Y + | {{Type|Double}} + |- + | Z + | {{Type|Double}} + |} + +==== Debug Sample ==== + +Sample data that is sent periodically after the client has subscribed with [[#Debug_Sample_Subscription|Debug Sample Subscription]]. + +The vanilla server only sends debug samples to players that are server operators. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x1A

''resource:''
debug_sample + | rowspan="2"| Play + | rowspan="2"| Client + | Sample + | {{Type|Prefixed Array}} of {{Type|Long}} + | Array of type-dependent samples. + |- + | Sample Type + | {{Type|VarInt}} {{Type|Enum}} + | See below. + |} + +Types: + +{| class="wikitable" + ! Id !! Name !! Description + |- + | 0 || Tick time || Four different tick-related metrics, each one represented by one long on the array. +They are measured in nano-seconds, and are as follows: +* 0: Full tick time: Aggregate of the three times below; +* 1: Server tick time: Main server tick logic; +* 2: Tasks time: Tasks scheduled to execute after the main logic; +* 3: Idle time: Time idling to complete the full 50ms tick cycle. +Note that the vanilla client calculates the timings used for min/max/average display by subtracting the idle time from the full tick time. This can cause the displayed values to go negative if the idle time is (nonsensically) greater than the full tick time. + |} + +==== Delete Message ==== + +Removes a message from the client's chat. This only works for messages with signatures, system messages cannot be deleted with this packet. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x1B

''resource:''
delete_chat + | rowspan="2"| Play + | rowspan="2"| Client + | Message ID + | {{Type|VarInt}} + | The message Id + 1, used for validating message signature. The next field is present only when value of this field is equal to 0. + |- + | Signature + | {{Type|Optional}} {{Type|Byte Array}} (256) + | The previous message's signature. Always 256 bytes and not length-prefixed. + |} + +==== Disconnect (play) ==== + +Sent by the server before it disconnects a client. The client assumes that the server has already closed the connection by the time the packet arrives. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x1C

''resource:''
disconnect + | Play + | Client + | Reason + | {{Type|Text Component}} + | Displayed to the client when the connection terminates. + |} + +==== Disguised Chat Message ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +Sends the client a chat message, but without any message signing information. + +The vanilla server uses this packet when the console is communicating with players through commands, such as /say, /tell, /me, among others. + +{| class="wikitable + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x1D

''resource:''
disguised_chat + | rowspan="4"| Play + | rowspan="4"| Client + | Message + | {{Type|Text Component}} + | This is used as the content parameter when formatting the message on the client. + |- + | Chat Type + | {{Type|ID or}} {{Type|Chat Type}} + | Either the type of chat in the minecraft:chat_type registry, defined by the [[Java Edition protocol#Registry_Data|Registry Data]] packet, or an inline definition. + |- + | Sender Name + | {{Type|Text Component}} + | The name of the one sending the message, usually the sender's display name. +This is used as the sender parameter when formatting the message on the client. + |- + | Target Name + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | The name of the one receiving the message, usually the receiver's display name. +This is used as the target parameter when formatting the message on the client. + |} + +==== Entity Event ==== + +Entity statuses generally trigger an animation for an entity. The available statuses vary by the entity's type (and are available to subclasses of that type as well). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x1E

''resource:''
entity_event + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|Int}} + | + |- + | Entity Status + | {{Type|Byte}} {{Type|Enum}} + | See [[Minecraft Wiki:Projects/wiki.vg merge/Entity statuses|Entity statuses]] for a list of which statuses are valid for each type of entity. + |} + +==== Teleport Entity ==== + +{{warning|The Mojang-specified name of this packet was changed in 1.21.2 from teleport_entity to entity_position_sync. There is a new teleport_entity, which this document more appropriately calls [[#Synchronize Vehicle Position|Synchronize Vehicle Position]]. That packet has a different function and will lead to confusing results if used in place of this one.}} + +This packet is sent by the server when an entity moves more than 8 blocks. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="10"| ''protocol:''
0x1F

''resource:''
entity_position_sync + | rowspan="10"| Play + | rowspan="10"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | X + | {{Type|Double}} + | + |- + | Y + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |- + | Velocity X + | {{Type|Double}} + | + |- + | Velocity Y + | {{Type|Double}} + | + |- + | Velocity Z + | {{Type|Double}} + | + |- + | Yaw + | {{Type|Float}} + | Rotation on the X axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Rotation on the Y axis, in degrees. + |- + | On Ground + | {{Type|Boolean}} + | +|} + +==== Explosion ==== + +Sent when an explosion occurs (creepers, TNT, and ghast fireballs). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x20

''resource:''
explode + | rowspan="9"| Play + | rowspan="9"| Client + | colspan="2"| X + | colspan="2"| {{Type|Double}} + | + |- + | colspan="2"| Y + | colspan="2"| {{Type|Double}} + | + |- + | colspan="2"| Z + | colspan="2"| {{Type|Double}} + | + |- + | rowspan="3"| Player Delta Velocity + | X + | rowspan="3"| {{Type|Prefixed Optional}} + | {{Type|Double}} + | rowspan="3"| Velocity difference of the player being pushed by the explosion. + |- + | Y + | {{Type|Double}} + |- + | Z + | {{Type|Double}} + |- + | colspan="2"| Explosion Particle ID + | colspan="2"| {{Type|VarInt}} + | The particle ID listed in [[Minecraft Wiki:Projects/wiki.vg merge/Particles|Particles]]. + |- + | colspan="2"| Explosion Particle Data + | colspan="2"| Varies + | Particle data as specified in [[Minecraft Wiki:Projects/wiki.vg merge/Particles|Particles]]. + |- + | colspan="2"| Explosion Sound + | colspan="2"| {{Type|ID or}} {{Type|Sound Event}} + | ID in the minecraft:sound_event registry, or an inline definition. + |} + +==== Unload Chunk ==== + +Tells the client to unload a chunk column. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x21

''resource:''
forget_level_chunk + | rowspan="2"| Play + | rowspan="2"| Client + | Chunk Z + | {{Type|Int}} + | Block coordinate divided by 16, rounded down. + |- + | Chunk X + | {{Type|Int}} + | Block coordinate divided by 16, rounded down. + |} + +Note: The order is inverted, because the client reads this packet as one big-endian {{Type|Long}}, with Z being the upper 32 bits. + +It is legal to send this packet even if the given chunk is not currently loaded. + +==== Game Event ==== + +Used for a wide variety of game events, from weather to bed use to game mode to demo messages. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x22

''resource:''
game_event + | rowspan="2"| Play + | rowspan="2"| Client + | Event + | {{Type|Unsigned Byte}} + | See below. + |- + | Value + | {{Type|Float}} + | Depends on Event. + |} + +''Events'': + +{| class="wikitable" + ! Event + ! Effect + ! Value + |- + | 0 + | No respawn block available + | Note: Displays message 'block.minecraft.spawn.not_valid' (You have no home bed or charged respawn anchor, or it was obstructed) to the player. + |- + | 1 + | Begin raining + | + |- + | 2 + | End raining + | + |- + | 3 + | Change game mode + | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. + |- + | 4 + | Win game + | 0: Just respawn player.
1: Roll the credits and respawn player.
Note that 1 is only sent by vanilla server when player has not yet achieved advancement "The end?", else 0 is sent. + |- + | 5 + | Demo event + | 0: Show welcome to demo screen.
101: Tell movement controls.
102: Tell jump control.
103: Tell inventory control.
104: Tell that the demo is over and print a message about how to take a screenshot. + |- + | 6 + | Arrow hit player + | Note: Sent when any player is struck by an arrow. + |- + | 7 + | Rain level change + | Note: Seems to change both sky color and lighting.
Rain level ranging from 0 to 1. + |- + | 8 + | Thunder level change + | Note: Seems to change both sky color and lighting (same as Rain level change, but doesn't start rain). It also requires rain to render by vanilla client.
Thunder level ranging from 0 to 1. + |- + | 9 + | Play pufferfish sting sound + |- + | 10 + | Play elder guardian mob appearance (effect and sound) + | + |- + | 11 + | Enable respawn screen + | 0: Enable respawn screen.
1: Immediately respawn (sent when the doImmediateRespawn gamerule changes). + |- + | 12 + | Limited crafting + | 0: Disable limited crafting.
1: Enable limited crafting (sent when the doLimitedCrafting gamerule changes). + |- + | 13 + | Start waiting for level chunks + | Instructs the client to begin the waiting process for the level chunks.
Sent by the server after the level is cleared on the client and is being re-sent (either during the first, or subsequent reconfigurations). + |} + +==== Open Horse Screen ==== + +This packet is used exclusively for opening the horse GUI. [[#Open Screen|Open Screen]] is used for all other GUIs. The client will not open the inventory if the Entity ID does not point to an horse-like animal. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x23

''resource:''
horse_screen_open + | rowspan="3"| Play + | rowspan="3"| Client + | Window ID + | {{Type|VarInt}} + | Same as the field of [[#Open Screen|Open Screen]]. + |- + | Inventory columns count + | {{Type|VarInt}} + | How many columns of horse inventory slots exist in the GUI, 3 slots per column. + |- + | Entity ID + | {{Type|Int}} + | The "owner" entity of the GUI. The client should close the GUI if the owner entity dies or is cleared. + |} + +==== Hurt Animation ==== + +Plays a bobbing animation for the entity receiving damage. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x24

''resource:''
hurt_animation + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | The ID of the entity taking damage + |- + | Yaw + | {{Type|Float}} + | The direction the damage is coming from in relation to the entity + |} + +==== Initialize World Border ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x25

''resource:''
initialize_border + | rowspan="8"| Play + | rowspan="8"| Client + | X + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |- + | Old Diameter + | {{Type|Double}} + | Current length of a single side of the world border, in meters. + |- + | New Diameter + | {{Type|Double}} + | Target length of a single side of the world border, in meters. + |- + | Speed + | {{Type|VarLong}} + | Number of real-time ''milli''seconds until New Diameter is reached. It appears that vanilla server does not sync world border speed to game ticks, so it gets out of sync with server lag. If the world border is not moving, this is set to 0. + |- + | Portal Teleport Boundary + | {{Type|VarInt}} + | Resulting coordinates from a portal teleport are limited to ±value. Usually 29999984. + |- + | Warning Blocks + | {{Type|VarInt}} + | In meters. + |- + | Warning Time + | {{Type|VarInt}} + | In seconds as set by /worldborder warning time. + |} + +The vanilla client determines how solid to display the warning by comparing to whichever is higher, the warning distance or whichever is lower, the distance from the current diameter to the target diameter or the place the border will be after warningTime seconds. In pseudocode: + + +distance = max(min(resizeSpeed * 1000 * warningTime, abs(targetDiameter - currentDiameter)), warningDistance); +if (playerDistance < distance) { + warning = 1.0 - playerDistance / distance; +} else { + warning = 0.0; +} + + +==== Clientbound Keep Alive (play) ==== + +The server will frequently send out a keep-alive, each containing a random ID. The client must respond with the same payload (see [[#Serverbound Keep Alive (play)|Serverbound Keep Alive]]). If the client does not respond to a Keep Alive packet within 15 seconds after it was sent, the server kicks the client. Vice versa, if the server does not send any keep-alives for 20 seconds, the client will disconnect and yields a "Timed out" exception. + +The vanilla server uses a system-dependent time in milliseconds to generate the keep alive ID value. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x26

''resource:''
keep_alive + | Play + | Client + | Keep Alive ID + | {{Type|Long}} + | + |} + +==== Chunk Data and Update Light ==== + +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Chunk Format}} +{{See also|#Unload Chunk}} + +Sent when a chunk comes into the client's view distance, specifying its terrain, lighting and block entities. + +The chunk must be within the view area previously specified with [[#Set Center Chunk|Set Center Chunk]]; see that packet for details. + +It is not strictly necessary to send all block entities in this packet; it is still legal to send them with [[#Block Entity Data|Block Entity Data]] later. +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x27

''resource:''
level_chunk_with_light + | rowspan="4"| Play + | rowspan="4"| Client + | Chunk X + | {{Type|Int}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Chunk Z + | {{Type|Int}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Data + | {{Type|Chunk Data}} + | + |- + | Light + | {{Type|Light Data}} + | + |} + +Unlike the [[#Update Light|Update Light]] packet which uses the same format, setting the bit corresponding to a section to 0 in both of the block light or sky light masks does not appear to be useful, and the results in testing have been highly inconsistent. + +==== World Event ==== + +Sent when a client is to play a sound or particle effect. + +By default, the Minecraft client adjusts the volume of sound effects based on distance. The final boolean field is used to disable this, and instead the effect is played from 2 blocks away in the correct direction. Currently this is only used for effect 1023 (wither spawn), effect 1028 (enderdragon death), and effect 1038 (end portal opening); it is ignored on other effects. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x28

''resource:''
level_event + | rowspan="4"| Play + | rowspan="4"| Client + | Event + | {{Type|Int}} + | The event, see below. + |- + | Location + | {{Type|Position}} + | The location of the event. + |- + | Data + | {{Type|Int}} + | Extra data for certain events, see below. + |- + | Disable Relative Volume + | {{Type|Boolean}} + | See above. + |} + +Events: + +{| class="wikitable" + ! ID + ! Name + ! Data + |- + ! colspan="3"| Sound + |- + | 1000 + | Dispenser dispenses + | + |- + | 1001 + | Dispenser fails to dispense + | + |- + | 1002 + | Dispenser shoots + | + |- + | 1004 + | Firework shot + | + |- + | 1009 + | Fire extinguished + | + |- + | 1010 + | Play record + | An ID in the minecraft:item registry, corresponding to a [[Music Disc|record item]]. If the ID doesn't correspond to a record, the packet is ignored. Any record already being played at the given location is overwritten. See [[Minecraft Wiki:Projects/wiki.vg merge/Data Generators|Data Generators]] for information on item IDs. + |- + | 1011 + | Stop record + | + |- + | 1015 + | Ghast warns + | + |- + | 1016 + | Ghast shoots + | + |- + | 1017 + | Ender dragon shoots + | + |- + | 1018 + | Blaze shoots + | + |- + | 1019 + | Zombie attacks wooden door + | + |- + | 1020 + | Zombie attacks iron door + | + |- + | 1021 + | Zombie breaks wooden door + | + |- + | 1022 + | Wither breaks block + | + |- + | 1023 + | Wither spawned + | + |- + | 1024 + | Wither shoots + | + |- + | 1025 + | Bat takes off + | + |- + | 1026 + | Zombie infects + | + |- + | 1027 + | Zombie villager converted + | + |- + | 1028 + | Ender dragon dies + | + |- + | 1029 + | Anvil destroyed + | + |- + | 1030 + | Anvil used + | + |- + | 1031 + | Anvil lands + | + |- + | 1032 + | Portal travel + | + |- + | 1033 + | Chorus flower grows + | + |- + | 1034 + | Chorus flower dies + | + |- + | 1035 + | Brewing stand brews + | + |- + | 1038 + | End portal created + | + |- + | 1039 + | Phantom bites + | + |- + | 1040 + | Zombie converts to drowned + | + |- + | 1041 + | Husk converts to zombie by drowning + | + |- + | 1042 + | Grindstone used + | + |- + | 1043 + | Book page turned + | + |- + | 1044 + | Smithing table used + | + |- + | 1045 + | Pointed dripstone landing + | + |- + | 1046 + | Lava dripping on cauldron from dripstone + | + |- + | 1047 + | Water dripping on cauldron from dripstone + | + |- + | 1048 + | Skeleton converts to stray + | + |- + | 1049 + | Crafter successfully crafts item + | + |- + | 1050 + | Crafter fails to craft item + | + |- + ! colspan="3"| Particle + |- + | 1500 + | Composter composts + | + |- + | 1501 + | Lava converts block (either water to stone, or removes existing blocks such as torches) + | + |- + | 1502 + | Redstone torch burns out + | + |- + | 1503 + | Ender eye placed in end portal frame + | + |- + | 1504 + | Fluid drips from dripstone + | + |- + | 1505 + | Bone meal particles and sound + | How many particles to spawn. + |- + | 2000 + | Dispenser activation smoke + | Direction, see below. + |- + | 2001 + | Block break + block break sound + | Block state ID (see [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Block state registry|Chunk Format#Block state registry]]). + |- + | 2002 + | Splash potion. Particle effect + glass break sound. + | RGB color as an integer (e.g. 8364543 for #7FA1FF). + |- + | 2003 + | Eye of ender entity break animation — particles and sound + | + |- + | 2004 + | Spawner spawns mob: smoke + flames + | + |- + | 2006 + | Dragon breath + | + |- + | 2007 + | Instant splash potion. Particle effect + glass break sound. + | RGB color as an integer (e.g. 8364543 for #7FA1FF). + |- + | 2008 + | Ender dragon destroys block + | + |- + | 2009 + | Wet sponge vaporizes + | + |- + | 2010 + | Crafter activation smoke + | Direction, see below. + |- + | 2011 + | Bee fertilizes plant + | How many particles to spawn. + |- + | 2012 + | Turtle egg placed + | How many particles to spawn. + |- + | 2013 + | Smash attack (mace) + | How many particles to spawn. + |- + | 3000 + | End gateway spawns + | + |- + | 3001 + | Ender dragon resurrected + | + |- + | 3002 + | Electric spark + | + |- + | 3003 + | Copper apply wax + | + |- + | 3004 + | Copper remove wax + | + |- + | 3005 + | Copper scrape oxidation + | + |- + | 3006 + | Sculk charge + | + |- + | 3007 + | Sculk shrieker shriek + | + |- + | 3008 + | Block finished brushing + | Block state ID (see [[Minecraft Wiki:Projects/wiki.vg merge/Chunk Format#Block state registry|Chunk Format#Block state registry]]) + |- + | 3009 + | Sniffer egg cracks + | If 1, 3-6, if any other number, 1-3 particles will be spawned. + |- + | 3011 + | Trial spawner spawns mob (at spawner) + | + |- + | 3012 + | Trial spawner spawns mob (at spawn location) + | + |- + | 3013 + | Trial spawner detects player + | Number of players nearby + |- + | 3014 + | Trial spawner ejects item + | + |- + | 3015 + | Vault activates + | + |- + | 3016 + | Vault deactivates + | + |- + | 3017 + | Vault ejects item + | + |- + | 3018 + | Cobweb weaved + | + |- + | 3019 + | Ominous trial spawner detects player + | Number of players nearby + |- + | 3020 + | Trial spawner turns ominous + | If 0, the sound will be played at 0.3 volume. Otherwise, it is played at full volume. + |- + | 3021 + | Ominous item spawner spawns item + | + |} + +Smoke directions: + +{| class="wikitable" + ! ID + ! Direction + |- + | 0 + | Down + |- + | 1 + | Up + |- + | 2 + | North + |- + | 3 + | South + |- + | 4 + | West + |- + | 5 + | East + |} + +==== Particle ==== + +Displays the named particle + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="12"| ''protocol:''
0x29

''resource:''
level_particles + | rowspan="12"| Play + | rowspan="12"| Client + | Long Distance + | {{Type|Boolean}} + | If true, particle distance increases from 256 to 65536. + |- + | Always Visible + | {{Type|Boolean}} + | Whether this particle should always be visible. + |- + | X + | {{Type|Double}} + | X position of the particle. + |- + | Y + | {{Type|Double}} + | Y position of the particle. + |- + | Z + | {{Type|Double}} + | Z position of the particle. + |- + | Offset X + | {{Type|Float}} + | This is added to the X position after being multiplied by random.nextGaussian(). + |- + | Offset Y + | {{Type|Float}} + | This is added to the Y position after being multiplied by random.nextGaussian(). + |- + | Offset Z + | {{Type|Float}} + | This is added to the Z position after being multiplied by random.nextGaussian(). + |- + | Max Speed + | {{Type|Float}} + | + |- + | Particle Count + | {{Type|Int}} + | The number of particles to create. + |- + | Particle ID + | {{Type|VarInt}} + | The particle ID listed in [[Minecraft Wiki:Projects/wiki.vg merge/Particles|Particles]]. + |- + | Data + | Varies + | Particle data as specified in [[Minecraft Wiki:Projects/wiki.vg merge/Particles|Particles]]. + |} + +==== Update Light ==== + +Updates light levels for a chunk. See [[Light]] for information on how lighting works in Minecraft. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x2A

''resource:''
light_update + | rowspan="3"| Play + | rowspan="3"| Client + | Chunk X + | {{Type|VarInt}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Chunk Z + | {{Type|VarInt}} + | Chunk coordinate (block coordinate divided by 16, rounded down) + |- + | Data + | {{Type|Light Data}} + | + |} + +A bit will never be set in both the block light mask and the empty block light mask, though it may be present in neither of them (if the block light does not need to be updated for the corresponding chunk section). The same applies to the sky light mask and the empty sky light mask. + +==== Login (play) ==== + +See [[protocol encryption]] for information on logging in. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="22"| ''protocol:''
0x2B

''resource:''
login + | rowspan="22"| Play + | rowspan="22"| Client + | Entity ID + | {{Type|Int}} + | The player's Entity ID (EID). + |- + | Is hardcore + | {{Type|Boolean}} + | + |- + | Dimension Names + | {{Type|Prefixed Array}} of {{Type|Identifier}} + | Identifiers for all dimensions on the server. + |- + | Max Players + | {{Type|VarInt}} + | Was once used by the client to draw the player list, but now is ignored. + |- + | View Distance + | {{Type|VarInt}} + | Render distance (2-32). + |- + | Simulation Distance + | {{Type|VarInt}} + | The distance that the client will process specific things, such as entities. + |- + | Reduced Debug Info + | {{Type|Boolean}} + | If true, a vanilla client shows reduced information on the [[debug screen]]. For servers in development, this should almost always be false. + |- + | Enable respawn screen + | {{Type|Boolean}} + | Set to false when the doImmediateRespawn gamerule is true. + |- + | Do limited crafting + | {{Type|Boolean}} + | Whether players can only craft recipes they have already unlocked. Currently unused by the client. + |- + | Dimension Type + | {{Type|VarInt}} + | The ID of the type of dimension in the minecraft:dimension_type registry, defined by the Registry Data packet. + |- + | Dimension Name + | {{Type|Identifier}} + | Name of the dimension being spawned into. + |- + | Hashed seed + | {{Type|Long}} + | First 8 bytes of the SHA-256 hash of the world's seed. Used client side for biome noise + |- + | Game mode + | {{Type|Unsigned Byte}} + | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. + |- + | Previous Game mode + | {{Type|Byte}} + | -1: Undefined (null), 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. The previous game mode. Vanilla client uses this for the debug (F3 + N & F3 + F4) game mode switch. (More information needed) + |- + | Is Debug + | {{Type|Boolean}} + | True if the world is a [[debug mode]] world; debug mode worlds cannot be modified and have predefined blocks. + |- + | Is Flat + | {{Type|Boolean}} + | True if the world is a [[superflat]] world; flat worlds have different void fog and a horizon at y=0 instead of y=63. + |- + | Has death location + | {{Type|Boolean}} + | If true, then the next two fields are present. + |- + | Death dimension name + | {{Type|Optional}} {{Type|Identifier}} + | Name of the dimension the player died in. + |- + | Death location + | {{Type|Optional}} {{Type|Position}} + | The location that the player died at. + |- + | Portal cooldown + | {{Type|VarInt}} + | The number of ticks until the player can use the last used portal again. Looks like it's an attempt to fix MC-180. + |- + | Sea level + | {{Type|VarInt}} + | + |- + | Enforces Secure Chat + | {{Type|Boolean}} + | + |} + +==== Map Data ==== + +Updates a rectangular area on a [[map]] item. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="13"| ''protocol:''
0x2C

''resource:''
map_item_data + | rowspan="13"| Play + | rowspan="13"| Client + | colspan="2"| Map ID + | colspan="2"| {{Type|VarInt}} + | Map ID of the map being modified + |- + | colspan="2"| Scale + | colspan="2"| {{Type|Byte}} + | From 0 for a fully zoomed-in map (1 block per pixel) to 4 for a fully zoomed-out map (16 blocks per pixel) + |- + | colspan="2"| Locked + | colspan="2"| {{Type|Boolean}} + | True if the map has been locked in a cartography table + |- + | rowspan="5"| Icons + | Type + | rowspan="5"| {{Type|Prefixed Optional}} {{Type|Prefixed Array}} + | {{Type|VarInt}} {{Type|Enum}} + | See below + |- + | X + | {{Type|Byte}} + | Map coordinates: -128 for furthest left, +127 for furthest right + |- + | Z + | {{Type|Byte}} + | Map coordinates: -128 for highest, +127 for lowest + |- + | Direction + | {{Type|Byte}} + | 0-15 + |- + | Display Name + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | + |- + | rowspan="5"| Color Patch + | Columns + | colspan="2"| {{Type|Unsigned Byte}} + | Number of columns updated + |- + | Rows + | colspan="2"| {{Type|Optional}} {{Type|Unsigned Byte}} + | Only if Columns is more than 0; number of rows updated + |- + | X + | colspan="2"| {{Type|Optional}} {{Type|Unsigned Byte}} + | Only if Columns is more than 0; x offset of the westernmost column + |- + | Z + | colspan="2"| {{Type|Optional}} {{Type|Unsigned Byte}} + | Only if Columns is more than 0; z offset of the northernmost row + |- + | Data + | colspan="2"| {{Type|Optional}} {{Type|Prefixed Array}} of {{Type|Unsigned Byte}} + | Only if Columns is more than 0; see [[Map item format]] + |} + +For icons, a direction of 0 is a vertical icon and increments by 22.5° (360/16). + +Types are based off of rows and columns in map_icons.png: + +{| class="wikitable" + |- + ! Icon type + ! Result + |- + | 0 + | White arrow (players) + |- + | 1 + | Green arrow (item frames) + |- + | 2 + | Red arrow + |- + | 3 + | Blue arrow + |- + | 4 + | White cross + |- + | 5 + | Red pointer + |- + | 6 + | White circle (off-map players) + |- + | 7 + | Small white circle (far-off-map players) + |- + | 8 + | Mansion + |- + | 9 + | Monument + |- + | 10 + | White Banner + |- + | 11 + | Orange Banner + |- + | 12 + | Magenta Banner + |- + | 13 + | Light Blue Banner + |- + | 14 + | Yellow Banner + |- + | 15 + | Lime Banner + |- + | 16 + | Pink Banner + |- + | 17 + | Gray Banner + |- + | 18 + | Light Gray Banner + |- + | 19 + | Cyan Banner + |- + | 20 + | Purple Banner + |- + | 21 + | Blue Banner + |- + | 22 + | Brown Banner + |- + | 23 + | Green Banner + |- + | 24 + | Red Banner + |- + | 25 + | Black Banner + |- + | 26 + | Treasure marker + |- + | 27 + | Desert Village + |- + | 28 + | Plains Village + |- + | 29 + | Savanna Village + |- + | 30 + | Snowy Village + |- + | 31 + | Taiga Village + |- + | 32 + | Jungle Temple + |- + | 33 + | Swamp Hut + |- + | 34 + | Trial Chambers + |} + +==== Merchant Offers ==== + +The list of trades a villager NPC is offering. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="15"| ''protocol:''
0x2D

''resource:''
merchant_offers + | rowspan="15"| Play + | rowspan="15"| Client + | colspan="2"| Window ID + | colspan="2"| {{Type|VarInt}} + | The ID of the window that is open; this is an int rather than a byte. + |- + | rowspan="10"| Trades + | Input item 1 + | rowspan="10"| {{Type|Prefixed Array}} + | Trade Item + | See below. The first item the player has to supply for this villager trade. The count of the item stack is the default "price" of this trade. + |- + | Output item + | {{Type|Slot}} + | The item the player will receive from this villager trade. + |- + | Input item 2 + | {{Type|Prefixed Optional}} Trade Item + | The second item the player has to supply for this villager trade. + |- + | Trade disabled + | {{Type|Boolean}} + | True if the trade is disabled; false if the trade is enabled. + |- + | Number of trade uses + | {{Type|Int}} + | Number of times the trade has been used so far. If equal to the maximum number of trades, the client will display a red X. + |- + | Maximum number of trade uses + | {{Type|Int}} + | Number of times this trade can be used before it's exhausted. + |- + | XP + | {{Type|Int}} + | Amount of XP the villager will earn each time the trade is used. + |- + | Special Price + | {{Type|Int}} + | Can be zero or negative. The number is added to the price when an item is discounted due to player reputation or other effects. + |- + | Price Multiplier + | {{Type|Float}} + | Can be low (0.05) or high (0.2). Determines how much demand, player reputation, and temporary effects will adjust the price. + |- + | Demand + | {{Type|Int}} + | If positive, causes the price to increase. Negative values seem to be treated the same as zero. + |- + | colspan="2"| Villager level + | colspan="2"| {{Type|VarInt}} + | Appears on the trade GUI; meaning comes from the translation key merchant.level. + level. +1: Novice, 2: Apprentice, 3: Journeyman, 4: Expert, 5: Master. + |- + | colspan="2"| Experience + | colspan="2"| {{Type|VarInt}} + | Total experience for this villager (always 0 for the wandering trader). + |- + | colspan="2"| Is regular villager + | colspan="2"| {{Type|Boolean}} + | True if this is a regular villager; false for the wandering trader. When false, hides the villager level and some other GUI elements. + |- + | colspan="2"| Can restock + | colspan="2"| {{Type|Boolean}} + | True for regular villagers and false for the wandering trader. If true, the "Villagers restock up to two times per day." message is displayed when hovering over disabled trades. + |} + +Trade Item: +{| class="wikitable" + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Meaning + |- + | colspan="2"| Item ID + | colspan="2"| {{Type|VarInt}} + | The [[Java Edition data values#Blocks|item ID]]. Item IDs are distinct from block IDs; see [[Minecraft Wiki:Projects/wiki.vg merge/Data Generators|Data Generators]] for more information. + |- + | colspan="2"| Item Count + | colspan="2"| {{Type|VarInt}} + | The item count. + |- + | rowspan="2"| Components + | Component type + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|VarInt}} {{Type|Enum}} + | The type of component. See [[Java_Edition_protocol/Slot_Data#Structured_components|Structured components]] for more detail. + |- + | Component data + | Varies + | The component-dependent data. See [[Java_Edition_protocol/Slot_Data#Structured_components|Structured components]] for more detail. + |- + |} + +Modifiers can increase or decrease the number of items for the first input slot. The second input slot and the output slot never change the number of items. The number of items may never be less than 1, and never more than the stack size. If special price and demand are both zero, only the default price is displayed. If either is non-zero, then the adjusted price is displayed next to the crossed-out default price. The adjusted prices is calculated as follows: + +Adjusted price = default price + floor(default price x multiplier x demand) + special price + +[[File:1.14-merchant-slots.png|thumb|The merchant UI, for reference]] +{{-}} + +==== Update Entity Position ==== + +This packet is sent by the server when an entity moves a small distance. The change in position is represented as a [[#Fixed-point numbers|fixed-point number]] with 12 fraction bits and 4 integer bits. As such, the maximum movement distance along each axis is 8 blocks in the negative direction, or 7.999755859375 blocks in the positive direction. If the movement exceeds these limits, [[#Teleport Entity|Teleport Entity]] should be sent instead. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x2E

''resource:''
move_entity_pos + | rowspan="5"| Play + | rowspan="5"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Delta X + | {{Type|Short}} + | Change in X position as currentX * 4096 - prevX * 4096. + |- + | Delta Y + | {{Type|Short}} + | Change in Y position as currentY * 4096 - prevY * 4096. + |- + | Delta Z + | {{Type|Short}} + | Change in Z position as currentZ * 4096 - prevZ * 4096. + |- + | On Ground + | {{Type|Boolean}} + | + |} + +==== Update Entity Position and Rotation ==== + +This packet is sent by the server when an entity rotates and moves. See [[#Update Entity Position]] for how the position is encoded. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="7"| ''protocol:''
0x2F

''resource:''
move_entity_pos_rot + | rowspan="7"| Play + | rowspan="7"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Delta X + | {{Type|Short}} + | Change in X position as currentX * 4096 - prevX * 4096. + |- + | Delta Y + | {{Type|Short}} + | Change in Y position as currentY * 4096 - prevY * 4096. + |- + | Delta Z + | {{Type|Short}} + | Change in Z position as currentZ * 4096 - prevZ * 4096. + |- + | Yaw + | {{Type|Angle}} + | New angle, not a delta. + |- + | Pitch + | {{Type|Angle}} + | New angle, not a delta. + |- + | On Ground + | {{Type|Boolean}} + | + |} + +==== Move Minecart Along Track ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! colspan="2"| Notes + |- + | rowspan="10"| ''protocol:''
0x30

''resource:''
move_minecart_along_track + | rowspan="10"| Play + | rowspan="10"| Client + | colspan="2"| Entity ID + | colspan="2"| {{Type|VarInt}} + | + |- + | rowspan="9"| Steps + | X + | rowspan="9"| {{Type|Prefixed Array}} + | {{Type|Double}} + | + |- + | Y + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |- + | Velocity X + | {{Type|Double}} + | + |- + | Velocity Y + | {{Type|Double}} + | + |- + | Velocity Z + | {{Type|Double}} + | + |- + | Yaw + | {{Type|Angle}} + | + |- + | Pitch + | {{Type|Angle}} + | + |- + | Weight + | {{Type|Float}} +|} + +==== Update Entity Rotation ==== + +This packet is sent by the server when an entity rotates. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x31

''resource:''
move_entity_rot + | rowspan="4"| Play + | rowspan="4"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Yaw + | {{Type|Angle}} + | New angle, not a delta. + |- + | Pitch + | {{Type|Angle}} + | New angle, not a delta. + |- + | On Ground + | {{Type|Boolean}} + | + |} + +==== Move Vehicle ==== + +Note that all fields use absolute positioning and do not allow for relative positioning. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x32

''resource:''
move_vehicle + | rowspan="5"| Play + | rowspan="5"| Client + | X + | {{Type|Double}} + | Absolute position (X coordinate). + |- + | Y + | {{Type|Double}} + | Absolute position (Y coordinate). + |- + | Z + | {{Type|Double}} + | Absolute position (Z coordinate). + |- + | Yaw + | {{Type|Float}} + | Absolute rotation on the vertical axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Absolute rotation on the horizontal axis, in degrees. + |} + +==== Open Book ==== + +Sent when a player right clicks with a signed book. This tells the client to open the book GUI. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x33

''resource:''
open_book + | Play + | Client + | Hand + | {{Type|VarInt}} {{Type|Enum}} + | 0: Main hand, 1: Off hand . + |} + +==== Open Screen ==== + +This is sent to the client when it should open an inventory, such as a chest, workbench, furnace, or other container. Resending this packet with already existing window id, will update the window title and window type without closing the window. + +This message is not sent to clients opening their own inventory, nor do clients inform the server in any way when doing so. From the server's perspective, the inventory is always "open" whenever no other windows are. + +For horses, use [[#Open Horse Screen|Open Horse Screen]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x34

''resource:''
open_screen + | rowspan="3"| Play + | rowspan="3"| Client + | Window ID + | {{Type|VarInt}} + | An identifier for the window to be displayed. vanilla server implementation is a counter, starting at 1. There can only be one window at a time; this is only used to ignore outdated packets targeting already-closed windows. Note also that the Window ID field in most other packets is only a single byte, and indeed, the vanilla server wraps around after 100. + |- + | Window Type + | {{Type|VarInt}} + | The window type to use for display. Contained in the minecraft:menu registry; see [[Minecraft Wiki:Projects/wiki.vg merge/Inventory|Inventory]] for the different values. + |- + | Window Title + | {{Type|Text Component}} + | The title of the window. + |} + +==== Open Sign Editor ==== + +Sent when the client has placed a sign and is allowed to send [[#Update Sign|Update Sign]]. There must already be a sign at the given location (which the client does not do automatically) - send a [[#Block Update|Block Update]] first. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2" | ''protocol:''
0x35

''resource:''
open_sign_editor + | rowspan="2" | Play + | rowspan="2" | Client + | Location + | {{Type|Position}} + | + |- + | Is Front Text + | {{Type|Boolean}} + | Whether the opened editor is for the front or on the back of the sign + |} + +==== Ping (play) ==== + +Packet is not used by the vanilla server. When sent to the client, client responds with a [[#Pong (play)|Pong]] packet with the same id. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x36

''resource:''
ping + | Play + | Client + | ID + | {{Type|Int}} + | + |} + +==== Ping Response (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x37

''resource:''
pong_response + | Play + | Client + | Payload + | {{Type|Long}} + | Should be the same as sent by the client. + |} + +==== Place Ghost Recipe ==== + +Response to the serverbound packet ([[#Place Recipe|Place Recipe]]), with the same recipe ID. Appears to be used to notify the UI. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x38

''resource:''
place_ghost_recipe + | rowspan="2"| Play + | rowspan="2"| Client + | Window ID + | {{Type|VarInt}} + | + |- + | Recipe Display + | {{Type|Recipe Display}} + | + |} + +==== Player Abilities (clientbound) ==== + +The latter 2 floats are used to indicate the flying speed and field of view respectively, while the first byte is used to determine the value of 4 booleans. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x39

''resource:''
player_abilities + | rowspan="3"| Play + | rowspan="3"| Client + | Flags + | {{Type|Byte}} + | Bit field, see below. + |- + | Flying Speed + | {{Type|Float}} + | 0.05 by default. + |- + | Field of View Modifier + | {{Type|Float}} + | Modifies the field of view, like a speed potion. A vanilla server will use the same value as the movement speed sent in the [[#Update Attributes|Update Attributes]] packet, which defaults to 0.1 for players. + |} + +About the flags: + +{| class="wikitable" + |- + ! Field + ! Bit + |- + | Invulnerable + | 0x01 + |- + | Flying + | 0x02 + |- + | Allow Flying + | 0x04 + |- + | Creative Mode (Instant Break) + | 0x08 + |} + +If Flying is set but Allow Flying is unset, the player is unable to stop flying. + +==== Player Chat Message ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +Sends the client a chat message from a player. + +Currently a lot is unknown about this packet, blank descriptions are for those that are unknown + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Sector + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="15"| ''protocol:''
0x3A

''resource:''
player_chat + | rowspan="15"| Play + | rowspan="15"| Client + | rowspan="4"| Header + | colspan="2"| Global Index + | {{Type|VarInt}} + | + |- + | colspan="2"| Sender + | {{Type|UUID}} + | Used by the vanilla client for the disableChat launch option. Setting both longs to 0 will always display the message regardless of the setting. + |- + | colspan="2"| Index + | {{Type|VarInt}} + | + |- + | colspan="2"| Message Signature bytes + | {{Type|Prefixed Optional}} {{Type|Byte Array}} (256) + | Cryptography, the signature consists of the Sender UUID, Session UUID from the [[#Player Session|Player Session]] packet, Index, Salt, Timestamp in epoch seconds, the length of the original chat content, the original content itself, the length of Previous Messages, and all of the Previous message signatures. These values are hashed with [https://en.wikipedia.org/wiki/SHA-2 SHA-256] and signed using the [https://en.wikipedia.org/wiki/RSA_(cryptosystem) RSA] cryptosystem. Modifying any of these values in the packet will cause this signature to fail. This buffer is always 256 bytes long and it is not length-prefixed. + |- + | rowspan="3"| Body + | colspan="2"| Message + | {{Type|String}} (256) + | Raw (optionally) signed sent message content. +This is used as the content parameter when formatting the message on the client. + |- + | colspan="2"| Timestamp + | {{Type|Long}} + | Represents the time the message was signed as milliseconds since the [https://en.wikipedia.org/wiki/Unix_time epoch], used to check if the message was received within 2 minutes of it being sent. + |- + | colspan="2"| Salt + | {{Type|Long}} + | Cryptography, used for validating the message signature. + |- + | rowspan="2"| {{Type|Prefixed Array}} (20) + | Message ID + | {{Type|VarInt}} + | The message Id + 1, used for validating message signature. The next field is present only when value of this field is equal to 0. + |- + | Signature + | {{Type|Optional}} {{Type|Byte Array}} (256) + | The previous message's signature. Contains the same type of data as Message Signature bytes (256 bytes) above. Not length-prefxied. + |- + | rowspan="3"| Other + | colspan="2"| Unsigned Content + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | + |- + | colspan="2"| Filter Type + | {{Type|VarInt}} {{Type|Enum}} + | If the message has been filtered + |- + | colspan="2"| Filter Type Bits + | {{Type|Optional}} {{Type|BitSet}} + | Only present if the Filter Type is Partially Filtered. Specifies the indexes at which characters in the original message string should be replaced with the # symbol (i.e. filtered) by the vanilla client + |- + | rowspan="3"| Chat Formatting + | colspan="2"| Chat Type + | {{Type|ID or}} {{Type|Chat Type}} + | Either the type of chat in the minecraft:chat_type registry, defined by the [[Java Edition protocol#Registry_Data|Registry Data]] packet, or an inline definition. + |- + | colspan="2"| Sender Name + | {{Type|Text Component}} + | The name of the one sending the message, usually the sender's display name. +This is used as the sender parameter when formatting the message on the client. + |- + | colspan="2"| Target Name + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | The name of the one receiving the message, usually the receiver's display name. +This is used as the target parameter when formatting the message on the client. + |} +[[File:MinecraftChat.drawio4.png|thumb|Player Chat Handling Logic]] + +Filter Types: + +The filter type mask should NOT be specified unless partially filtered is selected + +{| class="wikitable" + ! ID + ! Name + ! Description + |- + | 0 + | PASS_THROUGH + | Message is not filtered at all + |- + | 1 + | FULLY_FILTERED + | Message is fully filtered + |- + | 2 + | PARTIALLY_FILTERED + | Only some characters in the message are filtered + |} + +==== End Combat ==== + +Unused by the vanilla client. This data was once used for twitch.tv metadata circa 1.8. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x3B

''resource:''
player_combat_end + | rowspan="1"| Play + | rowspan="1"| Client + | Duration + | {{Type|VarInt}} + | Length of the combat in ticks. + |} + +==== Enter Combat ==== + +Unused by the vanilla client. This data was once used for twitch.tv metadata circa 1.8. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x3C

''resource:''
player_combat_enter + | rowspan="1"| Play + | rowspan="1"| Client + | colspan="3"| ''no fields'' + |} + +==== Combat Death ==== + +Used to send a respawn screen. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x3D

''resource:''
player_combat_kill + | rowspan="2"| Play + | rowspan="2"| Client + | Player ID + | {{Type|VarInt}} + | Entity ID of the player that died (should match the client's entity ID). + |- + | Message + | {{Type|Text Component}} + | The death message. + |} + +==== Player Info Remove ==== + +Used by the server to remove players from the player list. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x3E

''resource:''
player_info_remove + | Play + | Client + | UUIDs + | {{Type|Prefixed Array}} of {{Type|UUID}} + | UUIDs of players to remove. + |} + +==== Player Info Update ==== + +Sent by the server to update the user list ( in the client). + +{{Warning|The EnumSet type is only used here and it is currently undocumented}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x3F

''resource:''
player_info_update + | rowspan="3"| Play + | rowspan="3"| Client + | colspan="2"| Actions + | colspan="2"| {{Type|EnumSet}} + | Determines what actions are present. + |- + | rowspan="2" | Players + | UUID + | rowspan="2" | {{Type|Prefixed Array}} + | {{Type|UUID}} + | The player UUID + |- + | Player Actions + | {{Type|Array}} of [[#player-info:player-actions|Player Actions]] + | The length of this array is determined by the number of [[#player-info:player-actions|Player Actions]] that give a non-zero value when applying its mask to the actions flag. For example given the decimal number 5, binary 00000101. The masks 0x01 and 0x04 would return a non-zero value, meaning the Player Actions array would include two actions: Add Player and Update Game Mode. + |} + + +{| class="wikitable" + |+ id="player-info:player-actions" | Player Actions + ! Action + ! Mask + ! colspan="2" | Field Name + ! colspan="2" | Type + ! Notes + |- + | rowspan="4" | Add Player + | rowspan="4" | 0x01 + | colspan="2" | Name + | colspan="2" | {{Type|String}} (16) + |- + | rowspan="3" | Property + | Name + | rowspan="3"| {{Type|Prefixed Array}} (16) + | {{Type|String}} (64) + | + |- + | Value + | {{Type|String}} (32767) + | + |- + | Signature + | {{Type|Prefixed Optional}} {{Type|String}} (1024) + | + |- + | rowspan="4" | Initialize Chat + | rowspan="4" | 0x02 + | rowspan="4" | Data + | Chat session ID + | rowspan="4" | {{Type|Prefixed Optional}} + | {{Type|UUID}} + | + |- + | Public key expiry time + | {{Type|Long}} + | Key expiry time, as a UNIX timestamp in milliseconds. Only sent if Has Signature Data is true. + |- + | Encoded public key + | {{Type|Prefixed Array}} (512) of {{Type|Byte}} + | The player's public key, in bytes. Only sent if Has Signature Data is true. + |- + | Public key signature + | {{Type|Prefixed Array}} (4096) of {{Type|Byte}} + | The public key's digital signature. Only sent if Has Signature Data is true. + |- + | Update Game Mode + | 0x04 + | colspan="2" | Game Mode + | colspan="2" | {{Type|VarInt}} + |- + | Update Listed + | 0x08 + | colspan="2" | Listed + | colspan="2" | {{Type|Boolean}} + | Whether the player should be listed on the player list. + |- + | Update Latency + | 0x10 + | colspan="2" | Ping + | colspan="2" | {{Type|VarInt}} + | Measured in milliseconds. + |- + | Update Display Name + | 0x20 + | colspan="2" | Display Name + | colspan="2" | {{Type|Prefixed Optional}} {{Type|Text Component}} + | Only sent if Has Display Name is true. + |- + | Update List Priority + | 0x40 + | colspan="2" | Priority + | colspan="2" | {{Type|VarInt}} + | See below. + |- + | Update Hat + | 0x80 + | colspan="2" | Visible + | colspan="2" | {{Type|Boolean}} + | Whether the player's hat skin layer is shown. + |} + +The properties included in this packet are the same as in [[#Login Success|Login Success]], for the current player. + +Ping values correspond with icons in the following way: +* A ping that negative (i.e. not known to the server yet) will result in the no connection icon. +* A ping under 150 milliseconds will result in 5 bars +* A ping under 300 milliseconds will result in 4 bars +* A ping under 600 milliseconds will result in 3 bars +* A ping under 1000 milliseconds (1 second) will result in 2 bars +* A ping greater than or equal to 1 second will result in 1 bar. + +The order of players in the player list is determined as follows: +* Players with higher priorities are sorted before those with lower priorities. +* Among players of equal priorities, spectators are sorted after non-spectators. +* Within each of those groups, players are sorted into teams. The teams are ordered case-sensitively by team name in ascending order. Players with no team are listed first. +* The players of each team (and non-team) are sorted case-insensitively by name in ascending order. + +==== Look At ==== + +Used to rotate the client player to face the given location or entity (for /teleport [] facing). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x40

''resource:''
player_look_at + | rowspan="8"| Play + | rowspan="8"| Client + |- + | Feet/eyes + | {{Type|VarInt}} {{Type|Enum}} + | Values are feet=0, eyes=1. If set to eyes, aims using the head position; otherwise aims using the feet position. + |- + | Target x + | {{Type|Double}} + | x coordinate of the point to face towards. + |- + | Target y + | {{Type|Double}} + | y coordinate of the point to face towards. + |- + | Target z + | {{Type|Double}} + | z coordinate of the point to face towards. + |- + | Is entity + | {{Type|Boolean}} + | If true, additional information about an entity is provided. + |- + | Entity ID + | {{Type|Optional}} {{Type|VarInt}} + | Only if is entity is true — the entity to face towards. + |- + | Entity feet/eyes + | {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}} + | Whether to look at the entity's eyes or feet. Same values and meanings as before, just for the entity's head/feet. + |} + +If the entity given by entity ID cannot be found, this packet should be treated as if is entity was false. + +==== Synchronize Player Position ==== + +Teleports the client, e.g. during login, when using an ender pearl, in response to invalid move packets, etc. + +Due to latency, the server may receive outdated movement packets sent before the client was aware of the teleport. To account for this, the server ignores all movement packets from the client until a [[#Confirm Teleportation|Confirm Teleportation]] packet with an ID matching the one sent in the teleport packet is received. + +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 counterclockwise, with 90 at (-1, 0), 180 at (0, -1) and 270 at (1, 0). Additionally, yaw is not clamped to between 0 and 360 degrees; any number is valid, including negative numbers and numbers greater than 360 (see [https://bugs.mojang.com/browse/MC-90097 MC-90097]). + +Pitch is measured in degrees, where 0 is looking straight ahead, -90 is looking straight up, and 90 is looking straight down. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="10"| ''protocol:''
0x41

''resource:''
player_position + | rowspan="10"| Play + | rowspan="10"| Client + | Teleport ID + | {{Type|VarInt}} + | Client should confirm this packet with [[#Confirm Teleportation|Confirm Teleportation]] containing the same Teleport ID. + |- + | X + | {{Type|Double}} + | Absolute or relative position, depending on Flags. + |- + | Y + | {{Type|Double}} + | Absolute or relative position, depending on Flags. + |- + | Z + | {{Type|Double}} + | Absolute or relative position, depending on Flags. + |- + | Velocity X + | {{Type|Double}} + | + |- + | Velocity Y + | {{Type|Double}} + | + |- + | Velocity Z + | {{Type|Double}} + | + |- + | Yaw + | {{Type|Float}} + | Absolute or relative rotation on the X axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Absolute or relative rotation on the Y axis, in degrees. + |- + | Flags + | {{Type|Teleport Flags}} + | + |} + +==== Player Rotation ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x42

''resource:''
player_rotation + | rowspan="2"| Play + | rowspan="2"| Client + | Yaw + | {{Type|Float}} + | Rotation on the X axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Rotation on the Y axis, in degrees. + |} + +==== Recipe Book Add ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! colspan="2"| Notes + |- + | rowspan="7"| ''protocol:''
0x43

''resource:''
recipe_book_add + | rowspan="7"| Play + | rowspan="7"| Client + | rowspan="6"| Recipes + | Recipe ID + | rowspan="6"| {{Type|Prefixed Array}} + | {{Type|VarInt}} + | ID to assign to the recipe. + |- + | Display + | {{Type|Recipe Display}} + | + |- + | Group ID + | {{Type|VarInt}} + | + |- + | Category ID + | {{Type|VarInt}} + | ID in the minecraft:recipe_book_category registry. + |- + | Ingredients + | {{Type|Prefixed Optional}} {{Type|Prefixed Array}} of {{Type|ID Set}} + | IDs in the minecraft:item registry, or an inline definition. + |- + | Flags + | {{Type|Byte}} + | 0x01: show notification; 0x02: highlight as new + |- + | colspan="2"| Replace + | colspan="2"| {{Type|Boolean}} + | Replace or Add to known recipes + |} + +==== Recipe Book Remove ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x44

''resource:''
recipe_book_remove + | Play + | Client + | Recipes + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | IDs of recipes to remove. + |} + +==== Recipe Book Settings ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x45

''resource:''
recipe_book_settings + | rowspan="8"| Play + | rowspan="8"| Client + | Crafting Recipe Book Open + | {{Type|Boolean}} + | If true, then the crafting recipe book will be open when the player opens its inventory. + |- + | Crafting Recipe Book Filter Active + | {{Type|Boolean}} + | If true, then the filtering option is active when the players opens its inventory. + |- + | Smelting Recipe Book Open + | {{Type|Boolean}} + | If true, then the smelting recipe book will be open when the player opens its inventory. + |- + | Smelting Recipe Book Filter Active + | {{Type|Boolean}} + | If true, then the filtering option is active when the players opens its inventory. + |- + | Blast Furnace Recipe Book Open + | {{Type|Boolean}} + | If true, then the blast furnace recipe book will be open when the player opens its inventory. + |- + | Blast Furnace Recipe Book Filter Active + | {{Type|Boolean}} + | If true, then the filtering option is active when the players opens its inventory. + |- + | Smoker Recipe Book Open + | {{Type|Boolean}} + | If true, then the smoker recipe book will be open when the player opens its inventory. + |- + | Smoker Recipe Book Filter Active + | {{Type|Boolean}} + | If true, then the filtering option is active when the players opens its inventory. + |} + +==== Remove Entities ==== + +Sent by the server when an entity is to be destroyed on the client. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x46

''resource:''
remove_entities + | Play + | Client + | Entity IDs + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | The list of entities to destroy. + |} + +==== Remove Entity Effect ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x47

''resource:''
remove_mob_effect + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Effect ID + | {{Type|VarInt}} + | See [[Status effect#Effect list|this table]]. + |} + +==== Reset Score ==== + +This is sent to the client when it should remove a scoreboard item. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x48

''resource:''
reset_score + | rowspan="2"| Play + | rowspan="2"| Client + | Entity Name + | {{Type|String}} (32767) + | The entity whose score this is. For players, this is their username; for other entities, it is their UUID. + |- + | Objective Name + | {{Type|Prefixed Optional}} {{Type|String}} (32767) + | The name of the objective the score belongs to. + |} + +==== Remove Resource Pack (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x49

''resource:''
resource_pack_pop + | Play + | Client + | UUID + | {{Type|Optional}} {{Type|UUID}} + | The UUID of the resource pack to be removed. + |} + +==== Add Resource Pack (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x4A

''resource:''
resource_pack_push + | rowspan="5"| Play + | rowspan="5"| Client + | UUID + | {{Type|UUID}} + | The unique identifier of the resource pack. + |- + | URL + | {{Type|String}} (32767) + | The URL to the resource pack. + |- + | Hash + | {{Type|String}} (40) + | A 40 character hexadecimal, case-insensitive [[wikipedia:SHA-1|SHA-1]] hash of the resource pack file.
If it's not a 40 character hexadecimal string, the client will not use it for hash verification and likely waste bandwidth. + |- + | Forced + | {{Type|Boolean}} + | The vanilla client will be forced to use the resource pack from the server. If they decline they will be kicked from the server. + |- + | Prompt Message + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | This is shown in the prompt making the client accept or decline the resource pack. + |} + +==== Respawn ==== + +{{missing info|section|Although the number of portal cooldown ticks is included in this packet, the whole portal usage process is still dictated entirely by the server. What kind of effect does this value have on the client, if any?}} + +To change the player's dimension (overworld/nether/end), send them a respawn packet with the appropriate dimension, followed by prechunks/chunks for the new dimension, and finally a position and look packet. You do not need to unload chunks, the client will do it automatically. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="13"| ''protocol:''
0x4B

''resource:''
respawn + | rowspan="13"| Play + | rowspan="13"| Client + | Dimension Type + | {{Type|VarInt}} + | The ID of type of dimension in the minecraft:dimension_type registry, defined by the [[Java Edition protocol#Registry_data|Registry Data]] packet. + |- + | Dimension Name + | {{Type|Identifier}} + | Name of the dimension being spawned into. + |- + | Hashed seed + | {{Type|Long}} + | First 8 bytes of the SHA-256 hash of the world's seed. Used client side for biome noise + |- + | Game mode + | {{Type|Unsigned Byte}} + | 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. + |- + | Previous Game mode + | {{Type|Byte}} + | -1: Undefined (null), 0: Survival, 1: Creative, 2: Adventure, 3: Spectator. The previous game mode. Vanilla client uses this for the debug (F3 + N & F3 + F4) game mode switch. (More information needed) + |- + | Is Debug + | {{Type|Boolean}} + | True if the world is a [[debug mode]] world; debug mode worlds cannot be modified and have predefined blocks. + |- + | Is Flat + | {{Type|Boolean}} + | True if the world is a [[superflat]] world; flat worlds have different void fog and a horizon at y=0 instead of y=63. + |- + | Has death location + | {{Type|Boolean}} + | If true, then the next two fields are present. + |- + | Death dimension Name + | {{Type|Optional}} {{Type|Identifier}} + | Name of the dimension the player died in. + |- + | Death location + | {{Type|Optional}} {{Type|Position}} + | The location that the player died at. + |- + | Portal cooldown + | {{Type|VarInt}} + | The number of ticks until the player can use the portal again. + |- + | Sea level + | {{Type|VarInt}} + | + |- + | Data kept + | {{Type|Byte}} + | Bit mask. 0x01: Keep attributes, 0x02: Keep metadata. Tells which data should be kept on the client side once the player has respawned. +In the vanilla implementation, this is context dependent: +* normal respawns (after death) keep no data; +* exiting the end poem/credits keeps the attributes; +* other dimension changes (portals or teleports) keep all data. + |} + +{{warning|Avoid changing player's dimension to same dimension they were already in unless they are dead. If you change the dimension to one they are already in, weird bugs can occur, such as the player being unable to attack other players in new world (until they die and respawn). + +Before 1.16, if you must respawn a player in the same dimension without killing them, send two respawn packets, one to a different world and then another to the world you want. You do not need to complete the first respawn; it only matters that you send two packets.}} + +==== Set Head Rotation ==== + +Changes the direction an entity's head is facing. + +While sending the Entity Look packet changes the vertical rotation of the head, sending this packet appears to be necessary to rotate the head horizontally. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x4C

''resource:''
rotate_head + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Head Yaw + | {{Type|Angle}} + | New angle, not a delta. + |} + +==== Update Section Blocks ==== + +Fired whenever 2 or more blocks are changed within the same chunk on the same tick. + +{{Warning|Changing blocks in chunks not loaded by the client is unsafe (see note on [[#Block Update|Block Update]]).}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x4D

''resource:''
section_blocks_update + | rowspan="2"| Play + | rowspan="2"| Client + | Chunk section position + | {{Type|Long}} + | Chunk section coordinate (encoded chunk x and z with each 22 bits, and section y with 20 bits, from left to right). + |- + | Blocks + | {{Type|Prefixed Array}} of {{Type|VarLong}} + | Each entry is composed of the block state id, shifted left by 12, and the relative block position in the chunk section (4 bits for x, z, and y, from left to right). + |} + +Chunk section position is encoded: + +((sectionX & 0x3FFFFF) << 42) | (sectionY & 0xFFFFF) | ((sectionZ & 0x3FFFFF) << 20); + +and decoded: + +sectionX = long >> 42; +sectionY = long << 44 >> 44; +sectionZ = long << 22 >> 42; + + +Blocks are encoded: + +blockStateId << 12 | (blockLocalX << 8 | blockLocalZ << 4 | blockLocalY) +//Uses the local position of the given block position relative to its respective chunk section + +and decoded: + +blockStateId = long >> 12; +blockLocalX = (long >> 8) & 0xF; +blockLocalY = long & 0xF; +blockLocalZ = (long >> 4) & 0xF; + + +==== Select Advancements Tab ==== + +Sent by the server to indicate that the client should switch advancement tab. Sent either when the client switches tab in the GUI or when an advancement in another tab is made. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x4E

''resource:''
select_advancements_tab + | Play + | Client + | Identifier + | {{Type|Prefixed Optional}} {{Type|Identifier}} + | See below. + |} + +The {{Type|Identifier}} must be one of the following if no custom data pack is loaded: + +{| class="wikitable" + ! Identifier + |- + | minecraft:story/root + |- + | minecraft:nether/root + |- + | minecraft:end/root + |- + | minecraft:adventure/root + |- + | minecraft:husbandry/root + |} + +If no or an invalid identifier is sent, the client will switch to the first tab in the GUI. + +==== Server Data ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x4F

''resource:''
server_data + | rowspan="2"| Play + | rowspan="2"| Client + | MOTD + | {{Type|Text Component}} + | + |- + | Icon + | {{Type|Prefixed Optional}} {{Type|Prefixed Array}} of {{Type|Byte}} + | Icon bytes in the PNG format. + |} + +==== Set Action Bar Text ==== + +Displays a message above the hotbar. Equivalent to [[#System Chat Message|System Chat Message]] with Overlay set to true, except that [[Minecraft Wiki:Projects/wiki.vg merge/Chat#Social Interactions (blocking)|chat message blocking]] isn't performed. Used by the vanilla server only to implement the /title command. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x50

''resource:''
set_action_bar_text + | rowspan="1"| Play + | rowspan="1"| Client + | Action bar text + | {{Type|Text Component}} + |} + +==== Set Border Center ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x51

''resource:''
set_border_center + | rowspan="2"| Play + | rowspan="2"| Client + | X + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |} + +==== Set Border Lerp Size ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x52

''resource:''
set_border_lerp_size + | rowspan="3"| Play + | rowspan="3"| Client + | Old Diameter + | {{Type|Double}} + | Current length of a single side of the world border, in meters. + |- + | New Diameter + | {{Type|Double}} + | Target length of a single side of the world border, in meters. + |- + | Speed + | {{Type|VarLong}} + | Number of real-time ''milli''seconds until New Diameter is reached. It appears that vanilla server does not sync world border speed to game ticks, so it gets out of sync with server lag. If the world border is not moving, this is set to 0. + |} + +==== Set Border Size ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x53

''resource:''
set_border_size + | rowspan="1"| Play + | rowspan="1"| Client + | Diameter + | {{Type|Double}} + | Length of a single side of the world border, in meters. + |} + +==== Set Border Warning Delay ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x54

''resource:''
set_border_warning_delay + | rowspan="1"| Play + | rowspan="1"| Client + | Warning Time + | {{Type|VarInt}} + | In seconds as set by /worldborder warning time. + |} + +==== Set Border Warning Distance ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x55

''resource:''
set_border_warning_distance + | rowspan="1"| Play + | rowspan="1"| Client + | Warning Blocks + | {{Type|VarInt}} + | In meters. + |} + +==== Set Camera ==== + +Sets the entity that the player renders from. This is normally used when the player left-clicks an entity while in spectator mode. + +The player's camera will move with the entity and look where it is looking. The entity is often another player, but can be any type of entity. The player is unable to move this entity (move packets will act as if they are coming from the other entity). + +If the given entity is not loaded by the player, this packet is ignored. To return control to the player, send this packet with their entity ID. + +The vanilla server resets this (sends it back to the default entity) whenever the spectated entity is killed or the player sneaks, but only if they were spectating an entity. It also sends this packet whenever the player switches out of spectator mode (even if they weren't spectating an entity). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x56

''resource:''
set_camera + | Play + | Client + | Camera ID + | {{Type|VarInt}} + | ID of the entity to set the client's camera to. + |} + +The vanilla client also loads certain shaders for given entities: + +* Creeper → shaders/post/creeper.json +* Spider (and cave spider) → shaders/post/spider.json +* Enderman → shaders/post/invert.json +* Anything else → the current shader is unloaded + +==== Set Center Chunk ==== + +Sets the center position of the client's chunk loading area. The area is square-shaped, spanning 2 × server view distance + 7 chunks on both axes (width, not radius!). Since the area's width is always an odd number, there is no ambiguity as to which chunk is the center. + +The vanilla client ignores attempts to send chunks located outside the loading area, and immediately unloads any existing chunks no longer inside it. + +The center chunk is normally the chunk the player is in, but apart from the implications on chunk loading, the (vanilla) client takes no issue with this not being the case. Indeed, as long as chunks are sent only within the default loading area centered on the world origin, it is not necessary to send this packet at all. This may be useful for servers with small bounded worlds, such as minigames, since it ensures chunks never need to be resent after the client has joined, saving on bandwidth. + +The vanilla server sends this packet whenever the player moves across a chunk border horizontally, and also (according to testing) for any integer change in the vertical axis, even if it doesn't go across a chunk section border. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x57

''resource:''
set_chunk_cache_center + | rowspan="2"| Play + | rowspan="2"| Client + | Chunk X + | {{Type|VarInt}} + | Chunk X coordinate of the loading area center. + |- + | Chunk Z + | {{Type|VarInt}} + | Chunk Z coordinate of the loading area center. + |} + +==== Set Render Distance ==== + +Sent by the integrated singleplayer server when changing render distance. This packet is sent by the server when the client reappears in the overworld after leaving the end. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x58

''resource:''
set_chunk_cache_radius + | Play + | Client + | View Distance + | {{Type|VarInt}} + | Render distance (2-32). + |} + +==== Set Cursor Item ==== + +Replaces or sets the inventory item that's being dragged with the mouse. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x59

''resource:''
set_cursor_item + | Play + | Client + | Carried item + | {{Type|Slot}} + | + |} + +==== Set Default Spawn Position ==== + +Sent by the server after login to specify the coordinates of the spawn point (the point at which players spawn at, and which the compass points to). It can be sent at any time to update the point compasses point at. + +The client uses this as the default position of the player upon spawning, though it's a good idea to always override this default by sending [[#Synchronize Player Position|Synchronize Player Position]]. When converting the position to floating point, 0.5 is added to the x and z coordinates and 1.0 to the y coordinate, so as to place the player centered on top of the specified block position. + +Before receiving this packet, the client uses the default position 8, 64, 8, and angle 0.0 (resulting in a default player spawn position of 8.5, 65.0, 8.5). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x5A

''resource:''
set_default_spawn_position + | rowspan="2"| Play + | rowspan="2"| Client + | Location + | {{Type|Position}} + | Spawn location. + |- + | Angle + | {{Type|Float}} + | The angle at which to respawn at. + |} + +==== Display Objective ==== + +This is sent to the client when it should display a scoreboard. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x5B

''resource:''
set_display_objective + | rowspan="2"| Play + | rowspan="2"| Client + | Position + | {{Type|VarInt}} + | The position of the scoreboard. 0: list, 1: sidebar, 2: below name, 3 - 18: team specific sidebar, indexed as 3 + team color. + |- + | Score Name + | {{Type|String}} (32767) + | The unique name for the scoreboard to be displayed. + |} + +==== Set Entity Metadata ==== + +Updates one or more [[Java Edition protocol/Entity_metadata#Entity Metadata Format|metadata]] properties for an existing entity. Any properties not included in the Metadata field are left unchanged. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x5C

''resource:''
set_entity_data + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Metadata + | [[Java Edition protocol/Entity_metadata#Entity Metadata Format|Entity Metadata]] + | + |} + +==== Link Entities ==== + +This packet is sent when an entity has been [[Lead|leashed]] to another entity. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x5D

''resource:''
set_entity_link + | rowspan="2"| Play + | rowspan="2"| Client + | Attached Entity ID + | {{Type|Int}} + | Attached entity's EID. + |- + | Holding Entity ID + | {{Type|Int}} + | ID of the entity holding the lead. Set to -1 to detach. + |} + +==== Set Entity Velocity ==== + +Velocity is in units of 1/8000 of a block per server tick (50ms); for example, -1343 would move (-1343 / 8000) = −0.167875 blocks per tick (or −3.3575 blocks per second). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x5E

''resource:''
set_entity_motion + | rowspan="4"| Play + | rowspan="4"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Velocity X + | {{Type|Short}} + | Velocity on the X axis. + |- + | Velocity Y + | {{Type|Short}} + | Velocity on the Y axis. + |- + | Velocity Z + | {{Type|Short}} + | Velocity on the Z axis. + |} + +==== Set Equipment ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! colspan="2"| Notes + |- + | rowspan="3"| ''protocol:''
0x5F

''resource:''
set_equipment + | rowspan="3"| Play + | rowspan="3"| Client + | colspan="2"| Entity ID + | colspan="2"| {{Type|VarInt}} + | colspan="2"| Entity's ID. + |- + | rowspan="2"| Equipment + | Slot + | rowspan="2"| {{Type|Array}} + | {{Type|Byte}} {{Type|Enum}} + | rowspan="2"| The length of the array is unknown, it must be read until the most significant bit is 1 ((Slot >>> 7 & 1) == 1) + | Equipment slot (see below). Also has the top bit set if another entry follows, and otherwise unset if this is the last item in the array. + |- + | Item + | {{Type|Slot}} + | + |} + +Equipment slot can be one of the following: + +{| class="wikitable" + ! ID + ! Equipment slot + |- + | 0 + | Main hand + |- + | 1 + | Off hand + |- + | 2 + | Boots + |- + | 3 + | Leggings + |- + | 4 + | Chestplate + |- + | 5 + | Helmet + |- + | 6 + | Body + |} + +==== Set Experience ==== + +Sent by the server when the client should change experience levels. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x60

''resource:''
set_experience + | rowspan="3"| Play + | rowspan="3"| Client + | Experience bar + | {{Type|Float}} + | Between 0 and 1. + |- + | Level + | {{Type|VarInt}} + | + |- + | Total Experience + | {{Type|VarInt}} + | See [[Experience#Leveling up]] on the Minecraft Wiki for Total Experience to Level conversion. + |} + +==== Set Health ==== + +Sent by the server to set the health of the player it is sent to. + +Food [[Food#Hunger and saturation|saturation]] acts as a food “overcharge”. Food values will not decrease while the saturation is over zero. New players logging in or respawning automatically get a saturation of 5.0. Eating food increases the saturation as well as the food bar. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x61

''resource:''
set_health + | rowspan="3"| Play + | rowspan="3"| Client + | Health + | {{Type|Float}} + | 0 or less = dead, 20 = full HP. + |- + | Food + | {{Type|VarInt}} + | 0–20. + |- + | Food Saturation + | {{Type|Float}} + | Seems to vary from 0.0 to 5.0 in integer increments. + |} + +==== Set Held Item (clientbound) ==== + +Sent to change the player's slot selection. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x62

''resource:''
set_held_slot + | Play + | Client + | Slot + | {{Type|VarInt}} + | The slot which the player has selected (0–8). + |} + +==== Update Objectives ==== + +This is sent to the client when it should create a new [[scoreboard]] objective or remove one. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="10"| ''protocol:''
0x63

''resource:''
set_objective + | rowspan="10"| Play + | rowspan="10"| Client + | colspan="2"| Objective Name + | {{Type|String}} (32767) + | A unique name for the objective. + |- + | colspan="2"| Mode + | {{Type|Byte}} + | 0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text. + |- + | colspan="2"| Objective Value + | {{Type|Optional}} {{Type|Text Component}} + | Only if mode is 0 or 2.The text to be displayed for the score. + |- + | colspan="2"| Type + | {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}} + | Only if mode is 0 or 2. 0 = "integer", 1 = "hearts". + |- + | colspan="2"| Has Number Format + | {{Type|Optional}} {{Type|Boolean}} + | Only if mode is 0 or 2. Whether this objective has a set number format for the scores. + |- + | colspan="2"| Number Format + | {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}} + | Only if mode is 0 or 2 and the previous boolean is true. Determines how the score number should be formatted. + |- + ! Number Format + ! Field Name + ! + ! + |- + | 0: blank + | colspan="2"| ''no fields'' + | Show nothing. + |- + | 1: styled + | Styling + | [[Minecraft Wiki:Projects/wiki.vg merge/NBT#Specification:compound_tag|Compound Tag]] + | The styling to be used when formatting the score number. Contains the [[Minecraft Wiki:Projects/wiki.vg merge/Text formatting#Styling fields|text component styling fields]]. + |- + | 2: fixed + | Content + | {{Type|Text Component}} + | The text to be used as placeholder. + |} + +==== Set Passengers ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x64

''resource:''
set_passengers + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | Vehicle's EID. + |- + | Passengers + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | EIDs of entity's passengers. + |} + +==== Set Player Inventory Slot ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x65

''resource:''
set_player_inventory + | rowspan="2"| Play + | rowspan="2"| Client + | Slot + | {{Type|VarInt}} + | + |- + | Slot Data + | {{Type|Slot}} + | + |} + +==== Update Teams ==== + +Creates and updates teams. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="20"| ''protocol:''
0x66

''resource:''
set_player_team + | rowspan="20"| Play + | rowspan="20"| Client + | colspan="2"| Team Name + | {{Type|String}} (32767) + | A unique name for the team. (Shared with scoreboard). + |- + | colspan="2"| Method + | {{Type|Byte}} + | Determines the layout of the remaining packet. + |- + | rowspan="8"| 0: create team + | Team Display Name + | {{Type|Text Component}} + | + |- + | Friendly Flags + | {{Type|Byte}} + | Bit mask. 0x01: Allow friendly fire, 0x02: can see invisible players on same team. + |- + | Name Tag Visibility + | {{Type|VarInt}} {{Type|Enum}} + | 0 = ALWAYS, 1 = NEVER, 2 = HIDE_FOR_OTHER_TEAMS, 3 = HIDE_FOR_OWN_TEAMS + |- + | Collision Rule + | {{Type|VarInt}} {{Type|Enum}} + | 0 = ALWAYS, 1 = NEVER, 2 = PUSH_OTHER_TEAMS, 3 = PUSH_OWN_TEAM + |- + | Team Color + | {{Type|VarInt}} {{Type|Enum}} + | Used to color the name of players on the team; see below. + |- + | Team Prefix + | {{Type|Text Component}} + | Displayed before the names of players that are part of this team. + |- + | Team Suffix + | {{Type|Text Component}} + | Displayed after the names of players that are part of this team. + |- + | Entities + | {{Type|Prefixed Array}} of {{Type|String}} (32767) + | Identifiers for the entities in this team. For players, this is their username; for other entities, it is their UUID. + |- + | 1: remove team + | ''no fields'' + | ''no fields'' + | + |- + | rowspan="7"| 2: update team info + | Team Display Name + | {{Type|Text Component}} + | + |- + | Friendly Flags + | {{Type|Byte}} + | Bit mask. 0x01: Allow friendly fire, 0x02: can see invisible entities on same team. + |- + | Name Tag Visibility + | {{Type|VarInt}} {{Type|Enum}} + | 0 = ALWAYS, 1 = NEVER, 2 = HIDE_FOR_OTHER_TEAMS, 3 = HIDE_FOR_OWN_TEAMS + |- + | Collision Rule + | {{Type|VarInt}} {{Type|Enum}} + | 0 = ALWAYS, 1 = NEVER, 2 = PUSH_OTHER_TEAMS, 3 = PUSH_OWN_TEAM + |- + | Team Color + | {{Type|VarInt}} {{Type|Enum}} + | Used to color the name of players on the team; see below. + |- + | Team Prefix + | {{Type|Text Component}} + | Displayed before the names of players that are part of this team. + |- + | Team Suffix + | {{Type|Text Component}} + | Displayed after the names of players that are part of this team. + |- + | 3: add entities to team + | Entities + | {{Type|Prefixed Array}} of {{Type|String}} (32767) + | Identifiers for the added entities. For players, this is their username; for other entities, it is their UUID. + |- + | 4: remove entities from team + | Entities + | {{Type|Prefixed Array}} of {{Type|String}} (32767) + | Identifiers for the removed entities. For players, this is their username; for other entities, it is their UUID. + |} + +Team Color: The color of a team defines how the names of the team members are visualized; any formatting code can be used. The following table lists all the possible values. + +{| class="wikitable" + ! ID + ! Formatting + |- + | 0-15 + | Color formatting, same values as in [[Minecraft Wiki:Projects/wiki.vg merge/Text formatting#Colors|Text formatting#Colors]]. + |- + | 16 + | Obfuscated + |- + | 17 + | Bold + |- + | 18 + | Strikethrough + |- + | 19 + | Underlined + |- + | 20 + | Italic + |- + | 21 + | Reset + |} + +==== Update Score ==== + +This is sent to the client when it should update a scoreboard item. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x67

''resource:''
set_score + | rowspan="9"| Play + | rowspan="9"| Client + | colspan="2"| Entity Name + | {{Type|String}} (32767) + | The entity whose score this is. For players, this is their username; for other entities, it is their UUID. + |- + | colspan="2"| Objective Name + | {{Type|String}} (32767) + | The name of the objective the score belongs to. + |- + | colspan="2"| Value + | {{Type|VarInt}} + | The score to be displayed next to the entry. + |- + | colspan="2"| Display Name + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | The custom display name. + |- + | colspan="2"| Number Format + | {{Type|Prefixed Optional}} {{Type|VarInt}} {{Type|Enum}} + | Determines how the score number should be formatted. + |- + ! Number Format + ! Field Name + ! + ! + |- + | 0: blank + | colspan="2"| ''no fields'' + | Show nothing. + |- + | 1: styled + | Styling + | [[Minecraft Wiki:Projects/wiki.vg merge/NBT#Specification:compound_tag|Compound Tag]] + | The styling to be used when formatting the score number. Contains the [[Minecraft Wiki:Projects/wiki.vg merge/Text formatting#Styling fields|text component styling fields]]. + |- + | 2: fixed + | Content + | {{Type|Text Component}} + | The text to be used as placeholder. + |} + +==== Set Simulation Distance ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x68

''resource:''
set_simulation_distance + | Play + | Client + | Simulation Distance + | {{Type|VarInt}} + | The distance that the client will process specific things, such as entities. + |} + +==== Set Subtitle Text ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x69

''resource:''
set_subtitle_text + | rowspan="1"| Play + | rowspan="1"| Client + | Subtitle Text + | {{Type|Text Component}} + | + |} + +==== Update Time ==== + +Time is based on ticks, where 20 ticks happen every second. There are 24000 ticks in a day, making Minecraft days exactly 20 minutes long. + +The time of day is based on the timestamp modulo 24000. 0 is sunrise, 6000 is noon, 12000 is sunset, and 18000 is midnight. + +The default SMP server increments the time by 20 every second. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x6A

''resource:''
set_time + | rowspan="3"| Play + | rowspan="3"| Client + | World Age + | {{Type|Long}} + | In ticks; not changed by server commands. + |- + | Time of day + | {{Type|Long}} + | The world (or region) time, in ticks. + |- + | Time of day increasing + | {{Type|Boolean}} + | If true, the client should automatically advance the time of day according to its ticking rate. + |} + +==== Set Title Text ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x6B

''resource:''
set_title_text + | rowspan="1"| Play + | rowspan="1"| Client + | Title Text + | {{Type|Text Component}} + | + |} + +==== Set Title Animation Times ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x6C

''resource:''
set_titles_animation + | rowspan="3"| Play + | rowspan="3"| Client + | Fade In + | {{Type|Int}} + | Ticks to spend fading in. + |- + | Stay + | {{Type|Int}} + | Ticks to keep the title displayed. + |- + | Fade Out + | {{Type|Int}} + | Ticks to spend fading out, not when to start fading out. + |} + +==== Entity Sound Effect ==== + +Plays a sound effect from an entity, either by hardcoded ID or Identifier. Sound IDs and names can be found [https://pokechu22.github.io/Burger/1.21.html#sounds here]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="6"| ''protocol:''
0x6D

''resource:''
sound_entity + | rowspan="6"| Play + | rowspan="6"| Client + | Sound Event + | {{Type|ID or}} {{Type|Sound Event}} + | ID in the minecraft:sound_event registry, or an inline definition. + |- + | Sound Category + | {{Type|VarInt}} {{Type|Enum}} + | The category that this sound will be played from ([https://gist.github.com/konwboj/7c0c380d3923443e9d55 current categories]). + |- + | Entity ID + | {{Type|VarInt}} + | + |- + | Volume + | {{Type|Float}} + | 1.0 is 100%, capped between 0.0 and 1.0 by vanilla clients. + |- + | Pitch + | {{Type|Float}} + | Float between 0.5 and 2.0 by vanilla clients. + |- + | Seed + | {{Type|Long}} + | Seed used to pick sound variant. + |} + +==== Sound Effect ==== + +Plays a sound effect at the given location, either by hardcoded ID or Identifier. Sound IDs and names can be found [https://pokechu22.github.io/Burger/1.21.html#sounds here]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x6E

''resource:''
sound + | rowspan="8"| Play + | rowspan="8"| Client + | Sound Event + | {{Type|ID or}} {{Type|Sound Event}} + | ID in the minecraft:sound_event registry, or an inline definition. + |- + | Sound Category + | {{Type|VarInt}} {{Type|Enum}} + | The category that this sound will be played from ([https://gist.github.com/konwboj/7c0c380d3923443e9d55 current categories]). + |- + | Effect Position X + | {{Type|Int}} + | Effect X multiplied by 8 ([[Minecraft Wiki:Projects/wiki.vg merge/Data types#Fixed-point numbers|fixed-point number]] with only 3 bits dedicated to the fractional part). + |- + | Effect Position Y + | {{Type|Int}} + | Effect Y multiplied by 8 ([[Minecraft Wiki:Projects/wiki.vg merge/Data types#Fixed-point numbers|fixed-point number]] with only 3 bits dedicated to the fractional part). + |- + | Effect Position Z + | {{Type|Int}} + | Effect Z multiplied by 8 ([[Minecraft Wiki:Projects/wiki.vg merge/Data types#Fixed-point numbers|fixed-point number]] with only 3 bits dedicated to the fractional part). + |- + | Volume + | {{Type|Float}} + | 1.0 is 100%, capped between 0.0 and 1.0 by vanilla clients. + |- + | Pitch + | {{Type|Float}} + | Float between 0.5 and 2.0 by vanilla clients. + |- + | Seed + | {{Type|Long}} + | Seed used to pick sound variant. + |} + +==== Start Configuration ==== + +Sent during gameplay in order to redo the configuration process. The client must respond with [[#Acknowledge Configuration|Acknowledge Configuration]] for the process to start. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x6F

''resource:''
start_configuration + | rowspan="1"| Play + | rowspan="1"| Client + | colspan="3"| ''no fields'' + |} + +This packet switches the connection state to [[#Configuration|configuration]]. + +==== Stop Sound ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x70

''resource:''
stop_sound + | rowspan="3"| Play + | rowspan="3"| Client + | Flags + | {{Type|Byte}} + | Controls which fields are present. + |- + | Source + | {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}} + | Only if flags is 3 or 1 (bit mask 0x1). See below. If not present, then sounds from all sources are cleared. + |- + | Sound + | {{Type|Optional}} {{Type|Identifier}} + | Only if flags is 2 or 3 (bit mask 0x2). A sound effect name, see [[#Custom Sound Effect|Custom Sound Effect]]. If not present, then all sounds are cleared. + |} + +Categories: + +{| class="wikitable" + ! Name !! Value + |- + | master || 0 + |- + | music || 1 + |- + | record || 2 + |- + | weather || 3 + |- + | block || 4 + |- + | hostile || 5 + |- + | neutral || 6 + |- + | player || 7 + |- + | ambient || 8 + |- + | voice || 9 + |} + +==== Store Cookie (play) ==== + +Stores some arbitrary data on the client, which persists between server transfers. The vanilla client only accepts cookies of up to 5 kiB in size. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x71

''resource:''
store_cookie + | rowspan="2"| Play + | rowspan="2"| Client + | Key + | {{Type|Identifier}} + | The identifier of the cookie. + |- + | Payload + | {{Type|Prefixed Array}} (5120) of {{Type|Byte}} + | The data of the cookie. + |} + +==== System Chat Message ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +Sends the client a raw system message. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x72

''resource:''
system_chat + | rowspan="2"| Play + | rowspan="2"| Client + | Content + | {{Type|Text Component}} + | Limited to 262144 bytes. + |- + | Overlay + | {{Type|Boolean}} + | Whether the message is an actionbar or chat message. See also [[#Set Action Bar Text]]. + |} + +==== Set Tab List Header And Footer ==== + +This packet may be used by custom servers to display additional information above/below the player list. It is never sent by the vanilla server. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x73

''resource:''
tab_list + | rowspan="2"| Play + | rowspan="2"| Client + | Header + | {{Type|Text Component}} + | To remove the header, send a empty text component: {"text":""}. + |- + | Footer + | {{Type|Text Component}} + | To remove the footer, send a empty text component: {"text":""}. + |} + +==== Tag Query Response ==== + +Sent in response to [[#Query Block Entity Tag|Query Block Entity Tag]] or [[#Query Entity Tag|Query Entity Tag]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x74

''resource:''
tag_query + | rowspan="2"| Play + | rowspan="2"| Client + | Transaction ID + | {{Type|VarInt}} + | Can be compared to the one sent in the original query packet. + |- + | NBT + | {{Type|NBT}} + | The NBT of the block or entity. May be a TAG_END (0) in which case no NBT is present. + |} + +==== Pickup Item ==== + +Sent by the server when someone picks up an item lying on the ground — its sole purpose appears to be the animation of the item flying towards you. It doesn't destroy the entity in the client memory, and it doesn't add it to your inventory. The server only checks for items to be picked up after each [[#Set Player Position|Set Player Position]] (and [[#Set Player Position And Rotation|Set Player Position And Rotation]]) packet sent by the client. The collector entity can be any entity; it does not have to be a player. The collected entity also can be any entity, but the vanilla server only uses this for items, experience orbs, and the different varieties of arrows. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x75

''resource:''
take_item_entity + | rowspan="3"| Play + | rowspan="3"| Client + | Collected Entity ID + | {{Type|VarInt}} + | + |- + | Collector Entity ID + | {{Type|VarInt}} + | + |- + | Pickup Item Count + | {{Type|VarInt}} + | Seems to be 1 for XP orbs, otherwise the number of items in the stack. + |} + +==== Synchronize Vehicle Position ==== + +Teleports the entity on the client without changing the reference point of movement deltas in future [[#Update Entity Position|Update Entity Position]] packets. Seems to be used to make relative adjustments to vehicle positions; more information needed. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="11"| ''protocol:''
0x76

''resource:''
teleport_entity + | rowspan="11"| Play + | rowspan="11"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | X + | {{Type|Double}} + | + |- + | Y + | {{Type|Double}} + | + |- + | Z + | {{Type|Double}} + | + |- + | Velocity X + | {{Type|Double}} + | + |- + | Velocity Y + | {{Type|Double}} + | + |- + | Velocity Z + | {{Type|Double}} + | + |- + | Yaw + | {{Type|Float}} + | Rotation on the Y axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Rotation on the Y axis, in degrees. + |- + | Flags + | {{Type|Teleport Flags}} + | + |- + | On Ground + | {{Type|Boolean}} + | + |} + +==== Test Instance Block Status ==== + +Updates the status of the currently open [[Test Instance Block]] screen, if any. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x77

''resource:''
test_instance_block_status + | rowspan="5"| Play + | rowspan="5"| Client + | Status + | {{Type|Text Component}} + | + |- + | Has Size + | {{Type|Boolean}} + | + |- + | Size X + | {{Type|Optional}} {{Type|Double}} + | Only present if Has Size is true. + |- + | Size Y + | {{Type|Optional}} {{Type|Double}} + | Only present if Has Size is true. + |- + | Size Z + | {{Type|Optional}} {{Type|Double}} + | Only present if Has Size is true. + |} + +==== Set Ticking State ==== + +Used to adjust the ticking rate of the client, and whether it's frozen. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2" | ''protocol:''
0x78

''resource:''
ticking_state + | rowspan="2" | Play + | rowspan="2" | Client + | Tick rate + | {{Type|Float}} + | + |- + | Is frozen + | {{Type|Boolean}} + | + |} + +==== Step Tick ==== + +Advances the client processing by the specified number of ticks. Has no effect unless client ticking is frozen. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x79

''resource:''
ticking_step + | Play + | Client + | Tick steps + | {{Type|VarInt}} + | + |} + +==== Transfer (play) ==== + +Notifies the client that it should transfer to the given server. Cookies previously stored are preserved between server transfers. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x7A

''resource:''
transfer + | rowspan="2"| Play + | rowspan="2"| Client + | colspan="2"| Host + | colspan="2"| {{Type|String}} + | The hostname or IP of the server. + |- + | colspan="2"| Port + | colspan="2"| {{Type|VarInt}} + | The port of the server. + |} + +==== Update Advancements ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="7"| ''protocol:''
0x7B

''resource:''
update_advancements + | rowspan="7"| Play + | rowspan="7"| Client + | colspan="2"| Reset/Clear + | colspan="2"| {{Type|Boolean}} + | Whether to reset/clear the current advancements. + |- + | rowspan="2"| Advancement mapping + | Key + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | The identifier of the advancement. + |- + | Value + | Advancement + | See below + |- + | colspan="2"| Identifiers + | colspan="2"| {{Type|Prefixed Array}} of {{Type|Identifier}} + | The identifiers of the advancements that should be removed. + |- + | rowspan="2"| Progress mapping + | Key + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | The identifier of the advancement. + |- + | Value + | Advancement progress + | See below. + |- + | colspan="2"| Show advancements + | colspan="2"| {{Type|Boolean}} + | + |} + +Advancement structure: + +{| class="wikitable" + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | colspan="2"| Parent id + | colspan="2"| {{Type|Prefixed Optional}} {{Type|Identifier}} + | The identifier of the parent advancement. + |- + | colspan="2"| Display data + | colspan="2"| {{Type|Prefixed Optional}} Advancement display + | See below. + |- + | colspan="2"| Nested requirements + | {{Type|Prefixed Array}} + | {{Type|Prefixed Array}} of {{Type|String}} (32767) + | Array with a sub-array of criteria. To check if the requirements are met, each sub-array must be tested and mapped with the OR operator, resulting in a boolean array. +These booleans must be mapped with the AND operator to get the result. + |- + | colspan="2"| Sends telemetry data + | colspan="2"| {{Type|Boolean}} + | Whether the client should include this achievement in the telemetry data when it's completed. +The vanilla client only sends data for advancements on the minecraft namespace. + |} + +Advancement display: + +{| class="wikitable" + ! Field Name + ! Field Type + ! Notes + |- + | Title + | {{Type|Text Component}} + | + |- + | Description + | {{Type|Text Component}} + | + |- + | Icon + | {{Type|Slot}} + | + |- + | Frame type + | {{Type|VarInt}} {{Type|Enum}} + | 0 = task, 1 = challenge, 2 = goal. + |- + | Flags + | {{Type|Int}} + | 0x01: has background texture; 0x02: show_toast; 0x04: hidden. + |- + | Background texture + | {{Type|Optional}} {{Type|Identifier}} + | Background texture location. Only if flags indicates it. + |- + | X coord + | {{Type|Float}} + | + |- + | Y coord + | {{Type|Float}} + | + |} + +Advancement progress: + +{| class="wikitable" + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| Criteria + | Criterion identifier + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | The identifier of the criterion. + |- + | Date of achieving + | {{Type|Prefixed Optional}} {{Type|Long}} + | Present if achieved. As returned by [https://docs.oracle.com/javase/6/docs/api/java/util/Date.html#getTime() Date.getTime]. + |} + +==== Update Attributes ==== + +Sets [[Attribute|attributes]] on the given entity. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x7C

''resource:''
update_attributes + | rowspan="4"| Play + | rowspan="4"| Client + | colspan="2"| Entity ID + | colspan="2"| {{Type|VarInt}} + | + |- + | rowspan="3"| Property + | Id + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|VarInt}} + | ID in the minecraft:attribute registry. See also [[Attribute#Attributes]]. + |- + | Value + | {{Type|Double}} + | See below. + |- + | Modifiers + | {{Type|Prefixed Array}} of Modifier Data + | See [[Attribute#Modifiers]]. Modifier Data defined below. + |} + +''Modifier Data'' structure: + +{| class="wikitable" + |- + ! Field Name + ! Field Type + ! Notes + |- + | Id + | {{Type|Identifier}} + | + |- + | Amount + | {{Type|Double}} + | May be positive or negative. + |- + | Operation + | {{Type|Byte}} + | See below. + |} + +The operation controls how the base value of the modifier is changed. + +* 0: Add/subtract amount +* 1: Add/subtract amount percent of the current value +* 2: Multiply by amount percent + +All of the 0's are applied first, and then the 1's, and then the 2's. + +==== Entity Effect ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="5"| ''protocol:''
0x7D

''resource:''
update_mob_effect + | rowspan="5"| Play + | rowspan="5"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Effect ID + | {{Type|VarInt}} + | See [[Status effect#Effect list|this table]]. + |- + | Amplifier + | {{Type|VarInt}} + | Vanilla client displays effect level as Amplifier + 1. + |- + | Duration + | {{Type|VarInt}} + | Duration in ticks. (-1 for infinite) + |- + | Flags + | {{Type|Byte}} + | Bit field, see below. + |} + +{{missing info|section|What exact effect does the blend bit flag have on the client? What happens if it is used on effects besides DARKNESS?}} + +Within flags: + +* 0x01: Is ambient - was the effect spawned from a beacon? All beacon-generated effects are ambient. Ambient effects use a different icon in the HUD (blue border rather than gray). If all effects on an entity are ambient, the [[Java Edition protocol/Entity_metadata#Living Entity|"Is potion effect ambient" living metadata field]] should be set to true. Usually should not be enabled. +* 0x02: Show particles - should all particles from this effect be hidden? Effects with particles hidden are not included in the calculation of the effect color, and are not rendered on the HUD (but are still rendered within the inventory). Usually should be enabled. +* 0x04: Show icon - should the icon be displayed on the client? Usually should be enabled. +* 0x08: Blend - should the effect's hard-coded blending be applied? Currently only used in the DARKNESS effect to apply extra void fog and adjust the gamma value for lighting. + +==== Update Recipes ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x7E

''resource:''
update_recipes + | rowspan="4"| Play + | rowspan="4"| Client + | rowspan="2"| Property Sets + | Property Set ID + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | + |- + | Items + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | IDs in the minecraft:item registry. + |- + | rowspan="2"| Stonecutter Recipes + | Ingredients + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|ID Set}} + | + |- + | Slot Display + | {{Type|Slot Display}} + | + |} + +==== Update Tags (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x7F

''resource:''
update_tags + | rowspan="2"| Play + | rowspan="2"| Client + | rowspan="2"| Registry to tags map + | Registry + | rowspan="2"| {{Type|Prefixed Array}} + | {{Type|Identifier}} + | Registry identifier (Vanilla expects tags for the registries minecraft:block, minecraft:item, minecraft:fluid, minecraft:entity_type, and minecraft:game_event) + |- + | Tags + | {{Type|Prefixed Array}} of Tag (See below) + | + |} + +A tag looks like this: + +{| class="wikitable" + ! Field Name + ! Field Type + ! Notes + |- + | Tag name + | {{Type|Identifier}} + | + |- + | Entries + | {{Type|Prefixed Array}} of {{Type|VarInt}} + | Numeric IDs of the given type (block, item, etc.). This list replaces the previous list of IDs for the given tag. If some preexisting tags are left unmentioned, a warning is printed. + |} + +See [[Tag]] on the Minecraft Wiki for more information, including a list of vanilla tags. + +==== Projectile Power ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x80

''resource:''
projectile_power + | rowspan="2"| Play + | rowspan="2"| Client + | Entity ID + | {{Type|VarInt}} + | + |- + | Power + | {{Type|Double}} + | + |} + +==== Custom Report Details ==== + +Contains a list of key-value text entries that are included in any crash or disconnection report generated during connection to the server. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x81

''resource:''
custom_report_details + | rowspan="2"| Play + | rowspan="2"| Client + | rowspan="2"| Details + | Title + | rowspan="2"| {{Type|Prefixed Array}} (32) + | {{Type|String}} (128) + | + |- + | Description + | {{Type|String}} (4096) + | +|} + +==== Server Links ==== + +This packet contains a list of links that the vanilla client will display in the menu available from the pause menu. Link labels can be built-in or custom (i.e., any text). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x82

''resource:''
server_links + | rowspan="3"| Play + | rowspan="3"| Client + | rowspan="3"| Links + | Is built-in + | rowspan="3"| {{Type|Prefixed Array}} + | {{Type|Boolean}} + | Determines if the following label is built-in (from enum) or custom (text component). + |- + | Label + | {{Type|VarInt}} {{Type|Enum}} / {{Type|Text Component}} + | See below. + |- + | URL + | {{Type|String}} + | Valid URL. +|} + +{| class="wikitable" + ! ID + ! Name + ! Notes + |- + | 0 + | Bug Report + | Displayed on connection error screen; included as a comment in the disconnection report. + |- + | 1 + | Community Guidelines + | + |- + | 2 + | Support + | + |- + | 3 + | Status + | + |- + | 4 + | Feedback + | + |- + | 5 + | Community + | + |- + | 6 + | Website + | + |- + | 7 + | Forums + | + |- + | 8 + | News + | + |- + | 9 + | Announcements + | + |- + |} + +==== Waypoint ==== + +Adds, removes, or updates an entry that will be tracked on the player locator bar. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x83

''resource:''
waypoint + | rowspan="9"| Play + | rowspan="9"| Client + | colspan="2"| Operation + | colspan="2"| {{Type|VarInt}} {{Type|Enum}} + | 0: track, 1: untrack, 2: update. + |- + | colspan="2"| Identifier + | colspan="2"| {{Type|Uuid}} {{Type|or}} {{Type|String}} + | Something that uniquely identifies this specific waypoint. + |- + | colspan="2"| Icon style + | colspan="2"| {{Type|Identifier}} + | Path to the waypoint style JSON: assets//waypoint_style/.json. + |- + | rowspan="4"| Color + |- + | Red + | rowspan="3"| {{Type|Prefixed Optional}} + | {{Type|Unsigned Byte}} + | rowspan="3"| The color of the waypoint icon. + |- + | Green + | {{Type|Unsigned Byte}} + |- + | Blue + | {{Type|Unsigned Byte}} + |- + | colspan="2"| {{Type|VarInt}} {{Type|Enum}} + | colspan="2"| Waypoint type + | Defines how the following field is read. + |- + | colspan="2"| Waypoint data + | colspan="2"| Varies + | + {| class="wikitable" + ! Type + ! Field Name + ! Field Data + ! Notes + |- + | 0: Empty + | colspan="3"| ''no fields'' + |- + | rowspan="3"| 1: Vec3i + | X + | {{Type|VarInt}} + | rowspan="3"| The position that the waypoint will point to. + |- + | Y + | {{Type|VarInt}} + |- + | Z + | {{Type|VarInt}} + |- + | rowspan="2"| 2: Chunk + | X + | {{Type|VarInt}} + | rowspan="2"| The chunk coordinates that the waypoint will point to. + |- + | Z + | {{Type|VarInt}} + |- + | 3: Azimuth + | Angle + | {{Type|Float}} + | The angle that will be pointed to, in radians. + |} + |} + +==== Clear Dialog (play) ==== + +If we're currently in a dialog screen, then this removes the current screen and switches back to the previous one. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x84

''resource:''
clear_dialog + | Play + | Client + | colspan="3"| ''no fields'' + |} + +==== Show Dialog (play) ==== + +Show a custom dialog screen to the client. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x85

''resource:''
show_dialog + | Play + | Client + | Dialog + | {{Type|ID or}} {{Type|NBT}} + | ID in the minecraft:dialog registry, or an inline definition as described at [[Java_Edition_protocol/Registry_data#Dialog|Registry_data#Dialog]]. + |} + +=== Serverbound === + +==== Confirm Teleportation ==== + +Sent by client as confirmation of [[#Synchronize Player Position|Synchronize Player Position]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x00

''resource:''
accept_teleportation + | Play + | Server + | Teleport ID + | {{Type|VarInt}} + | The ID given by the [[#Synchronize Player Position|Synchronize Player Position]] packet. + |} + +==== Query Block Entity Tag ==== + +Used when F3+I is pressed while looking at a block. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x01

''resource:''
block_entity_tag_query + | rowspan="2"| Play + | rowspan="2"| Server + | Transaction ID + | {{Type|VarInt}} + | An incremental ID so that the client can verify that the response matches. + |- + | Location + | {{Type|Position}} + | The location of the block to check. + |} + +==== Bundle Item Selected ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x02

''resource:''
bundle_item_selected + | rowspan="2"| Play + | rowspan="2"| Server + | Slot of Bundle + | {{Type|VarInt}} + | + |- + | Slot in Bundle + | {{Type|VarInt}} + | + |} + +==== Change Difficulty ==== + +Must have at least op level 2 to use. Appears to only be used on singleplayer; the difficulty buttons are still disabled in multiplayer. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x03

''resource:''
change_difficulty + | rowspan="1"| Play + | rowspan="1"| Server + | New difficulty + | {{Type|Unsigned Byte}} {{Type|Enum}} + | 0: peaceful, 1: easy, 2: normal, 3: hard. + |} + +==== Change Game Mode ==== + +Requests for the server to update our game mode. Has no effect on vanilla servers if the client doesn't have the required permissions. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x04

''resource:''
change_game_mode + | Play + | Server + | Game mode + | {{Type|VarInt}} {{Type|Enum}} + | 0: survival, 1: creative, 2: adventure, 3: spectator. + |} + +==== Acknowledge Message ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x05

''resource:''
chat_ack + | rowspan="1"| Play + | rowspan="1"| Server + | Message Count + | {{Type|VarInt}} + | + |} + +==== Chat Command ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x06

''resource:''
chat_command + | rowspan="1"| Play + | rowspan="1"| Server + | colspan="2"| Command + | colspan="2"| {{Type|String}} (32767) + | colspan="2"| The command typed by the client. + |} + +==== Signed Chat Command ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x07

''resource:''
chat_command_signed + | rowspan="8"| Play + | rowspan="8"| Server + | colspan="2"| Command + | colspan="2"| {{Type|String}} (32767) + | colspan="2"| The command typed by the client. + |- + | colspan="2"| Timestamp + | colspan="2"| {{Type|Long}} + | colspan="2"| The timestamp that the command was executed. + |- + | colspan="2"| Salt + | colspan="2"| {{Type|Long}} + | colspan="2"| The salt for the following argument signatures. + |- + | rowspan="2"| Array of argument signatures + | Argument name + | rowspan="2"| {{Type|Prefixed Array}} (8) + | {{Type|String}} (16) + | The name of the argument that is signed by the following signature. + |- + | Signature + | {{Type|Byte Array}} (256) + | The signature that verifies the argument. Always 256 bytes and is not length-prefixed. + |- + | colspan="2"| Message Count + | colspan="2"| {{Type|VarInt}} + | colspan="2"| + |- + | colspan="2"| Acknowledged + | colspan="2"| {{Type|Fixed BitSet}} (20) + | colspan="2"| + |- + | colspan="2"| Checksum + | colspan="2"| {{Type|Byte}} + | colspan="2"| + |} + +==== Chat Message ==== + +{{Main|Minecraft_Wiki:Projects/wiki.vg_merge/Chat}} + +Used to send a chat message to the server. The message may not be longer than 256 characters or else the server will kick the client. + +The server will broadcast a [[#Player Chat Message|Player Chat Message]] packet with Chat Type minecraft:chat to all players that haven't disabled chat (including the player that sent the message). See [[Minecraft Wiki:Projects/wiki.vg merge/Chat#Processing chat|Chat#Processing chat]] for more information. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="7"| ''protocol:''
0x08

''resource:''
chat + | rowspan="7"| Play + | rowspan="7"| Server + | Message + | {{Type|String}} (256) + |Content of the message +|- + | Timestamp + | {{Type|Long}} + |Number of milliseconds since the epoch (1 Jan 1970, midnight, UTC) +|- + | Salt + | {{Type|Long}} + | The salt used to verify the signature hash. Randomly generated by the client + |- + | Signature + | {{Type|Prefixed Optional}} {{Type|Byte Array}} (256) + +| The signature used to verify the chat message's authentication. When present, always 256 bytes and not length-prefixed. +This is a SHA256 with RSA digital signature computed over the following: + +* The number 1 as a 4-byte int. Always 00 00 00 01. +* The player's 16 byte UUID. +* The chat session (a 16 byte UUID generated randomly generated by the client). +* The index of the message within this chat session as a 4-byte int. First message is 0, next message is 1, etc. Incremented each time the client sends a chat message. +* The salt (from above) as a 8-byte long. +* The timestamp (from above) converted from millisecods to seconds, so divide by 1000, as a 8-byte long. +* The length of the message in bytes (from above) as a 4-byte int. +* The message bytes. +* The number of messages in the last seen set, as a 4-byte int. Always in the range [0,20]. +* For each message in the last seen set, from oldest to newest, the 256 byte signature of that message. + + +The client's chat private key is used for the message signature. +|- + | Message Count + | {{Type|VarInt}} + |Number of signed clientbound chat messages the client has seen from the server since the last serverbound chat message from this client. The server will use this to update its last seen list for the client. +|- + | Acknowledged + | {{Type|Fixed BitSet}} (20) + | +Bitmask of which message signatures from the last seen set were used to sign this message. The most recent is the highest bit. If there are less than 20 messages in the last seen set, the lower bits will be zeros. +|- + | Checksum + | {{Type|Byte}} + | + |} + +==== Player Session ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x09

''resource:''
chat_session_update + | rowspan="4"| Play + | rowspan="4"| Server + | colspan="2"| Session Id + | {{Type|UUID}} + | + |- + | rowspan="3"| Public Key + | Expires At + | {{Type|Long}} + | The time the play session key expires in [https://en.wikipedia.org/wiki/Unix_time epoch] milliseconds. + |- + | Public Key + | {{Type|Prefixed Array}} (512) of {{Type|Byte}} + | A byte array of an X.509-encoded public key. + |- + | Key Signature + | {{Type|Prefixed Array}} (4096) of {{Type|Byte}} + | The signature consists of the player UUID, the key expiration timestamp, and the public key data. These values are hashed using [https://en.wikipedia.org/wiki/SHA-1 SHA-1] and signed using Mojang's private [https://en.wikipedia.org/wiki/RSA_(cryptosystem) RSA] key. + |} + +==== Chunk Batch Received ==== + +Notifies the server that the chunk batch has been received by the client. The server uses the value sent in this packet to adjust the number of chunks to be sent in a batch. + +The vanilla server will stop sending further chunk data until the client acknowledges the sent chunk batch. After the first acknowledgement, the server adjusts this number to allow up to 10 unacknowledged batches. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0A

''resource:''
chunk_batch_received + | rowspan="1"| Play + | rowspan="1"| Server + | Chunks per tick + | {{Type|Float}} + | Desired chunks per tick. + |} + +==== Client Status ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0B

''resource:''
client_command + | rowspan="1"| Play + | rowspan="1"| Server + | Action ID + | {{Type|VarInt}} {{Type|Enum}} + | See below + |} + +''Action ID'' values: + +{| class="wikitable" + |- + ! Action ID + ! Action + ! Notes + |- + | 0 + | Perform respawn + | Sent when the client is ready to respawn after death. + |- + | 1 + | Request stats + | Sent when the client opens the Statistics menu. + |} + +==== Client Tick End ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | ''protocol:''
0x0C

''resource:''
client_tick_end + | Play + | Server + | colspan="3"| ''no fields'' + |} + +==== Client Information (play) ==== + +Sent when the player connects, or when settings are changed. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x0D

''resource:''
client_information + | rowspan="9"| Play + | rowspan="9"| Server + | Locale + | {{Type|String}} (16) + | e.g. en_GB. + |- + | View Distance + | {{Type|Byte}} + | Client-side render distance, in chunks. + |- + | Chat Mode + | {{Type|VarInt}} {{Type|Enum}} + | 0: enabled, 1: commands only, 2: hidden. See [[Minecraft Wiki:Projects/wiki.vg merge/Chat#Client chat mode|Chat#Client chat mode]] for more information. + |- + | Chat Colors + | {{Type|Boolean}} + | “Colors” multiplayer setting. The vanilla server stores this value but does nothing with it (see [https://bugs.mojang.com/browse/MC-64867 MC-64867]). Third-party servers such as Hypixel disable all coloring in chat and system messages when it is false. + |- + | Displayed Skin Parts + | {{Type|Unsigned Byte}} + | Bit mask, see below. + |- + | Main Hand + | {{Type|VarInt}} {{Type|Enum}} + | 0: Left, 1: Right. + |- + | Enable text filtering + | {{Type|Boolean}} + | Enables filtering of text on signs and written book titles. The vanilla client sets this according to the profanityFilterPreferences.profanityFilterOn account attribute indicated by the [[Minecraft Wiki:Projects/wiki.vg merge/Mojang API#Player Attributes|/player/attributes Mojang API endpoint]]. In offline mode it is always false. + |- + | Allow server listings + | {{Type|Boolean}} + | Servers usually list online players, this option should let you not show up in that list. + |- + | Particle Status + | {{Type|VarInt}} {{Type|Enum}} + | 0: all, 1: decreased, 2: minimal + |} + +''Displayed Skin Parts'' flags: + +* Bit 0 (0x01): Cape enabled +* Bit 1 (0x02): Jacket enabled +* Bit 2 (0x04): Left Sleeve enabled +* Bit 3 (0x08): Right Sleeve enabled +* Bit 4 (0x10): Left Pants Leg enabled +* Bit 5 (0x20): Right Pants Leg enabled +* Bit 6 (0x40): Hat enabled + +The most significant bit (bit 7, 0x80) appears to be unused. + +==== Command Suggestions Request ==== + +Sent when the client needs to tab-complete a minecraft:ask_server suggestion type. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x0E

''resource:''
command_suggestion + | rowspan="2"| Play + | rowspan="2"| Server + | Transaction Id + | {{Type|VarInt}} + | The id of the transaction that the server will send back to the client in the response of this packet. Client generates this and increments it each time it sends another tab completion that doesn't get a response. + |- + | Text + | {{Type|String}} (32500) + | All text behind the cursor without the / (e.g. to the left of the cursor in left-to-right languages like English). + |} + +==== Acknowledge Configuration ==== + +Sent by the client upon receiving a [[#Start Configuration|Start Configuration]] packet from the server. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x0F

''resource:''
configuration_acknowledged + | rowspan="1"| Play + | rowspan="1"| Server + | colspan="3"| ''no fields'' + |} + +This packet switches the connection state to [[#Configuration|configuration]]. + +==== Click Container Button ==== + +Used when clicking on window buttons. Until 1.14, this was only used by enchantment tables. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x10

''resource:''
container_button_click + | rowspan="2"| Play + | rowspan="2"| Server + | Window ID + | {{Type|VarInt}} + | The ID of the window sent by [[#Open Screen|Open Screen]]. + |- + | Button ID + | {{Type|VarInt}} + | Meaning depends on window type; see below. + |} + +{| class="wikitable" + ! Window type + ! ID + ! Meaning + |- + | rowspan="3"| Enchantment Table + | 0 || Topmost enchantment. + |- + | 1 || Middle enchantment. + |- + | 2 || Bottom enchantment. + |- + | rowspan="4"| Lectern + | 1 || Previous page (which does give a redstone output). + |- + | 2 || Next page. + |- + | 3 || Take Book. + |- + | 100+page || Opened page number - 100 + number. + |- + | Stonecutter + | colspan="2"| Recipe button number - 4*row + col. Depends on the item. + |- + | Loom + | colspan="2"| Recipe button number - 4*row + col. Depends on the item. + |} + +==== Click Container ==== + +This packet is sent by the client when the player clicks on a slot in a window. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! colspan="2"| Field Name + ! colspan="2"| Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x11

''resource:''
container_click + | rowspan="8"| Play + | rowspan="8"| Server + | colspan="2"| Window ID + | colspan="2"| {{Type|VarInt}} + | The ID of the window which was clicked. 0 for player inventory. The server ignores any packets targeting a Window ID other than the current one, including ignoring 0 when any other window is open. + |- + | colspan="2"| State ID + | colspan="2"| {{Type|VarInt}} + | The last received State ID from either a [[#Set Container Slot|Set Container Slot]] or a [[#Set Container Content|Set Container Content]] packet. + |- + | colspan="2"| Slot + | colspan="2"| {{Type|Short}} + | The clicked slot number, see below. + |- + | colspan="2"| Button + | colspan="2"| {{Type|Byte}} + | The button used in the click, see below. + |- + | colspan="2"| Mode + | colspan="2"| {{Type|VarInt}} {{Type|Enum}} + | Inventory operation mode, see below. + |- + | rowspan="2"| Array of changed slots + | Slot number + | rowspan="2"| {{Type|Prefixed Array}} (128) + | {{Type|Short}} + | + |- + | Slot data + | {{Type|Hashed Slot}} + | New data for this slot, in the client's opinion; see below. + |- + | colspan="2"| Carried item + | colspan="2"| {{Type|Hashed Slot}} + | Item carried by the cursor. Has to be empty (item ID = -1) for drop mode, otherwise nothing will happen. + |} + +See [[Minecraft Wiki:Projects/wiki.vg merge/Inventory|Inventory]] for further information about how slots are indexed. + +After performing the action, the server compares the results to the slot change information included in the packet, as applied on top of the server's view of the container's state prior to the action. For any slots that do not match, it sends [[#Set Container Slot|Set Container Slot]] packets containing the correct results. If State ID does not match the last ID sent by the server, it will instead send a full [[#Set Container Content|Set Container Content]] to resynchronize the client. + +When right-clicking on a stack of items, half the stack will be picked up and half left in the slot. If the stack is an odd number, the half left in the slot will be smaller of the amounts. + +The distinct type of click performed by the client is determined by the combination of the Mode and Button fields. + +{| class="wikitable" + ! Mode + ! Button + ! Slot + ! Trigger + |- + ! rowspan="4"| 0 + | 0 + | Normal + | Left mouse click + |- + | 1 + | Normal + | Right mouse click + |- + | 0 + | -999 + | Left click outside inventory (drop cursor stack) + |- + | 1 + | -999 + | Right click outside inventory (drop cursor single item) + |- + ! rowspan="2"| 1 + | 0 + | Normal + | Shift + left mouse click + |- + | 1 + | Normal + | Shift + right mouse click ''(identical behavior)'' + |- + ! rowspan="7"| 2 + | 0 + | Normal + | Number key 1 + |- + | 1 + | Normal + | Number key 2 + |- + | 2 + | Normal + | Number key 3 + |- + | ⋮ + | ⋮ + | ⋮ + |- + | 8 + | Normal + | Number key 9 + |- + | ⋮ + | ⋮ + | Button is used as the slot index (impossible in vanilla clients) + |- + | 40 + | Normal + | Offhand swap key F + |- + ! 3 + | 2 + | Normal + | Middle click, only defined for creative players in non-player inventories. + |- + ! rowspan="2"| 4 + | 0 + | Normal + | Drop key (Q) + |- + | 1 + | Normal + | Control + Drop key (Q) + |- + ! rowspan="9"| 5 + | 0 + | -999 + | Starting left mouse drag + |- + | 4 + | -999 + | Starting right mouse drag + |- + | 8 + | -999 + | Starting middle mouse drag, only defined for creative players in non-player inventories. + |- + | 1 + | Normal + | Add slot for left-mouse drag + |- + | 5 + | Normal + | Add slot for right-mouse drag + |- + | 9 + | Normal + | Add slot for middle-mouse drag, only defined for creative players in non-player inventories. + |- + | 2 + | -999 + | Ending left mouse drag + |- + | 6 + | -999 + | Ending right mouse drag + |- + | 10 + | -999 + | Ending middle mouse drag, only defined for creative players in non-player inventories. + |- + ! rowspan="2"| 6 + | 0 + | Normal + | Double click + |- + | 1 + | Normal + | Pickup all but check items in reverse order (impossible in vanilla clients) + |} + +Starting from version 1.5, “painting mode” is available for use in inventory windows. It is done by picking up stack of something (more than 1 item), then holding mouse button (left, right or middle) and dragging held stack over empty (or same type in case of right button) slots. In that case client sends the following to server after mouse button release (omitting first pickup packet which is sent as usual): + +# packet with mode 5, slot -999, button (0 for left | 4 for right); +# packet for every slot painted on, mode is still 5, button (1 | 5); +# packet with mode 5, slot -999, button (2 | 6); + +If any of the painting packets other than the “progress” ones are sent out of order (for example, a start, some slots, then another start; or a left-click in the middle) the painting status will be reset. + +==== Close Container ==== + +This packet is sent by the client when closing a window. + +vanilla clients send a Close Window packet with Window ID 0 to close their inventory even though there is never an [[#Open Screen|Open Screen]] packet for the inventory. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x12

''resource:''
container_close + | rowspan="1"| Play + | rowspan="1"| Server + | Window ID + | {{Type|VarInt}} + | This is the ID of the window that was closed. 0 for player inventory. + |} + +==== Change Container Slot State ==== + +This packet is sent by the client when toggling the state of a Crafter. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x13

''resource:''
container_slot_state_changed + | rowspan="3"| Play + | rowspan="3"| Server + | Slot ID + | {{Type|VarInt}} + | This is the ID of the slot that was changed. + |- + | Window ID + | {{Type|VarInt}} + | This is the ID of the window that was changed. + |- + | State + | {{Type|Boolean}} + | The new state of the slot. True for enabled, false for disabled. + |} + +==== Cookie Response (play) ==== + +Response to a [[#Cookie_Request_(play)|Cookie Request (play)]] from the server. The vanilla server only accepts responses of up to 5 kiB in size. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x14

''resource:''
cookie_response + | rowspan="2"| Play + | rowspan="2"| Server + | Key + | {{Type|Identifier}} + | The identifier of the cookie. + |- + | Payload + | {{Type|Prefixed Optional}} {{Type|Prefixed Array}} (5120) of {{Type|Byte}} + | The data of the cookie. + |} + +==== Serverbound Plugin Message (play) ==== + +{{Main|Minecraft Wiki:Projects/wiki.vg merge/Plugin channels}} + +Mods and plugins can use this to send their data. Minecraft itself uses some [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channels]]. These internal channels are in the minecraft namespace. + +More documentation on this: [https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/ https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/] + +Note that the length of Data is known only from the packet length, since the packet has no length field of any kind. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x15

''resource:''
custom_payload + | rowspan="2"| Play + | rowspan="2"| Server + | Channel + | {{Type|Identifier}} + | Name of the [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|plugin channel]] used to send the data. + |- + | Data + | {{Type|Byte Array}} (32767) + | Any data, depending on the channel. minecraft: channels are documented [[Minecraft Wiki:Projects/wiki.vg merge/Plugin channels|here]]. The length of this array must be inferred from the packet length. + |} + +In vanilla servers, the maximum data length is 32767 bytes. + +==== Debug Sample Subscription ==== + +Subscribes to the specified type of debug sample data, which is then sent periodically to the client via [[#Debug_Sample|Debug Sample]]. + +The subscription is retained for 10 seconds (the vanilla server checks that both 10.001 real-time seconds and 201 ticks have elapsed), after which the client is automatically unsubscribed. The vanilla client resends this packet every 5 seconds to keep up the subscription. + +The vanilla server only allows subscriptions from players that are server operators. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x16

''resource:''
debug_sample_subscription + | rowspan="1"| Play + | rowspan="1"| Server + | Sample Type + | {{Type|VarInt}} {{Type|Enum}} + | The type of debug sample to subscribe to. Can be one of the following: +* 0 - Tick time + |} + +==== Edit Book ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x17

''resource:''
edit_book + | rowspan="3"| Play + | rowspan="3"| Server + | Slot + | {{Type|VarInt}} + | The hotbar slot where the written book is located + |- + | Entries + | {{Type|Prefixed Array}} (100) of {{Type|String}} (1024) + | Text from each page. Maximum string length is 1024 chars. + |- + | Title + | {{Type|Prefixed Optional}} {{Type|String}} (32) + | Title of book. Present if book is being signed, not present if book is being edited. + |} + +==== Query Entity Tag ==== + +Used when F3+I is pressed while looking at an entity. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x18

''resource:''
entity_tag_query + | rowspan="2"| Play + | rowspan="2"| Server + | Transaction ID + | {{Type|VarInt}} + | An incremental ID so that the client can verify that the response matches. + |- + | Entity ID + | {{Type|VarInt}} + | The ID of the entity to query. + |} + +==== Interact ==== + +This packet is sent from the client to the server when the client attacks or right-clicks another entity (a player, minecart, etc). + +A vanilla server only accepts this packet if the entity being attacked/used is visible without obstruction and within a 4-unit radius of the player's position. + +The target X, Y, and Z fields represent the difference between the vector location of the cursor at the time of the packet and the entity's position. + +Note that middle-click in creative mode is interpreted by the client and sent as a [[#Set Creative Mode Slot|Set Creative Mode Slot]] packet instead. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="7"| ''protocol:''
0x19

''resource:''
interact + | rowspan="7"| Play + | rowspan="7"| Server + | Entity ID + | {{Type|VarInt}} + | The ID of the entity to interact. Note the special case described below. + |- + | Type + | {{Type|VarInt}} {{Type|Enum}} + | 0: interact, 1: attack, 2: interact at. + |- + | Target X + | {{Type|Optional}} {{Type|Float}} + | Only if Type is interact at. + |- + | Target Y + | {{Type|Optional}} {{Type|Float}} + | Only if Type is interact at. + |- + | Target Z + | {{Type|Optional}} {{Type|Float}} + | Only if Type is interact at. + |- + | Hand + | {{Type|Optional}} {{Type|VarInt}} {{Type|Enum}} + | Only if Type is interact or interact at; 0: main hand, 1: off hand. + |- + | Sneak Key Pressed + | {{Type|Boolean}} + | If the client is pressing the sneak key. Has the same effect as a Player Command Press/Release sneak key preceding the interaction, and the state is permanently changed. + |} + +Interaction with the ender dragon is an odd special case characteristic of release deadline–driven design. 8 consecutive entity IDs following the dragon's ID (id + 1, id + 2, ..., id + 8) are reserved for the 8 hitboxes that make up the dragon: + +{| class="wikitable" + ! ID offset + ! Description + |- + | 0 + | The dragon itself (never used in this packet) + |- + | 1 + | Head + |- + | 2 + | Neck + |- + | 3 + | Body + |- + | 4 + | Tail 1 + |- + | 5 + | Tail 2 + |- + | 6 + | Tail 3 + |- + | 7 + | Wing 1 + |- + | 8 + | Wing 2 + |} + +==== Jigsaw Generate ==== + +Sent when Generate is pressed on the [[Jigsaw Block]] interface. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x1A

''resource:''
jigsaw_generate + | rowspan="3"| Play + | rowspan="3"| Server + | Location + | {{Type|Position}} + | Block entity location. + |- + | Levels + | {{Type|VarInt}} + | Value of the levels slider/max depth to generate. + |- + | Keep Jigsaws + | {{Type|Boolean}} + | + |} + +==== Serverbound Keep Alive (play) ==== + +The server will frequently send out a keep-alive (see [[#Clientbound Keep Alive (play)|Clientbound Keep Alive]]), each containing a random ID. The client must respond with the same packet. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x1B

''resource:''
keep_alive + | rowspan="1"| Play + | rowspan="1"| Server + | Keep Alive ID + | {{Type|Long}} + | + |} + +==== Lock Difficulty ==== + +Must have at least op level 2 to use. Appears to only be used on singleplayer; the difficulty buttons are still disabled in multiplayer. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x1C

''resource:''
lock_difficulty + | rowspan="1"| Play + | rowspan="1"| Server + | Locked + | {{Type|Boolean}} + | + |} + +==== Set Player Position ==== + +Updates the player's XYZ position on the server. + +If the player is in a vehicle, the position is ignored (but in case of [[#Set Player Position and Rotation|Set Player Position and Rotation]], the rotation is still used as normal). No validation steps other than value range clamping are performed in this case. + +If the player is sleeping, the position (or rotation) is not changed, and a [[#Synchronize Player Position|Synchronize Player Position]] is sent if the received position deviated from the server's view by more than a meter. + +The vanilla server silently clamps the x and z coordinates between -30,000,000 and 30,000,000, and the y coordinate between -20,000,000 and 20,000,000. A similar condition has historically caused a kick for "Illegal position"; this is no longer the case. However, infinite or NaN coordinates (or angles) still result in a kick for multiplayer.disconnect.invalid_player_movement. + +As of 1.20.6, checking for moving too fast is achieved like this (sic): + +* Each server tick, the player's current position is stored. +* When the player moves, the offset from the stored position to the requested position is computed (Δx, Δy, Δz). +* The requested movement distance squared is computed as Δx² + Δy² + Δz². +* The baseline expected movement distance squared is computed based on the player's server-side velocity as Vx² + Vy² + Vz². The player's server-side velocity is a somewhat ill-defined quantity that includes among other things gravity, jump velocity and knockback, but ''not'' regular horizontal movement. A proper description would bring much of Minecraft's physics engine with it. It is accessible as the Motion NBT tag on the player entity. +* The maximum permitted movement distance squared is computed as 100 (300 if the player is using an elytra), multiplied by the number of movement packets received since the last tick, including this one, unless that value is greater than 5, in which case no multiplier is applied. +* If the requested movement distance squared minus the baseline distance squared is more than the maximum squared, the player is moving too fast. + +If the player is moving too fast, it is logged that " moved too quickly! " followed by the change in x, y, and z, and the player is teleported back to their current (before this packet) server-side position. + +Checking for block collisions is achieved like this: + +* A temporary collision-checked move of the player is attempted from its current position to the requested one. +* The offset from the resulting position to the requested position is computed. If the absolute value of the offset on the y axis is less than 0.5, it (only the y component) is rounded down to 0. +* If the magnitude of the offset is greater than 0.25 and the player isn't in creative or spectator mode, it is logged that " moved wrongly!", and the player is teleported back to their current (before this packet) server-side position. +* In addition, if the player's hitbox stationary at the requested position would intersect with a block, and they aren't in spectator mode, they are teleported back without a log message. + +Checking for illegal flight is achieved like this: + +* When a movement packet is received, a flag indicating whether or not the player is floating mid-air is updated. The flag is set if the move test described above detected no collision below the player ''and'' the y component of the offset from the player's current position to the requested one is greater than -0.5, unless any of various conditions permitting flight (creative mode, elytra, levitation effect, etc., but not jumping) are met. +* Each server tick, it is checked if the flag has been set for more than 80 consecutive ticks. If so, and the player isn't currently sleeping, dead or riding a vehicle, they are kicked for multiplayer.disconnect.flying. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x1D

''resource:''
move_player_pos + | rowspan="4"| Play + | rowspan="4"| Server + | X + | {{Type|Double}} + | Absolute position. + |- + | Feet Y + | {{Type|Double}} + | Absolute feet position, normally Head Y - 1.62. + |- + | Z + | {{Type|Double}} + | Absolute position. + |- + | Flags + | {{Type|Byte}} + | Bit field: 0x01: on ground, 0x02: pushing against wall. + |} + +==== Set Player Position and Rotation ==== + +A combination of [[#Set Player Rotation|Move Player Rotation]] and [[#Set Player Position|Move Player Position]]. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="6"| ''protocol:''
0x1E

''resource:''
move_player_pos_rot + | rowspan="6"| Play + | rowspan="6"| Server + | X + | {{Type|Double}} + | Absolute position. + |- + | Feet Y + | {{Type|Double}} + | Absolute feet position, normally Head Y - 1.62. + |- + | Z + | {{Type|Double}} + | Absolute position. + |- + | Yaw + | {{Type|Float}} + | Absolute rotation on the X Axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Absolute rotation on the Y Axis, in degrees. + |- + | Flags + | {{Type|Byte}} + | Bit field: 0x01: on ground, 0x02: pushing against wall. + |} + +==== Set Player Rotation ==== + +[[File:Minecraft-trig-yaw.png|thumb|The unit circle for yaw]] +[[File:Yaw.png|thumb|The unit circle of yaw, redrawn]] + +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 counterclockwise, with 90 at (-1, 0), 180 at (0,-1) and 270 at (1, 0). 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. + +The yaw and pitch of player (in degrees), standing at point (x0, y0, z0) and looking towards point (x, y, z) can be calculated with: + + dx = x-x0 + dy = y-y0 + dz = z-z0 + r = sqrt( dx*dx + dy*dy + dz*dz ) + yaw = -atan2(dx,dz)/PI*180 + if yaw < 0 then + yaw = 360 + yaw + pitch = -arcsin(dy/r)/PI*180 + +You can get a unit vector from a given yaw/pitch via: + + x = -cos(pitch) * sin(yaw) + y = -sin(pitch) + z = cos(pitch) * cos(yaw) + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x1F

''resource:''
move_player_rot + | rowspan="3"| Play + | rowspan="3"| Server + | Yaw + | {{Type|Float}} + | Absolute rotation on the X Axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Absolute rotation on the Y Axis, in degrees. + |- + | Flags + | {{Type|Byte}} + | Bit field: 0x01: on ground, 0x02: pushing against wall. + |} + +==== Set Player Movement Flags ==== + +This packet as well as [[#Set Player Position|Set Player Position]], [[#Set Player Rotation|Set Player Rotation]], and [[#Set Player Position and Rotation|Set Player Position and Rotation]] are called the “serverbound movement packets”. Vanilla clients will send Move Player Position once every 20 ticks even for a stationary player. + +This packet is used to indicate whether the player is on ground (walking/swimming), or airborne (jumping/falling). + +When dropping from sufficient height, fall damage is applied when this state goes from false to true. The amount of damage applied is based on the point where it last changed from true to false. Note that there are several movement related packets containing this state. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x20

''resource:''
move_player_status_only + | rowspan="1"| Play + | rowspan="1"| Server + | Flags + | {{Type|Byte}} + | Bit field: 0x01: on ground, 0x02: pushing against wall. + |} + +==== Move Vehicle ==== + +Sent when a player moves in a vehicle. Fields are the same as in [[#Set Player Position and Rotation|Set Player Position and Rotation]]. Note that all fields use absolute positioning and do not allow for relative positioning. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="6"| ''protocol:''
0x21

''resource:''
move_vehicle + | rowspan="6"| Play + | rowspan="6"| Server + | X + | {{Type|Double}} + | Absolute position (X coordinate). + |- + | Y + | {{Type|Double}} + | Absolute position (Y coordinate). + |- + | Z + | {{Type|Double}} + | Absolute position (Z coordinate). + |- + | Yaw + | {{Type|Float}} + | Absolute rotation on the vertical axis, in degrees. + |- + | Pitch + | {{Type|Float}} + | Absolute rotation on the horizontal axis, in degrees. + |- + | On Ground + | {{Type|Boolean}} + | ''(This value does not seem to exist)'' + |} + +==== Paddle Boat ==== + +Used to ''visually'' update whether boat paddles are turning. The server will update the [[Java Edition protocol/Entity_metadata#Boat|Boat entity metadata]] to match the values here. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x22

''resource:''
paddle_boat + | rowspan="2"| Play + | rowspan="2"| Server + | Left paddle turning + | {{Type|Boolean}} + | + |- + | Right paddle turning + | {{Type|Boolean}} + | + |} + +Right paddle turning is set to true when the left button or forward button is held, left paddle turning is set to true when the right button or forward button is held. + +==== Pick Item From Block ==== + +Used for pick block functionality (middle click) on blocks to retrieve items from the inventory in survival or creative mode or create them in creative mode. See [[Controls#Pick_Block]] for more information. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x23

''resource:''
pick_item_from_block + | rowspan="2"| Play + | rowspan="2"| Server + | Location + | {{Type|Position}} + | The location of the block. + |- + | Include Data + | {{Type|Boolean}} + | Used to tell the server to include block data in the new stack, works only if in creative mode. + |} + +==== Pick Item From Entity ==== + +Used for pick block functionality (middle click) on entities to retrieve items from the inventory in survival or creative mode or create them in creative mode. See [[Controls#Pick_Block]] for more information. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x24

''resource:''
pick_item_from_entity + | rowspan="2"| Play + | rowspan="2"| Server + | Entity ID + | {{Type|VarInt}} + | The ID of the entity to pick. + |- + | Include Data + | {{Type|Boolean}} + | Unused by the vanilla server. + |} + +==== Ping Request (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x25

''resource:''
ping_request + | rowspan="1"| Play + | rowspan="1"| Server + | Payload + | {{Type|Long}} + | May be any number. vanilla clients use a system-dependent time value which is counted in milliseconds. + |} + +==== Place Recipe ==== + +This packet is sent when a player clicks a recipe in the crafting book that is craftable (white border). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x26

''resource:''
place_recipe + | rowspan="3"| Play + | rowspan="3"| Server + | Window ID + | {{Type|VarInt}} + | + |- + | Recipe ID + | {{Type|VarInt}} + | ID of recipe previously defined in [[#Recipe Book Add|Recipe Book Add]]. + |- + | Make all + | {{Type|Boolean}} + | Affects the amount of items processed; true if shift is down when clicked. + |} + +==== Player Abilities (serverbound) ==== + +The vanilla client sends this packet when the player starts/stops flying with the Flags parameter changed accordingly. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x27

''resource:''
player_abilities + | rowspan="1"| Play + | rowspan="1"| Server + | Flags + | {{Type|Byte}} + | Bit mask. 0x02: is flying. + |} + +==== Player Action ==== + +Sent when the player mines a block. A vanilla server only accepts digging packets with coordinates within a 6-unit radius between the center of the block and the player's eyes. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x28

''resource:''
player_action + | rowspan="4"| Play + | rowspan="4"| Server + | Status + | {{Type|VarInt}} {{Type|Enum}} + | The action the player is taking against the block (see below). + |- + | Location + | {{Type|Position}} + | Block position. + |- + | Face + | {{Type|Byte}} {{Type|Enum}} + | The face being hit (see below). + |- + | Sequence + | {{Type|VarInt}} + | Block change sequence number (see [[#Acknowledge Block Change]]). + |} + +Status can be one of seven values: + +{| class="wikitable" + ! Value + ! Meaning + ! Notes + |- + | 0 + | Started digging + | Sent when the player starts digging a block. If the block was instamined or the player is in creative mode, the client will ''not'' send Status = Finished digging, and will assume the server completed the destruction. To detect this, it is necessary to [[Breaking#Speed|calculate the block destruction speed]] server-side. + |- + | 1 + | Cancelled digging + | Sent when the player lets go of the Mine Block key (default: left click). Face is always set to -Y. + |- + | 2 + | Finished digging + | Sent when the client thinks it is finished. + |- + | 3 + | Drop item stack + | Triggered by using the Drop Item key (default: Q) with the modifier to drop the entire selected stack (default: Control or Command, depending on OS). Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0. + |- + | 4 + | Drop item + | Triggered by using the Drop Item key (default: Q). Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0. + |- + | 5 + | Shoot arrow / finish eating + | Indicates that the currently held item should have its state updated such as eating food, pulling back bows, using buckets, etc. Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0. + |- + | 6 + | Swap item in hand + | Used to swap or assign an item to the second hand. Location is always set to 0/0/0, Face is always set to -Y. Sequence is always set to 0. + |} + +The Face field can be one of the following values, representing the face being hit: + +{| class="wikitable" + |- + ! Value + ! Offset + ! Face + |- + | 0 + | -Y + | Bottom + |- + | 1 + | +Y + | Top + |- + | 2 + | -Z + | North + |- + | 3 + | +Z + | South + |- + | 4 + | -X + | West + |- + | 5 + | +X + | East + |} + +==== Player Command ==== + +Sent by the client to indicate that it has performed certain actions: sneaking (crouching), sprinting, exiting a bed, jumping with a horse, and opening a horse's inventory while riding it. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x29

''resource:''
player_command + | rowspan="3"| Play + | rowspan="3"| Server + | Entity ID + | {{Type|VarInt}} + | Player ID (ignored by the vanilla server) + |- + | Action ID + | {{Type|VarInt}} {{Type|Enum}} + | The ID of the action, see below. + |- + | Jump Boost + | {{Type|VarInt}} + | Only used by the “start jump with horse” action, in which case it ranges from 0 to 100. In all other cases it is 0. + |} + +Action ID can be one of the following values: + +{| class="wikitable" + ! ID + ! Action + |- + | 0 + | Leave bed + |- + | 1 + | Start sprinting + |- + | 2 + | Stop sprinting + |- + | 3 + | Start jump with horse + |- + | 4 + | Stop jump with horse + |- + | 5 + | Open vehicle inventory + |- + | 6 + | Start flying with elytra + |} + +Leave bed is only sent when the “Leave Bed” button is clicked on the sleep GUI, not when waking up in the morning. + +Open vehicle inventory is only sent when pressing the inventory key (default: E) while on a horse or chest boat — all other methods of opening such an inventory (involving right-clicking or shift-right-clicking it) do not use this packet. + +==== Player Input ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x2A

''resource:''
player_input + | rowspan="1"| Play + | rowspan="1"| Server + | Flags + | {{Type|Unsigned Byte}} + | Bit mask; see below + |} + +The flags are as follows: + +{| class="wikitable" + |- + ! Hex Mask + ! Field + |- + | 0x01 + | Forward + |- + | 0x02 + | Backward + |- + | 0x04 + | Left + |- + | 0x08 + | Right + |- + | 0x10 + | Jump + |- + | 0x20 + | Sneak + |- + | 0x40 + | Sprint + |} + +==== Player Loaded ==== + +Sent by the client after the server starts sending chunks and the player's chunk has loaded. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x2B

''resource:''
player_loaded + | rowspan="1"| Play + | rowspan="1"| Server + | colspan="3"| ''no fields'' + |} + +==== Pong (play) ==== + +Response to the clientbound packet ([[#Ping (play)|Ping]]) with the same id. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x2C

''resource:''
pong + | rowspan="1"| Play + | rowspan="1"| Server + | ID + | {{Type|Int}} + | id is the same as the ping packet + |} + +==== Change Recipe Book Settings ==== + +Replaces Recipe Book Data, type 1. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x2D

''resource:''
recipe_book_change_settings + | rowspan="3"| Play + | rowspan="3"| Server + | Book ID + | {{Type|VarInt}} {{Type|Enum}} + | 0: crafting, 1: furnace, 2: blast furnace, 3: smoker. + |- + | Book Open + | {{Type|Boolean}} + | + |- + | Filter Active + | {{Type|Boolean}} + | + |} + +==== Set Seen Recipe ==== + +Sent when recipe is first seen in recipe book. Replaces Recipe Book Data, type 0. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x2E

''resource:''
recipe_book_seen_recipe + | rowspan="1"| Play + | rowspan="1"| Server + | Recipe ID + | {{Type|VarInt}} + | ID of recipe previously defined in Recipe Book Add. + |} + +==== Rename Item ==== + +Sent as a player is renaming an item in an anvil (each keypress in the anvil UI sends a new Rename Item packet). If the new name is empty, then the item loses its custom name (this is different from setting the custom name to the normal name of the item). The item name may be no longer than 50 characters long, and if it is longer than that, then the rename is silently ignored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x2F

''resource:''
rename_item + | rowspan="1"| Play + | rowspan="1"| Server + | Item name + | {{Type|String}} (32767) + | The new name of the item. + |} + +==== Resource Pack Response (play) ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x30

''resource:''
resource_pack + | rowspan="2"| Play + | rowspan="2"| Server + | UUID + | {{Type|UUID}} + | The unique identifier of the resource pack received in the [[#Add_Resource_Pack_(play)|Add Resource Pack (play)]] request. + |- + | Result + | {{Type|VarInt}} {{Type|Enum}} + | Result ID (see below). + |} + +Result can be one of the following values: + + +{| class="wikitable" + ! ID + ! Result + |- + | 0 + | Successfully downloaded + |- + | 1 + | Declined + |- + | 2 + | Failed to download + |- + | 3 + | Accepted + |- + | 4 + | Downloaded + |- + | 5 + | Invalid URL + |- + | 6 + | Failed to reload + |- + | 7 + | Discarded + |} + +==== Seen Advancements ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x31

''resource:''
seen_advancements + | rowspan="2"| Play + | rowspan="2"| Server + | Action + | {{Type|VarInt}} {{Type|Enum}} + | 0: Opened tab, 1: Closed screen. + |- + | Tab ID + | {{Type|Optional}} {{Type|Identifier}} + | Only present if action is Opened tab. + |} + +==== Select Trade ==== + +When a player selects a specific trade offered by a villager NPC. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x32

''resource:''
select_trade + | rowspan="1"| Play + | rowspan="1"| Server + | Selected slot + | {{Type|VarInt}} + | The selected slot in the players current (trading) inventory. + |} + +==== Set Beacon Effect ==== + +Changes the effect of the current beacon. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x33

''resource:''
set_beacon + | rowspan="2"| Play + | rowspan="2"| Server + | Primary Effect + | {{Type|Prefixed Optional}} {{Type|VarInt}} + | A [https://minecraft.wiki/w/Potion#ID Potion ID]. + |- + | Secondary Effect + | {{Type|Prefixed Optional}} {{Type|VarInt}} + | A [https://minecraft.wiki/w/Potion#ID Potion ID]. + |} + +==== Set Held Item (serverbound) ==== + +Sent when the player changes the slot selection. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x34

''resource:''
set_carried_item + | rowspan="1"| Play + | rowspan="1"| Server + | Slot + | {{Type|Short}} + | The slot which the player has selected (0–8). + |} + +==== Program Command Block ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x35

''resource:''
set_command_block + | rowspan="4"| Play + | rowspan="4"| Server + | Location + | {{Type|Position}} + | + |- + | Command + | {{Type|String}} (32767) + | + |- + | Mode || {{Type|VarInt}} {{Type|Enum}} || 0: chain, 1: repeating, 2: impulse. + |- + | Flags + | {{Type|Byte}} + | 0x01: Track Output (if false, the output of the previous command will not be stored within the command block); 0x02: Is conditional; 0x04: Automatic. + |} + +==== Program Command Block Minecart ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x36

''resource:''
set_command_minecart + | rowspan="3"| Play + | rowspan="3"| Server + | Entity ID + | {{Type|VarInt}} + | + |- + | Command + | {{Type|String}} (32767) + | + |- + | Track Output + | {{Type|Boolean}} + | If false, the output of the previous command will not be stored within the command block. + |} + +==== Set Creative Mode Slot ==== + +While the user is in the standard inventory (i.e., not a crafting bench) in Creative mode, the player will send this packet. + +Clicking in the creative inventory menu is quite different from non-creative inventory management. Picking up an item with the mouse actually deletes the item from the server, and placing an item into a slot or dropping it out of the inventory actually tells the server to create the item from scratch. (This can be verified by clicking an item that you don't mind deleting, then severing the connection to the server; the item will be nowhere to be found when you log back in.) As a result of this implementation strategy, the "Destroy Item" slot is just a client-side implementation detail that means "I don't intend to recreate this item.". Additionally, the long listings of items (by category, etc.) are a client-side interface for choosing which item to create. Picking up an item from such listings sends no packets to the server; only when you put it somewhere does it tell the server to create the item in that location. + +This action can be described as "set inventory slot". Picking up an item sets the slot to item ID -1. Placing an item into an inventory slot sets the slot to the specified item. Dropping an item (by clicking outside the window) effectively sets slot -1 to the specified item, which causes the server to spawn the item entity, etc.. All other inventory slots are numbered the same as the non-creative inventory (including slots for the 2x2 crafting menu, even though they aren't visible in the vanilla client). + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x37

''resource:''
set_creative_mode_slot + | rowspan="2"| Play + | rowspan="2"| Server + | Slot + | {{Type|Short}} + | Inventory slot. + |- + | Clicked Item + | {{Type|Slot}} + | + |} + +==== Program Jigsaw Block ==== + +Sent when Done is pressed on the [[Jigsaw Block]] interface. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="8"| ''protocol:''
0x38

''resource:''
set_jigsaw_block + | rowspan="8"| Play + | rowspan="8"| Server + | Location + | {{Type|Position}} + | Block entity location + |- + | Name + | {{Type|Identifier}} + | + |- + | Target + | {{Type|Identifier}} + | + |- + | Pool + | {{Type|Identifier}} + | + |- + | Final state + | {{Type|String}} (32767) + | "Turns into" on the GUI, final_state in NBT. + |- + | Joint type + | {{Type|String}} (32767) + | rollable if the attached piece can be rotated, else aligned. + |- + | Selection priority + | {{Type|VarInt}} + | + |- + | Placement priority + | {{Type|VarInt}} + | + |} + +==== Program Structure Block ==== + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="17"| ''protocol:''
0x39

''resource:''
set_structure_block + | rowspan="17"| Play + | rowspan="17"| Server + |- + | Location + | {{Type|Position}} + | Block entity location. + |- + | Action + | {{Type|VarInt}} {{Type|Enum}} + | An additional action to perform beyond simply saving the given data; see below. + |- + | Mode + | {{Type|VarInt}} {{Type|Enum}} + | One of SAVE (0), LOAD (1), CORNER (2), DATA (3). + |- + | Name + | {{Type|String}} (32767) + | + |- + | Offset X || {{Type|Byte}} + | Between -48 and 48. + |- + | Offset Y || {{Type|Byte}} + | Between -48 and 48. + |- + | Offset Z || {{Type|Byte}} + | Between -48 and 48. + |- + | Size X || {{Type|Byte}} + | Between 0 and 48. + |- + | Size Y || {{Type|Byte}} + | Between 0 and 48. + |- + | Size Z || {{Type|Byte}} + | Between 0 and 48. + |- + | Mirror + | {{Type|VarInt}} {{Type|Enum}} + | One of NONE (0), LEFT_RIGHT (1), FRONT_BACK (2). + |- + | Rotation + | {{Type|VarInt}} {{Type|Enum}} + | One of NONE (0), CLOCKWISE_90 (1), CLOCKWISE_180 (2), COUNTERCLOCKWISE_90 (3). + |- + | Metadata + | {{Type|String}} (128) + | + |- + | Integrity + | {{Type|Float}} + | Between 0 and 1. + |- + |Seed + |{{Type|VarLong}} + | + |- + | Flags + | {{Type|Byte}} + | 0x01: Ignore entities; 0x02: Show air; 0x04: Show bounding box; 0x08: Strict placement. + |} + +Possible actions: + +* 0 - Update data +* 1 - Save the structure +* 2 - Load the structure +* 3 - Detect size + +The vanilla client uses update data to indicate no special action should be taken (i.e. the done button). + +==== Set Test Block ==== + +Updates the value of the [[Test Block]] at the given position. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="3"| ''protocol:''
0x3A

''resource:''
set_test_block + | rowspan="3"| Play + | rowspan="3"| Server + | Position + | {{Type|Position}} + | + |- + | Mode + | {{Type|VarInt}} {{Type|Enum}} + | 0: start, 1: log, 2: fail, 3: accept + |- + | Message + | {{Type|String}} + | + |} + +==== Update Sign ==== + +This message is sent from the client to the server when the “Done” button is pushed after placing a sign. + +The server only accepts this packet after [[#Open Sign Editor|Open Sign Editor]], otherwise this packet is silently ignored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="6"| ''protocol:''
0x3B

''resource:''
sign_update + | rowspan="6"| Play + | rowspan="6"| Server + | Location + | {{Type|Position}} + | Block Coordinates. + |- + | Is Front Text + | {{Type|Boolean}} + | Whether the updated text is in front or on the back of the sign + |- + | Line 1 + | {{Type|String}} (384) + | First line of text in the sign. + |- + | Line 2 + | {{Type|String}} (384) + | Second line of text in the sign. + |- + | Line 3 + | {{Type|String}} (384) + | Third line of text in the sign. + |- + | Line 4 + | {{Type|String}} (384) + | Fourth line of text in the sign. + |} + +==== Swing Arm ==== + +Sent when the player's arm swings. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x3C

''resource:''
swing + | rowspan="1"| Play + | rowspan="1"| Server + | Hand + | {{Type|VarInt}} {{Type|Enum}} + | Hand used for the animation. 0: main hand, 1: off hand. + |} + +==== Teleport To Entity ==== + +Teleports the player to the given entity. The player must be in spectator mode. + +The vanilla client only uses this to teleport to players, but it appears to accept any type of entity. The entity does not need to be in the same dimension as the player; if necessary, the player will be respawned in the right world. If the given entity cannot be found (or isn't loaded), this packet will be ignored. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="1"| ''protocol:''
0x3D

''resource:''
teleport_to_entity + | rowspan="1"| Play + | rowspan="1"| Server + | Target Player + | {{Type|UUID}} + | UUID of the player to teleport to (can also be an entity UUID). + |} + +==== Test Instance Block Action ==== + +Tries to perform an action the [[Test Instance Block]] at the given position. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="10"| ''protocol:''
0x3E

''resource:''
test_instance_block_action + | rowspan="10"| Play + | rowspan="10"| Server + | Position + | {{Type|Position}} + | + |- + | Action + | {{Type|VarInt}} {{Type|Enum}} + | 0: init, 1: query, 2: set, 3: reset, 4: save, 5: export, 6: run. + |- + | Test + | {{Type|Prefixed Optional}} {{Type|VarInt}} + | ID in the minecraft:test_instance_kind registry. + |- + | Size X + | {{Type|VarInt}} + | + |- + | Size Y + | {{Type|VarInt}} + | + |- + | Size Z + | {{Type|VarInt}} + | + |- + | Rotation + | {{Type|VarInt}} {{Type|Enum}} + | 0: none, 1: clockwise 90°, 2: clockwise 180°, 3: counter-clockwise 90°. + |- + | Ignore Entities + | {{Type|Boolean}} + | + |- + | Status + | {{Type|VarInt}} {{Type|Enum}} + | 0: cleared, 1: running, 2: finished. + | + |- + | Error Message + | {{Type|Prefixed Optional}} {{Type|Text Component}} + | + |} + +==== Use Item On ==== + +{| class="wikitable" + |- + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="9"| ''protocol:''
0x3F

''resource:''
use_item_on + | rowspan="9"| Play + | rowspan="9"| Server + | Hand + | {{Type|VarInt}} {{Type|Enum}} + | The hand from which the block is placed; 0: main hand, 1: off hand. + |- + | Location + | {{Type|Position}} + | Block position. + |- + | Face + | {{Type|VarInt}} {{Type|Enum}} + | The face on which the block is placed (as documented at [[#Player Action|Player Action]]). + |- + | Cursor Position X + | {{Type|Float}} + | The position of the crosshair on the block, from 0 to 1 increasing from west to east. + |- + | Cursor Position Y + | {{Type|Float}} + | The position of the crosshair on the block, from 0 to 1 increasing from bottom to top. + |- + | Cursor Position Z + | {{Type|Float}} + | The position of the crosshair on the block, from 0 to 1 increasing from north to south. + |- + | Inside block + | {{Type|Boolean}} + | True when the player's head is inside of a block. + |- + | World Border Hit + | {{Type|Boolean}} + | Seems to always be false, even when interacting with blocks around or outside the world border, or while the player is outside the border. + |- + | Sequence + | {{Type|VarInt}} + | Block change sequence number (see [[#Acknowledge Block Change]]). + |} + +Upon placing a block, this packet is sent once. + +The Cursor Position X/Y/Z fields (also known as in-block coordinates) are calculated using raytracing. The unit corresponds to sixteen pixels in the default resource pack. For example, let's say a slab is being placed against the south face of a full block. The Cursor Position X will be higher if the player was pointing near the right (east) edge of the face, lower if pointing near the left. The Cursor Position Y will be used to determine whether it will appear as a bottom slab (values 0.0–0.5) or as a top slab (values 0.5-1.0). The Cursor Position Z should be 1.0 since the player was looking at the southernmost part of the block. + +Inside block is true when a player's head (specifically eyes) are inside of a block's collision. In 1.13 and later versions, collision is rather complicated and individual blocks can have multiple collision boxes. For instance, a ring of vines has a non-colliding hole in the middle. This value is only true when the player is directly in the box. In practice, though, this value is only used by scaffolding to place in front of the player when sneaking inside of it (other blocks will place behind when you intersect with them -- try with glass for instance). + +==== Use Item ==== + +Sent when pressing the Use Item key (default: right click) with an item in hand. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="4"| ''protocol:''
0x40

''resource:''
use_item + | rowspan="4"| Play + | rowspan="4"| Server + | Hand + | {{Type|VarInt}} {{Type|Enum}} + | Hand used for the animation. 0: main hand, 1: off hand. + |- + | Sequence + | {{Type|VarInt}} + | Block change sequence number (see [[#Acknowledge Block Change]]). + |- + | Yaw + | {{Type|Float}} + | Player head rotation along the Y-Axis. + |- + | Pitch + | {{Type|Float}} + | Player head rotation along the X-Axis. + |} + +The player's rotation is permanently updated according to the Yaw and Pitch fields before performing the action, unless there is no item in the specified hand. + +==== Custom Click Action (play) ==== + +Sent when the client clicks a {{Type|Text Component}} with the minecraft:custom click action. This is meant as an alternative to running a command, but will not have any effect on vanilla servers. + +{| class="wikitable" + ! Packet ID + ! State + ! Bound To + ! Field Name + ! Field Type + ! Notes + |- + | rowspan="2"| ''protocol:''
0x41

''resource:''
custom_click_action + | rowspan="2"| Play + | rowspan="2"| Server + | ID + | {{Type|Identifier}} + | The identifier for the click action. + |- + | Payload + | {{Type|NBT}} + | The data to send with the click action. May be a TAG_END (0). + |} + +== Navigation == +{{Navbox Java Edition technical|General}} + +[[Category:Protocol Details]] +[[Category:Java Edition protocol]] +{{license wiki.vg}} diff --git a/codec/slot/component.go b/codec/slot/component.go new file mode 100644 index 0000000..aa9f45a --- /dev/null +++ b/codec/slot/component.go @@ -0,0 +1,22 @@ +package slot + +import pk "github.com/Tnze/go-mc/net/packet" + +type Component interface { + Type() ComponentID + ID() string + + pk.Field +} + +type ComponentID int32 + +var components = make(map[ComponentID]Component) + +func ComponentFromID(id ComponentID) Component { + return components[id] +} + +func RegisterComponent(c Component) { + components[c.Type()] = c +} diff --git a/codec/slot/itemstack.go b/codec/slot/itemstack.go new file mode 100644 index 0000000..10d090d --- /dev/null +++ b/codec/slot/itemstack.go @@ -0,0 +1,111 @@ +package slot + +import ( + "io" + + pk "github.com/Tnze/go-mc/net/packet" +) + +type Slot struct { + Count int32 + ItemID int32 + AddComponent []Component + RemoveComponent []ComponentID +} + +func (s *Slot) WriteTo(w io.Writer) (n int64, err error) { + temp, err := pk.VarInt(s.Count).WriteTo(w) + if s.Count <= 0 || err != nil { + return temp, err + } + n += temp + temp, err = pk.VarInt(s.ItemID).WriteTo(w) + n += temp + if err != nil { + return temp, err + } + + temp, err = pk.VarInt(len(s.AddComponent)).WriteTo(w) + n += temp + if err != nil { + return temp, err + } + for _, c := range s.AddComponent { + temp, err = pk.VarInt(c.Type()).WriteTo(w) + n += temp + if err != nil { + return temp, err + } + temp, err = c.WriteTo(w) + n += temp + if err != nil { + return 0, err + } + } + + temp, err = pk.VarInt(len(s.RemoveComponent)).WriteTo(w) + n += temp + if err != nil { + return temp, err + } + for _, id := range s.RemoveComponent { + temp, err = pk.VarInt(id).WriteTo(w) + n += temp + if err != nil { + return temp, err + } + } + return temp, nil +} + +func (s *Slot) ReadFrom(r io.Reader) (n int64, err error) { + temp, err := (*pk.VarInt)(&s.Count).ReadFrom(r) + if s.Count <= 0 || err != nil { + return temp, err + } + n += temp + temp, err = (*pk.VarInt)(&s.ItemID).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + + addLens := int32(0) + temp, err = (*pk.VarInt)(&addLens).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + var id int32 + for i := int32(0); i < addLens; i++ { + temp, err = (*pk.VarInt)(&id).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + c := ComponentFromID(ComponentID(id)) + + temp, err = c.ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + } + + removeLens := int32(0) + temp, err = (*pk.VarInt)(&removeLens).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + + for i := int32(0); i < removeLens; i++ { + temp, err = (*pk.VarInt)(&id).ReadFrom(r) + n += temp + if err != nil { + return temp, err + } + } + + return n, nil +} diff --git a/gen-packet.sh b/gen-packet.sh new file mode 100755 index 0000000..750f3fd --- /dev/null +++ b/gen-packet.sh @@ -0,0 +1 @@ +packetizer ./codec \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a5d9b7a --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module git.konjactw.dev/patyhank/minego + +go 1.24 + +require ( + github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03 + github.com/google/uuid v1.6.0 +) + +replace github.com/Tnze/go-mc v1.20.3-0.20241224032005-539b4a3a7f03 => git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1caaf35 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2 h1:KiA1OsQQGjrKxev45URJPwvyuVwen9Bb4TzjEg/ojz8= +git.konjactw.dev/patyhank/go-mc v1.20.3-0.20250619063151-133e3fab4ac2/go.mod h1:e3pBU8tqRfYDHrhtZRtyfGdYijA86b1fF3XgnEDSgHk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/main.go b/main.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/main.go @@ -0,0 +1 @@ +package main