protocol

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 12 Imported by: 188

Documentation

Overview

Package protocol implements structures and functions used to write or read data related to the Minecraft Bedrock Edition protocol. The functions present in this package are generally used in the minecraft/protocol/packet library, where the encoding and decoding of packets may be found.

Index

Constants

View Source
const (
	CommandArgValid    = 0x100000
	CommandArgEnum     = 0x200000
	CommandArgSuffixed = 0x1000000
	CommandArgSoftEnum = 0x4000000

	CommandArgTypeInt         = 1
	CommandArgTypeFloat       = 2
	CommandArgTypeValue       = 3
	CommandArgTypeWildcardInt = 4
	CommandArgTypeOperator    = 5
	CommandArgTypeTarget      = 6
	CommandArgTypeFilepath    = 14
	CommandArgTypeString      = 29
	CommandArgTypePosition    = 37
	CommandArgTypeMessage     = 41
	CommandArgTypeRawText     = 43
	CommandArgTypeJSON        = 46
	CommandArgTypeCommand     = 53
)
View Source
const (
	// ParamOptionCollapseEnum specifies if the enum (only if the Type is actually an enum type. If not,
	// setting this to true has no effect) should be collapsed. This means that the options of the enum are
	// never shown in the actual usage of the command, but only as auto-completion, like it automatically does
	// with enums that have a big amount of options. To illustrate, it can make
	// <false|true|yes|no> <$Name: bool>.
	ParamOptionCollapseEnum = iota + 1
	ParamOptionHasSemanticConstraint
)
View Source
const (
	CommandOriginPlayer = iota
	CommandOriginBlock
	CommandOriginMinecartBlock
	CommandOriginDevConsole
	CommandOriginTest
	CommandOriginAutomationPlayer
	CommandOriginClientAutomation
	CommandOriginDedicatedServer
	CommandOriginEntity
	CommandOriginVirtual
	CommandOriginGameArgument
	CommandOriginEntityServer
)
View Source
const (
	EnchantmentSlotNone           = 0
	EnchantmentSlotAll            = 0xffff
	EnchantmentSlotArmour         = EnchantmentSlotHelmet | EnchantmentSlotChestplate | EnchantmentSlotLeggings | EnchantmentSlotBoots
	EnchantmentSlotHelmet         = 0x1
	EnchantmentSlotChestplate     = 0x2
	EnchantmentSlotLeggings       = 0x4
	EnchantmentSlotBoots          = 0x8
	EnchantmentSlotSword          = 0x10
	EnchantmentSlotBow            = 0x20
	EnchantmentSlotToolOther      = EnchantmentSlotHoe | EnchantmentSlotShears | EnchantmentSlotFlintAndSteel
	EnchantmentSlotHoe            = 0x40
	EnchantmentSlotShears         = 0x80
	EnchantmentSlotFlintAndSteel  = 0x100
	EnchantmentSlotDig            = EnchantmentSlotAxe | EnchantmentSlotPickaxe | EnchantmentSlotShovel
	EnchantmentSlotAxe            = 0x200
	EnchantmentSlotPickaxe        = 0x400
	EnchantmentSlotShovel         = 0x800
	EnchantmentSlotFishingRod     = 0x1000
	EnchantmentSlotCarrotOnAStick = 0x2000
	EnchantmentSlotElytra         = 0x4000
	EnchantmentSlotTrident        = 0x8000
)
View Source
const (
	// EntityLinkRemove is set to remove the link between two entities.
	EntityLinkRemove = iota
	// EntityLinkRider is set for entities that have control over the entity they're riding, such as in a
	// minecart.
	EntityLinkRider
	// EntityLinkPassenger is set for entities being a passenger of a vehicle they enter, such as the back
	// sit of a boat.
	EntityLinkPassenger
)
View Source
const (
	EntityDataByte = iota
	EntityDataInt16
	EntityDataInt32
	EntityDataFloat32
	EntityDataString
	EntityDataCompoundTag
	EntityDataBlockPos
	EntityDataInt64
	EntityDataVec3
)
View Source
const (
	// CurrentProtocol is the current protocol version for the version below.
	CurrentProtocol = 407
	// CurrentVersion is the current version of Minecraft as supported by the `packet` package.
	CurrentVersion = "1.16.0"
	// CurrentBlockVersion is the current version of blocks (states) of the game. This version is composed
	// of 4 bytes indicating a version, interpreted as a big endian int. The current version represents
	// 1.16.0.14 {1, 16, 0, 14}.
	CurrentBlockVersion int32 = 17825806
)
View Source
const (
	InventoryActionSourceContainer = 0
	InventoryActionSourceWorld     = 2
	InventoryActionSourceCreative  = 3
	InventoryActionSourceTODO      = 99999
)
View Source
const (
	WindowIDInventory = 0
	WindowIDOffHand   = 119
	WindowIDArmour    = 120
	WindowIDUI        = 124
)
View Source
const (
	UseItemActionClickBlock = iota
	UseItemActionClickAir
	UseItemActionBreakBlock
)
View Source
const (
	UseItemOnEntityActionInteract = iota
	UseItemOnEntityActionAttack
)
View Source
const (
	ReleaseItemActionRelease = iota
	ReleaseItemActionConsume
)
View Source
const (
	StackRequestActionTake = iota
	StackRequestActionPlace
	StackRequestActionSwap
	StackRequestActionDrop
	StackRequestActionDestroy
	StackRequestActionConsume
	StackRequestActionCreate
	StackRequestActionLabTableCombine
	StackRequestActionBeaconPayment
	StackRequestActionCraftRecipe
	StackRequestActionCraftRecipeAuto
	StackRequestActionCraftCreative
	StackRequestActionCraftNonImplementedDeprecated
	StackRequestActionCraftResultsDeprecated
)
View Source
const (
	MapObjectTypeEntity = iota
	MapObjectTypeBlock
)
View Source
const (
	RecipeShapeless = iota
	RecipeShaped
	RecipeFurnace
	RecipeFurnaceData
	RecipeMulti
	RecipeShulkerBox
	RecipeShapelessChemistry
	RecipeShapedChemistry
)
View Source
const (
	ScoreboardIdentityPlayer = iota + 1
	ScoreboardIdentityEntity
	ScoreboardIdentityFakePlayer
)
View Source
const (
	SkinAnimationHead = iota + 1
	SkinAnimationBody32x32
	SkinAnimationBody128x128
)
View Source
const (
	StructureMirrorNone = iota
	StructureMirrorLeftToRight
	StructureMirrorFrontToBack
)
View Source
const (
	CommandEnumConstraintCheatsEnabled = iota
)

Variables

This section is empty.

Functions

func Animation added in v1.3.0

func Animation(src *bytes.Buffer, x *SkinAnimation) error

Animation reads a SkinAnimation x from Buffer src.

func Attributes added in v0.3.0

func Attributes(src *bytes.Buffer, attributes *[]Attribute) error

Attributes reads an Attribute slice from bytes.Buffer src and stores it in the pointer passed.

func Blob added in v0.9.2

func Blob(src *bytes.Buffer, x *CacheBlob) error

Blob reads a CacheBlob x from Buffer src.

func BlockPosition added in v0.1.0

func BlockPosition(src *bytes.Buffer, x *BlockPos) error

BlockPosition reads a BlockPos from Buffer src and stores it to the BlockPos pointer passed.

func ByteSlice added in v0.9.2

func ByteSlice(src *bytes.Buffer, x *[]byte) error

ByteSlice reads a []byte x from Buffer src, setting the result to the pointer passed. The []byte read is prefixed by its length.

func CommandData

func CommandData(src *bytes.Buffer, x *Command, enums []CommandEnum, suffixes []string) error

CommandData reads a Command x from Buffer src using the enums and suffixes passed to match indices with the values these slices hold.

func CommandMessage added in v0.9.1

func CommandMessage(src *bytes.Buffer, x *CommandOutputMessage) error

CommandMessage reads a CommandOutputMessage x from Buffer src.

func CommandOriginData

func CommandOriginData(src *bytes.Buffer, x *CommandOrigin) error

CommandOriginData reads a CommandOrigin x from Buffer src.

func CommandParam

func CommandParam(src *bytes.Buffer, x *CommandParameter, enums []CommandEnum, suffixes []string) error

CommandParam reads a CommandParam x from Buffer src using the enums and suffixes passed to translate offsets to their respective values. CommandParam does not handle soft/dynamic enums. The caller is responsible to do this itself.

func CreativeEntry added in v1.7.0

func CreativeEntry(src *bytes.Buffer, x *CreativeItem) error

CreativeEntry reads a CreativeItem x from the Buffer src.

func Enchant added in v1.7.0

func Enchant(src *bytes.Buffer, x *EnchantmentInstance) error

Enchant reads an EnchantmentInstance x from Buffer src.

func EnchantOption added in v1.7.0

func EnchantOption(src *bytes.Buffer, x *EnchantmentOption) error

EnchantOption reads an EnchantmentOption x from Buffer src.

func EntityLinkAction added in v0.3.0

func EntityLinkAction(src *bytes.Buffer, x *EntityLink) error

EntityLinkAction reads a single entity link (action) from buffer src.

func EntityLinks(src *bytes.Buffer, x *[]EntityLink) error

EntityLinks reads a list of entity links from buffer src that are currently active.

func EntityMetadata added in v0.3.0

func EntityMetadata(src *bytes.Buffer, x *map[uint32]interface{}) error

EntityMetadata reads an entity metadata list from buffer src into map x. The types in the map will be one of byte, int16, int32, float32, string, map[string]interface{}, BlockPos, int64 or mgl32.Vec3.

func EnumConstraint

func EnumConstraint(src *bytes.Buffer, x *CommandEnumConstraint, enums []CommandEnum, enumValues []string) error

EnumConstraint reads a CommandEnumConstraint x from Buffer src using the enums and enum values passed.

func Float32 added in v0.1.0

func Float32(src *bytes.Buffer, x *float32) error

Float32 reads a float32 from Buffer src, setting the result to the pointer to a float32 passed.

func GameRules added in v0.1.0

func GameRules(src *bytes.Buffer, x *map[string]interface{}) error

GameRules reads a map of game rules from Buffer src. It sets one of the types 'bool', 'float32' or 'uint32' to the map x, with the key being the name of the game rule.

func InitialAttributes added in v0.3.0

func InitialAttributes(src *bytes.Buffer, attributes *[]Attribute) error

InitialAttributes reads an Attribute slice from bytes.Buffer src and stores it in the pointer passed. InitialAttributes is used when reading the attributes of a new entity. (AddEntity packet)

