Documentation ¶
Index ¶
- Constants
- Variables
- type AddEntity
- type AddItemEntity
- type AddPainting
- type AddPlayer
- type AdventureSettings
- type Animate
- type BlockEntityData
- type BlockEntry
- type BlockEvent
- type BlockPickRequest
- type BossEvent
- type Camera
- type ChangeDimension
- type ChunkRadiusUpdated
- type ClientBoundMapItemData
- type ClientToServerHandshake
- type ContainerClose
- type ContainerOpen
- type ContainerSetData
- type CraftingData
- type CraftingEvent
- type Decoder
- type Disconnect
- type Encoder
- type EntityEvent
- type EntityFall
- type EntityPickRequest
- type Event
- type Explode
- type FullChunkData
- type GUIDataPickItem
- type GameRulesChanged
- type Header
- type HurtArmour
- type Interact
- type InventoryContent
- type InventorySlot
- type InventoryTransaction
- type ItemFrameDropItem
- type LevelEvent
- type Login
- type MapInfoRequest
- type MobArmourEquipment
- type MobEffect
- type MobEquipment
- type ModalFormRequest
- type ModalFormResponse
- type MoveEntityAbsolute
- type MovePlayer
- type Packet
- type PlayStatus
- type PlayerAction
- type PlayerHotBar
- type PlayerInput
- type PlayerList
- type PlayerListEntry
- type PlayerSkin
- type Pool
- type RemoveEntity
- type RequestChunkRadius
- type ResourcePack
- type ResourcePackChunkData
- type ResourcePackChunkRequest
- type ResourcePackClientResponse
- type ResourcePackDataInfo
- type ResourcePackStack
- type ResourcePacksInfo
- type Respawn
- type RiderJump
- type ServerSettingsRequest
- type ServerSettingsResponse
- type ServerToClientHandshake
- type SetCommandsEnabled
- type SetDifficulty
- type SetEntityData
- type SetEntityLink
- type SetEntityMotion
- type SetHealth
- type SetLocalPlayerAsInitialised
- type SetPlayerGameType
- type SetSpawnPosition
- type SetTime
- type ShowCredits
- type SimpleEvent
- type SpawnExperienceOrb
- type StartGame
- type TakeItemEntity
- type Text
- type Transfer
- type Unknown
- type UpdateAttributes
- type UpdateBlock
Constants ¶
const ( AdventureFlagWorldImmutable = 1 << iota AdventureFlagNoPVP AdventureFlagAutoJump AdventureFlagAllowFlight AdventureFlagNoClip AdventureFlagWorldBuilder AdventureFlagFlying AdventureFlagMuted )
const ( CommandPermissionLevelNormal = iota CommandPermissionLevelOperator CommandPermissionLevelHost CommandPermissionLevelAutomation CommandPermissionLevelAdmin )
const ( ActionPermissionBuildAndMine = 1 << iota ActionPermissionDoorsAndSwitched ActionPermissionOpenContainers ActionPermissionAttackPlayers ActionPermissionAttackMobs ActionPermissionOperator ActionPermissionTeleport )
const ( PermissionLevelVisitor = iota PermissionLevelMember PermissionLevelOperator PermissionLevelCustom )
const ( AnimateActionSwingArm = iota + 1 AnimateActionStopSleep AnimateActionCriticalHit )
const ( BossEventShow = iota // BossEventRegisterPlayer is sent by the client to the server to request being shown the boss bar. BossEventRegisterPlayer BossEventHide // BossEventUnregisterPlayer is sent by the client to request the removal of the boss bar. BossEventUnregisterPlayer BossEventHealthPercentage BossEventTitle BossEventAppearanceProperties BossEventTexture )
const ( DimensionOverworld = iota DimensionNether DimensionEnd )
const ( MapUpdateFlagTexture = 1 << (iota + 1) MapUpdateFlagDecoration MapUpdateFlagInitialisation )
const ( ContainerDataFurnaceTickCount = iota ContainerDataFurnaceLitTime ContainerDataFurnaceLitDuration ContainerDataFurnaceFuelAux )
const ( ContainerDataBrewingStandBrewTime = iota ContainerDataBrewingStandFuelAmount ContainerDataBrewingStandFuelTotal )
const ( EntityEventHurt EntityEventDeath EntityEventArmSwing EntityEventTameFail EntityEventTameSucceed EntityEventShakeDry EntityEventUseItem EntityEventEatGrass EntityEventFishHookBubble EntityEventFishHookPosition EntityEventFishHook EntityEventFishHookTease EntityEventSquidInkCloud EntityEventZombieVillagerCure EntityEventRespawn EntityEventIronGolemOfferFlower EntityEventIronGolemWithdrawFlower EntityEventLookingForPartner EntityEventWitchSpell EntityEventFirework EntityEventSilverfishSpawn EntityEventWitchDrinkPotion EntityEventWitchThrowPotion EntityEventMinecartTNTPrimeFuse EntityEventPlayerAddXPLevels EntityEventElderGuardianCurse EntityEventAgentArmSwing EntityEventEnderDragonDeath EntityEventDustParticles EntityEventArrowShake // ... EntityEventEatingItem = 57 )
const ( EntityEventBabyAnimalFeed = iota + 60 EntityEventDeathSmokeCloud EntityEventCompleteTrade EntityEventRemoveLeash EntityEventConsumeToken EntityEventPlayerCheckTreasureHunterAchievement EntityEventEntitySpawn EntityEventDragonBreath EntityEventItemEntityMerge )
const ( EventAchievementAwarded = iota EventEntityInteract EventPortalBuilt EventPortalUsed EventMobKilled EventCauldronUsed EventPlayerDeath EventBossKilled EventAgentCommand EventAgentCreated EventBannerPatternRemoved EventCommandExecuted EventFishBucketed )
const ( IDLogin = iota + 0x01 IDPlayStatus IDServerToClientHandshake IDClientToServerHandshake IDDisconnect IDResourcePacksInfo IDResourcePackStack IDResourcePackClientResponse IDText IDSetTime IDStartGame IDAddPlayer IDAddEntity IDRemoveEntity IDAddItemEntity IDTakeItemEntity IDMoveEntityAbsolute IDMovePlayer IDRiderJump IDUpdateBlock IDAddPainting IDExplode IDLevelEvent IDBlockEvent IDEntityEvent IDMobEffect IDUpdateAttributes IDInventoryTransaction IDMobEquipment IDMobArmourEquipment IDInteract IDBlockPickRequest IDEntityPickRequest IDPlayerAction IDEntityFall IDHurtArmour IDSetEntityData IDSetEntityMotion IDSetEntityLink IDSetHealth IDSetSpawnPosition IDAnimate IDRespawn IDContainerOpen IDContainerClose IDPlayerHotBar IDInventoryContent IDInventorySlot IDContainerSetData IDCraftingData IDCraftingEvent IDGUIDataPickItem IDAdventureSettings IDBlockEntityData IDPlayerInput IDFullChunkData IDSetCommandsEnabled IDSetDifficulty IDChangeDimension IDSetPlayerGameType IDPlayerList IDSimpleEvent IDEvent IDSpawnExperienceOrb IDClientBoundMapItemData IDMapInfoRequest IDRequestChunkRadius IDChunkRadiusUpdated IDItemFrameDropItem IDGameRulesChanged IDCamera IDBossEvent IDShowCredits )
const ( IDResourcePackDataInfo = iota + 0x52 IDResourcePackChunkData IDResourcePackChunkRequest IDTransfer )
...
const ( IDModalFormRequest = iota + 0x64 IDModalFormResponse IDServerSettingsRequest IDServerSettingsResponse )
...
const ( InteractActionLeaveVehicle InteractActionMouseOverEntity InteractActionOpenInventory )
const ( InventoryTransactionTypeNormal = iota InventoryTransactionTypeMismatch InventoryTransactionTypeUseItem InventoryTransactionTypeUseItemOnEntity InventoryTransactionTypeReleaseItem )
const ( EventSoundClick = 1000 EventSoundClickFail = 1001 EventSoundShoot = 1002 EventSoundDoor = 1003 EventSoundFizz = 1004 EventSoundIgnite = 1005 EventSoundGhast = 1007 EventSoundGhastShoot = 1008 EventSoundBlazeShoot = 1009 EventSoundDoorBump = 1010 EventSoundDoorCrash = 1012 EventSoundEndermanTeleport = 1018 EventSoundAnvilBreak = 1020 EventSoundAnvilUse = 1021 EventSoundAnvilFall = 1022 EventSoundPop = 1030 EventSoundPortal = 1032 EventSoundItemFrameAddItem = 1040 EventSoundItemFrameBreak = 1041 EventSoundItemFramePlace = 1042 EventSoundItemFrameRemoveItem = 1043 EventSoundItemFrameRotateItem = 1044 EventSoundCamera = 1050 EventSoundOrb = 1051 EventSoundTotem = 1052 EventSoundArmourStandBreak = 1060 EventSoundArmourStandHit = 1061 EventSoundArmourStandFall = 1062 EventSoundArmourStandPlace = 1063 EventParticleShoot = 2000 EventParticleDestroy = 2001 EventParticleSplash = 2002 EventParticleEyeDespawn = 2003 EventParticleSpawn = 2004 EventGuardianCurse = 2006 EventParticleBlockForceField = 2008 EventParticleProjectileHit = 2009 EventParticleDragonEggTeleport = 2010 EventParticleEndermanTeleport = 2013 EventParticlePunchBlock = 2014 EventStartRain = 3001 EventStartThunder = 3002 EventStopRain = 3003 EventStopThunder = 3004 EventPauseGame = 3005 EventRedstoneTrigger = 3500 EventCauldronExplode = 3501 EventCauldronDyeArmour = 3502 EventCauldronCleanArmour = 3503 EventCauldronFillPotion = 3504 EventCauldronTakePotion = 3505 EventCauldronFillWater = 3506 EventCauldronTakeWater = 3507 EventCauldronAddDye = 3508 EventCauldronCleanBanner = 3509 EventBlockStartBreak = 3600 EventBlockStopBreak = 3601 EventSetData = 4000 EventPlayersSleeping = 9800 EventAddParticleMask = 0x4000 )
const ( MobEffectAdd = iota + 1 MobEffectModify MobEffectRemove )
const ( EffectSpeed = iota + 1 EffectSlowness EffectHaste EffectMiningFatigue EffectStrength EffectInstantHealth EffectInstantDamage EffectJumpBoost EffectNausea EffectRegeneration EffectResistance EffectFireResistance EffectWaterBreathing EffectInvisibility EffectBlindness EffectNightVision EffectHunger EffectWeakness EffectPoison EffectWither EffectHealthBoost EffectAbsorption EffectSaturation EffectLevitation EffectFatalPoison EffectConduitPower )
const ( MoveFlagOnGround = 1 << iota MoveFlagTeleport )
const ( MoveModeNormal = iota MoveModeReset MoveModeTeleport MoveModeRotation )
const ( TeleportCauseUnknown = iota TeleportCauseProjectile TeleportCauseChorusFruit TeleportCauseCommand TeleportCauseBehaviour )
const ( PlayStatusLoginSuccess int32 = iota PlayStatusLoginFailedClient PlayStatusLoginFailedServer PlayStatusPlayerSpawn PlayStatusLoginFailedInvalidTenant PlayStatusLoginFailedVanillaEdu PlayStatusLoginFailedEduVanilla PlayStatusLoginFailedServerFull )
const ( PlayerActionStartBreak = iota PlayerActionAbortBreak PlayerActionStopBreak PlayerActionGetUpdatedBlock PlayerActionDropItem PlayerActionStartSleeping PlayerActionStopSleeping PlayerActionRespawn PlayerActionJump PlayerActionStartSprint PlayerActionStopSprint PlayerActionStartSneak PlayerActionStopSneak PlayerActionDimensionChangeRequest PlayerActionDimensionChangeDone PlayerActionStartGlide PlayerActionStopGlide PlayerActionBuildDenied PlayerActionContinueBreak PlayerActionSetEnchantmentSeed PlayerActionStartSwimming PlayerActionStopSwimming PlayerActionStartSpinAttack PlayerActionStopSpinAttack )
const ( PlayerListActionAdd = iota PlayerListActionRemove )
const ( PackResponseRefused = iota + 1 PackResponseSendPacks PackResponseAllPacksDownloaded PackResponseCompleted )
const ( GameTypeSurvival = iota GameTypeCreative GameTypeAdventure GameTypeSurvivalSpectator GameTypeCreativeSpectator )
const ( SpawnTypePlayer = iota SpawnTypeWorld )
const ( SimpleEventCommandsEnabled = iota + 1 SimpleEventCommandsDisabled )
const ( TextTypeRaw = iota TextTypeChat TextTypeTranslation TextTypePopup TextTypeJukeboxPopup TextTypeTip TextTypeSystem TextTypeWhisper TextTypeAnnouncement TextTypeJSON )
const ( BlockUpdateNeighbours = 1 << iota BlockUpdateNetwork BlockUpdateNoGraphics BlockUpdatePriority )
const (
BlockEventChangeChestState = 1
)
const (
IDPlayerSkin = iota + 0x5d
)
...
const (
IDSetLocalPlayerAsInitialised = iota + 0x71
)
...
Variables ¶
var PacketsByName = map[string]func() Packet{}
PacketsByName is a map holding a function to create a new packet for each packet registered in Pool. These functions are indexed using the exact packet name they return.
Functions ¶
This section is empty.
Types ¶
type AddEntity ¶
type AddEntity struct { // EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across // different sessions of the same world, but most servers simply fill the runtime ID of the entity out for // this field. EntityUniqueID int64 // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // EntityType is the string entity type of the entity, for example 'minecraft:skeleton'. A list of these // entities may be found online. EntityType string // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot // see it, the entity will still show up if the player moves closer. Position mgl32.Vec3 // Velocity is the initial velocity the entity spawns with. This velocity will initiate client side // movement of the entity. Velocity mgl32.Vec3 // Pitch is the vertical rotation of the entity. Facing straight forward yields a pitch of 0. Pitch is // measured in degrees. Pitch float32 // Yaw is the horizontal rotation of the entity. Yaw is also measured in degrees. Yaw float32 // HeadYaw is the same as Yaw, except that it applies specifically to the head of the entity. A different // value for HeadYaw than Yaw means that the entity will have its head turned. HeadYaw float32 // Attributes is a slice of attributes that the entity has. It includes attributes such as its health, // movement speed, etc. Attributes []protocol.Attribute // EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in // particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'. // The metadata values are indexed by their property key. EntityMetadata map[uint32]interface{} // EntityLinks is a list of entity links that are currently active on the entity. These links alter the // way the entity shows up when first spawned in terms of it shown as riding an entity. Setting these // links is important for new viewers to see the entity is riding another entity. EntityLinks []protocol.EntityLink }
AddEntity is sent by the server to the client to spawn an entity to the player. It is used for every entity except other players, for which the AddPlayer packet is used.
type AddItemEntity ¶ added in v0.3.0
type AddItemEntity struct { // EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across // different sessions of the same world, but most servers simply fill the runtime ID of the entity out for // this field. EntityUniqueID int64 // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Item is the item that is spawned. It must have a valid ID for it to show up client-side. If it is not // a valid item, the client will crash when coming near. Item protocol.ItemStack // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot // see it, the entity will still show up if the player moves closer. Position mgl32.Vec3 // Velocity is the initial velocity the entity spawns with. This velocity will initiate client side // movement of the entity. Velocity mgl32.Vec3 // EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in // particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'. // The metadata values are indexed by their property key. EntityMetadata map[uint32]interface{} // FromFishing specifies if the item was obtained by fishing it up using a fishing rod. It is not clear // why the client needs to know this. FromFishing bool }
AddItemEntity is sent by the server to the client to make an item entity show up. It is one of the few entities that cannot be sent using the AddEntity packet
func (*AddItemEntity) Marshal ¶ added in v0.3.0
func (pk *AddItemEntity) Marshal(buf *bytes.Buffer)
Marshal ...
type AddPainting ¶
type AddPainting struct { // EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across // different sessions of the same world, but most servers simply fill the runtime ID of the entity out for // this field. EntityUniqueID int64 // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot // see it, the entity will still show up if the player moves closer. Position protocol.BlockPos // Direction is the facing direction of the painting. Direction int32 // Title is the title of the painting. It specifies the motive of the painting. The title of the painting // must be valid. Title string }
AddPainting is sent by the server to the client to make a painting entity show up. It is one of the few entities that cannot be sent using the AddEntity packet.
type AddPlayer ¶
type AddPlayer struct { // UUID is the UUID of the player. It is the same UUID that the client sent in the Login packet at the // start of the session. A player with this UUID must exist in the player list (built up using the // PlayerList packet), for it to show up in-game. UUID uuid.UUID // Username is the name of the player. This username is the username that will be set as the initial // name tag of the player. Username string // EntityUniqueID is the unique ID of the player. The unique ID is a value that remains consistent across // different sessions of the same world, but most servers simply fill the runtime ID of the player out for // this field. EntityUniqueID int64 // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // 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 // Position is the position to spawn the player on. If the player is on a distance that the viewer cannot // see it, the player will still show up if the viewer moves closer. Position mgl32.Vec3 // Velocity is the initial velocity the player spawns with. This velocity will initiate client side // movement of the player. Velocity mgl32.Vec3 // Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is // measured in degrees. Pitch float32 // Yaw is the horizontal rotation of the player. Yaw is also measured in degrees. Yaw float32 // HeadYaw is the same as Yaw, except that it applies specifically to the head of the player. A different // value for HeadYaw than Yaw means that the player will have its head turned. HeadYaw float32 // HeldItem is the item that the player is holding. The item is shown to the viewer as soon as the player // itself shows up. Needless to say that this field is rather pointless, as additional packets still must // be sent for armour to show up. HeldItem protocol.ItemStack // EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in // particular the way the player looks. Flags include ones such as 'on fire' and 'sprinting'. // The metadata values are indexed by their property key. EntityMetadata map[uint32]interface{} // Flags is a set of flags that specify certain properties of the player, such as whether or not it can // fly and/or move through blocks. Flags uint32 // CommandPermissionLevel is a set of permissions that specify what commands a player is allowed to execute. CommandPermissionLevel uint32 // ActionPermissions is, much like Flags, a set of flags that specify actions that the player is allowed // to undertake, such as whether it is allowed to edit blocks, open doors etc. ActionPermissions uint32 // PermissionLevel is the permission level of the player as it shows up in the player list built up using // the PlayerList packet. PermissionLevel uint32 // CustomStoredPermissions ... CustomStoredPermissions uint32 // PlayerUniqueID is a unique identifier of the player. It appears it is not required to fill this field // out with a correct value. Simply writing 0 seems to work. PlayerUniqueID int64 // EntityLinks is a list of entity links that are currently active on the player. These links alter the // way the player shows up when first spawned in terms of it shown as riding an entity. Setting these // links is important for new viewers to see the player is riding another entity. EntityLinks []protocol.EntityLink // DeviceID is the device ID set in one of the files found in the storage of the device of the player. It // may be changed freely, so it should not be relied on for anything. DeviceID string }
AddPlayer is sent by the server to the client to make a player entity show up client-side. It is one of the few entities that cannot be sent using the AddEntity packet.
type AdventureSettings ¶
type AdventureSettings struct { // Flags is a set of flags that specify certain properties of the player, such as whether or not it can // fly and/or move through blocks. It is one of the AdventureFlag constants above. Flags uint32 // CommandPermissionLevel is a permission level that specifies the kind of commands that the player is // allowed to use. It is one of the CommandPermissionLevel constants above. CommandPermissionLevel uint32 // ActionPermissions is, much like Flags, a set of flags that specify actions that the player is allowed // to undertake, such as whether it is allowed to edit blocks, open doors etc. It is a combination of the // ActionPermission constants above. ActionPermissions uint32 // PermissionLevel is the permission level of the player as it shows up in the player list built up using // the PlayerList packet. It is one of the PermissionLevel constants above. PermissionLevel uint32 // CustomStoredPermissions ... CustomStoredPermissions uint32 // PlayerUniqueID is a unique identifier of the player. It appears it is not required to fill this field // out with a correct value. Simply writing 0 seems to work. PlayerUniqueID int64 }
AdventureSettings is sent by the server to update game-play related features, in particular permissions to access these features for the client. It includes allowing the player to fly, build and mine, and attack entities. Most of these flags should be checked server-side instead of using this packet only. The client may also send this packet to the server when it updates one of these settings through the in-game settings interface. The server should verify if the player actually has permission to update those settings.
func (*AdventureSettings) Marshal ¶
func (pk *AdventureSettings) Marshal(buf *bytes.Buffer)
Marshal ...
type Animate ¶
type Animate struct { // ActionType is the ID of the animation action to execute. It is one of the action type constants that // may be found above. ActionType int32 // EntityRuntimeID is the runtime ID of the player that the animation should be played upon. The runtime // ID is unique for each world session, and entities are generally identified in packets using this // runtime ID. EntityRuntimeID uint64 // BoatRowingTime ... BoatRowingTime float32 }
Animate is sent by the server to send a player animation from one player to all viewers of that player. It is used for a couple of actions, such as arm swimming and critical hits.
type BlockEntityData ¶ added in v0.7.0
type BlockEntityData struct { // Position is the position of the block that holds the block entity. If no block entity is at this // position, the packet is ignored by the client. Position protocol.BlockPos // NBTData is the new data of the block that will be encoded to NBT and applied client-side, so that the // client can see the block update. The NBTData should contain all properties of the block, not just // properties that were changed. NBTData map[string]interface{} }
BlockEntityData is sent by the server to update data of a block entity client-side, for example the data of a chest.
func (*BlockEntityData) Marshal ¶ added in v0.7.0
func (pk *BlockEntityData) Marshal(buf *bytes.Buffer)
Marshal ...
type BlockEntry ¶ added in v0.1.0
type BlockEntry struct { // Name is the name of the block. It looks like 'minecraft:stone'. Name string // Data is the metadata value of the block. A lot of blocks only have 0 as data value, but some blocks // carry specific variants or properties encoded in the metadata. Data int16 }
BlockEntry is a block sent in the StartGame packet block runtime ID table. It holds a name and a metadata value of a block.
type BlockEvent ¶
type BlockEvent struct { // Position is the position of the block that an event occurred at. Position protocol.BlockPos // EventType is the type of the block event. The event type decides the way the event data that follows // is used. It is one of the constants found above. EventType int32 // EventData holds event type specific data. For chests for example, opening the chest means the data must // hold 1, whereas closing it should hold 0. EventData int32 }
BlockEvent is sent by the server to initiate a certain event that has something to do with blocks in specific, for example opening a chest.
type BlockPickRequest ¶
type BlockPickRequest struct { // Position is the position at which the client requested to pick the block. The block at that position // should have its item put in HotBarSlot if it is empty. Position protocol.BlockPos // AddBlockNBT specifies if the item should get all NBT tags from the block, meaning the item places a // block practically always equal to the one picked. AddBlockNBT bool // HotBarSlot is the slot that was held at the time of picking a block. HotBarSlot byte }
BlockPickRequest is sent by the client when it requests to pick a block in the world and place its item in their inventory.
func (*BlockPickRequest) Marshal ¶
func (pk *BlockPickRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type BossEvent ¶
type BossEvent struct { // BossEntityUniqueID is the unique ID of the boss entity that the boss event sent involves. The health // percentage and title of the boss bar depend on the health and name tag of this entity. BossEntityUniqueID int64 // EventType is the type of the event. The fields written depend on the event type set, and some event // types are sent by the client, whereas others are sent by the server. The event type is one of the // constants above. EventType uint32 // PlayerUniqueID is the unique ID of the player that is registered to or unregistered from the boss // fight. It is set if EventType is either BossEventRegisterPlayer or BossEventUnregisterPlayer. PlayerUniqueID int64 // BossBarTitle is the title shown above the boss bar. It currently does not function, and instead uses // the name tag of the boss entity at all times. It is only set if the EventType is BossEventShow or // BossEventTitle. BossBarTitle string // HealthPercentage is the percentage of health that is shown in the boss bar. It currently does not // function, and instead uses the health percentage of the boss entity at all times. It is only set if the // EventType is BossEventShow or BossEventHealthPercentage. HealthPercentage float32 // UnknownInt16: Might be something to do with the sky darkening... UnknownInt16 int16 // Colour is the colour of the boss bar that is shown when a player is subscribed. It currently does not // function. It is only set if the EventType is BossEventShow, BossEventAppearanceProperties or // BossEventTexture. Colour uint32 // Overlay is the overlay of the boss bar that is shown on top of the boss bar when a player is // subscribed. It currently does not function. It is only set if the EventType is BossEventShow, // BossEventAppearanceProperties or BossEventTexture. Overlay uint32 }
BossEvent is sent by the server to make a specific 'boss event' occur in the world. It includes features such as showing a boss bar to the player and turning the sky dark.
type Camera ¶
type Camera struct { // CameraEntityUniqueID is the unique ID of the camera entity from which the picture was taken. CameraEntityUniqueID int64 // TargetPlayerUniqueID is the unique ID of the target player. The unique ID is a value that remains // consistent across different sessions of the same world, but most servers simply fill the runtime ID of // the player out for this field. TargetPlayerUniqueID int64 }
Camera is sent by the server to use an Education Edition camera on a player. It produces an image client-side.
type ChangeDimension ¶
type ChangeDimension struct { // Dimension is the dimension that the client should be changed to. The fog colour will change depending // on the type of dimension, which is one of the constants above. // Note that Dimension MUST be a different dimension than the one that the player is currently in. Sending // a ChangeDimension packet with a Dimension that the player is currently in will result in a never-ending // dimension change screen. Dimension int32 // Position is the position in the new dimension that the player is spawned in. Position mgl32.Vec3 // Respawn specifies if the dimension change was respawn based, meaning that the player died in one // dimension and got respawned into another. The client will send a PlayerAction packet with // PlayerActionDimensionChangeRequest if it dies in another dimension, indicating that it needs a // DimensionChange packet with Respawn set to true. Respawn bool }
ChangeDimension is sent by the server to the client to send a dimension change screen client-side. Once the screen is cleared client-side, the client will send a PlayerAction packet with PlayerActionDimensionChangeDone.
type ChunkRadiusUpdated ¶
type ChunkRadiusUpdated struct { // ChunkRadius is the final chunk radius that the client will adapt when it receives the packet. It does // not have to be the same as the requested chunk radius. ChunkRadius int32 }
ChunkRadiusUpdated is sent by the server in response to a RequestChunkRadius packet. It defines the chunk radius that the server allows the client to have. This may be lower than the chunk radius requested by the client in the RequestChunkRadius packet.
func (*ChunkRadiusUpdated) Marshal ¶
func (pk *ChunkRadiusUpdated) Marshal(buf *bytes.Buffer)
Marshal ...
type ClientBoundMapItemData ¶
type ClientBoundMapItemData struct { // MapID is the unique identifier that represents the map that is updated over network. It remains // consistent across sessions. MapID int64 // UpdateFlags is a combination of flags found above that indicate what parts of the map should be updated // client-side. UpdateFlags uint32 // Dimension is the dimension of the map that should be updated, for example the overworld (0), the nether // (1) or the end (2). Dimension byte // LockedMap specifies if the map that was updated was a locked map, which may be done using a cartography // table. LockedMap bool // Scale is the scale of the map as it is shown in-game. It is written when any of the MapUpdateFlags are // set to the UpdateFlags field. Scale byte // MapsIncludedIn holds an array of map IDs that the map updated is included in. This has to do with the // scale of the map: Each map holds its own map ID and all map IDs of maps that include this map and have // a bigger scale. This means that a scale 0 map will have 5 map IDs in this slice, whereas a scale 4 map // will have only 1 (its own). // The actual use of this field remains unknown. MapsIncludedIn []int64 // TrackedObjects is a list of tracked objects on the map, which may either be entities or blocks. The // client makes sure these tracked objects are actually tracked. (position updated etc.) TrackedObjects []protocol.MapTrackedObject // Decorations is a list of fixed decorations located on the map. The decorations will not change // client-side, unless the server updates them. Decorations []protocol.MapDecoration // Height is the height of the texture area that was updated. The height may be a subset of the total // height of the map. Height int32 // Width is the width of the texture area that was updated. The width may be a subset of the total width // of the map. Width int32 // XOffset is the X offset in pixels at which the updated texture area starts. From this X, the updated // texture will extend exactly Width pixels to the right. XOffset int32 // YOffset is the Y offset in pixels at which the updated texture area starts. From this Y, the updated // texture will extend exactly Height pixels up. YOffset int32 // Pixels is a list of pixel colours for the new texture of the map. It is indexed as Pixels[y][x], with // the length of the outer slice having to be exactly Height long and the inner slices exactly Width long. Pixels [][]color.RGBA }
ClientBoundMapItemData is sent by the server to the client to update the data of a map shown to the client. It is sent with a combination of flags that specify what data is updated. The ClientBoundMapItemData packet may be used to update specific parts of the map only. It is not required to send the entire map each time when updating one part.
func (*ClientBoundMapItemData) Marshal ¶
func (pk *ClientBoundMapItemData) Marshal(buf *bytes.Buffer)
Marshal ...
type ClientToServerHandshake ¶
type ClientToServerHandshake struct { }
ClientToServerHandshake is sent by the client in response to a ServerToClientHandshake packet sent by the server. It is the first encrypted packet in the login handshake and serves as a confirmation that encryption is correctly initialised client side.
func (*ClientToServerHandshake) Marshal ¶
func (*ClientToServerHandshake) Marshal(buf *bytes.Buffer)
Marshal ...
type ContainerClose ¶
type ContainerClose struct { // WindowID is the ID representing the window of the container that should be closed. It must be equal to // the one sent in the ContainerOpen packet to close the designated window. WindowID byte }
ContainerClose is sent by the server to close a container the player currently has opened, which was opened using the ContainerOpen packet.
type ContainerOpen ¶
type ContainerOpen struct { // WindowID is the ID representing the window that is being opened. It may be used later to close the // container using a ContainerClose packet. WindowID byte // ContainerType is the type ID of the container that is being opened when opening the container at the // position of the packet. It depends on the block/entity, and could, for example, be the window type of // a chest or a hopper, but also a horse inventory. ContainerType byte // ContainerPosition is the position of the container opened. The position must point to a block entity // that actually has a container. If that is not the case, the window will not be opened and the packet // will be ignored, if a valid ContainerEntityUniqueID has not also been provided. ContainerPosition protocol.BlockPos // ContainerEntityUniqueID is the unique ID of the entity container that was opened. It is only used if // the ContainerType is one that points to an entity, for example a horse. ContainerEntityUniqueID int64 }
ContainerOpen is sent by the server to open a container client-side. This container must be physically present in the world, for the packet to have any effect. Unlike Java Edition, Bedrock Edition requires that chests for example must be present and in range to open its inventory.
type ContainerSetData ¶
type ContainerSetData struct { // WindowID is the ID of the window that should have its data set. The player must have a window open with // the window ID passed, or nothing will happen. WindowID byte // Key is the key of the property. It is one of the constants that can be found above. Multiple properties // share the same key, but the functionality depends on the type of the container that the data is set to. Key int32 // Value is the value of the property. Its use differs per property. Value int32 }
ContainerSetData is sent by the server to update specific data of a single container, meaning a block such as a furnace or a brewing stand. This data is usually used by the client to display certain features client-side.
func (*ContainerSetData) Marshal ¶
func (pk *ContainerSetData) Marshal(buf *bytes.Buffer)
Marshal ...
type CraftingData ¶
type CraftingData struct { // Recipes is a list of all recipes available on the server. It includes among others shapeless, shaped // and furnace recipes. The client will only be able to craft these recipes. Recipes []protocol.Recipe // CleanRecipes indicates if all recipes currently active on the client should be cleaned. Doing this // means that the client will have no recipes active by itself: Any CraftingData packets previously sent // will also be discarded, and only the recipes in this CraftingData packet will be used. CleanRecipes bool }
CraftingData is sent by the server to let the client know all crafting data that the server maintains. This includes shapeless crafting, crafting table recipes, furnace recipes etc. Each crafting station's recipes are included in it.
type CraftingEvent ¶
type CraftingEvent struct { // WindowID is the ID representing the window that the player crafted in. WindowID byte // CraftingType is a type that indicates the way the crafting was done, for example if a crafting table // was used. CraftingType int32 // TODO: Figure out the options for this. // RecipeUUID is the UUID of the recipe that was crafted. It points to the UUID of the recipe that was // sent earlier in the CraftingData packet. RecipeUUID uuid.UUID // Input is a list of items that the player put into the recipe so that it could create the Output items. // These items are consumed in the process. Input []protocol.ItemStack // Output is a list of items that were obtained as a result of crafting the recipe. Output []protocol.ItemStack }
CraftingEvent is sent by the client when it crafts a particular item. Note that this packet may be fully ignored, as the InventoryTransaction packet provides all the information required.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder handles the decoding of Minecraft packets sent through an io.Reader. These packets in turn contain multiple zlib compressed packets.
func NewDecoder ¶
NewDecoder returns a new decoder decoding data from the reader passed. One read call from the reader is assumed to consume an entire packet.
func (*Decoder) Decode ¶
Decode decodes one 'packet' from the reader passed in NewDecoder(), producing a slice of packets that it held and an error if not successful.
func (*Decoder) EnableEncryption ¶
EnableEncryption enables encryption for the Decoder using the secret key bytes passed. Each packet received will be decrypted.
type Disconnect ¶
type Disconnect struct { // HideDisconnectionScreen specifies if the disconnection screen should be hidden when the client is // disconnected, meaning it will be sent directly to the main menu. HideDisconnectionScreen bool // Message is an optional message to show when disconnected. This message is only written if the // HideDisconnectionScreen field is set to true. Message string }
Disconnect may be sent by the server to disconnect the client using an optional message to send as the disconnect screen.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder handles the encoding of Minecraft packets that are sent to an io.Writer. The packets are compressed and optionally encoded before they are sent to the io.Writer.
func NewEncoder ¶
NewEncoder returns a new Encoder for the io.Writer passed. Each final packet produced by the Encoder is sent with a single call to io.Writer.Write().
func (*Encoder) EnableEncryption ¶
EnableEncryption enables encryption for the Encoder using the secret key bytes passed. Each packet sent after encryption is enabled will be encrypted.
type EntityEvent ¶ added in v0.4.0
type EntityEvent struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // EventType is the ID of the event to be called. It is one of the constants that can be found above. EventType byte // EventData is optional data associated with a particular event. The data has a different function for // different events, however most events don't use this field at all. EventData int32 }
EntityEvent is sent by the server when a particular event happens that has to do with an entity. Some of these events are entity-specific, for example a wolf shaking itself dry, but others are used for each entity, such as dying.
func (*EntityEvent) Marshal ¶ added in v0.4.0
func (pk *EntityEvent) Marshal(buf *bytes.Buffer)
Marshal ...
type EntityFall ¶ added in v0.7.0
type EntityFall struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // FallDistance is the distance that the entity fell until it hit the ground. The damage would otherwise // be calculated using this field. FallDistance float32 // InVoid specifies if the fall was in the void. The player can't fall below roughly Y=-40. InVoid bool }
EntityFall is sent by the client when it falls from a distance onto a block that would damage the player. This packet should not be used at all by the server, as it can easily be spoofed using a proxy or custom client. Servers should implement fall damage using their own calculations.
func (*EntityFall) Marshal ¶ added in v0.7.0
func (pk *EntityFall) Marshal(buf *bytes.Buffer)
Marshal ...
type EntityPickRequest ¶ added in v0.6.0
type EntityPickRequest struct { // EntityUniqueID is the unique ID of the entity that was attempted to be picked. The server must find the // type of that entity and provide the correct spawn egg to the player. EntityUniqueID int64 // HotBarSlot is the held hot bar slot of the player at the time of trying to pick the entity. If empty, // the resulting spawn egg should be put into this slot. HotBarSlot byte }
EntityPickRequest is sent by the client when it tries to pick an entity, so that it gets a spawn egg which can spawn that entity.
func (*EntityPickRequest) Marshal ¶ added in v0.6.0
func (pk *EntityPickRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type Event ¶
type Event struct { // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // EventType is the type of the event to be called. It is one of the constants that may be found above. EventType int32 // Unknown ... TODO: Find out what this is for. Unknown byte }
Event is sent by the server to send an event with additional data. It is typically sent to the client for telemetry reasons, much like the SimpleEvent packet.
type Explode ¶ added in v0.3.0
type Explode struct { // Position is the centre position of the explosion that is taking place. It has no effect on the blocks // broken client-side, and seems to have no other functionality. Position mgl32.Vec3 // Radius is the radius of the explosion. It seems to have no functionality. Radius float32 // BlocksBroken is a list of all block positions that are to be destroyed by the explosion. This is the // only field that has functionality in the packet. BlocksBroken []protocol.BlockPos }
Explode is sent by the server to make an explosion happen. The explosion will break all blocks in the packet client-side.
type FullChunkData ¶ added in v0.2.0
type FullChunkData struct { // ChunkX is the X coordinate of the chunk sent. (To translate a block's X to a chunk's X: x >> 4) ChunkX int32 // ChunkZ is the Z coordinate of the chunk sent. (To translate a block's Z to a chunk's Z: z >> 4) ChunkZ int32 // Data is a serialised string of chunk data. The chunk data is composed of multiple sub-chunks, each of // which carry a version which indicates the way they are serialised. Data string }
FullChunkData is sent by the server to provide the client with a chunk of a world data (16xYx16 blocks). Typically a certain amount of chunks is sent to the client before sending it the spawn PlayStatus packet, so that the client spawns in a loaded world.
func (*FullChunkData) Marshal ¶ added in v0.2.0
func (pk *FullChunkData) Marshal(buf *bytes.Buffer)
Marshal ...
type GUIDataPickItem ¶
type GUIDataPickItem struct { // ItemName is the name of the item that shows up in the top part of the popup that shows up when // selecting an item. It is shown as if an item was selected by the player itself. ItemName string // ItemEffects is the line under the ItemName, where the effects of the item are usually situated. ItemEffects string // HotBarSlot is the hot bar slot to be selected/picked. This does not currently work, so it does not // matter what number this is. HotBarSlot int32 }
GUIDataPickItem is sent by the server to make the client 'select' a hot bar slot. It currently appears to be broken however, and does not actually set the selected slot to the hot bar slot set in the packet.
type GameRulesChanged ¶
type GameRulesChanged struct { // GameRules defines game rules changed with their respective values. The value of these game rules may be // either 'bool', 'int32' or 'float32'. // Note that some game rules are server side only, and don't necessarily need to be sent to the client. // Only changed game rules need to be sent in this packet. Game rules that were not changed do not need to // be sent if the client is already updated on them. GameRules map[string]interface{} }
GameRulesChanged is sent by the server to the client to update client-side game rules, such as game rules like the 'showcoordinates' game rule.
func (*GameRulesChanged) Marshal ¶
func (pk *GameRulesChanged) Marshal(buf *bytes.Buffer)
Marshal ...
type Header ¶
Header is the header of a packet. It exists out of a single varuint32 which is composed of a packet ID and a sender and target sub client ID. These IDs are used for split screen functionality.
type HurtArmour ¶
type HurtArmour struct { // Damage is the amount of damage points that was dealt to the player. The damage to the armour will be // calculated by the client based upon this damage, and will also be based upon any enchantments like // thorns that the armour may have. Damage int32 }
HurtArmour is sent by the server to damage the player's armour after being hit. The packet should never be used by servers as it hands the responsibility over to the player completely, while the server can easily reliably update the armour damage of players itself.
type Interact ¶
type Interact struct { // Action type is the ID of the action that was executed by the player. It is one of the constants that // may be found above. ActionType byte // TargetEntityRuntimeID is the runtime ID of the entity that the player interacted with. This is empty // for the InteractActionOpenInventory action type. TargetEntityRuntimeID uint64 // MouseOverPosition was the position relative to the entity moused over over which the player hovered // with its mouse/touch. It is only set if ActionType is InteractActionMouseOverEntity. MouseOverPosition mgl32.Vec3 }
Interact is sent by the client when it interacts with another entity in some way. It used to be used for normal entity and block interaction, but this is no longer the case now.
type InventoryContent ¶
type InventoryContent struct { // WindowID is the ID that identifies one of the windows that the client currently has opened, or one of // the consistent windows such as the main inventory. WindowID uint32 // Content is the new content of the inventory. The length of this slice must be equal to the full size of // the inventory window updated. Content []protocol.ItemStack }
InventoryContent is sent by the server to update the full content of a particular inventory. It is usually sent for the main inventory of the player, but also works for other inventories that are currently opened by the player.
func (*InventoryContent) Marshal ¶
func (pk *InventoryContent) Marshal(buf *bytes.Buffer)
Marshal ...
type InventorySlot ¶
type InventorySlot struct { // WindowID is the ID of the window that the packet modifies. It must point to one of the windows that the // client currently has opened. WindowID uint32 // Slot is the index of the slot that the packet modifies. The new item will be set to the slot at this // index. Slot uint32 // NewItem is the item to be put in the slot at Slot. It will overwrite any item that may currently // be present in that slot. NewItem protocol.ItemStack }
InventorySlot is sent by the server to update a single slot in one of the inventory windows that the client currently has opened. Usually this is the main inventory, but it may also be the off hand or, for example, a chest inventory.
type InventoryTransaction ¶
type InventoryTransaction struct { // Actions is a list of actions that took place, that form the inventory transaction together. Each of // these actions hold one slot in which one item was changed to another. In general, the combination of // all of these actions results in a balanced inventory transaction. This should be checked to ensure that // no items are cheated into the inventory. Actions []protocol.InventoryAction // TransactionData is a data object that holds data specific to the type of transaction that the // TransactionPacket held. Its concrete type must be one of NormalTransactionData, MismatchTransactionData // UseItemTransactionData, UseItemOnEntityTransactionData or ReleaseItemTransactionData. If nil is set, // the transaction will be assumed to of type InventoryTransactionTypeNormal. TransactionData protocol.InventoryTransactionData }
InventoryTransaction is a packet sent by the client. It essentially exists out of multiple sub-packets, each of which have something to do with the inventory in one way or another. Some of these sub-packets directly relate to the inventory, others relate to interaction with the world, that could potentially result in a change in the inventory.
func (*InventoryTransaction) Marshal ¶
func (pk *InventoryTransaction) Marshal(buf *bytes.Buffer)
Marshal ...
type ItemFrameDropItem ¶
type ItemFrameDropItem struct { // Position is the position of the item frame that had its item dropped. There must be a 'block entity' // present at this position. Position protocol.BlockPos }
ItemFrameDropItem is sent by the server to make the item in an item frame drop out of the frame client-side.
func (*ItemFrameDropItem) Marshal ¶
func (pk *ItemFrameDropItem) Marshal(buf *bytes.Buffer)
Marshal ...
type LevelEvent ¶
type LevelEvent struct { // EventType is the ID of the event that is being 'called'. It is one of the events found in the constants // above. EventType int32 // Position is the position of the level event. Practically every event requires this Vec3 set for it, as // particles, sounds and block editing relies on it. Position mgl32.Vec3 // EventData is an integer holding additional data of the event. The type of data held depends on the // EventType. EventData int32 }
LevelEvent is sent by the server to make a certain event in the level occur. It ranges from particles, to sounds, and other events such as starting rain and block breaking.
type Login ¶
type Login struct { // ClientProtocol is the protocol version of the player. The player is disconnected if the protocol is // incompatible with the protocol of the server. ClientProtocol int32 // ConnectionRequest is a string containing information about the player and JWTs that may be used to // verify if the player is connected to XBOX Live. The connection request also contains the necessary // client public key to initiate encryption. ConnectionRequest string }
Login is sent when the client initially tries to join the server. It is the first packet sent and contains information specific to the player.
type MapInfoRequest ¶
type MapInfoRequest struct { // MapID is the unique identifier that represents the map that is requested over network. It remains // consistent across sessions. MapID int64 }
MapInfoRequest is sent by the client to request the server to deliver information of a certain map in the inventory of the player. The server should respond with a ClientBoundMapItemData packet.
type MobArmourEquipment ¶
type MobArmourEquipment struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Helmet is the equipped helmet of the entity. Items that are not wearable on the head will not be // rendered by the client. Unlike in Java Edition, blocks cannot be worn. Helmet protocol.ItemStack // Chestplate is the chestplate of the entity. Items that are not wearable as chestplate will not be // rendered. Chestplate protocol.ItemStack // Leggings is the item worn as leggings by the entity. Items not wearable as leggings will not be // rendered client-side. Leggings protocol.ItemStack // Boots is the item worn as boots by the entity. Items not wearable as boots will not be rendered. Boots protocol.ItemStack }
MobArmourEquipment is sent by the server to the client to update the armour an entity is wearing. It is sent for both players and other entities, such as zombies.
func (*MobArmourEquipment) Marshal ¶
func (pk *MobArmourEquipment) Marshal(buf *bytes.Buffer)
Marshal ...
type MobEffect ¶
type MobEffect struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Operation is the operation of the packet. It is either MobEffectAdd, MobEffectModify or MobEffectRemove // and specifies the result of the packet client-side. Operation byte // EffectType is the ID of the effect to be added, removed or modified. It is one of the constants that // may be found above. EffectType int32 // Amplifier is the amplifier of the effect. Take note that the amplifier is not the same as the effect's // level. The level is usually one higher than the amplifier, and the amplifier can actually be negative // to reverse the behaviour effect. Amplifier int32 // Particles specifies if viewers of the entity that gets the effect shows particles around it. If set to // false, no particles are emitted around the entity. Particles bool // Duration is the duration of the effect in seconds. After the duration has elapsed, the effect will be // removed automatically client-side. Duration int32 }
MobEffect is sent by the server to apply an effect to the player, for example an effect like poison. It may also be used to modify existing effects, or removing them completely.
type MobEquipment ¶
type MobEquipment struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // NewItem is the new item held after sending the MobEquipment packet. The entity will be shown holding // that item to the player it was sent to. NewItem protocol.ItemStack // InventorySlot is the slot in the inventory that was held. This is the same as HotBarSlot, and only // remains for backwards compatibility. InventorySlot byte // HotBarSlot is the slot in the hot bar that was held. It is the same as InventorySlot, which is only // there for backwards compatibility purposes. HotBarSlot byte // WindowID is the window ID of the window that had its equipped item changed. This is usually the window // ID of the normal inventory, but may also be something else, for example with the off hand. WindowID byte }
MobEquipment is sent by the client to the server and the server to the client to make the other side aware of the new item that an entity is holding. It is used to show the item in the hand of entities such as zombies too.
type ModalFormRequest ¶
type ModalFormRequest struct { // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player // submits the form, so that the server can identify which form was submitted. FormID uint32 // FormData is a JSON encoded object of form data. The content of the object differs, depending on the // type of the form sent, which is also set in the JSON. FormData string }
ModalFormRequest is sent by the server to make the client open a form. This form may be either a modal form which has two options, a menu form for a selection of options and a custom form for properties.
func (*ModalFormRequest) Marshal ¶
func (pk *ModalFormRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type ModalFormResponse ¶
type ModalFormResponse struct { // FormID is the form ID of the form the client has responded to. It is the same as the ID sent in the // ModalFormRequest, and may be used to identify which form was submitted. FormID uint32 // ResponseData is a JSON encoded value representing the response of the player. If the form was // cancelled, a JSON encoded 'null' is in the response. For a modal form, the response is either true or // false, for a menu form, the response is an integer specifying the index of the button clicked, and for // a custom form, the response is an array containing a value for each element. ResponseData string }
ModalFormResponse is sent by the client in response to a ModalFormRequest, after the player has submitted the form sent. It contains the options/properties selected by the player, or a JSON encoded 'null' if the form was closed by clicking the X at the top right corner of the form.
func (*ModalFormResponse) Marshal ¶
func (pk *ModalFormResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type MoveEntityAbsolute ¶ added in v0.3.0
type MoveEntityAbsolute struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Flags is a combination of flags that specify details of the movement. It is a combination of the flags // above. Flags byte // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot // see it, the entity will still show up if the player moves closer. Position mgl32.Vec3 // Rotation is a Vec3 holding the X, Y and Z rotation of the entity after the movement. This is a Vec3 for // the reason that projectiles like arrows don't have yaw/pitch, but do have roll. Rotation mgl32.Vec3 }
MoveEntityAbsolute is sent by the server to move an entity to an absolute position. It is typically used for movements where high accuracy isn't needed, such as for long range teleporting.
func (*MoveEntityAbsolute) Marshal ¶ added in v0.3.0
func (pk *MoveEntityAbsolute) Marshal(buf *bytes.Buffer)
Marshal ...
type MovePlayer ¶
type MovePlayer struct { // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Position is the position to spawn the player on. If the player is on a distance that the viewer cannot // see it, the player will still show up if the viewer moves closer. Position mgl32.Vec3 // Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is // measured in degrees. Pitch float32 // Yaw is the horizontal rotation of the player. Yaw is also measured in degrees. Yaw float32 // HeadYaw is the same as Yaw, except that it applies specifically to the head of the player. A different // value for HeadYaw than Yaw means that the player will have its head turned. HeadYaw float32 // Mode is the mode of the movement. It specifies the way the player's movement should be shown to other // players. It is one of the constants above. Mode byte // OnGround specifies if the player is considered on the ground. Note that proxies or hacked clients could // fake this to always be true, so it should not be taken for granted. OnGround bool // RiddenEntityRuntimeID is the runtime ID of the entity that the player might currently be riding. If not // riding, this should be left 0. RiddenEntityRuntimeID uint64 // TeleportCause is written only if Mode is MoveModeTeleport. It specifies the cause of the teleportation, // which is one of the constants above. TeleportCause int32 // TeleportItem is the item network ID of the item type that was used to teleport. It is only non-zero if // the teleport cause was an item. TeleportItem int32 }
MovePlayer is sent by players to send their movement to the server, and by the server to update the movement of player entities to other players.
type Packet ¶
type Packet interface { // ID returns the ID of the packet. All of these identifiers of packets may be found in id.go. ID() uint32 // Marshal encodes the packet to its binary representation into buf. Marshal(buf *bytes.Buffer) // Unmarshal decodes a serialised packet in buf into the Packet instance. The serialised packet passed // into Unmarshal will not have a header in it. Unmarshal(buf *bytes.Buffer) error }
Packet represents a packet that may be sent over a Minecraft network connection. The packet needs to hold a method to encode itself to binary and decode itself from binary.
type PlayStatus ¶
type PlayStatus struct { // Status is the status of the packet. It is one of the constants found above. Status int32 }
PlayStatus is sent by the server to update a player on the play status. This includes failed statuses due to a mismatched version, but also success statuses.
type PlayerAction ¶
type PlayerAction struct { // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // ActionType is the ID of the action that was executed by the player. It is one of the constants that may // be found above. ActionType int32 // BlockPosition is the position of the target block, if the action with the ActionType set concerned a // block. If that is not the case, the block position will be zero. BlockPosition protocol.BlockPos // BlockFace is the face of the target block that was touched. If the action with the ActionType set // concerned a block. If not, the face is always 0. BlockFace int32 }
PlayerAction is sent by the client when it executes any action, for example starting to sprint, swim, starting the breaking of a block, dropping an item, etc.
type PlayerHotBar ¶
type PlayerHotBar struct { // SelectedHotBarSlot ... SelectedHotBarSlot uint32 // WindowID ... WindowID byte // SelectHotBarSlot ... SelectHotBarSlot bool }
PlayerHotBar is sent by the server to the client. It used to be used to link hot bar slots of the player to actual slots in the inventory, but as of 1.2, this was changed and hot bar slots are no longer a free floating part of the inventory. Since 1.2, the packet has been re-purposed, but its new functionality is not clear.
type PlayerInput ¶
type PlayerInput struct { // Movement is the movement vector of the input. It should be thought of in Pocket Edition controls, where // specific arrows (or a combination of two, resulting in a diagonal arrow) decide the direction of // movement. The movement vector typically has a length of 1: Either it has movement on one axis, or it // has a combination, resulting in sqrt(2)/2 for both axes. Movement mgl32.Vec2 // Jumping indicates if the player was pressing the jump button during the input. It does not define if // the player was actually in the air or not. Jumping bool // Sneaking indicates if the player was sneaking during the input. Note that this may also be checked by // keeping the sneaking state updated using the PlayerAction packet. Sneaking bool }
PlayerInput is sent by the client to the server when the player is moving but the server does not allow it to update its movement using the MovePlayer packet. It includes situations where the player is riding an entity like a boat. If this is the case, the packet is sent roughly every tick.
type PlayerList ¶
type PlayerList struct { // Action is the action to execute upon the player list. The entries that follow specify which entries are // added or removed from the player list. Action byte // Entries is a list of all player list entries that should be added/removed from the player list, // depending on the Action set. Entries []PlayerListEntry }
PlayerList is sent by the server to update the client-side player list in the in-game menu screen. It shows the icon of each player if the correct XUID is written in the packet. Sending the PlayerList packet is obligatory when sending an AddPlayer packet. The added player will not show up to a client if it has not been added to the player list, because several properties of the player are obtained from the player list, such as the skin.
type PlayerListEntry ¶ added in v0.7.0
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 // SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex' // for the default Alex skin. SkinID string // SkinData is a byte slice of 64*32*4, 64*64*4 or 128*128*4 bytes. It is a RGBA ordered byte // representation of the skin colours. SkinData string // 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 string // SkinGeometryName is the geometry name of the skin geometry above. This name must be equal to one of the // outer names found in the SkinGeometry, so that the client can find the correct geometry data. SkinGeometryName string // SkinGeometry is a base64 JSON encoded structure of the geometry data of a skin, containing properties // such as bones, uv, pivot etc. SkinGeometry 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 }
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 PlayerSkin ¶
type PlayerSkin 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 skin to show up on the player. UUID uuid.UUID // SkinID is a unique ID produced for the skin, for example 'c18e65aa-7b21-4637-9b63-8ad63622ef01_Alex' // for the default Alex skin. SkinID string // NewSkinName no longer has a function: The field can be left empty at all times. NewSkinName string // OldSkinName no longer has a function: The field can be left empty at all times. OldSkinName string // SkinData is a byte slice of 64*32*4, 64*64*4 or 128*128*4 bytes. It is a RGBA ordered byte // representation of the skin colours. SkinData string // 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 string // SkinGeometryName is the geometry name of the skin geometry above. This name must be equal to one of the // outer names found in the SkinGeometry, so that the client can find the correct geometry data. SkinGeometryName string // SkinGeometry is a base64 JSON encoded structure of the geometry data of a skin, containing properties // such as bones, uv, pivot etc. SkinGeometry string // PremiumSkin specifies if the skin equipped was a premium skin, meaning a payment was required in the // marketplace to get access to it. PremiumSkin bool }
PlayerSkin is sent by the client to the server when it updates its own skin using the in-game skin picker. It is relayed by the server, or sent if the server changes the skin of a player on its own accord. Note that the packet can only be sent for players that are in the player list at the time of sending.
type RemoveEntity ¶
type RemoveEntity struct { // EntityUniqueID is the unique ID of the entity to be removed. The unique ID is a value that remains // consistent across different sessions of the same world, but most servers simply fill the runtime ID // of the entity out for this field. EntityUniqueID int64 }
RemoveEntity is sent by the server to remove an entity that currently exists in the world from the client- side. Sending this packet if the client cannot already see this entity will have no effect.
type RequestChunkRadius ¶
type RequestChunkRadius struct { // ChunkRadius is the requested chunk radius. This value is always the value set in the settings of the // player. ChunkRadius int32 }
RequestChunkRadius is sent by the client to the server to update the server on the chunk view radius that it has set in the settings. The server may respond with a ChunkRadiusUpdated packet with either the chunk radius requested, or a different chunk radius if the server chooses so.
func (*RequestChunkRadius) Marshal ¶
func (pk *RequestChunkRadius) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePack ¶ added in v0.1.0
type ResourcePack 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 int64 // 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 }
ResourcePack represents a resource pack sent over network. It holds information about the resource pack such as its name, description and version.
type ResourcePackChunkData ¶
type ResourcePackChunkData struct { // UUID is the unique ID of the resource pack that the chunk of data is taken out of. UUID string // ChunkIndex is the current chunk index of the chunk. It is a number that starts at 0 and is incremented // for each resource pack data chunk sent to the client. ChunkIndex int32 // DataOffset is the current progress in bytes or offset in the data that the resource pack data chunk is // taken from. DataOffset int64 // Data is a byte slice containing a chunk of data from the resource pack. It must be of the same size or // less than the DataChunkSize set in the ResourcePackDataInfo packet. Data []byte }
ResourcePackChunkData is sent to the client so that the client can download the resource pack. Each packet holds a chunk of the compressed resource pack, of which the size is defined in the ResourcePackDataInfo packet sent before.
func (*ResourcePackChunkData) Marshal ¶
func (pk *ResourcePackChunkData) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackChunkRequest ¶
type ResourcePackChunkRequest struct { // UUID is the unique ID of the resource pack that the chunk of data is requested from. UUID string // ChunkIndex is the requested chunk index of the chunk. It is a number that starts at 0 and is // incremented for each resource pack data chunk requested. ChunkIndex int32 }
ResourcePackChunkRequest is sent by the client to request a chunk of data from a particular resource pack, that it has obtained information about in a ResourcePackDataInfo packet.
func (*ResourcePackChunkRequest) Marshal ¶
func (pk *ResourcePackChunkRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackClientResponse ¶
type ResourcePackClientResponse struct { // Response is the response type of the response. It is one of the constants found above. Response byte // PacksToDownload is a list of resource pack UUIDs combined with their version that need to be downloaded // (for example SomePack_1.0.0), if the Response field is PackResponseSendPacks. PacksToDownload []string }
ResourcePackClientResponse is sent by the client in response to resource packets sent by the server. It is used to let the server know what action needs to be taken for the client to have all resource packs ready and set.
func (*ResourcePackClientResponse) Marshal ¶
func (pk *ResourcePackClientResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackDataInfo ¶
type ResourcePackDataInfo struct { // UUID is the unique ID of the resource pack that the info concerns. UUID string // DataChunkSize is the maximum size in bytes of the chunks in which the total size of the resource pack // to be sent will be divided. A size of 1MB (1024*1024) means that a resource pack of 15.5MB will be // split into 16 data chunks. DataChunkSize int32 // ChunkCount is the total amount of data chunks that the sent resource pack will exist out of. It is the // total size of the resource pack divided by the DataChunkSize field. ChunkCount int32 // 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 int64 // Hash is a SHA256 hash of the content of the resource pack. Hash string }
ResourcePackDataInfo is sent by the server to the client to inform the client about the data contained in one of the resource packs that are about to be sent.
func (*ResourcePackDataInfo) Marshal ¶
func (pk *ResourcePackDataInfo) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePackStack ¶
type ResourcePackStack struct { // TexturePackRequired specifies if the client must accept the texture packs the server has in order to // join the server. If set to true, the client gets the option to either download the resource packs and // join, or quit entirely. Behaviour packs never have to be downloaded. TexturePackRequired bool // BehaviourPack is a list of behaviour packs that the client needs to download before joining the server. // All of these behaviour packs will be applied together, and the order does not necessarily matter. BehaviourPacks []ResourcePack // TexturePacks is a list of texture packs that the client needs to download before joining the server. // The order of these texture packs specifies the order that they are applied in on the client side. The // first in the list will be applied first. TexturePacks []ResourcePack // Experimental specifies if the resource packs in the stack are experimental. This is internal and should // always be set to false. Experimental bool }
ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs should be applied (and downloaded) by the client.
func (*ResourcePackStack) Marshal ¶
func (pk *ResourcePackStack) Marshal(buf *bytes.Buffer)
Marshal ...
type ResourcePacksInfo ¶
type ResourcePacksInfo struct { // TexturePackRequired specifies if the client must accept the texture packs the server has in order to // join the server. If set to true, the client gets the option to either download the resource packs and // join, or quit entirely. Behaviour packs never have to be downloaded. TexturePackRequired bool // HasScripts specifies if any of the resource packs contain scripts in them. If set to true, only clients // that support scripts will be able to download them. HasScripts bool // BehaviourPack is a list of behaviour packs that the client needs to download before joining the server. // All of these behaviour packs will be applied together. BehaviourPacks []ResourcePack // TexturePacks is a list of texture packs that the client needs to download before joining the server. // The order of these texture packs is not relevant in this packet. It is however important in the // ResourcePackStack packet. TexturePacks []ResourcePack }
ResourcePacksInfo is sent by the server to inform the client on what resource packs the server has. It sends a list of the resource packs it has and basic information on them like the version and description.
func (*ResourcePacksInfo) Marshal ¶
func (pk *ResourcePacksInfo) Marshal(buf *bytes.Buffer)
Marshal ...
type Respawn ¶
type Respawn struct { // Position is the position on which the player should be respawned. The position might be in a different // dimension, in which case the client should first be sent a ChangeDimension packet. Position mgl32.Vec3 }
Respawn is sent by the server to make a player respawn client-side. It is sent in response to a PlayerAction packet with ActionType PlayerActionRespawn.
type RiderJump ¶ added in v0.3.0
type RiderJump struct { // JumpStrength is the strength of the jump, depending on how long the rider has held the jump button. JumpStrength int32 }
RiderJump is sent by the client to the server when it jumps while riding an entity that has the WASDControlled entity flag set, for example when riding a horse.
type ServerSettingsRequest ¶
type ServerSettingsRequest struct { }
ServerSettingsRequest is sent by the client to request the settings specific to the server. These settings are shown in a separate tab client-side, and have the same structure as a custom form.
func (*ServerSettingsRequest) Marshal ¶
func (*ServerSettingsRequest) Marshal(buf *bytes.Buffer)
Marshal ...
type ServerSettingsResponse ¶
type ServerSettingsResponse struct { // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player // submits the form, so that the server can identify which form was submitted. FormID uint32 // FormData is a JSON encoded object of form data. The content of the object differs, depending on the // type of the form sent, which is also set in the JSON. FormData string }
ServerSettingsResponse is optionally sent by the server in response to a ServerSettingsRequest from the client. It is structured the same as a ModalFormRequest packet, and if filled out correctly, will show a specific tab for the server in the settings of the client. A ModalFormResponse packet is sent by the client in response to a ServerSettingsResponse, when the client fills out the settings and closes the settings again.
func (*ServerSettingsResponse) Marshal ¶
func (pk *ServerSettingsResponse) Marshal(buf *bytes.Buffer)
Marshal ...
type ServerToClientHandshake ¶
type ServerToClientHandshake struct { // JWT is a raw JWT token containing data such as the public key from the server, the algorithm used and // the server's token. It is used for the client to produce a shared secret. JWT string }
ServerToClientHandshake is sent by the server to the client to complete the key exchange in order to initialise encryption on client and server side. It is followed up by a ClientToServerHandshake packet from the client.
func (*ServerToClientHandshake) Marshal ¶
func (pk *ServerToClientHandshake) Marshal(buf *bytes.Buffer)
Marshal ...
type SetCommandsEnabled ¶
type SetCommandsEnabled struct { // Enabled defines if the commands should be enabled, or if false, disabled. Enabled bool }
SetCommandsEnabled is sent by the server to enable or disable the ability to execute commands for the client. If disabled, the client itself will stop the execution of commands.
func (*SetCommandsEnabled) Marshal ¶
func (pk *SetCommandsEnabled) Marshal(buf *bytes.Buffer)
Marshal ...
type SetDifficulty ¶
type SetDifficulty struct { // Difficulty is the new difficulty that the world has. Difficulty uint32 }
SetDifficulty is sent by the server to update the client-side difficulty of the client. The actual effect of this packet on the client isn't very significant, as the difficulty is handled server-side.
type SetEntityData ¶ added in v0.7.0
type SetEntityData struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in // particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'. // The metadata values are indexed by their property key. EntityMetadata map[uint32]interface{} }
SetEntityData is sent by the server to update the entity metadata of an entity. It includes flags such as if the entity is on fire, but also properties such as the air it has left until it starts drowning.
func (*SetEntityData) Marshal ¶ added in v0.7.0
func (pk *SetEntityData) Marshal(buf *bytes.Buffer)
Marshal ...
type SetEntityLink ¶ added in v0.7.0
type SetEntityLink struct { // EntityLink is the link to be set client-side. It links two entities together, so that one entity rides // another. Note that players that see those entities later will not see the link, unless it is also sent // in the AddEntity and AddPlayer packets. EntityLink protocol.EntityLink }
SetEntityLink is sent by the server to initiate an entity link client-side, meaning one entity will start riding another.
func (*SetEntityLink) Marshal ¶ added in v0.7.0
func (pk *SetEntityLink) Marshal(buf *bytes.Buffer)
Marshal ...
type SetEntityMotion ¶ added in v0.7.0
type SetEntityMotion struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Velocity is the new velocity the entity gets. This velocity will initiate the client-side movement of // the entity. Velocity mgl32.Vec3 }
SetEntityMotion is sent by the server to change the client-side velocity of an entity. It is usually used in combination with server-side movement calculation.
func (*SetEntityMotion) Marshal ¶ added in v0.7.0
func (pk *SetEntityMotion) Marshal(buf *bytes.Buffer)
Marshal ...
type SetHealth ¶
type SetHealth struct { // Health is the new health of the player. Health int32 }
SetHealth is sent by the server. It sets the health of the player it is sent to. The SetHealth packet should no longer be used. Instead, the health attribute should be used so that the health and maximum health may be changed directly.
type SetLocalPlayerAsInitialised ¶
type SetLocalPlayerAsInitialised struct { // EntityRuntimeID is the entity runtime ID the player was assigned earlier in the login sequence in the // StartGame packet. EntityRuntimeID uint64 }
SetLocalPlayerAsInitialised is sent by the client in response to a PlayStatus packet with the status set to 3. The packet marks the moment at which the client is fully initialised and can receive any packet without discarding it.
func (*SetLocalPlayerAsInitialised) Marshal ¶
func (pk *SetLocalPlayerAsInitialised) Marshal(buf *bytes.Buffer)
Marshal ...
type SetPlayerGameType ¶
type SetPlayerGameType struct { // GameType is the new game type of the player. It is one of the constants that can be found above. Some // of these game types require additional flags to be set in an AdventureSettings packet for the game mode // to obtain its full functionality. GameType int32 }
SetPlayerGameType is sent by the server to update the game type, which is otherwise known as the game mode, of a player.
func (*SetPlayerGameType) Marshal ¶
func (pk *SetPlayerGameType) Marshal(buf *bytes.Buffer)
Marshal ...
type SetSpawnPosition ¶
type SetSpawnPosition struct { // SpawnType is the type of spawn to set. It is either SpawnTypePlayer or SpawnTypeWorld, and specifies // the behaviour of the spawn set. If SpawnTypeWorld is set, the position to which compasses will point is // also changed. SpawnType int32 // Position is the new position of the spawn that was set. If SpawnType is SpawnTypeWorld, compasses will // point to this position. Position protocol.BlockPos // SpawnForced specifies if the spawn is forced. SpawnForced bool }
SetSpawnPosition is sent by the server to update the spawn position of a player, for example when sleeping in a bed.
func (*SetSpawnPosition) Marshal ¶
func (pk *SetSpawnPosition) Marshal(buf *bytes.Buffer)
Marshal ...
type SetTime ¶
type SetTime struct { // Time is the current time. The time is not limited to 24000 (time of day), but continues progressing // after that. Time int32 }
SetTime is sent by the server to update the current time client-side. The client actually advances time client-side by itself, so this packet does not need to be sent each tick. It is merely a means of synchronising time between server and client.
type ShowCredits ¶
type ShowCredits struct { // PlayerRuntimeID is the entity runtime ID of the player to show the credits to. It's not clear why this // field is actually here in the first place. PlayerRuntimeID uint64 // StatusType is the status type of the credits. It is one of the constants above, and either starts or // stops the credits. StatusType int32 }
ShowCredits is sent by the server to show the Minecraft credits screen to the client. It is typically sent when the player beats the ender dragon and leaves the End.
type SimpleEvent ¶
type SimpleEvent struct { // EventType is the type of the event to be called. It is one of the constants that may be found above. EventType int16 }
SimpleEvent is sent by the server to send a 'simple event' to the client, meaning an event without any additional event data. The event is typically used by the client for telemetry.
type SpawnExperienceOrb ¶
type SpawnExperienceOrb struct { // Position is the position to spawn the experience orb on. If the entity is on a distance that the player // cannot see it, the entity will still show up if the player moves closer. Position mgl32.Vec3 // ExperienceAmount is the amount of experience in experience points that the orb carries. The client-side // size of the orb depends on the amount of experience in the orb: There are 11 possible sizes for the // orb, for 1–2, 3–6, 7–16, 17–36, 37–72, 73–148, 149–306, 307–616, 617–1236, 1237–2476, and 2477 and up. ExperienceAmount int32 }
SpawnExperienceOrb is sent by the server to spawn an experience orb entity client-side. Much like the AddPainting packet, it is one of the few packets that spawn an entity without using the AddEntity packet.
func (*SpawnExperienceOrb) Marshal ¶
func (pk *SpawnExperienceOrb) Marshal(buf *bytes.Buffer)
Marshal ...
type StartGame ¶
type StartGame struct { // EntityUniqueID is the unique ID of the player. The unique ID is a value that remains consistent across // different sessions of the same world, but most servers simply fill the runtime ID of the entity out for // this field. EntityUniqueID int64 // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // PlayerGameMode is the game mode the player currently has. It is a value from 0-4, with 0 being // survival mode, 1 being creative mode, 2 being adventure mode, 3 being survival spectator and 4 being // creative spectator. PlayerGameMode int32 // PlayerPosition is the spawn position of the player in the world. In servers this is often the same as // the world's spawn position found below. PlayerPosition mgl32.Vec3 // Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is // measured in degrees. Pitch float32 // Yaw is the horizontal rotation of the player. Yaw is also measured in degrees. Yaw float32 // WorldSeed is the seed used to generate the world. Unlike in PC edition, the seed is a 32bit integer // here. WorldSeed int32 // Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2, with 0 being // the overworld, 1 being the nether and 2 being the end. Dimension int32 // Generator is the generator used for the world. It is a value from 0-4, with 0 being old limited worlds, // 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and 4 being end worlds. A value of // 0 will actually make the client stop rendering chunks you send beyond the world limit. Generator int32 // WorldGameMode is the game mode that a player gets when it first spawns in the world. It has no effect // on the actual game mode the player spawns with. See PlayerGameMode for that. WorldGameMode int32 // Difficulty is the difficulty of the world. It is a value from 0-3, with 0 being peaceful, 1 being easy, // 2 being normal and 3 being hard. Difficulty int32 // WorldSpawn is the block on which the world spawn of the world. This coordinate has no effect on the // place that the client spawns, but it does have an effect on the direction that a compass points. WorldSpawn protocol.BlockPos // AchievementsDisabled defines if achievements are disabled in the world. The client crashes if this // value is set to true while the player's or the world's game mode is creative, and it's recommended to // simply always set this to false as a server. AchievementsDisabled bool // DayCycleLockTime is the time at which the day cycle was locked if the day cycle is disabled using the // respective game rule. The client will maintain this time as long as the day cycle is disabled. DayCycleLockTime int32 // EducationMode specifies if the world is specifically for education edition clients. Setting this to // true for normal editions actually temporarily 'transforms' the client into Education Edition, with even // the ability to see that title on the home screen. EducationMode bool // EducationFeaturesEnabled specifies if the world has education edition features enabled, such as the // blocks or entities specific to education edition. EducationFeaturesEnabled bool // RainLevel is the level specifying the intensity of the rain falling. When set to 0, no rain falls at // all. RainLevel float32 // LightningLevel is the level specifying the intensity of the thunder. This may actually be set // independently from the RainLevel, meaning dark clouds can be produced without rain. LightningLevel float32 // ConfirmedPlatformLockedContent ... ConfirmedPlatformLockedContent bool // MultiPlayerGame specifies if the world is a multi-player game. This should always be set to true for // servers. MultiPlayerGame bool // LANBroadcastEnabled specifies if LAN broadcast was intended to be enabled for the world. LANBroadcastEnabled bool // XBLBroadcastMode is the mode used to broadcast the joined game across XBOX Live. XBLBroadcastMode int32 // PlatformBroadcastMode is the mode used to broadcast the joined game across the platform. PlatformBroadcastMode int32 // CommandsEnabled specifies if commands are enabled for the player. It is recommended to always set this // to true on the server, as setting it to false means the player cannot, under any circumstance, use a // command. CommandsEnabled bool // TexturePackRequired specifies if the texture pack the world might hold is required, meaning the client // was forced to download it before joining. TexturePackRequired bool // GameRules defines game rules currently active with their respective values. The value of these game // rules may be either 'bool', 'int32' or 'float32'. Some game rules are server side only, and don't // necessarily need to be sent to the client. GameRules map[string]interface{} // BonusChestEnabled specifies if the world had the bonus map setting enabled when generating it. It does // not have any effect client-side. BonusChestEnabled bool // StartWithMapEnabled specifies if the world has the start with map setting enabled, meaning each joining // player obtains a map. This should always be set to false, because the client obtains a map all on its // own accord if this is set to true. StartWithMapEnabled bool // PlayerPermissions is the permission level of the player. It is a value from 0-3, with 0 being visitor, // 1 being member, 2 being operator and 3 being custom. PlayerPermissions int32 // ServerChunkTickRadius is the radius around the player in which chunks are ticked. Most servers set this // value to a fixed number, as it does not necessarily affect anything client-side. ServerChunkTickRadius int32 // HasLockedBehaviourPack specifies if the behaviour pack of the world is locked, meaning it cannot be // disabled from the world. This is typically set for worlds on the marketplace that have a dedicated // behaviour pack. HasLockedBehaviourPack bool // HasLockedTexturePack specifies if the texture pack of the world is locked, meaning it cannot be // disabled from the world. This is typically set for worlds on the marketplace that have a dedicated // texture pack. HasLockedTexturePack bool // FromLockedWorldTemplate specifies if the world from the server was from a locked world template. For // servers this should always be set to false. FromLockedWorldTemplate bool // MSAGamerTagsOnly .. MSAGamerTagsOnly bool // FromWorldTemplate specifies if the world from the server was from a world template. For servers this // should always be set to false. FromWorldTemplate bool // WorldTemplateSettingsLocked specifies if the world was a template that locks all settings that change // properties above in the settings GUI. It is recommended to set this to true for servers that do not // allow things such as setting game rules through the GUI. WorldTemplateSettingsLocked bool // LevelID is a base64 encoded world ID that is used to identify the world. LevelID string // WorldName is the name of the world that the player is joining. Note that this field shows up above the // player list for the rest of the game session, and cannot be changed. Setting the server name to this // field is recommended. WorldName string // PremiumWorldTemplateID is a UUID specific to the premium world template that might have been used to // generate the world. Servers should always fill out an empty string for this. PremiumWorldTemplateID string // Trial specifies if the world was a trial world, meaning features are limited and there is a time limit // on the world. Trial bool // Time is the total time that has elapsed since the start of the world. Time int64 // EnchantmentSeed is the seed used to seed the random used to produce enchantments in the enchantment // table. Note that the exact correct random implementation must be used to produce the correct results // both client- and server-side. EnchantmentSeed int32 // Blocks is a list of all blocks and variants existing in the game. Failing to send any of the blocks // that are in the game, including any specific variants of that block, will crash mobile clients. It // seems Windows 10 games do not crash. Blocks []BlockEntry // MultiPlayerCorrelationID is a unique ID specifying the multi-player session of the player. A random // UUID should be filled out for this field. MultiPlayerCorrelationID string // OnlySpawnV1Villagers is a hack that Mojang put in place to preserve backwards compatibility with old // villagers. The bool is never actually read though, so it has no functionality. OnlySpawnV1Villagers bool }
StartGame is sent by the server to send information about the world the player will be spawned in. It contains information about the position the player spawns in, and information about the world in general such as its game rules.
type TakeItemEntity ¶ added in v0.3.0
type TakeItemEntity struct { // ItemEntityRuntimeID is the entity runtime ID of the item that is being taken by another entity. It will // disappear to viewers after showing the pick-up animation. ItemEntityRuntimeID uint64 // TakerEntityRuntimeID is the runtime ID of the entity that took the item, which is usually a player, but // could be another entity like a zombie too. TakerEntityRuntimeID uint64 }
TakeItemEntity is sent by the server when a player picks up an item entity. It makes the item entity disappear to viewers and shows the pick-up animation.
func (*TakeItemEntity) Marshal ¶ added in v0.3.0
func (pk *TakeItemEntity) Marshal(buf *bytes.Buffer)
Marshal ...
type Text ¶
type Text struct { // TextType is the type of the text sent. When a client sends this to the server, it should always be // TextTypeChat. If the server sends it, it may be one of the other text types above. TextType byte // NeedsTranslation specifies if any of the messages need to be translated. It seems that where % is found // in translatable text types, these are translated regardless of this bool. Translatable text types // include TextTypeTip, TextTypePopup and TextTypeJukeboxPopup. NeedsTranslation bool // SourceName is the name of the source of the messages. This source is displayed in text types such as // the TextTypeChat and TextTypeWhisper, where typically the username is shown. SourceName string // Message is the message of the packet. This field is set for each TextType and is the main component of // the packet. Message string // Parameters is a list of parameters that should be filled into the message. These parameters are only // written if the type of the packet is TextTypeTip, TextTypePopup or TextTypeJukeboxPopup. Parameters []string // XUID is the XBOX Live user ID of the player that sent the message. It is only set for packets of // TextTypeChat. When sent to a player, the player will only be shown the chat message if a player with // this XUID is present in the player list and not muted, or if the XUID is empty. 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 }
Text is sent by the client to the server to send chat messages, and by the server to the client to forward or send messages, which may be chat, popups, tips etc.
type Transfer ¶
type Transfer struct { // Address is the address of the new server, which might be either a hostname or an actual IP address. Address string // Port is the UDP port of the new server. Port uint16 }
Transfer is sent by the server to transfer a player from the current server to another. Doing so will fully disconnect the client, bring it back to the main menu and make it connect to the next server.
type Unknown ¶
type Unknown struct { // PacketID is the packet ID of the packet. PacketID uint32 // Payload is the raw payload of the packet. Payload []byte }
Unknown is an implementation of the Packet interface for unknown/unimplemented packets. It holds the packet ID and the raw payload. It serves as a way to read raw unknown packets and forward them to another connection, without necessarily implementing them.
type UpdateAttributes ¶
type UpdateAttributes struct { // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and // entities are generally identified in packets using this runtime ID. EntityRuntimeID uint64 // Attributes is a slice of new attributes that the entity gets. It includes attributes such as its // health, movement speed, etc. Note that only changed attributes have to be sent in this packet. It is // not required to send attributes that did not have their values changed. Attributes []protocol.Attribute }
UpdateAttributes is sent by the server to update an amount of attributes of any entity in the world. These attributes include ones such as the health or the movement speed of the entity.
func (*UpdateAttributes) Marshal ¶
func (pk *UpdateAttributes) Marshal(buf *bytes.Buffer)
Marshal ...
type UpdateBlock ¶
type UpdateBlock struct { // Position is the block position at which a block is updated. Position protocol.BlockPos // NewBlockRuntimeID is the runtime ID of the block that is placed at Position after sending the packet // to the client. The runtime ID must point to a block sent in the list in the StartGame packet. NewBlockRuntimeID uint32 // Flags is a combination of flags that specify the way the block is updated client-side. It is a // combination of the flags above, but typically sending only the BlockUpdateNetwork flag is sufficient. Flags uint32 // Layer is the world layer on which the block is updated. For most blocks, this is the first layer, as // that layer is the default layer to place blocks on, but for blocks inside of each other, this differs. Layer uint32 }
UpdateBlock is sent by the server to update a block client-side, without resending the entire chunk that the block is located in. It is particularly useful for small modifications like block breaking/placing.
Source Files ¶
- add_entity.go
- add_item_entity.go
- add_painting.go
- add_player.go
- adventure_settings.go
- animate.go
- block_entity_data.go
- block_event.go
- block_pick_request.go
- boss_event.go
- camera.go
- change_dimension.go
- chunk_radius_updated.go
- client_bound_map_item_data.go
- client_to_server_handshake.go
- container_close.go
- container_open.go
- container_set_data.go
- crafting_data.go
- crafting_event.go
- decoder.go
- disconnect.go
- encoder.go
- encryption.go
- entity_event.go
- entity_fall.go
- entity_pick_request.go
- event.go
- explode.go
- full_chunk_data.go
- game_rules_changed.go
- gui_data_pick_item.go
- hurt_armour.go
- id.go
- interact.go
- inventory_content.go
- inventory_slot.go
- inventory_transaction.go
- item_frame_drop_item.go
- level_event.go
- login.go
- map_info_request.go
- mob_armour_equipment.go
- mob_effect.go
- mob_equipment.go
- modal_form_request.go
- modal_form_response.go
- move_entity_absolute.go
- move_player.go
- packet.go
- play_status.go
- player_action.go
- player_hot_bar.go
- player_input.go
- player_list.go
- player_skin.go
- pool.go
- remove_entity.go
- request_chunk_radius.go
- resource_pack_chunk_data.go
- resource_pack_chunk_request.go
- resource_pack_client_response.go
- resource_pack_data_info.go
- resource_pack_stack.go
- resource_packs_info.go
- respawn.go
- rider_jump.go
- server_settings_request.go
- server_settings_response.go
- server_to_client_handshake.go
- set_commands_enabled.go
- set_difficulty.go
- set_entity_data.go
- set_entity_link.go
- set_entity_motion.go
- set_health.go
- set_local_player_as_initialised.go
- set_player_game_type.go
- set_spawn_position.go
- set_time.go
- show_credits.go
- simple_event.go
- spawn_experience_orb.go
- start_game.go
- take_item_entity.go
- text.go
- transfer.go
- unknown.go
- update_attributes.go
- update_block.go
- util.go