@@ -189,15 +189,6 @@ class ConnectionModule(reactContext: ReactApplicationContext)
189189 return @launch
190190 }
191191
192- // Calculate the necessary packet IDs.
193- val is1164 = protocolVersion >= PROTOCOL_VERSION_1164
194- val is117 = protocolVersion >= PROTOCOL_VERSION_117
195- val is119 = protocolVersion >= PROTOCOL_VERSION_119
196- val is1191 = protocolVersion >= PROTOCOL_VERSION_1191
197- val is1193 = protocolVersion >= PROTOCOL_VERSION_1193
198- val is1194 = protocolVersion >= PROTOCOL_VERSION_1194
199- val is1202 = protocolVersion >= PROTOCOL_VERSION_1202
200- val is1203 = protocolVersion >= PROTOCOL_VERSION_1203
201192 // Login state packet IDs
202193 val loginSuccessId = 0x02
203194 val loginAcknowledgedId = 0x03
@@ -209,30 +200,30 @@ class ConnectionModule(reactContext: ReactApplicationContext)
209200 val finishConfigurationServerBoundId = 0x02
210201 // Play state packet IDs
211202 val startConfigurationClientBoundId =
212- if (is1203 ) 0x67
213- else if (is1202 ) 0x65
203+ if (protocolVersion >= PROTOCOL_VERSION_1203 ) 0x67
204+ else if (protocolVersion >= PROTOCOL_VERSION_1202 ) 0x65
214205 else - 1
215206 val acknowledgeConfigurationServerBoundId =
216- if (is1202 ) 0x0b
207+ if (protocolVersion >= PROTOCOL_VERSION_1202 ) 0x0b
217208 else - 1
218209 val playKeepAliveClientBoundId =
219- if (is1202 ) 0x24
220- else if (is1194 ) 0x23
221- else if (is1193 ) 0x1f
222- else if (is1191 ) 0x20
223- else if (is119 ) 0x1e
224- else if (is117 ) 0x21
225- else if (is1164 ) 0x1f
210+ if (protocolVersion >= PROTOCOL_VERSION_1202 ) 0x24
211+ else if (protocolVersion >= PROTOCOL_VERSION_1194 ) 0x23
212+ else if (protocolVersion >= PROTOCOL_VERSION_1193 ) 0x1f
213+ else if (protocolVersion >= PROTOCOL_VERSION_1191 ) 0x20
214+ else if (protocolVersion >= PROTOCOL_VERSION_119 ) 0x1e
215+ else if (protocolVersion >= PROTOCOL_VERSION_117 ) 0x21
216+ else if (protocolVersion >= PROTOCOL_VERSION_1164 ) 0x1f
226217 else - 1
227218 val playKeepAliveServerBoundId =
228- if (is1203 ) 0x15
229- else if (is1202 ) 0x14
230- else if (is1194 ) 0x12
231- else if (is1193 ) 0x11
232- else if (is1191 ) 0x12
233- else if (is119 ) 0x11
234- else if (is117 ) 0x0f
235- else if (is1164 ) 0x10
219+ if (protocolVersion >= PROTOCOL_VERSION_1203 ) 0x15
220+ else if (protocolVersion >= PROTOCOL_VERSION_1202 ) 0x14
221+ else if (protocolVersion >= PROTOCOL_VERSION_1194 ) 0x12
222+ else if (protocolVersion >= PROTOCOL_VERSION_1193 ) 0x11
223+ else if (protocolVersion >= PROTOCOL_VERSION_1191 ) 0x12
224+ else if (protocolVersion >= PROTOCOL_VERSION_119 ) 0x11
225+ else if (protocolVersion >= PROTOCOL_VERSION_117 ) 0x0f
226+ else if (protocolVersion >= PROTOCOL_VERSION_1164 ) 0x10
236227 else - 1
237228
238229 // Re-use the current thread, start reading from the socket.
@@ -283,7 +274,7 @@ class ConnectionModule(reactContext: ReactApplicationContext)
283274 compressionThreshold = threshold
284275 compressionEnabled = threshold >= 0
285276 } else if (packet.id.value == loginSuccessId && state == ConnectionState .LOGIN ) {
286- state = if (is1202 ) {
277+ state = if (protocolVersion >= PROTOCOL_VERSION_1202 ) {
287278 directlyWritePacket(loginAcknowledgedId, ByteArray (0 ))
288279 ConnectionState .CONFIGURATION
289280 } else ConnectionState .PLAY
0 commit comments