func InvAction added in v0.4.0

func InvAction(src *bytes.Buffer, action *InventoryAction, netIDs bool) error

InvAction reads an inventory action from buffer src.

func Item added in v0.3.0

func Item(src *bytes.Buffer, x *ItemStack) error

Item reads an item stack from buffer src and stores it into item stack x.

func ItemEnchants added in v1.7.0

func ItemEnchants(src *bytes.Buffer, x *ItemEnchantments) error

ItemEnchants reads an ItemEnchantments x from Buffer src.

func ItemInst added in v1.7.0

func ItemInst(src *bytes.Buffer, x *ItemInstance) error

ItemInst reads an ItemInstance x from Buffer src.

func MapDeco added in v0.7.0

func MapDeco(buf *bytes.Buffer, x *MapDecoration) error

MapDeco reads a MapDecoration from buf into x.

func MapTrackedObj added in v0.7.0

func MapTrackedObj(buf *bytes.Buffer, x *MapTrackedObject) error

MapTrackedObj reads a MapTrackedObject from buf into x.

func PackInfo added in v0.12.0

func PackInfo(buf *bytes.Buffer, x *ResourcePackInfo) error

PackInfo reads a resource pack info entry from the bytes.Buffer passed.

func PlayerAddEntry added in v0.12.0

func PlayerAddEntry(buf *bytes.Buffer, x *PlayerListEntry) error

PlayerAddEntry reads a PlayerListEntry x from Buffer buf in a way that adds a player to the list.

func PlayerRemoveEntry added in v0.12.0

func PlayerRemoveEntry(buf *bytes.Buffer, x *PlayerListEntry) error

PlayerRemoveEntry reads a PlayerListEntry x from Buffer buf in a way that removes a player from the list.

func PotContainerChangeRecipe added in v1.3.5

func PotContainerChangeRecipe(src *bytes.Buffer, x *PotionContainerChangeRecipe) error

PotContainerChangeRecipe reads a PotionContainerChangeRecipe x from Buffer src.

func PotRecipe added in v1.3.5

func PotRecipe(src *bytes.Buffer, x *PotionRecipe) error

PotRecipe reads a PotionRecipe x from Buffer src.

func RecipeIngredient added in v0.9.2

func RecipeIngredient(src *bytes.Buffer, x *ItemStack) error

RecipeIngredient reads an ItemStack x as a recipe ingredient from Buffer src.

func Rotation added in v0.3.0

func Rotation(src *bytes.Buffer, x *mgl32.Vec3) error

Rotation reads a rotation object from buffer src and stores it in Vec3 x. The rotation object exists out of 3 bytes.

func ScoreEntry added in v0.9.1

func ScoreEntry(src *bytes.Buffer, x *ScoreboardEntry, modify bool) error

ScoreEntry reads a ScoreboardEntry x from Buffer src. It reads the display information if modify is true, as expected when the SetScore packet is sent to modify entries.

func SerialisedSkin added in v1.3.0

func SerialisedSkin(src *bytes.Buffer, x *Skin) error

SerialisedSkin reads a Skin x from Buffer src.

func SetItemSlot added in v1.7.0

func SetItemSlot(src *bytes.Buffer, x *LegacySetItemSlot) error

SetItemSlot reads a LegacySetItemSlot x from Buffer src.

func SkinPiece added in v1.4.0

func SkinPiece(src *bytes.Buffer, x *PersonaPiece) error

SkinPiece reads a PersonaPiece x from Buffer src.

func SkinPieceTint added in v1.4.0

func SkinPieceTint(src *bytes.Buffer, x *PersonaPieceTintColour) error

SkinPieceTint reads a PersonaPieceTintColour x from Buffer src.

func StackContainerInfo added in v1.7.0

func StackContainerInfo(src *bytes.Buffer, x *StackResponseContainerInfo) error

StackContainerInfo reads a StackResponseContainerInfo x from Buffer src.

func StackPack added in v0.12.0

func StackPack(buf *bytes.Buffer, x *StackResourcePack) error

StackPack reads a StackResourcePack x to Buffer buf.

func StackReqSlotInfo

func StackReqSlotInfo(src *bytes.Buffer, x *StackRequestSlotInfo) error

StackReqSlotInfo reads a StackRequestSlotInfo x from Buffer src.

func StackRequest

func StackRequest(src *bytes.Buffer, x *ItemStackRequest) error

StackRequest reads an ItemStackRequest x from Buffer src.

func StackResponse added in v1.7.0

func StackResponse(src *bytes.Buffer, x *ItemStackResponse) error

StackResponse reads an ItemStackResponse x from Buffer src.

func StackSlotInfo added in v1.7.0

func StackSlotInfo(src *bytes.Buffer, x *StackResponseSlotInfo) error

StackSlotInfo reads a StackResponseSlotInfo x from Buffer src.

func String added in v0.1.0

func String(src *bytes.Buffer, x *string) error

String reads a string from Buffer src, setting the result to the pointer to a string passed. The string read is prefixed by a varuint32.

func StructSettings

func StructSettings(src *bytes.Buffer, x *StructureSettings) error

StructSettings reads StructureSettings x from Buffer src.

func UBlockPosition added in v0.1.0

func UBlockPosition(src *bytes.Buffer, x *BlockPos) error

UBlockPosition reads an unsigned BlockPos from Buffer src and stores it to the BlockPos pointer passed. The difference between this and BlockPosition is that the Y coordinate is read as a varuint32.

func UUID added in v0.3.0

func UUID(src *bytes.Buffer, id *uuid.UUID) error

UUID reads a little endian UUID from buffer src into UUID id.

func VarRGBA added in v0.7.0

func VarRGBA(buf *bytes.Buffer, x *color.RGBA) error

VarRGBA reads an RGBA value from buf into x packed into a varuint32.

func Varint32

func Varint32(src *bytes.Buffer, x *int32) error

Varint32 reads up to 5 bytes from the source buffer passed and sets the integer produced to a pointer.

func Varint64

func Varint64(src *bytes.Buffer, x *int64) error

Varint64 reads up to 10 bytes from the source buffer passed and sets the integer produced to a pointer.

func Varuint32

func Varuint32(src *bytes.Buffer, x *uint32) error

Varuint32 reads up to 5 bytes from the source buffer passed and sets the integer produced to a pointer.

func Varuint64

func Varuint64(src *bytes.Buffer, x *uint64) error

Varuint64 reads up to 10 bytes from the source buffer passed and sets the integer produced to a pointer.

func Vec2 added in v0.7.0

func Vec2(src *bytes.Buffer, x *mgl32.Vec2) error

Vec2 reads an mgl32.Vec2 (float32 vector) from Buffer src, setting the result to the pointer to an mgl32.Vec2 passed.

func Vec3 added in v0.1.0

func Vec3(src *bytes.Buffer, x *mgl32.Vec3) error

Vec3 reads an mgl32.Vec3 (float32 vector) from Buffer src, setting the result to the pointer to an mgl32.Vec3 passed.

func WriteAnimation added in v1.3.0

func WriteAnimation(dst *bytes.Buffer, x SkinAnimation) error

WriteAnimation writes a SkinAnimation x to Buffer dst.

func WriteAttributes added in v0.3.0

func WriteAttributes(dst *bytes.Buffer, x []Attribute) error

WriteAttributes writes a slice of Attributes x to buffer dst.

func WriteBlob added in v0.9.2

func WriteBlob(dst *bytes.Buffer, x CacheBlob) error

WriteBlob writes a CacheBlob x to Buffer dst.

func WriteBlockPosition added in v0.1.0

func WriteBlockPosition(dst *bytes.Buffer, x BlockPos) error

WriteBlockPosition writes a BlockPos x to Buffer dst, composed of 3 varint32s.

func WriteByteSlice added in v0.9.2

func WriteByteSlice(dst *bytes.Buffer, x []byte) error

WriteByteSlice writes a []byte x to Buffer dst. The []byte is prefixed by a varuint32 holding its length.

func WriteCommandData

func WriteCommandData(dst *bytes.Buffer, x Command, enumIndices map[string]int, suffixIndices map[string]int, dynamicEnumIndices map[string]int) error

WriteCommandData writes a Command x to Buffer dst, using the enum indices and suffix indices passed to translate enums and suffixes to the indices that they're written in in the buffer.

func WriteCommandMessage added in v0.9.1

func WriteCommandMessage(dst *bytes.Buffer, x CommandOutputMessage) error

WriteCommandMessage writes a CommandOutputMessage x to Buffer dst.

func WriteCommandOriginData added in v0.9.1

func WriteCommandOriginData(dst *bytes.Buffer, x CommandOrigin) error

WriteCommandOriginData writes a CommandOrigin x to Buffer dst.

func WriteCommandParam

func WriteCommandParam(dst *bytes.Buffer, x CommandParameter, enumIndices map[string]int, suffixIndices map[string]int, dynamicEnumIndices map[string]int) error

WriteCommandParam writes a CommandParameter x to Buffer dst, using the enum indices and suffix indices to translate the respective values to the offset in the buffer.

func WriteCreativeEntry added in v1.7.0

func WriteCreativeEntry(dst *bytes.Buffer, x CreativeItem) error

WriteCreativeEntry writes a CreativeItem x to the Buffer dst.

func WriteEnchant added in v1.7.0

func WriteEnchant(dst *bytes.Buffer, x EnchantmentInstance) error

WriteEnchant writes an EnchantmentInstance x to Buffer dst.

func WriteEnchantOption added in v1.7.0

func WriteEnchantOption(dst *bytes.Buffer, x EnchantmentOption) error

WriteEnchantOption writes an EnchantmentOption x to Buffer dst.

func WriteEntityLinkAction added in v0.3.0

func WriteEntityLinkAction(dst *bytes.Buffer, x EntityLink) error

WriteEntityLinkAction writes a single entity link x to buffer dst.

func WriteEntityLinks(dst *bytes.Buffer, x []EntityLink) error

WriteEntityLinks writes a list of entity links currently active to buffer dst.

func WriteEntityMetadata added in v0.3.0

func WriteEntityMetadata(dst *bytes.Buffer, x map[uint32]interface{}) error

WriteEntityMetadata writes an entity metadata list x to buffer dst. The types held by the map must be one of byte, int16, int32, float32, string, map[string]interface{}, BlockPos, int64 or mgl32.Vec3. The function will panic if a different type is encountered.

func WriteEnumConstraint

func WriteEnumConstraint(dst *bytes.Buffer, x CommandEnumConstraint, enumIndices map[string]int, enumValueIndices map[string]int) error

