Go to file
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
.github Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
assets Custom resource packs (#68) 2022-09-17 19:32:40 -07:00
crates Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
extracted Update to 1.19.4 (#302) 2023-03-31 14:58:47 -07:00
extractor Registry codec extractor (#316) 2023-04-10 01:39:03 -07:00
tools Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
.gitignore dump_schedule utility (#300) 2023-03-23 01:01:50 -07:00
Cargo.toml Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
CODE_OF_CONDUCT.md Add code of conduct (#126) 2022-10-19 18:07:43 -07:00
CONTRIBUTING.md Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
LICENSE.txt prepare for crates.io 2022-01-20 06:39:49 -08:00
README.md Reorganize Project (#321) 2023-04-21 14:43:59 -07:00
rustfmt.toml Change rustfmt settings 2022-08-28 21:31:07 -07:00

license chat on Discord GitHub sponsors

A Rust framework for building Minecraft: Java Edition servers.

Built on top of Bevy ECS, Valence is an effort to create a Minecraft compatible server completely from scratch in Rust. You can think of Valence as a game engine for Minecraft servers. It doesn't do much by default, but by writing game logic yourself and leveraging Bevy's powerful plugin system, you can make almost anything.

Opinionated features like dynamic scripting, dedicated executables, and vanilla game mechanics are all expected to be built as optional plugins. This level of modularity is desirable for those looking to build highly custom experiences in Minecraft such as minigame servers.

⚠️ Valence is still early in development with many features unimplemented or incomplete. Expect to encounter bugs, limitations, and breaking changes.

Goals

Valence aims to be the following:

  • Complete. Abstractions for the full breadth of the Minecraft protocol.
  • Flexible. Can easily extend Valence from within user code. Direct access to the Minecraft protocol is provided.
  • Modular. Pick and choose the components you need.
  • Intuitive. An API that is easy to use and difficult to misuse. Extensive documentation and examples are important.
  • Efficient. Optimal use of system resources with multiple CPU cores in mind. Valence uses very little memory and can support thousands of players at the same time without lag (assuming you have the bandwidth).
  • Up to date. Targets the most recent stable version of Minecraft. Support for multiple versions at once is not planned. However, you can use a proxy with ViaBackwards to achieve backwards compatibility with older clients.

Current Status

Here are some noteworthy achievements:

  • valence_nbt: A speedy new library for Minecraft's Named Binary Tag (NBT) format.
  • Authentication, encryption, and compression
  • Block states
  • Chunks
  • Entities and metadata
  • Bounding volume hierarchy for fast spatial entity queries
  • Player list and player skins
  • Dimensions, biomes, and worlds
  • JSON Text API
  • A Fabric mod for extracting data from the game into JSON files. These files are processed by a build script to generate Rust code for the project. The JSON files can be used in other projects as well.
  • Inventories
  • Items
  • Particles
  • Anvil file format (read only)
  • Proxy support (Velocity, Bungeecord and Waterfall)

Here is a short video showing the examples and some of Valence's capabilities.

Getting Started

Running the Examples

After cloning the repository, run

cargo r -r --example

to view the list of examples. I recommend giving parkour, conway, terrain, and cow_sphere a try.

Next, open your Minecraft client and connect to the address localhost. If all goes well you should be playing on the server.

Adding Valence as a Dependency

Valence is published to crates.io. Run cargo add valence to add it to your project. Documentation is available here.

However, the crates.io version is likely outdated. To use the most recent development version, add Valence as a git dependency

[dependencies]
valence = { git = "https://github.com/valence-rs/valence" }

View the latest documentation by running cargo d --open in your project.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md. You can also join the Discord to discuss the project and ask questions.

License

Code is licensed under MIT while the Valence logo is under CC BY-NC-ND 4.0

Funding

If you would like to contribute financially, consider sponsoring me (rj00a) on GitHub or Patreon.

I would love to continue working on Valence and your support would help me do that. Thanks!