Skip to content

API reference / @jsprismarine/protocol / AbilityLayer

Class: AbilityLayer ​

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:51

One "SerializedAbilitiesDataSerializedLayer" entry of an UpdateAbilitiesPacket.

Wire order, all little-endian: "SerializedLayer" uint16, "AbilitiesSet" uint32, "AbilityValues" uint32, "FlySpeed" float, "VerticalFlySpeed" float, "WalkSpeed" float. layerFlags holds both bitsets. A flag present in the map is set in "AbilitiesSet", and its boolean is the matching bit of "AbilityValues", except for the speed flags described on SPEED_FLAGS.

Constructors ​

Constructor ​

new AbilityLayer(): AbilityLayer

Returns ​

AbilityLayer

Properties ​

flySpeed ​

flySpeed: number = 0.05

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:55


layerFlags ​

layerFlags: Map<AbilityLayerFlag, boolean>

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:53


layerType ​

layerType: AbilityLayerType = AbilityLayerType.BASE

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:52


verticalFlySpeed ​

verticalFlySpeed: number = 1

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:63

How fast the player climbs and descends while flying.

Added at 2168, between the other two rather than after them. A layer that writes only the horizontal speeds is four bytes short, and the client rejects the whole packet rather than the layer.


walkSpeed ​

walkSpeed: number = 0.1

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:64

Methods ​

getEncodedFlags() ​

getEncodedFlags(): object

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:72

Packs layerFlags into the two uint32 bitsets.

Returns ​

object

flagsHash is "AbilitiesSet" and valuesHash is "AbilityValues", both as unsigned numbers so bit 31 does not come out negative.

flagsHash ​

flagsHash: number

valuesHash ​

valuesHash: number


setEncodedFlags() ​

setEncodedFlags(flagsHash, valuesHash): void

Defined in: protocol/src/packet/UpdateAbilitiesPacket.ts:89

Rebuilds layerFlags from the two uint32 bitsets read off the wire.

Every set bit of "AbilitiesSet" becomes a map entry. Its value is the matching bit of "AbilityValues", or true for a speed flag since those carry no value bit. Bits above ABILITY_COUNT are kept so a decoded layer encodes to the same bytes.

Parameters ​

flagsHash ​

number

valuesHash ​

number

Returns ​

void