WriteEnumConstraint writes a CommandEnumConstraint x to Buffer dst using the enum (value) indices passed.

func WriteFloat32 added in v0.1.0

func WriteFloat32(dst *bytes.Buffer, x float32) error

WriteFloat32 writes a float32 to Buffer dst, by first converting it to a uint32.

func WriteGameRules added in v0.1.0

func WriteGameRules(dst *bytes.Buffer, x map[string]interface{}) error

WriteGameRules writes a map of game rules x, indexed by their names to Buffer dst. The types of the map values must be either 'bool', 'float32' or 'uint32'. If one of the values has a different type, the function will panic.

func WriteInitialAttributes added in v0.3.0

func WriteInitialAttributes(dst *bytes.Buffer, x []Attribute) error

WriteInitialAttributes writes a slice of Attributes x to buffer dst. WriteInitialAttributes is used when writing the attributes of a new entity. (AddEntity packet)

func WriteInvAction added in v0.4.0

func WriteInvAction(dst *bytes.Buffer, action InventoryAction, netIDs bool) error

WriteInvAction writes an inventory action to buffer dst.

func WriteItem added in v0.3.0

func WriteItem(dst *bytes.Buffer, x ItemStack) error

WriteItem writes an item stack x to buffer dst.

func WriteItemEnchants added in v1.7.0

func WriteItemEnchants(dst *bytes.Buffer, x ItemEnchantments) error

WriteItemEnchants writes an ItemEnchantments x to Buffer dst.

func WriteItemInst added in v1.7.0

func WriteItemInst(dst *bytes.Buffer, x ItemInstance) error

WriteItemInst writes an ItemInstance x to Buffer dst.

func WriteMapDeco added in v0.7.0

func WriteMapDeco(buf *bytes.Buffer, x MapDecoration) error

WriteMapDeco writes a MapDecoration x to buf.

func WriteMapTrackedObj added in v0.7.0

func WriteMapTrackedObj(buf *bytes.Buffer, x MapTrackedObject) error

WriteMapTrackedObj writes a MapTrackedObject xx to buf.

func WritePackInfo added in v0.12.0

func WritePackInfo(buf *bytes.Buffer, x ResourcePackInfo) error

WritePackInfo writes a resource pack info entry to the bytes.Buffer passed.

func WritePlayerAddEntry added in v0.12.0

func WritePlayerAddEntry(buf *bytes.Buffer, x PlayerListEntry) error

WritePlayerAddEntry writes a PlayerListEntry x to Buffer buf in a way that adds the player to the list.

func WritePlayerRemoveEntry added in v0.12.0

func WritePlayerRemoveEntry(buf *bytes.Buffer, x PlayerListEntry) error

WritePlayerRemoveEntry writes a PlayerListEntry x to Buffer buf in a way that removes a player from the list.

func WritePotContainerChangeRecipe added in v1.3.5

func WritePotContainerChangeRecipe(dst *bytes.Buffer, x PotionContainerChangeRecipe) error

WritePotContainerChangeRecipe writes a PotionContainerChangeRecipe x to Buffer dst.

func WritePotRecipe added in v1.3.5

func WritePotRecipe(dst *bytes.Buffer, x PotionRecipe) error

WritePotRecipe writes a PotionRecipe x to Buffer dst.

func WriteRecipeIngredient added in v0.9.2

func WriteRecipeIngredient(dst *bytes.Buffer, x ItemStack) error

WriteRecipeIngredient writes an ItemStack x as a recipe ingredient to Buffer dst.

func WriteRotation added in v0.3.0

func WriteRotation(dst *bytes.Buffer, x mgl32.Vec3) error

WriteRotation writes a rotation Vec3 to buffer dst as 3 bytes.

func WriteScoreEntry added in v0.9.1

func WriteScoreEntry(dst *bytes.Buffer, x ScoreboardEntry, modify bool) error

WriteScoreEntry writes a ScoreboardEntry x to Buffer dst. If modify is set to true, the display information of the entry is written. If not, it is ignored, as expected when the SetScore packet is sent to modify entries.

func WriteSerialisedSkin added in v1.3.0

func WriteSerialisedSkin(dst *bytes.Buffer, x Skin) error

WriteSerialisedSkin writes a Skin x to Buffer dst. WriteSerialisedSkin panics if the fields of the skin have invalid values, usually indicating that the dimensions of the skin images are incorrect.

func WriteSetItemSlot added in v1.7.0

func WriteSetItemSlot(dst *bytes.Buffer, x LegacySetItemSlot) error

WriteSetItemSlot writes a LegacySetItemSlot x to Buffer dst.

func WriteSkinPiece added in v1.4.0

func WriteSkinPiece(dst *bytes.Buffer, x PersonaPiece) error

WriteSkinPiece writes a PersonaPiece x to Buffer dst.

func WriteSkinPieceTint added in v1.4.0

func WriteSkinPieceTint(dst *bytes.Buffer, x PersonaPieceTintColour) error

WriteSkinPieceTint writes a PersonaPieceTintColour x to Buffer dst.

func WriteStackContainerInfo added in v1.7.0

func WriteStackContainerInfo(dst *bytes.Buffer, x StackResponseContainerInfo) error

WriteStackContainerInfo writes a StackResponseContainerInfo x to Buffer dst.

func WriteStackPack added in v0.12.0

func WriteStackPack(buf *bytes.Buffer, x StackResourcePack) error

WriteStackPack writes a StackResourcePack x to Buffer buf.

func WriteStackReqSlotInfo added in v1.7.0

func WriteStackReqSlotInfo(dst *bytes.Buffer, x StackRequestSlotInfo) error

WriteStackReqSlotInfo writes a StackRequestSlotInfo x to Buffer dst.

func WriteStackRequest

func WriteStackRequest(dst *bytes.Buffer, x ItemStackRequest) error

WriteStackRequest writes an ItemStackRequest x to Buffer dst.

func WriteStackResponse added in v1.7.0

func WriteStackResponse(dst *bytes.Buffer, x ItemStackResponse) error

WriteStackResponse writes an ItemStackResponse x to Buffer dst.

func WriteStackSlotInfo added in v1.7.0

func WriteStackSlotInfo(dst *bytes.Buffer, x StackResponseSlotInfo) error

WriteStackSlotInfo writes a StackResponseSlotInfo x to Buffer dst.

func WriteString added in v0.1.0

func WriteString(dst *bytes.Buffer, x string) error

WriteString writes a string x to Buffer dst. The string is a slice of bytes prefixed by a varuint32 specifying its length.

func WriteStructSettings added in v0.9.2

func WriteStructSettings(dst *bytes.Buffer, x StructureSettings) error

WriteStructSettings writes StructureSettings x to Buffer dst.

func WriteUBlockPosition added in v0.1.0

func WriteUBlockPosition(dst *bytes.Buffer, x BlockPos) error

WriteUBlockPosition writes an unsigned BlockPos x to Buffer dst, composed of a varint32, varuint32 and a varint32.

func WriteUUID added in v0.3.0

func WriteUUID(dst *bytes.Buffer, id uuid.UUID) error

WriteUUID writes a little endian UUID id to buffer dst.

func WriteVarRGBA added in v0.7.0

func WriteVarRGBA(buf *bytes.Buffer, x color.RGBA) error

WriteVarRGBA writes an RGBA value to buf by packing it into a varuint32.

func WriteVarint32

func WriteVarint32(dst *bytes.Buffer, x int32) error

WriteVarint32 writes an int32 to the destination buffer passed with a size of 1-5 bytes.

func WriteVarint64

func WriteVarint64(dst *bytes.Buffer, x int64) error

WriteVarint64 writes an int64 to the destination buffer passed with a size of 1-10 bytes.

func WriteVaruint32

func WriteVaruint32(dst *bytes.Buffer, x uint32) error

WriteVaruint32 writes a uint32 to the destination buffer passed with a size of 1-5 bytes.

func WriteVaruint64

func WriteVaruint64(dst *bytes.Buffer, x uint64) error

WriteVaruint64 writes a uint64 to the destination buffer passed with a size of 1-10 bytes.

func WriteVec2 added in v0.7.0

func WriteVec2(dst *bytes.Buffer, x mgl32.Vec2) error

WriteVec2 writes an mgl32.Vec2 (float32 vector) to Buffer dst, writing each of the float32s separately.

func WriteVec3 added in v0.1.0

func WriteVec3(dst *bytes.Buffer, x mgl32.Vec3) error

WriteVec3 writes an mgl32.Vec3 (float32 vector) to Buffer dst, writing each of the float32s separately.

Types

type Attribute

type Attribute struct {
	// Name is the name of the attribute, for example 'minecraft:health'. These names must be identical to
	// the ones defined client-side.
	Name string
	// Value is the current value of the attribute. This value will be applied to the entity when sent in a
	// packet.
	Value float32
	// Max and Min specify the boundaries within the value of the attribute must be. The definition of these
	// fields differ per attribute. The maximum health of an entity may be changed, whereas the maximum
	// movement speed for example may not be.
	Max, Min float32
	// Default is the default value of the attribute. It's not clear why this field must be sent to the
	// client, but it is required regardless.
	Default float32
}

Attribute is an entity attribute, that holds specific data such as the health of the entity. Each attribute holds a default value, maximum and minimum value, name and its current value.

type AutoCraftRecipeStackRequestAction

type AutoCraftRecipeStackRequestAction struct {
	CraftRecipeStackRequestAction
}

AutoCraftRecipeStackRequestAction is sent by the client similarly to the CraftRecipeStackRequestAction. The only difference is that the recipe is automatically created and crafted by shift clicking the recipe book.

type BeaconPaymentStackRequestAction

type BeaconPaymentStackRequestAction struct {
	// PrimaryEffect and SecondaryEffect are the effects that were selected from the beacon.
	PrimaryEffect, SecondaryEffect int32
}

BeaconPaymentStackRequestAction is sent by the client when it submits an item to enable effects from a beacon. These items will have been moved into the beacon item slot in advance.

func (*BeaconPaymentStackRequestAction) Marshal

func (a *BeaconPaymentStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*BeaconPaymentStackRequestAction) Unmarshal added in v1.7.0

Unmarshal ...

type BlockPos

type BlockPos [3]int32

BlockPos is the position of a block. It is composed of three integers, and is typically written as either 3 varint32s or a varint32, varuint32 and varint32.

func (BlockPos) X

func (pos BlockPos) X() int32

X returns the X coordinate of the block position. It is equivalent to BlockPos[0].

func (BlockPos) Y

