Commit graph

17 commits

Author SHA1 Message Date
Ryan Johnson
420f2d1b7c
Move protocol code to valence_protocol + redesigns (#153)
Closes #83 

This PR aims to move all of Valence's networking code to the new
`valence_protocol` crate. Anything not specific to valence is going in
the new crate. It also redesigns the way packets are defined and makes a
huge number of small additions and improvements. It should be much
easier to see where code is supposed to go from now on.

`valence_protocol` is a new library which enables interactions with
Minecraft's protocol. It is completely decoupled from valence and can be
used to build new clients, servers, tools, etc.

There are two additions that will help with #5 especially:
- It is now easy to define new packets or modifications of existing
packets. Not all packets need to be bidirectional.
- The `CachedEncode` type has been created. This is used to safely cache
redundant calls to `Encode::encode`.
2022-11-13 06:10:42 -08:00
Ryan Johnson
56ebcaf50d
Add Username<S> type (#132)
There are a number of places where usernames are passed around. Using this type ensures that the contained string is actually a valid username and not some other kind of string. For instance you can use it as a function argument to indicate that only valid usernames are accepted, or return it from a function to indicate that only valid usernames are produced.

This is analogous to the existing `Ident<S>` type.
2022-10-22 20:17:06 -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
a53738355f Fix bug in ident and use AsRef instead of Borrow 2022-10-13 22:28:12 -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
afe390836c Remove dbg! calls and make some tweaks to Ident 2022-10-11 14:05:00 -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
Ryan Johnson
36b63e777e
Replace serde_nbt with valence_nbt (#80)
valence_nbt has a much nicer API and avoids the complications brought by integrating with serde. valence_nbt also fixes some bugs and is 3x faster according to benchmarks.
2022-09-23 04:03:21 -07:00
Ryan Johnson
fdedf74d29
Add clippy lints and format checks (#46)
The nightly rust toolchain is used because we are currently using unstable rustfmt settings.
2022-09-09 21:59:10 -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
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
4b83801066 Clean up docs and fix clippy issues 2022-07-14 23:18:20 -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
3ac711ca74 Use idiomatic names
The Rust stdlib uses "Kind" instead of "Type".
2022-07-05 19:21:52 -07:00
Ryan
efc2873908 Reorganize modules 2022-06-09 20:26:21 -07:00
Renamed from src/identifier.rs (Browse further)