Commit graph

20 commits

Author SHA1 Message Date
Ryan Johnson
f4714cf255
Redesign packet processing and improve Client update procedure. (#146)
Closes #82
Closes #43
Closes #64

# Changes and Improvements
- Packet encoding/decoding happens within `Client` instead of being sent
over a channel first. This is better for performance and lays the
groundwork for #83.
- Reduce the amount of copying necessary by leveraging the `bytes` crate
and recent changes to `EncodePacket`. Performance is noticeably improved
with maximum players in the `rust-mc-bot` test going from 750 to 1050.
- Packet encoding/decoding code is decoupled from IO. This is easier to
understand and more suitable for a future protocol lib.
- Precise control over the number of bytes that are buffered for
sending/receiving. This is important for limiting maximum memory usage
correctly.
- "packet controllers" are introduced, which are convenient structures
for managing packet IO before and during the play state.
- `byte_channel` module is created to help implement the
`PlayPacketController`. This is essentially a channel of bytes
implemented with an `Arc<Mutex<BytesMut>>`.
- Error handling in the update procedure for clients was improved using
`anyhow::Result<()>` to exit as early as possible. The `client` module
is a bit cleaner as a result.
- The `LoginPlay` packet is always sent before all other play packets.
We no longer have to worry about the behavior of packets sent before
that packet. Most packet deferring performed currently can be
eliminated.
- The packet_inspector was rewritten in response to the above changes.
- Timeouts on IO operations behave better.

# Known Issues
- The packet_inspector now re-encodes packets rather than just decoding
them. This will cause problems when trying to use it with the vanilla
server because there are missing clientbound packets and other issues.
This will be fixed when the protocol module is moved to a separate
crate.
2022-11-01 03:11:51 -07:00
Ryan Johnson
71d82c5330
Add encoded_len method to Encode trait. (#125)
This allows packets to calculate their exact length up front.
This isn't currently tested or being used for anything, but that will come in later changes.
2022-10-19 01:52:02 -07:00
Ryan Johnson
7d0c254874
Rewrite ident module (again) (#111)
Ident is now a wrapper around any string type `S`.
2022-10-12 03:53:59 -07:00
Ryan Johnson
23fdc41610
Clean up ident module and add lifetime (#108)
This lifetime will be useful for zero-copy decoding later.
2022-10-11 01:10:49 -07:00
guac420
96f5614941
Add support for Slot data decoding (#25)
* Impl Seek for reader in Decode Trait

* Add support for Slot data type

* Update tests and rust fmt

* Add tests for Slot

Also fixed bugs I found while testing

* Update slot signature

* Resolved requested changes

Updated decode trait signature and removed unnecessary getters/setters in `Slot`
2022-09-08 21:39:08 -07:00
TheEternalShine
b9b0728fd3
Add named text color parsing (#23) 2022-09-05 16:24:33 -07:00
Ryan
f7a35f356e Update rust docs 2022-09-02 00:06:45 -07:00
Ryan
5fb46178dd Don't hide the protocol module behind a feature 2022-08-31 19:20:49 -07:00
Ryan
a5a560220c New player list implementation 2022-08-09 14:44:04 -07:00
Ryan
4b83801066 Clean up docs and fix clippy issues 2022-07-14 23:18:20 -07:00
Ryan
4a12def900 Redesign the spatial index API and add raycast example 2022-07-14 03:40:26 -07:00
Ryan
3f150b4c8a Document most items 2022-07-11 05:08:02 -07:00
Ryan
24cf864ed1 Don't export items arbitrarily at the crate root 2022-07-06 18:27:59 -07:00
Ryan
5fcde5f7ae Implement title and subtitle 2022-07-06 00:16:07 -07:00
Ryan
3ac711ca74 Use idiomatic names
The Rust stdlib uses "Kind" instead of "Type".
2022-07-05 19:21:52 -07:00
Ryan
a259bdf840 Add the packet inspector proxy 2022-07-01 15:29:31 -07:00
Ryan
efc2873908 Reorganize modules 2022-06-09 20:26:21 -07:00
Ryan
732183dd62 Rip out the ECS. 2022-04-29 00:48:41 -07:00
Ryan
f35d8e7b13 Tweak text.rs 2022-04-17 17:05:13 -07:00
Ryan
5bbbb258d1 move from private repo 2022-04-14 14:55:45 -07:00