diff --git a/README.md b/README.md index 61bfdfe1..ce04da32 100644 --- a/README.md +++ b/README.md @@ -346,7 +346,7 @@ and where to learn what to send and when. import httpx -from mcproto.client import Client +from mcproto.interactions.client import Client from mcproto.connection import TCPAsyncConnection from mcproto.auth.account import Account from mcproto.types.uuid import UUID @@ -371,8 +371,8 @@ async def main(): async with httpx.AsyncClient() as client: async with (await TCPAsyncConnection.make_client((HOST, PORT), 2)) as connection: client = Client( - host="localhost", - port=25565, + host=HOST, + port=PORT, httpx_client=client, account=account, conn=connection, @@ -388,20 +388,26 @@ async def main(): # In the back, the `status` function has performed a handshake to transition us from # the initial (None) game state, to the STATUS game state, and then sent a status # request, getting back a response. - + # # The Client instance also includes a `login` function, which is capable to go through # the entire login flow, leaving you in PLAY game state. Note that unless you've # set MINECRAFT_ACCESS_TOKEN, you will only be able to do this for warez servers. - + # # But since we just called `status`, it left us in the STATUS game state, but we need # to be in LOGIN game state. The `login` function will work if called from an initial # game state (None), as it's smart enough to perform a handshake getting us to LOGIN, # however it doesn't know what to do from STATUS game state. - + # # What we can do, is simply set game_state back to None (this is what happens during # initialization of the Client class), making the login function send out another # handshake, this time transitioning to LOGIN instead of STATUS. We could also create # a completely new client instance. + # + # Note that this way of naively resetting the game-state won't always work, as the + # underlying connection isn't actually reset, and it's possible that in some cases, + # the server simply won't let us perform another handshake on the same connection. + # You will likely encounter this if you attempt to request status twice, however + # transitioning to login in this way will generally work. client.game_state = None client.login() @@ -419,7 +425,7 @@ To start this server, you can run the following: ```python import httpx -from mcproto.server import Server +from mcproto.interactions.server import Server HOST = "0.0.0.0" PORT = 25565 diff --git a/mcproto/interaction/__init__.py b/mcproto/interactions/__init__.py similarity index 100% rename from mcproto/interaction/__init__.py rename to mcproto/interactions/__init__.py diff --git a/mcproto/interaction/client.py b/mcproto/interactions/client.py similarity index 99% rename from mcproto/interaction/client.py rename to mcproto/interactions/client.py index dfa3e774..59b7a4f0 100644 --- a/mcproto/interaction/client.py +++ b/mcproto/interactions/client.py @@ -5,7 +5,7 @@ from mcproto.auth.account import Account from mcproto.connection import TCPAsyncConnection from mcproto.encryption import encrypt_token_and_secret, generate_shared_secret -from mcproto.interaction.exceptions import InvalidGameStateError, UnexpectedPacketError +from mcproto.interactions.exceptions import InvalidGameStateError, UnexpectedPacketError from mcproto.multiplayer import compute_server_hash, join_request from mcproto.packets.handshaking.handshake import Handshake, NextState from mcproto.packets.interactions import async_read_packet, async_write_packet diff --git a/mcproto/interaction/exceptions.py b/mcproto/interactions/exceptions.py similarity index 100% rename from mcproto/interaction/exceptions.py rename to mcproto/interactions/exceptions.py diff --git a/mcproto/interaction/server.py b/mcproto/interactions/server.py similarity index 99% rename from mcproto/interaction/server.py rename to mcproto/interactions/server.py index 7e52944b..d2dbf9bf 100644 --- a/mcproto/interaction/server.py +++ b/mcproto/interactions/server.py @@ -9,7 +9,7 @@ from mcproto.connection import TCPAsyncConnection from mcproto.encryption import decrypt_token_and_secret, generate_rsa_key, generate_verify_token -from mcproto.interaction.exceptions import InvalidVerifyTokenError, UnexpectedPacketError +from mcproto.interactions.exceptions import InvalidVerifyTokenError, UnexpectedPacketError from mcproto.multiplayer import compute_server_hash, join_check from mcproto.packets.handshaking.handshake import Handshake, NextState from mcproto.packets.interactions import async_read_packet, async_write_packet