@@ -110,37 +110,39 @@ The above roughly translates to the following JavaScript code to read a packet:
110
110
` ` ` js
111
111
function read_position(stream) {
112
112
const ret = {}
113
- ret.x = stream.readSignedInt32LE ()
114
- ret.z = stream.readUnsignedInt32LE ()
115
- ret.y = stream.readFloat32LE ()
113
+ ret.x = stream.readLI32 ()
114
+ ret.z = stream.readLU32 ()
115
+ ret.y = stream.readLF32 ()
116
116
return ret
117
117
}
118
118
119
119
function read_player_position(stream) {
120
120
const ret = {}
121
121
ret.on_ground = Boolean(stream.readU8())
122
- ret.position = read_player_position (stream)
122
+ ret.position = read_position (stream)
123
123
let __movement_reason = stream.readU8()
124
124
let movement_reason = { 0 : ' player_jump' , 1: 'player_autojump', 2: 'player_sneak', 3: 'player_sprint', 4: 'player_fall' }[__movement_reason]
125
125
switch (movement_reason) {
126
126
case 'player_jump' :
127
127
case 'player_autojump' :
128
- ret.original_position = read_player_position (stream)
129
- ret.jump_tick = stream.readInt64LE(stream )
128
+ ret.original_position = read_position (stream)
129
+ ret.jump_tick = stream.readLI64( )
130
130
break
131
131
case 'player_fall' :
132
- ret.original_position = read_player_position (stream)
132
+ ret.original_position = read_position (stream)
133
133
break
134
134
default : break
135
135
}
136
136
ret.player_hunger = undefined
137
137
if (movement_reason == 'player_sprint') ret.player_hunger = stream.readU8()
138
138
ret.last_positions = []
139
- for (let i = 0; i < stream.readUnsignedVarInt(); i++) {
139
+ let __latest_positions_len = stream.readUnsignedVarInt()
140
+ for (let i = 0; i < __latest_positions_len; i++) {
140
141
ret.last_positions.push(read_player_position(stream))
141
142
}
142
143
ret.keys_down = []
143
- for (let i = 0; i < stream.readZigZagVarInt(); i++) {
144
+ let __keys_down_len = stream.readZigZagVarInt()
145
+ for (let i = 0; i < __keys_down_len; i++) {
144
146
const ret1 = {}
145
147
ret1.up = Boolean(stream.readU8())
146
148
ret1.down = Boolean(stream.readU8())
0 commit comments