Commit graph

26 commits

Author SHA1 Message Date
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
Ryan Johnson 58a3fbf6a3
Update example showcase video in README.md
Video courtesy of @emortaldev.
2023-04-12 22:59:55 -07:00
Ryan Johnson a69cc5d1c3
Tweak README.md 2023-03-06 19:48:20 -08:00
Ryan Johnson 190a60a13a
Emphasize project status in README.md 2023-03-06 15:41:32 -08:00
Ryan Johnson bcd686990d
Tweak README.md 2023-02-17 14:05:10 -08:00
Ryan Johnson cb9230ec34
ECS Rewrite (#184)
This PR redesigns Valence's architecture around the Bevy Entity
Component System framework (`bevy_ecs` and `bevy_app`). Along the way, a
large number of changes and improvements have been made.
- Valence is now a Bevy plugin. This allows Valence to integrate with
the wider Bevy ecosystem.
- The `Config` trait has been replaced with the plugin struct which is
much easier to configure. Async callbacks are grouped into their own
trait.
- `World` has been renamed to `Instance` to avoid confusion with
`bevy_ecs::world::World`.
- Entities, clients, player list, and inventories are all just ECS
components/resources. There is no need for us to have our own
generational arena/slotmap/etc for each one.
- Client events use Bevy's event system. Users can read events with the
`EventReader` system parameter. This also means that events are
dispatched at an earlier stage of the program where access to the full
server is available. There is a special "event loop" stage which is used
primarily to avoid the loss of ordering information between events.
- Chunks have been completely overhauled to be simpler and faster. The
distinction between loaded and unloaded chunks has been mostly
eliminated. The per-section bitset that tracked changes has been
removed, which should further reduce memory usage. More operations on
chunks are available such as removal and cloning.
- The full client's game profile is accessible rather than just the
textures.
- Replaced `vek` with `glam` for parity with Bevy.
- Basic inventory support has been added.
- Various small changes to `valence_protocol`.
- New Examples
- The terrain and anvil examples are now fully asynchronous and will not
block the main tick loop while chunks are loading.

# TODOs
- [x] Implement and dispatch client events.
- ~~[ ] Finish implementing the new entity/chunk update algorithm.~~ New
approach ended up being slower. And also broken.
- [x] [Update rust-mc-bot to
1.19.3](https://github.com/Eoghanmc22/rust-mc-bot/pull/3).
- [x] Use rust-mc-bot to test for and fix any performance regressions.
Revert to old entity/chunk update algorithm if the new one turns out to
be slower for some reason.
- [x] Make inventories an ECS component.
- [x] Make player lists an ECS ~~component~~ resource.
- [x] Expose all properties of the client's game profile.
- [x] Update the examples.
- [x] Update `valence_anvil`.
- ~~[ ] Update `valence_spatial_index` to use `glam` instead of `vek`.~~
Maybe later
- [x] Make entity events use a bitset.
- [x] Update docs.

Closes #69
Closes #179
Closes #53

---------

Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
Co-authored-by: AviiNL <me@avii.nl>
Co-authored-by: Danik Vitek <x3665107@gmail.com>
Co-authored-by: Snowiiii <71594357+Snowiiii@users.noreply.github.com>
2023-02-11 09:51:53 -08:00
Ryan Johnson 9f8250d4f9
Update README.md with current project status. 2023-02-03 19:04:54 -08:00
Ryan Johnson e386c9e2c2
Add Anvil file format support to README.md 2022-12-29 21:16:33 -08:00
jivvy 295678e92d
Add Particles (#150)
Implements the clientbound particle packet.

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
2022-12-29 00:26:19 -08:00
Ryan Johnson b8e41cbb9a
Change 'Flexible' bullet in README.md
With the introduction of `valence_protocol` and some future plans, I've decided it's unrealistic to try and hide all the protocol code. There are situations where direct access is necessary.
2022-11-13 06:44:22 -08:00
Ryan Johnson 9f1c946839
Check off proxy support in README.md 2022-11-12 16:45:57 -08:00
Ryan Johnson b08a0a6845
Uncheck proxy support in README.md
Unchecking this for now since there is a bug preventing it from working fully.
2022-10-21 20:00:19 -07:00
Tert0 c707ed1d04
Proxy Support (#48)
This PR adds Proxy Support.

Closes #39

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
2022-10-21 19:50:13 -07:00
Ryan Johnson f26f4be1fe
Add link to CONTRIBUTING.md in README.md 2022-10-08 18:08:48 -07:00
EmperialDev 1f996f7549
Add Items (#92)
Adding all the items, just like the blocks are. This will adress 1. and 2. bullet from issue #53
This will also make it easier to convert between block <-> item.
2022-10-05 09:28:08 -07:00
Ryan 00668839bd Wrong person lmao 2022-09-19 21:17:00 -07:00
Ryan 7f22e709cb Add GitHub sponsors 2022-09-19 21:08:14 -07:00
Ryan 0453b94eea Recommend git dependency instead of path dependency in README.md 2022-09-13 04:33:11 -07:00
Ryan Johnson ce02b50623
Clarify status of crates.io crate in the readme 2022-09-06 18:05:57 -07:00
Ryan Johnson 2ee96056a7
Explain the project better in the README 2022-09-03 20:27:49 -07:00
Ryan d98681e3b3 Add doc link 2022-09-03 07:34:55 -07:00
Ryan Johnson bf792392b5
Update README.md 2022-09-03 07:27:49 -07:00
Ryan 15d276ad2e Add logo to README 2022-07-12 17:50:36 -07:00
Ryan 3f150b4c8a Document most items 2022-07-11 05:08:02 -07:00
Ryan 8b29a04af8 prepare for crates.io 2022-01-20 06:39:49 -08:00
Ryan Johnson 30fa1b175c
Initial commit 2022-01-20 05:47:28 -08:00