Commit graph

7 commits

Author SHA1 Message Date
AviiNL d36998dc9c
Packet inspector fixes (#375)
## Description

packet_to_string now returns a Result as not to crash the app when
showing TextView on a packet that fails to decode for whatever reason.
2023-06-17 22:54:53 -07:00
Ryan Johnson 3a3fd9f202
Add screenshot to packet inspector README.md 2023-06-17 22:21:36 -07:00
AviiNL 8712fea19e
new packet inspector (#369)
## Description

Describe the changes you've made. Link to any issues this PR fixes or
addresses.
... changes... wel, lets see... uuhhmmm, i rewrote the entire packet
inspector :)

(also dont mind the snarkyness of that sentence, im tired)

closes #346
2023-06-17 08:40:51 -04:00
Ryan Johnson c4741b68b8
Registry Redesign (#361)
## Description

- Revert the "biomes/dimensions as entities" idea since it caused too
many problems without much to show for it.
- Make use of `valence_nbt`'s serde support in `valence_biome` and
`valence_dimension`.
- Reduce boilerplate, reorganize `valence_registry` a bit.
- Tweak default biome registry such that `BiomeId::default` always
corresponds to "minecraft:plains".
- Add `Option` and unit variant support to `valence_nbt`'s serde impl.
2023-06-11 09:08:38 -07:00
Ryan Johnson c5557e744d
Move packets out of valence_core. (#335)
## Description

- Move all packets out of `valence_core` and into the places where
they're actually used. This has a few benefits:
- Avoids compiling code for packets that go unused when feature flags
are disabled.
- Code is distributed more uniformly across crates, improving
compilation times.
- Improves local reasoning when everything relevant to a module is
defined in the same place.
  - Easier to share code between the packet consumer and the packet.
- Tweak `Packet` macro syntax.
- Update `syn` to 2.0.
- Reorganize some code in `valence_client` (needs further work).
- Impl `WritePacket` for `Instance`.
- Remove packet enums such as `S2cPlayPacket` and `C2sPlayPacket`.
- Replace `assert_packet_count` and `assert_packet_order` macros with
non-macro methods.
To prevent this PR from getting out of hand, I've disabled the packet
inspector and stresser until they have been rewritten to account for
these changes.
2023-05-29 01:36:11 -07:00
Gingeh e5de2d3f20
Add cli arg for log level to playground (#343)
## Description
Fixes #305 

`cargo run -- -l trace`

Uses `Level`'s `FromStr` impl, which accepts numbers 1-5 or
case-insensitive level names. Default level is `Level::DEBUG`
2023-05-28 08:57:07 -04:00
Ryan Johnson eaf1e18610
Reorganize Project (#321)
## Description

- `valence` and `valence_protocol` have been divided into smaller crates
in order to parallelize the build and improve IDE responsiveness. In the
process, code architecture has been made clearer by removing circular
dependencies between modules. `valence` is now just a shell around the
other crates.
- `workspace.packages` and `workspace.dependencies` are now used. This
makes dependency managements and crate configuration much easier.
- `valence_protocol` is no more. Most things from `valence_protocol`
ended up in `valence_core`. We won't advertise `valence_core` as a
general-purpose protocol library since it contains too much
valence-specific stuff. Closes #308.
- Networking code (login, initial TCP connection handling, etc.) has
been extracted into the `valence_network` crate. The API has been
expanded and improved with better defaults. Player counts and initial
connections to the server are now tracked separately. Player counts
function by default without any user configuration.
- Some crates like `valence_anvil`, `valence_network`,
`valence_player_list`, `valence_inventory`, etc. are now optional. They
can be enabled/disabled with feature flags and `DefaultPlugins` just
like bevy.
- Whole-server unit tests have been moved to `valence/src/tests` in
order to avoid [cyclic
dev-dependencies](https://github.com/rust-lang/cargo/issues/4242).
- Tools like `valence_stresser` and `packet_inspector` have been moved
to a new `tools` directory. Renamed `valence_stresser` to `stresser`.
Closes #241.
- Moved all benches to `valence/benches/` to make them easier to run and
organize.

Ignoring transitive dependencies and `valence_core`, here's what the
dependency graph looks like now:

```mermaid
graph TD
	network --> client
	client --> instance
	biome --> registry
	dimension --> registry
	instance --> biome
	instance --> dimension
	instance --> entity
	player_list --> client
	inventory --> client
	anvil --> instance
	entity --> block
```

### Issues
- Inventory tests inspect many private implementation details of the
inventory module, forcing us to mark things as `pub` and
`#[doc(hidden)]`. It would be ideal if the tests only looked at
observable behavior.
- Consider moving packets in `valence_core` elsewhere. `Particle` wants
to use `BlockState`, but that's defined in `valence_block`, so we can't
use it without causing cycles.
- Unsure what exactly should go in `valence::prelude`.
- This could use some more tests of course, but I'm holding off on that
until I'm confident this is the direction we want to take things.

## TODOs
- [x] Update examples.
- [x] Update benches.
- [x] Update main README.
- [x] Add short READMEs to crates.
- [x] Test new schedule to ensure behavior is the same. 
- [x] Update tools.
- [x] Copy lints to all crates.
- [x] Fix docs, clippy, etc.
2023-04-21 14:43:59 -07:00