@@ -346,7 +346,7 @@ and where to learn what to send and when.
346
346
347
347
import httpx
348
348
349
- from mcproto.client import Client
349
+ from mcproto.interactions. client import Client
350
350
from mcproto.connection import TCPAsyncConnection
351
351
from mcproto.auth.account import Account
352
352
from mcproto.types.uuid import UUID
@@ -371,8 +371,8 @@ async def main():
371
371
async with httpx.AsyncClient() as client:
372
372
async with (await TCPAsyncConnection.make_client((HOST , PORT ), 2 )) as connection:
373
373
client = Client(
374
- host = " localhost " ,
375
- port = 25565 ,
374
+ host = HOST ,
375
+ port = PORT ,
376
376
httpx_client = client,
377
377
account = account,
378
378
conn = connection,
@@ -388,20 +388,26 @@ async def main():
388
388
# In the back, the `status` function has performed a handshake to transition us from
389
389
# the initial (None) game state, to the STATUS game state, and then sent a status
390
390
# request, getting back a response.
391
-
391
+ #
392
392
# The Client instance also includes a `login` function, which is capable to go through
393
393
# the entire login flow, leaving you in PLAY game state. Note that unless you've
394
394
# set MINECRAFT_ACCESS_TOKEN, you will only be able to do this for warez servers.
395
-
395
+ #
396
396
# But since we just called `status`, it left us in the STATUS game state, but we need
397
397
# to be in LOGIN game state. The `login` function will work if called from an initial
398
398
# game state (None), as it's smart enough to perform a handshake getting us to LOGIN,
399
399
# however it doesn't know what to do from STATUS game state.
400
-
400
+ #
401
401
# What we can do, is simply set game_state back to None (this is what happens during
402
402
# initialization of the Client class), making the login function send out another
403
403
# handshake, this time transitioning to LOGIN instead of STATUS. We could also create
404
404
# a completely new client instance.
405
+ #
406
+ # Note that this way of naively resetting the game-state won't always work, as the
407
+ # underlying connection isn't actually reset, and it's possible that in some cases,
408
+ # the server simply won't let us perform another handshake on the same connection.
409
+ # You will likely encounter this if you attempt to request status twice, however
410
+ # transitioning to login in this way will generally work.
405
411
client.game_state = None
406
412
407
413
client.login()
@@ -419,7 +425,7 @@ To start this server, you can run the following:
419
425
420
426
``` python
421
427
import httpx
422
- from mcproto.server import Server
428
+ from mcproto.interactions. server import Server
423
429
424
430
HOST = " 0.0.0.0"
425
431
PORT = 25565
0 commit comments