Skip to content

Commit

Permalink
Rename interaction -> interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDrike committed May 18, 2024
1 parent 2550a2a commit a01f2c4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a01f2c4

Please sign in to comment.