func (pos BlockPos) Y() int32

Y returns the Y coordinate of the block position. It is equivalent to BlockPos[1].

func (BlockPos) Z

func (pos BlockPos) Z() int32

Z returns the Z coordinate of the block position. It is equivalent to BlockPos[2].

type CacheBlob

type CacheBlob struct {
	// Hash is the hash of the blob. The hash is computed using xxHash, and must be deterministic for the same
	// chunk data.
	Hash uint64
	// Payload is the data of the blob. When sent, the client will associate the Hash of the blob with the
	// Payload in it.
	Payload []byte
}

CacheBlob represents a blob as used in the client side blob cache protocol. It holds a hash of its data and the full data of it.

type Command

type Command struct {
	// Name is the name of the command. The command may be executed using this name, and will be shown in the
	// /help list with it. It currently seems that the client crashes if the Name contains uppercase letters.
	Name string
	// Description is the description of the command. It is shown in the /help list and when starting to write
	// a command.
	Description string
	// Flags is a combination of flags not currently known. Leaving the Flags field empty appears to work.
	Flags byte
	// PermissionLevel is the command permission level that the player required to execute this command. The
	// field no longer seems to serve a purpose, as the client does not handle the execution of commands
	// anymore: The permissions should be checked server-side.
	PermissionLevel byte
	// Aliases is a list of aliases of the command name, that may alternatively be used to execute the command
	// in the same way.
	Aliases []string
	// Overloads is a list of command overloads that specify the ways in which a command may be executed. The
	// overloads may be completely different.
	Overloads []CommandOverload
}

Command holds the data that a command requires to be shown to a player client-side. The command is shown in the /help command and auto-completed using this data.

type CommandEnum

type CommandEnum struct {
	// Type is the type of the command enum. The type will show up in the command usage as the type of the
	// argument if it has a certain amount of arguments, or when Options is set to true in the
	// command holding the enum.
	Type string
	// Options is a list of options that are valid for the client to submit to the command. They will be able
	// to be auto-completed and show up as options client-side.
	Options []string
	// Dynamic specifies if the command enum is considered dynamic. If set to true, it is written differently
	// and may be updated during runtime as a result using the UpdateSoftEnum packet.
	Dynamic bool
}

CommandEnum represents an enum in a command usage. The enum typically has a type and a set of options that are valid. A value that is not one of the options results in a failure during execution.

type CommandEnumConstraint

type CommandEnumConstraint struct {
	// EnumOption is the option in an enum that the constraints should be applied to.
	EnumOption string
	// EnumName is the name of the enum of which the EnumOption above should be constrained.
	EnumName string
	// Constraints is a list of constraints that should be applied to the enum option. It is one of the values
	// found above.
	Constraints []byte
}

CommandEnumConstraint is sent in the AvailableCommands packet to limit what values of an enum may be used taking in account things such as whether cheats are enabled.

type CommandOrigin

type CommandOrigin struct {
	// Origin is one of the values above that specifies the origin of the command. The origin may change,
	// depending on what part of the client actually called the command. The command may be issued by a
	// websocket server, for example.
	Origin uint32
	// UUID is the UUID of the command called. This UUID is a bit odd as it is not specified by the server. It
	// is not clear what exactly this UUID is meant to identify, but it is unique for each command called.
	UUID uuid.UUID
	// RequestID is an ID that identifies the request of the client. The server should send a CommandOrigin
	// with the same request ID to ensure it can be matched with the request by the caller of the command.
	// This is especially important for websocket servers and it seems that this field is only non-empty for
	// these websocket servers.
	RequestID string
	// PlayerUniqueID is an ID that identifies the player, the same as the one found in the AdventureSettings
	// packet. Filling it out with 0 seems to work.
	// PlayerUniqueID is only written if Origin is CommandOriginDevConsole or CommandOriginTest.
	PlayerUniqueID int64
}

CommandOrigin holds data that identifies the origin of the requesting of a command. It holds several fields that may be used to get specific information. When sent in a CommandRequest packet, the same CommandOrigin should be sent in a CommandOutput packet.

type CommandOutputMessage

type CommandOutputMessage struct {
	// Success indicates if the output message was one of a successful command execution. If set to true, the
	// output message is by default coloured white, whereas if set to false, the message is by default
	// coloured red.
	Success bool
	// Message is the message that is sent to the client in the chat window. It may either be simply a
	// message or a translated built-in string like 'commands.tp.success.coordinates', combined with specific
	// parameters below.
	Message string
	// Parameters is a list of parameters that serve to supply the message sent with additional information,
	// such as the position that a player was teleported to or the effect that was applied to an entity.
	// These parameters only apply for the Minecraft built-in command output.
	Parameters []string
}

CommandOutputMessage represents a message sent by a command that holds the output of one of the commands executed.

type CommandOverload

type CommandOverload struct {
	// Parameters is a list of command parameters that are part of the overload. These parameters specify the
	// usage of the command when this overload is applied.
	Parameters []CommandParameter
}

CommandOverload represents an overload of a command. This overload can be compared to function overloading in languages such as java. It represents a single usage of the command. A command may have multiple different overloads, which are handled differently.

type CommandParameter

type CommandParameter struct {
	// Name is the name of the command parameter. It shows up in the usage like <$Name: $Type>, with the
	// exception of enum types, which show up simply as a list of options if the list is short enough and
	// Options is set to false.
	Name string
	// Type is a rather odd combination of type(flag)s that result in a certain parameter type to show up
	// client-side. It is a combination of the flags above. The basic types must be combined with the
	// ArgumentTypeFlagBasic flag (and integers with a suffix ArgumentTypeFlagSuffixed), whereas enums are
	// combined with the ArgumentTypeFlagEnum flag.
	Type uint32
	// Optional specifies if the command parameter is optional to enter. Note that no non-optional parameter
	// should ever be present in a command overload after an optional parameter. When optional, the parameter
	// shows up like so: [$Name: $Type], whereas when mandatory, it shows up like so: <$Name: $Type>.
	Optional bool
	// Options holds a combinations of options that additionally apply to the command parameter. The list of
	// options can be found above.
	Options byte

	// Enum is the enum of the parameter if it should be of the type enum. If non-empty, the parameter will
	// be treated as an enum and show up as such client-side.
	Enum CommandEnum
	// Suffix is the suffix of the parameter if it should receive one. Note that only integer argument types
	// are able to receive a suffix, and so the type, if Suffix is a non-empty string, will always be an
	// integer.
	Suffix string
}

CommandParameter represents a single parameter of a command overload, which accepts a certain type of input values. It has a name and a type which show up client-side when a player is entering the command.

type ConsumeStackRequestAction

type ConsumeStackRequestAction struct {
	DestroyStackRequestAction
}

ConsumeStackRequestAction is sent by the client when it uses an item to craft another item. The original item is 'consumed'.

type CraftCreativeStackRequestAction

type CraftCreativeStackRequestAction struct {
	// CreativeItemNetworkID is the network ID of the creative item that is being created. This is one of the
	// creative item network IDs sent in the CreativeContent packet.
	CreativeItemNetworkID uint32
}

CraftCreativeStackRequestAction is sent by the client when it takes an item out fo the creative inventory. The item is thus not really crafted, but instantly created.

func (*CraftCreativeStackRequestAction) Marshal

func (a *CraftCreativeStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*CraftCreativeStackRequestAction) Unmarshal added in v1.7.0

Unmarshal ...

type CraftNonImplementedStackRequestAction

type CraftNonImplementedStackRequestAction struct{}

CraftNonImplementedStackRequestAction is an action sent for inventory actions that aren't yet implemented in the new system. These include, for example, anvils.

func (*CraftNonImplementedStackRequestAction) Marshal

Marshal ...

func (*CraftNonImplementedStackRequestAction) Unmarshal added in v1.7.0

Unmarshal ...

type CraftRecipeStackRequestAction

type CraftRecipeStackRequestAction struct {
	// RecipeNetworkID is the network ID of the recipe that is about to be crafted. This network ID matches
	// one of the recipes sent in the CraftingData packet, where each of the recipes have a RecipeNetworkID as
	// of 1.16.
	RecipeNetworkID uint32
}

CraftRecipeStackRequestAction is sent by the client the moment it begins crafting an item. This is the first action sent, before the Consume and Create item stack request actions. This action is also sent when an item is enchanted. Enchanting should be treated mostly the same way as crafting, where the old item is consumed.

func (*CraftRecipeStackRequestAction) Marshal

func (a *CraftRecipeStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*CraftRecipeStackRequestAction) Unmarshal added in v1.7.0

func (a *CraftRecipeStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type CraftResultsDeprecatedStackRequestAction

type CraftResultsDeprecatedStackRequestAction struct {
	ResultItems  []ItemStack
	TimesCrafted byte
}

CraftResultsDeprecatedStackRequestAction is an additional, deprecated packet sent by the client after crafting. It holds the final results and the amount of times the recipe was crafted. It shouldn't be used. This action is also sent when an item is enchanted. Enchanting should be treated mostly the same way as crafting, where the old item is consumed.

func (*CraftResultsDeprecatedStackRequestAction) Marshal

Marshal ...

func (*CraftResultsDeprecatedStackRequestAction) Unmarshal added in v1.7.0

Unmarshal ...

type CreateStackRequestAction

type CreateStackRequestAction struct {
	// ResultsSlot is the slot in the inventory in which the results of the crafting ingredients are to be
	// placed.
	ResultsSlot byte
}

CreateStackRequestAction is sent by the client when an item is created through being used as part of a recipe. For example, when milk is used to craft a cake, the buckets are leftover. The buckets are moved to the slot sent by the client here. Note that before this is sent, an action for consuming all items in the crafting table/grid is sent. Items that are not fully consumed when used for a recipe should not be destroyed there, but instead, should be turned into their respective resulting items.

func (*CreateStackRequestAction) Marshal

func (a *CreateStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*CreateStackRequestAction) Unmarshal added in v1.7.0

func (a *CreateStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type CreativeItem

type CreativeItem struct {
	// CreativeItemNetworkID is a unique ID for the creative item. It has to be unique for each creative item
	// sent to the client. An incrementing ID per creative item does the job.
	CreativeItemNetworkID uint32
	// Item is the item that should be added to the creative inventory.
	Item ItemStack
}

CreativeItem represents a creative item present in the creative inventory.

type DestroyStackRequestAction

type DestroyStackRequestAction struct {
	// Count is the count of the item in the source slot that was destroyed.
	Count byte
	// Source is the source slot from which items came that were destroyed by moving them into the creative
	// inventory.
	Source StackRequestSlotInfo
}

DestroyStackRequestAction is sent by the client when it destroys an item in creative mode by moving it back into the creative inventory.

func (*DestroyStackRequestAction) Marshal

func (a *DestroyStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*DestroyStackRequestAction) Unmarshal added in v1.7.0

func (a *DestroyStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type DeviceOS

type DeviceOS int

DeviceOS is a device DeviceOS identifier. It holds a value of one of the constants below and may be found in packets such as the Login packet.

const (
	DeviceAndroid DeviceOS = iota + 1
	DeviceIOS
	DeviceOSX
	DeviceFireOS
	DeviceGearVR
	DeviceHololens
	DeviceWin10
	DeviceWin32
	DeviceDedicated
	DeviceTVOS
	DeviceOrbis
	DeviceNX
	DeviceXBOX
)

type DropStackRequestAction

type DropStackRequestAction struct {
	// Count is the count of the item in the source slot that was taken towards the destination slot.
	Count byte
	// Source is the source slot from which items were dropped to the ground.
	Source StackRequestSlotInfo
	// Randomly seems to be set to false in most cases. I'm not entirely sure what this does, but this is what
	// vanilla calls this field.
	Randomly bool
}

DropStackRequestAction is sent by the client when it drops an item out of the inventory when it has its inventory opened. This action is not sent when a player drops an item out of the hotbar using the Q button (or the equivalent on mobile). The InventoryTransaction packet is still used for that action, regardless of whether the item stack network IDs are used or not.

func (*DropStackRequestAction) Marshal

func (a *DropStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*DropStackRequestAction) Unmarshal added in v1.7.0

func (a *DropStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type EnchantmentInstance

type EnchantmentInstance struct {
	Type  byte
	Level byte
}

EnchantmentInstance represents a single enchantment instance with the type of the enchantment and its level.

type EnchantmentOption

type EnchantmentOption struct {
	// Cost is the cost of the option. This is the amount of XP levels required to select this enchantment
	// option.
	Cost uint32
	// Enchantments holds the enchantments that will be applied to the item when this option is clicked.
	Enchantments ItemEnchantments
	// Name is a name that will be translated to the 'Standard Galactic Alphabet'
	// (https://minecraft.gamepedia.com/Enchanting_Table#Standard_Galactic_Alphabet) client-side. The names
	// generally have no meaning, such as:
	// 'animal imbue range galvanize '
	// 'bless inside creature shrink '
	// 'elder free of inside '
	Name string
	// RecipeNetworkID is a unique network ID for this enchantment option. When enchanting, the client
	// will submit this network ID in a ItemStackRequest packet with the CraftRecipe action, so that the
	// server knows which enchantment was selected.
	// Note that this ID should still be unique with other actual recipes. It's recommended to start counting
	// for enchantment network IDs from the counter used for producing network IDs for the normal recipes.
	RecipeNetworkID uint32
}

EnchantmentOption represents a single option in the enchantment table for a single item.

type EntityLink struct {
	// RiddenEntityUniqueID is the entity unique ID of the entity that is being ridden. For a player sitting
	// in a boat, this is the unique ID of the boat.
	RiddenEntityUniqueID int64
	// RiderEntityUniqueID is the entity unique ID of the entity that is riding. For a player sitting in a
	// boat, this is the unique ID of the player.
	RiderEntityUniqueID int64
	// Type is one of the types above. It specifies the way the entity is linked to another entity.
	Type byte
	// Immediate is set to immediately dismount an entity from another. This should be set when the mount of
	// an entity is killed.
	Immediate bool
	// RiderInitiated specifies if the link was created by the rider, for example the player starting to ride
	// a horse by itself. This is generally true in vanilla environment for players.
	RiderInitiated bool
}

EntityLink is a link between two entities, typically being one entity riding another.

type FurnaceDataRecipe

type FurnaceDataRecipe FurnaceRecipe

FurnaceDataRecipe is a recipe specifically used for furnace-type crafting stations. It is equal to FurnaceRecipe, except it has an input item with a specific metadata value, instead of any metadata value.

func (*FurnaceDataRecipe) Marshal

func (recipe *FurnaceDataRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*FurnaceDataRecipe) Unmarshal

func (recipe *FurnaceDataRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type FurnaceRecipe

type FurnaceRecipe struct {
	// InputType is the item type of the input item. The metadata value of the item is not used in the
	// FurnaceRecipe. Use FurnaceDataRecipe to allow an item with only one metadata value.
	InputType ItemType
	// Output is the item that is created as a result of smelting/cooking an item in the furnace.
	Output ItemStack
	// Block is the block name that is required to create the output of the recipe. The block is not prefixed
	// with 'minecraft:', so it will look like 'furnace' as an example.
	Block string
}

FurnaceRecipe is a recipe that is specifically used for all kinds of furnaces. These recipes don't just apply to furnaces, but also blast furnaces and smokers.

func (*FurnaceRecipe) Marshal

func (recipe *FurnaceRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*FurnaceRecipe) Unmarshal

func (recipe *FurnaceRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type InventoryAction

type InventoryAction struct {
	// SourceType is the source type of the inventory action. It is one of the constants above.
	SourceType uint32
	// WindowID is the ID of the window that the client has opened. The window ID is not set if the SourceType
	// is InventoryActionSourceWorld.
	WindowID int32
	// SourceFlags is a combination of flags that is only set if the SourceType is InventoryActionSourceWorld.
	SourceFlags uint32
	// InventorySlot is the slot in which the action took place. Each action only describes the change of item
	// in a single slot.
	InventorySlot uint32
	// OldItem is the item that was present in the slot before the inventory action. It should be checked by
	// the server to ensure the inventories were not out of sync.
	OldItem ItemStack
	// NewItem is the new item that was put in the InventorySlot that the OldItem was in. It must be checked
	// in combination with other inventory actions to ensure that the transaction is balanced.
	NewItem ItemStack
	// StackNetworkID is the unique network ID of the new stack. This is always 0 when an InventoryTransaction
	// packet is sent by the client. It is also always 0 when the HasNetworkIDs field in the
	// InventoryTransaction packet is set to false.
	StackNetworkID int32
}

InventoryAction represents a single action that took place during an inventory transaction. On itself, this inventory action is always unbalanced: It must be combined with other actions in an inventory transaction to form a balanced transaction.

type InventoryTransactionData

type InventoryTransactionData interface {
	// Marshal encodes the inventory transaction data to its binary representation into buf.
	Marshal(buf *bytes.Buffer)
	// Unmarshal decodes a serialised inventory transaction data object in buf into the
	// InventoryTransactionData instance.
	Unmarshal(buf *bytes.Buffer) error
}

InventoryTransactionData represents an object that holds data specific to an inventory transaction type. The data it holds depends on the type.

type ItemEnchantments

type ItemEnchantments struct {
	// Slot is the enchantment slot of the item that was put into the enchantment table, for which the
	// following enchantments will apply.
	// The possible slots can be found above.
	Slot int32
	// Enchantments is an array of 3 slices of enchantment instances. Each array represents enchantments that
	// will be added to the item with a different activation type. The arrays in which enchantments are sent
	// by the vanilla server are as follows:
	// slice 1 { protection, fire protection, feather falling, blast protection, projectile protection,
	//           thorns, respiration, depth strider, aqua affinity, frost walker, soul speed }
	// slice 2 { sharpness, smite, bane of arthropods, fire aspect, looting, silk touch, unbreaking, fortune,
	//           flame, luck of the sea, impaling }
	// slice 3 { knockback, efficiency, power, punch, infinity, lure, mending, curse of binding,
	//           curse of vanishing, riptide, loyalty, channeling, multishot, piercing, quick charge }
	// The first slice holds armour enchantments, the differences between the slice 2 and slice 3 are more
	// vaguely defined.
	Enchantments [3][]EnchantmentInstance
}

ItemEnchantments holds information on the enchantments that are applied to an item when a specific button is clicked in the enchantment table.

type ItemEntry

type ItemEntry struct {
	// Name if the name of the item, which is a name like 'minecraft:stick'.
	Name string
	// LegacyID is the legacy ID of the item. It must point to either an existing item ID or a new one if it
	// seeks to implement a new item.
	LegacyID int16
}

ItemEntry is an item sent in the StartGame item table. It holds a name and a legacy ID, which is used to point back to that name.

type ItemInstance

type ItemInstance struct {
	// StackNetworkID is the network ID of the item stack. If the stack is empty, 0 is always written for this
	// field. If not, the field should be set to 1 if the server authoritative inventories are disabled in the
	// StartGame packet, or to a unique stack ID if it is enabled.
	StackNetworkID int32
	// Stack is the actual item stack of the item instance.
	Stack ItemStack
}

ItemInstance represents a unique instance of an item stack. These instances carry a specific network ID that is persistent for the stack.

type ItemStack

type ItemStack struct {
	ItemType
	// Count is the count of items that the item stack holds.
	Count int16
	// NBTData is a map that is serialised to its NBT representation when sent in a packet.
	NBTData map[string]interface{}
	// CanBePlacedOn is a list of block identifiers like 'minecraft:stone' which the item, if it is an item
	// that can be placed, can be placed on top of.
	CanBePlacedOn []string
	// CanBreak is a list of block identifiers like 'minecraft:dirt' that the item is able to break.
	CanBreak []string
}

ItemStack represents an item instance/stack over network. It has a network ID and a metadata value that define its type.

type ItemStackRequest

type ItemStackRequest struct {
	// RequestID is a unique ID for the request. This ID is used by the server to send a response for this
	// specific request in the ItemStackResponse packet.
	RequestID int32
	// Actions is a list of actions performed by the client. The actual type of the actions depends on which
	// ID was present, and is one of the concrete types below.
	Actions []StackRequestAction
}

ItemStackRequest represents a single request present in an ItemStackRequest packet sent by the client to change an item in an inventory. Item stack requests are either approved or rejected by the server using the ItemStackResponse packet.

type ItemStackResponse

type ItemStackResponse struct {
	// Success specifies if the request with the RequestID below was successful. If this is the case, the
	// ContainerInfo below will have information on what slots ended up changing. If not, the container info
	// will be empty.
	Success bool
	// RequestID is the unique ID of the request that this response is in reaction to. If rejected, the client
	// will undo the actions from the request with this ID.
	RequestID int32
	// ContainerInfo holds information on the containers that had their contents changed as a result of the
	// request.
	ContainerInfo []StackResponseContainerInfo
}

ItemStackResponse is a response to an individual ItemStackRequest.

type ItemType

type ItemType struct {
	// NetworkID is the numerical network ID of the item. This is sometimes a positive ID, and sometimes a
	// negative ID, depending on what item it concerns.
	NetworkID int32
	// MetadataValue is the metadata value of the item. For some items, this is the damage value, whereas for
	// other items it is simply an identifier of a variant of the item.
	MetadataValue int16
}

ItemType represents a consistent combination of network ID and metadata value of an item. It cannot usually be changed unless a new item is obtained.

type LabTableCombineStackRequestAction

type LabTableCombineStackRequestAction struct{}

LabTableCombineStackRequestAction is sent by the client when it uses a lab table to combine item stacks.

func (*LabTableCombineStackRequestAction) Marshal

Marshal ...

func (*LabTableCombineStackRequestAction) Unmarshal added in v1.7.0

Unmarshal ...

type LegacySetItemSlot

type LegacySetItemSlot struct {
	ContainerID byte
	Slots       []byte
}

LegacySetItemSlot represents a slot that was changed during an InventoryTransaction. These slots have to have their values set accordingly for actions such as when dropping an item out of the hotbar, where the inventory container and the slot that had its item dropped is passed.

type LimitHitError added in v0.7.0

type LimitHitError struct {
	Limit int
	Type  string
}

LimitHitError is returned by a reading operation if it hits the limit of the maximum amount of elements in an array.

func (LimitHitError) Error added in v0.7.0

func (err LimitHitError) Error() string

Error ...

type MapDecoration

type MapDecoration struct {
	// Type is the type of the map decoration. The type specifies the shape (and sometimes the colour) that
	// the map decoration gets.
	Type byte
	// Rotation is the rotation of the map decoration. It is byte due to the 16 fixed directions that the
	// map decoration may face.
	Rotation byte
	// X is the offset on the X axis in pixels of the decoration.
	X byte
	// Y is the offset on the Y axis in pixels of the decoration.
	Y byte
	// Label is the name of the map decoration. This name may be of any value.
	Label string
	// Colour is the colour of the map decoration. Some map decoration types have a specific colour set
	// automatically, whereas others may be changed.
	Colour color.RGBA
}

MapDecoration is a fixed decoration on a map: Its position or other properties do not change automatically client-side.

type MapTrackedObject

type MapTrackedObject struct {
	// Type is the type of the tracked object. It is either MapObjectTypeEntity or MapObjectTypeBlock.
	Type int32
	// EntityUniqueID is the unique ID of the entity, if the tracked object was an entity. It needs not to be
	// filled out if Type is not MapObjectTypeEntity.
	EntityUniqueID int64
	// BlockPosition is the position of the block, if the tracked object was a block. It needs not to be
	// filled out if Type is not MapObjectTypeBlock.
	BlockPosition BlockPos
}

MapTrackedObject is an object on a map that is 'tracked' by the client, such as an entity or a block. This object may move, which is handled client-side.

type MismatchTransactionData

type MismatchTransactionData struct{}

MismatchTransactionData represents a mismatched inventory transaction's data object.

func (*MismatchTransactionData) Marshal

Marshal ...

func (*MismatchTransactionData) Unmarshal added in v0.4.0

Unmarshal ...

type MultiRecipe

type MultiRecipe struct {
	// UUID is a UUID identifying the recipe. This can actually be set to an empty UUID if the CraftingEvent
	// packet is not used.
	UUID uuid.UUID
	// RecipeNetworkID is a unique ID used to identify the recipe over network. Each recipe must have a unique
	// network ID. Recommended is to just increment a variable for each unique recipe registered.
	// This field must never be 0.
	RecipeNetworkID uint32
}

MultiRecipe serves as an 'enable' switch for multi-shape recipes.

func (*MultiRecipe) Marshal

func (recipe *MultiRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*MultiRecipe) Unmarshal

func (recipe *MultiRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type NegativeCountError added in v0.7.0

type NegativeCountError struct {
	Type string
}

NegativeCountError is returned when a count prefix of an array-type structure is a negative number. Most types only have unsigned count prefixes, but some do not and may return this error.

func (NegativeCountError) Error added in v0.7.0

func (err NegativeCountError) Error() string

Error ...

type NormalTransactionData

type NormalTransactionData struct{}

NormalTransactionData represents an inventory transaction data object for normal transactions, such as crafting. It has no content.

func (*NormalTransactionData) Marshal

func (*NormalTransactionData) Marshal(*bytes.Buffer)

Marshal ...

func (*NormalTransactionData) Unmarshal added in v0.4.0

func (*NormalTransactionData) Unmarshal(*bytes.Buffer) error

Unmarshal ...

type PersonaPiece

type PersonaPiece struct {
	// PieceId is a UUID that identifies the piece itself, which is unique for each separate piece.
	PieceID string
	// PieceType holds the type of the piece. Several types I was able to find immediately are listed below.
	// - persona_skeleton
	// - persona_body
	// - persona_skin
	// - persona_bottom
	// - persona_feet
	// - persona_top
	// - persona_mouth
	// - persona_hair
	// - persona_eyes
	// - persona_facial_hair
	PieceType string
	// PackID is a UUID that identifies the pack that the persona piece belongs to.
	PackID string
	// Default specifies if the piece is one of the default pieces. This is true when the piece is one of
	// those that a Steve or Alex skin have.
	Default bool
	// ProductID is a UUID that identifies the piece when it comes to purchases. It is empty for pieces that
	// have the 'Default' field set to true.
	ProductID string
}

PersonaPiece represents a piece of a persona skin. All pieces are sent separately.

type PersonaPieceTintColour

type PersonaPieceTintColour struct {
	// PieceType is the type of the persona skin piece that this tint colour concerns. The piece type must
	// always be present in the persona pieces list, but not each piece type has a tint colour sent.
	// Pieces that do have a tint colour that I was able to find immediately are listed below.
	// - persona_mouth
	// - persona_eyes
	// - persona_hair
	PieceType string
	// Colours is a list four colours written in hex notation (note, that unlike the SkinColour field in
	// the ClientData struct, this is actually ARGB, not just RGB).
	// The colours refer to different parts of the skin piece. The 'persona_eyes' may have the following
	// colours: ["#ffa12722","#ff2f1f0f","#ff3aafd9","#0"]
	// The first hex colour represents the tint colour of the iris, the second hex colour represents the
	// eyebrows and the third represents the sclera. The fourth is #0 because there are only 3 parts of the
	// persona_eyes skin piece.
	Colours []string
}

PersonaPieceTintColour describes the tint colours of a specific piece of a persona skin.

type PlaceStackRequestAction

type PlaceStackRequestAction struct {
	// contains filtered or unexported fields
}

PlaceStackRequestAction is sent by the client to the server to place x amount of items from one slot into another slot, such as when shift clicking an item in the inventory to move it around or when moving an item in the cursor into a slot.

func (*PlaceStackRequestAction) Marshal

func (a *PlaceStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*PlaceStackRequestAction) Unmarshal added in v1.7.0

func (a *PlaceStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type PlayerListEntry

type PlayerListEntry struct {
	// UUID is the UUID of the player as sent in the Login packet when the client joined the server. It must
	// match this UUID exactly for the correct XBOX Live icon to show up in the list.
	UUID uuid.UUID
	// EntityUniqueID is the unique entity ID of the player. This ID typically stays consistent during the
	// lifetime of a world, but servers often send the runtime ID for this.
	EntityUniqueID int64
	// Username is the username that is shown in the player list of the player that obtains a PlayerList
	// packet with this entry. It does not have to be the same as the actual username of the player.
	Username string
	// XUID is the XBOX Live user ID of the player, which will remain consistent as long as the player is
	// logged in with the XBOX Live account.
	XUID string
	// PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for
	// Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to
	// chat with each other.
	PlatformChatID string
	// BuildPlatform is the platform of the player as sent by that player in the Login packet.
	BuildPlatform int32
	// Skin is the skin of the player that should be added to the player list. Once sent here, it will not
	// have to be sent again.
	Skin Skin
	// Teacher is a Minecraft: Education Edition field. It specifies if the player to be added to the player
	// list is a teacher.
	Teacher bool
	// Host specifies if the player that is added to the player list is the host of the game.
	Host bool
}

PlayerListEntry is an entry found in the PlayerList packet. It represents a single player using the UUID found in the entry, and contains several properties such as the skin.

type PotionContainerChangeRecipe

type PotionContainerChangeRecipe struct {
	// InputItemID is the item ID of the item to be put in. This is typically either the ID of a normal potion
	// or a splash potion.
	InputItemID int32
	// ReagentItemID is the item ID of the item that needs to be added to the container in order to create the
	// output item.
	ReagentItemID int32
	// OutputItemID is the item that is created using a combination of the InputItem and ReagentItem, which is
	// typically either the ID of a splash potion or a lingering potion.
	OutputItemID int32
}

PotionContainerChangeRecipe represents a recipe to turn a potion from one type to another. This means from a drinkable potion + gunpowder -> splash potion, and from a splash potion + dragon breath -> lingering potion.

type PotionRecipe

type PotionRecipe struct {
	// InputPotionID is the item ID of the potion to be put in.
	InputPotionID int32
	// InputPotionMetadata is the type of the potion to be put in. This is typically the meta of the
	// awkward potion (or water bottle to create an awkward potion).
	InputPotionMetadata int32
	// ReagentItemID is the item ID of the item that needs to be added to the brewing stand in order to brew
	// the output potion.
	ReagentItemID int32
	// ReagentItemMetadata is the metadata value of the item that needs to be added to the brewing stand in
	// order to brew the output potion.
	ReagentItemMetadata int32
	// OutputPotionID is the item ID of the potion obtained as a result of the brewing recipe.
	OutputPotionID int32
	// OutputPotionMetadata is the type of the potion that is obtained as a result of brewing the input
	// potion with the reagent item.
	OutputPotionMetadata int32
}

PotionRecipe represents a potion mixing recipe which may be used in a brewing stand.

type Recipe

type Recipe interface {
	// Marshal encodes the recipe data to its binary representation into buf.
	Marshal(buf *bytes.Buffer)
	// Unmarshal decodes a serialised recipe in buf into the recipe instance.
	Unmarshal(buf *bytes.Buffer) error
}

Recipe represents a recipe that may be sent in a CraftingData packet to let the client know what recipes are available server-side.

type ReleaseItemTransactionData

type ReleaseItemTransactionData struct {
	// ActionType is the type of the ReleaseItem inventory transaction. It is one of the action types found
	// in the constants above, and specifies the way the item was released.
	// As of 1.13, the ActionType is always 0. This field can be ignored, because releasing food (by consuming
	// it) or releasing a bow (to shoot an arrow) is essentially the same.
	ActionType uint32
	// HotBarSlot is the hot bar slot that the player was holding while releasing the item. It should be used
	// to ensure that the hot bar slot and held item are correctly synchronised with the server.
	HotBarSlot int32
	// HeldItem is the item that was released. The server should check if this item is actually present in the
	// HotBarSlot.
	HeldItem ItemStack
	// HeadPosition is the position of the player's head at the time of releasing the item. This is used
	// mainly for purposes such as spawning eating particles at that position.
	HeadPosition mgl32.Vec3
}

ReleaseItemTransactionData represents an inventory transaction data object sent when the client releases the item it was using, for example when stopping while eating or stopping the charging of a bow.

func (*ReleaseItemTransactionData) Marshal

func (data *ReleaseItemTransactionData) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ReleaseItemTransactionData) Unmarshal added in v0.4.0

func (data *ReleaseItemTransactionData) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type ResourcePackInfo added in v0.12.0

type ResourcePackInfo struct {
	// UUID is the UUID of the resource pack. Each resource pack downloaded must have a different UUID in
	// order for the client to be able to handle them properly.
	UUID string
	// Version is the version of the resource pack. The client will cache resource packs sent by the server as
	// long as they carry the same version. Sending a resource pack with a different version than previously
	// will force the client to re-download it.
	Version string
	// Size is the total size in bytes that the resource pack occupies. This is the size of the compressed
	// archive (zip) of the resource pack.
	Size uint64
	// ContentKey is the key used to decrypt the resource pack if it is encrypted. This is generally the case
	// for marketplace resource packs.
	ContentKey string
	// SubPackName ...
	SubPackName string
	// ContentIdentity ...
	ContentIdentity string
	// HasScripts specifies if the resource packs has any scripts in it. A client will only download the
	// resource pack if it supports scripts, which, up to 1.11, only includes Windows 10.
	HasScripts bool
}

ResourcePackInfo represents a resource pack's info sent over network. It holds information about the resource pack such as its name, description and version.

type ScoreboardEntry

type ScoreboardEntry struct {
	// EntryID is a unique identifier of this entry. Each entry that represents a different value should get
	// its own entry ID. When modifying a scoreboard, entries that represent the same line should have the
	// same entry ID.
	EntryID int64
	// ObjectiveName is the name of the objective that this scoreboard entry is for. It must be identical to
	// the one set in the SetDisplayObjective packet previously sent.
	ObjectiveName string
	// Score is the score that the entry represents. Scoreboard entries are ordered using this score, so in
	// order to get the scoreboard to be ordered as expected when trying to write non-score related text on
	// a scoreboard, this score should be incremented for each entry.
	Score int32
	// IdentityType is the identity type of the scoreboard entry. The entry may represent an entity, player or
	// a fake player, as the constants above indicate.
	// In order to write plain text to the scoreboard, ScoreboardIdentityFakePlayer should always be used, in
	// combination with the DisplayName field. A different identity type will use the name of the entity.
	IdentityType byte
	// EntityUniqueID is the unique ID of either the player or the entity represented by the scoreboard entry.
	// This field is only used if IdentityType is either ScoreboardIdentityEntity or ScoreboardIdentityPlayer.
	EntityUniqueID int64
	// DisplayName is the custom name of the scoreboard entry. This field is only used if IdentityType is
	// ScoreboardIdentityFakePlayer. If this identity type is not used, the name of the entity/player will be
	// shown instead.
	DisplayName string
}

ScoreboardEntry represents a single entry that may be found on a scoreboard. These entries represent a line on the scoreboard each.

type ScoreboardIdentityEntry

type ScoreboardIdentityEntry struct {
	// EntryID is the unique identifier of the entry that the identity should be associated with, or that
	// associations should be cleared from.
	EntryID int64
	// EntityUniqueID is the unique ID that the entry should be associated with. It is empty if the
	// SetScoreboardIdentity packet is sent to remove associations with identities.
	EntityUniqueID int64
}

ScoreboardIdentityEntry holds an entry to either associate an identity with one of the entries in a scoreboard, or to remove associations.

type ShapedChemistryRecipe

type ShapedChemistryRecipe ShapedRecipe

ShapedChemistryRecipe is a recipe specifically made for chemistry related features, which exist only in the Education Edition. It functions the same as a normal ShapedRecipe.

func (*ShapedChemistryRecipe) Marshal

func (recipe *ShapedChemistryRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ShapedChemistryRecipe) Unmarshal

func (recipe *ShapedChemistryRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type ShapedRecipe

type ShapedRecipe struct {
	// RecipeID is a unique ID of the recipe. This ID must be unique amongst all other types of recipes too,
	// but its functionality is not exactly known.
	RecipeID string
	// Width is the width of the recipe's shape.
	Width int32
	// Height is the height of the recipe's shape.
	Height int32
	// Input is a list of items that serve as the input of the shapeless recipe. These items are the items
	// required to craft the output. The amount of input items must be exactly equal to Width * Height.
	Input []ItemStack
	// Output is a list of items that are created as a result of crafting the recipe.
	Output []ItemStack
	// UUID is a UUID identifying the recipe. This can actually be set to an empty UUID if the CraftingEvent
	// packet is not used.
	UUID uuid.UUID
	// Block is the block name that is required to craft the output of the recipe. The block is not prefixed
	// with 'minecraft:', so it will look like 'crafting_table' as an example.
	Block string
	// Priority ...
	Priority int32
	// RecipeNetworkID is a unique ID used to identify the recipe over network. Each recipe must have a unique
	// network ID. Recommended is to just increment a variable for each unique recipe registered.
	// This field must never be 0.
	RecipeNetworkID uint32
}

ShapedRecipe is a recipe that has a specific shape that must be used to craft the output of the recipe. Trying to craft the item in any other shape will not work. The ShapedRecipe is of the same structure as the ShapedChemistryRecipe.

func (*ShapedRecipe) Marshal

func (recipe *ShapedRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ShapedRecipe) Unmarshal

func (recipe *ShapedRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type ShapelessChemistryRecipe

type ShapelessChemistryRecipe ShapelessRecipe

ShapelessChemistryRecipe is a recipe specifically made for chemistry related features, which exist only in the Education Edition. They function the same as shapeless recipes do.

func (*ShapelessChemistryRecipe) Marshal

func (recipe *ShapelessChemistryRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ShapelessChemistryRecipe) Unmarshal

func (recipe *ShapelessChemistryRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type ShapelessRecipe

type ShapelessRecipe struct {
	// RecipeID is a unique ID of the recipe. This ID must be unique amongst all other types of recipes too,
	// but its functionality is not exactly known.
	RecipeID string
	// Input is a list of items that serve as the input of the shapeless recipe. These items are the items
	// required to craft the output.
	Input []ItemStack
	// Output is a list of items that are created as a result of crafting the recipe.
	Output []ItemStack
	// UUID is a UUID identifying the recipe. This can actually be set to an empty UUID if the CraftingEvent
	// packet is not used.
	UUID uuid.UUID
	// Block is the block name that is required to craft the output of the recipe. The block is not prefixed
	// with 'minecraft:', so it will look like 'crafting_table' as an example.
	// The available blocks are:
	// - crafting_table
	// - cartography_table
	// - stonecutter
	// - furnace
	// - blast_furnace
	// - smoker
	// - campfire
	Block string
	// Priority ...
	Priority int32
	// RecipeNetworkID is a unique ID used to identify the recipe over network. Each recipe must have a unique
	// network ID. Recommended is to just increment a variable for each unique recipe registered.
	// This field must never be 0.
	RecipeNetworkID uint32
}

ShapelessRecipe is a recipe that has no particular shape. Its functionality is shared with the RecipeShulkerBox and RecipeShapelessChemistry types.

func (*ShapelessRecipe) Marshal

func (recipe *ShapelessRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ShapelessRecipe) Unmarshal

func (recipe *ShapelessRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type ShulkerBoxRecipe

type ShulkerBoxRecipe ShapelessRecipe

ShulkerBoxRecipe is a shapeless recipe made specifically for shulker box crafting, so that they don't lose their user data when dyeing a shulker box.

func (*ShulkerBoxRecipe) Marshal

func (recipe *ShulkerBoxRecipe) Marshal(buf *bytes.Buffer)

Marshal ...

func (*ShulkerBoxRecipe) Unmarshal

func (recipe *ShulkerBoxRecipe) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type Skin

type Skin struct {
	// SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex'
	// for the default Alex skin.
	SkinID string
	// SkinResourcePatch is a JSON encoded object holding some fields that point to the geometry that the
	// skin has.
	// The JSON object that this holds specifies the way that the geometry of animations and the default skin
	// of the player are combined.
	SkinResourcePatch []byte
	// SkinImageWidth and SkinImageHeight hold the dimensions of the skin image. Note that these are not the
	// dimensions in bytes, but in pixels.
	SkinImageWidth, SkinImageHeight uint32
	// SkinData is a byte slice of SkinImageWidth * SkinImageHeight bytes. It is an RGBA ordered byte
	// representation of the skin pixels.
	SkinData []byte
	// Animations is a list of all animations that the skin has.
	Animations []SkinAnimation
	// CapeImageWidth and CapeImageHeight hold the dimensions of the cape image. Note that these are not the
	// dimensions in bytes, but in pixels.
	CapeImageWidth, CapeImageHeight uint32
	// CapeData is a byte slice of 64*32*4 bytes. It is a RGBA ordered byte representation of the cape
	// colours, much like the SkinData.
	CapeData []byte
	// SkinGeometry is a JSON encoded structure of the geometry data of a skin, containing properties
	// such as bones, uv, pivot etc.
	SkinGeometry []byte
	// TODO: Find out what value AnimationData holds and when it does hold something.
	AnimationData []byte
	// PremiumSkin specifies if this is a skin that was purchased from the marketplace.
	PremiumSkin bool
	// PersonaSkin specifies if this is a skin that was created using the in-game skin creator.
	PersonaSkin bool
	// PersonaCapeOnClassicSkin specifies if the skin had a Persona cape (in-game skin creator cape) equipped
	// on a classic skin.
	PersonaCapeOnClassicSkin bool
	// CapeID is a unique identifier that identifies the cape. It usually holds a UUID in it.
	CapeID string
	// FullSkinID is an ID that represents the skin in full. The actual functionality is unknown: The client
	// does not seem to send a value for this.
	FullSkinID string
	// SkinColour is a hex representation (including #) of the base colour of the skin. An example of the
	// colour sent here is '#b37b62'.
	SkinColour string
	// ArmSize is the size of the arms of the player's model. This is either 'wide' (generally for male skins)
	// or 'slim' (generally for female skins).
	ArmSize string
	// PersonaPieces is a list of all persona pieces that the skin is composed of.
	PersonaPieces []PersonaPiece
	// PieceTintColours is a list of specific tint colours for (some of) the persona pieces found in the list
	// above.
	PieceTintColours []PersonaPieceTintColour
	// Trusted specifies if the skin is 'trusted'. No code should rely on this field, as any proxy or client
	// can easily change it.
	Trusted bool
}

Skin represents the skin of a player as sent over network. The skin holds a texture and a model, and optional animations which may be present when the skin is created using persona or bought from the marketplace.

type SkinAnimation

type SkinAnimation struct {
	// ImageWidth and ImageHeight hold the dimensions of the animation image. Note that these are not the
	// dimensions in bytes, but in pixels.
	ImageWidth, ImageHeight uint32
	// ImageData is a byte slice of ImageWidth * ImageHeight bytes. It is an RGBA ordered byte representation
	// of the animation image pixels. The ImageData contains FrameCount images in it, which each represent one
	// stage of the animation. The actual part of the skin that this field holds depends on the AnimationType,
	// where SkinAnimationHead holds only the head and its hat, whereas the other animations hold the entire
	// body of the skin.
	ImageData []byte
	// AnimationType is the type of the animation, which is one of the types found above. The data that
	// ImageData contains depends on this type.
	AnimationType uint32
	// FrameCount is the amount of frames that the skin animation holds. The number of frames here is the
	// amount of images that may be found in the ImageData field.
	FrameCount float32
}

SkinAnimation represents an animation that may be added to a skin. The client plays the animation itself, without the server having to do so. The rate at which these animations play appears to be decided by the client.

type StackRequestAction

type StackRequestAction interface {
	// Marshal encodes the stack request action its binary representation into buf.
	Marshal(buf *bytes.Buffer)
	// Unmarshal decodes a serialised stack request action object in buf into the InventoryTransactionData
	// instance.
	Unmarshal(buf *bytes.Buffer) error
}

StackRequestAction represents a single action related to the inventory present in an ItemStackRequest. The action is one of the concrete types below, each of which are indicative of a different action by the client, such as moving an item around the inventory or placing a block.

type StackRequestSlotInfo

type StackRequestSlotInfo struct {
	// ContainerID is the ID of the container that the slot was in.
	ContainerID byte
	// Slot is the index of the slot within the container with the ContainerID above.
	Slot byte
	// StackNetworkID is the unique stack ID that the client assumes to be present in this slot. The server
	// must check if these IDs match. If they do not match, servers should reject the stack request that the
	// action holding this info was in.
	StackNetworkID int32
}

StackRequestSlotInfo holds information on a specific slot client-side.

type StackResourcePack

type StackResourcePack struct {
	// UUID is the UUID of the resource pack. Each resource pack downloaded must have a different UUID in
	// order for the client to be able to handle them properly.
	UUID string
	// Version is the version of the resource pack. The client will cache resource packs sent by the server as
	// long as they carry the same version. Sending a resource pack with a different version than previously
	// will force the client to re-download it.
	Version string
	// SubPackName ...
	SubPackName string
}

StackResourcePack represents a resource pack sent on the stack of the client. When sent, the client will apply them in the order of the stack sent.

type StackResponseContainerInfo

type StackResponseContainerInfo struct {
	// ContainerID is the container ID of the container that the slots that follow are in. For the main
	// inventory, this value seems to be 0x1b. For the cursor, this value seems to be 0x3a. For the crafting
	// grid, this value seems to be 0x0d.
	ContainerID byte
	// SlotInfo holds information on what item stack should be present in specific slots in the container.
	SlotInfo []StackResponseSlotInfo
}

StackResponseContainerInfo holds information on what slots in a container have what item stack in them.

type StackResponseSlotInfo

type StackResponseSlotInfo struct {
	// Slot and HotbarSlot seem to be the same value every time: The slot that was actually changed. I'm not
	// sure if these slots ever differ.
	Slot, HotbarSlot byte
	// Count is the total count of the item stack. This count will be shown client-side after the response is
	// sent to the client.
	Count byte
	// StackNetworkID is the network ID of the new stack at a specific slot.
	StackNetworkID int32
}

StackResponseSlotInfo holds information on what item stack should be present in a specific slot.

type StructureSettings

type StructureSettings struct {
	// PaletteName is the name of the palette used in the structure. Currently, it seems that this field is
	// always 'default'.
	PaletteName string
	// IgnoreEntities specifies if the structure should ignore entities or include them. If set to false,
	// entities will also show up in the exported structure.
	IgnoreEntities bool
	// IgnoreBlocks specifies if the structure should ignore blocks or include them. If set to false, blocks
	// will show up in the exported structure.
	IgnoreBlocks bool

	// Size is the size of the area that is about to be exported. The area exported will start at the
	// Position + Offset, and will extend as far as Size specifies.
	Size BlockPos
	// Offset is the offset position that was set in the structure block. The area exported is offset by this
	// position.
	Offset BlockPos
	// LastTouchedByPlayerUniqueID is the unique ID of the player that last touched the structure block that
	// these settings concern.
	LastTouchedByPlayerUniqueID int64

	// Rotation is the rotation that the structure block should obtain.
	Rotation byte
	// Mirror specifies the way the structure should be mirrored. It is either no mirror at all, left to
	// right mirror or front to back, as the constants above specify.
	Mirror byte
	// Integrity is usually 1, but may be set to a number between 0 and 1 to omit blocks randomly, using
	// the Seed that follows.
	Integrity float32
	// Seed is the seed used to omit blocks if Integrity is not equal to one. If the Seed is 0, a random
	// seed is selected to omit blocks.
	Seed uint32
}

StructureSettings is a struct holding settings of a structure block. Its fields may be changed using the in-game UI on the client-side.

type SwapStackRequestAction

type SwapStackRequestAction struct {
	// Source and Destination point to the source slot from which Count of the item stack were taken and the
	// destination slot to which this item was moved.
	Source, Destination StackRequestSlotInfo
}

SwapStackRequestAction is sent by the client to swap the item in its cursor with an item present in another container. The two item stacks swap places.

func (*SwapStackRequestAction) Marshal

func (a *SwapStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*SwapStackRequestAction) Unmarshal added in v1.7.0

func (a *SwapStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type TakeStackRequestAction

type TakeStackRequestAction struct {
	// contains filtered or unexported fields
}

TakeStackRequestAction is sent by the client to the server to take x amount of items from one slot in a container to the cursor.

func (*TakeStackRequestAction) Marshal

func (a *TakeStackRequestAction) Marshal(buf *bytes.Buffer)

Marshal ...

func (*TakeStackRequestAction) Unmarshal added in v1.7.0

func (a *TakeStackRequestAction) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type UseItemOnEntityTransactionData

type UseItemOnEntityTransactionData struct {
	// TargetEntityRuntimeID is the entity runtime ID of the target that was clicked. It is the runtime ID
	// that was assigned to it in the AddEntity packet.
	TargetEntityRuntimeID uint64
	// ActionType is the type of the UseItemOnEntity inventory transaction. It is one of the action types
	// found in the constants above, and specifies the way the player interacted with the entity.
	ActionType uint32
	// HotBarSlot is the hot bar slot that the player was holding while clicking the entity. It should be used
	// to ensure that the hot bar slot and held item are correctly synchronised with the server.
	HotBarSlot int32
	// HeldItem is the item that was held to interact with the entity. The server should check if this item
	// is actually present in the HotBarSlot.
	HeldItem ItemStack
	// Position is the position of the player at the time of clicking the entity.
	Position mgl32.Vec3
	// ClickedPosition is the position that was clicked relative to the entity's base coordinate. It can be
	// used to find out exactly where a player clicked the entity.
	ClickedPosition mgl32.Vec3
}

UseItemOnEntityTransactionData represents an inventory transaction data object sent when the client uses an item on an entity.

func (*UseItemOnEntityTransactionData) Marshal

func (data *UseItemOnEntityTransactionData) Marshal(buf *bytes.Buffer)

Marshal ...

func (*UseItemOnEntityTransactionData) Unmarshal added in v0.4.0

func (data *UseItemOnEntityTransactionData) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

type UseItemTransactionData

type UseItemTransactionData struct {
	// ActionType is the type of the UseItem inventory transaction. It is one of the action types found above,
	// and specifies the way the player interacted with the block.
	ActionType uint32
	// BlockPosition is the position of the block that was interacted with. This is only really a correct
	// block position if ActionType is not UseItemActionClickAir.
	BlockPosition BlockPos
	// BlockFace is the face of the block that was interacted with. When clicking the block, it is the face
	// clicked. When breaking the block, it is the face that was last being hit until the block broke.
	BlockFace int32
	// HotBarSlot is the hot bar slot that the player was holding while clicking the block. It should be used
	// to ensure that the hot bar slot and held item are correctly synchronised with the server.
	HotBarSlot int32
	// HeldItem is the item that was held to interact with the block. The server should check if this item
	// is actually present in the HotBarSlot.
	HeldItem ItemStack
	// Position is the position of the player at the time of interaction. For clicking a block, this is the
	// position at that time, whereas for breaking the block it is the position at the time of breaking.
	Position mgl32.Vec3
	// ClickedPosition is the position that was clicked relative to the block's base coordinate. It can be
	// used to find out exactly where a player clicked the block.
	ClickedPosition mgl32.Vec3
	// BlockRuntimeID is the runtime ID of the block that was clicked. It may be used by the server to verify
	// that the player's world client-side is synchronised with the server's.
	BlockRuntimeID uint32
}

UseItemTransactionData represents an inventory transaction data object sent when the client uses an item on a block.

func (*UseItemTransactionData) Marshal

func (data *UseItemTransactionData) Marshal(buf *bytes.Buffer)

Marshal ...

func (*UseItemTransactionData) Unmarshal added in v0.4.0

func (data *UseItemTransactionData) Unmarshal(buf *bytes.Buffer) error

Unmarshal ...

Directories

Path Synopsis
jwt
Package packet implements every packet in the Minecraft Bedrock Edition protocol using the functions found in the minecraft/protocol package.
Package packet implements every packet in the Minecraft Bedrock Edition protocol using the functions found in the minecraft/protocol package.

Jump to

Keyboard shortcuts

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