2022-07-28 00:10:35 +10:00
|
|
|
use std::collections::BTreeMap;
|
2022-04-27 12:48:35 +10:00
|
|
|
|
2023-04-01 08:58:47 +11:00
|
|
|
use anyhow::Context;
|
2023-03-22 17:29:38 +11:00
|
|
|
use heck::{ToPascalCase, ToShoutySnakeCase, ToSnakeCase};
|
|
|
|
use proc_macro2::TokenStream;
|
2022-04-29 17:48:41 +10:00
|
|
|
use quote::quote;
|
|
|
|
use serde::Deserialize;
|
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-22 07:43:59 +10:00
|
|
|
use valence_build_utils::{ident, rerun_if_changed, write_generated_file};
|
2022-04-27 12:48:35 +10:00
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
#[derive(Deserialize, Clone, Debug)]
|
|
|
|
struct Entity {
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
typ: Option<String>,
|
|
|
|
translation_key: Option<String>,
|
|
|
|
fields: Vec<Field>,
|
|
|
|
parent: Option<String>,
|
2022-07-06 11:08:40 +10:00
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
#[derive(Deserialize, Clone, Debug)]
|
2023-04-01 08:58:47 +11:00
|
|
|
struct EntityTypes {
|
|
|
|
entity_type: BTreeMap<String, i32>,
|
2022-04-27 12:48:35 +10:00
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
#[derive(Deserialize, Clone, Debug)]
|
2022-04-27 12:48:35 +10:00
|
|
|
struct Field {
|
2022-07-28 00:10:35 +10:00
|
|
|
name: String,
|
|
|
|
index: u8,
|
|
|
|
#[serde(flatten)]
|
|
|
|
default_value: Value,
|
2022-04-27 12:48:35 +10:00
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
#[derive(Deserialize, Clone, Debug)]
|
|
|
|
#[serde(tag = "type", content = "default_value", rename_all = "snake_case")]
|
|
|
|
enum Value {
|
2023-04-01 08:58:47 +11:00
|
|
|
Byte(i8),
|
2022-07-28 00:10:35 +10:00
|
|
|
Integer(i32),
|
2022-12-28 19:42:54 +11:00
|
|
|
Long(i64),
|
2022-07-28 00:10:35 +10:00
|
|
|
Float(f32),
|
|
|
|
String(String),
|
|
|
|
TextComponent(String),
|
|
|
|
OptionalTextComponent(Option<String>),
|
|
|
|
ItemStack(String),
|
|
|
|
Boolean(bool),
|
|
|
|
Rotation {
|
|
|
|
pitch: f32,
|
|
|
|
yaw: f32,
|
|
|
|
roll: f32,
|
|
|
|
},
|
|
|
|
BlockPos(BlockPos),
|
|
|
|
OptionalBlockPos(Option<BlockPos>),
|
|
|
|
Facing(String),
|
|
|
|
OptionalUuid(Option<String>),
|
2023-04-01 08:58:47 +11:00
|
|
|
BlockState(String),
|
2022-07-28 00:10:35 +10:00
|
|
|
OptionalBlockState(Option<String>),
|
|
|
|
NbtCompound(String),
|
|
|
|
Particle(String),
|
|
|
|
VillagerData {
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
typ: String,
|
|
|
|
profession: String,
|
|
|
|
level: i32,
|
|
|
|
},
|
|
|
|
OptionalInt(Option<i32>),
|
|
|
|
EntityPose(String),
|
|
|
|
CatVariant(String),
|
|
|
|
FrogVariant(String),
|
|
|
|
OptionalGlobalPos(Option<()>), // TODO
|
|
|
|
PaintingVariant(String),
|
2023-04-01 08:58:47 +11:00
|
|
|
SnifferState(String),
|
|
|
|
Vector3f {
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
z: f32,
|
|
|
|
},
|
|
|
|
Quaternionf {
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
z: f32,
|
|
|
|
w: f32,
|
|
|
|
},
|
2022-07-06 11:08:40 +10:00
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
#[derive(Deserialize, Debug, Clone, Copy)]
|
|
|
|
struct BlockPos {
|
|
|
|
x: i32,
|
|
|
|
y: i32,
|
|
|
|
z: i32,
|
2022-07-06 11:08:40 +10:00
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
impl Value {
|
2023-03-22 17:29:38 +11:00
|
|
|
pub fn type_id(&self) -> u8 {
|
2022-05-16 19:36:14 +10:00
|
|
|
match self {
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Byte(_) => 0,
|
|
|
|
Value::Integer(_) => 1,
|
2022-12-28 19:42:54 +11:00
|
|
|
Value::Long(_) => 2,
|
|
|
|
Value::Float(_) => 3,
|
|
|
|
Value::String(_) => 4,
|
|
|
|
Value::TextComponent(_) => 5,
|
|
|
|
Value::OptionalTextComponent(_) => 6,
|
|
|
|
Value::ItemStack(_) => 7,
|
|
|
|
Value::Boolean(_) => 8,
|
|
|
|
Value::Rotation { .. } => 9,
|
|
|
|
Value::BlockPos(_) => 10,
|
|
|
|
Value::OptionalBlockPos(_) => 11,
|
|
|
|
Value::Facing(_) => 12,
|
|
|
|
Value::OptionalUuid(_) => 13,
|
2023-04-01 08:58:47 +11:00
|
|
|
Value::BlockState(_) => 14,
|
|
|
|
Value::OptionalBlockState(_) => 15,
|
|
|
|
Value::NbtCompound(_) => 16,
|
|
|
|
Value::Particle(_) => 17,
|
|
|
|
Value::VillagerData { .. } => 18,
|
|
|
|
Value::OptionalInt(_) => 19,
|
|
|
|
Value::EntityPose(_) => 20,
|
|
|
|
Value::CatVariant(_) => 21,
|
|
|
|
Value::FrogVariant(_) => 22,
|
|
|
|
Value::OptionalGlobalPos(_) => 23,
|
|
|
|
Value::PaintingVariant(_) => 24,
|
|
|
|
Value::SnifferState(_) => 25,
|
|
|
|
Value::Vector3f { .. } => 26,
|
|
|
|
Value::Quaternionf { .. } => 27,
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
pub fn field_type(&self) -> TokenStream {
|
2022-05-16 19:36:14 +10:00
|
|
|
match self {
|
2023-04-01 08:58:47 +11:00
|
|
|
Value::Byte(_) => quote!(i8),
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Integer(_) => quote!(i32),
|
2022-12-28 19:42:54 +11:00
|
|
|
Value::Long(_) => quote!(i64),
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Float(_) => quote!(f32),
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::String(_) => quote!(String),
|
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-22 07:43:59 +10:00
|
|
|
Value::TextComponent(_) => quote!(valence_core::text::Text),
|
|
|
|
Value::OptionalTextComponent(_) => quote!(Option<valence_core::text::Text>),
|
|
|
|
Value::ItemStack(_) => quote!(valence_core::item::ItemStack),
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Boolean(_) => quote!(bool),
|
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-22 07:43:59 +10:00
|
|
|
Value::Rotation { .. } => quote!(crate::EulerAngle),
|
|
|
|
Value::BlockPos(_) => quote!(valence_core::block_pos::BlockPos),
|
|
|
|
Value::OptionalBlockPos(_) => quote!(Option<valence_core::block_pos::BlockPos>),
|
|
|
|
Value::Facing(_) => quote!(valence_core::direction::Direction),
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::OptionalUuid(_) => quote!(Option<::uuid::Uuid>),
|
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-22 07:43:59 +10:00
|
|
|
Value::BlockState(_) => quote!(valence_block::BlockState),
|
|
|
|
Value::OptionalBlockState(_) => quote!(valence_block::BlockState),
|
|
|
|
Value::NbtCompound(_) => quote!(valence_nbt::Compound),
|
2023-05-29 18:36:11 +10:00
|
|
|
Value::Particle(_) => quote!(valence_core::particle::Particle),
|
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-22 07:43:59 +10:00
|
|
|
Value::VillagerData { .. } => quote!(crate::VillagerData),
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::OptionalInt(_) => quote!(Option<i32>),
|
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-22 07:43:59 +10:00
|
|
|
Value::EntityPose(_) => quote!(crate::Pose),
|
|
|
|
Value::CatVariant(_) => quote!(crate::CatKind),
|
|
|
|
Value::FrogVariant(_) => quote!(crate::FrogKind),
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::OptionalGlobalPos(_) => quote!(()), // TODO
|
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-22 07:43:59 +10:00
|
|
|
Value::PaintingVariant(_) => quote!(crate::PaintingKind),
|
|
|
|
Value::SnifferState(_) => quote!(crate::SnifferState),
|
|
|
|
Value::Vector3f { .. } => quote!(glam::f32::Vec3),
|
|
|
|
Value::Quaternionf { .. } => quote!(glam::f32::Quat),
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
pub fn default_expr(&self) -> TokenStream {
|
|
|
|
match self {
|
|
|
|
Value::Byte(b) => quote!(#b),
|
|
|
|
Value::Integer(i) => quote!(#i),
|
2022-12-28 19:42:54 +11:00
|
|
|
Value::Long(l) => quote!(#l),
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Float(f) => quote!(#f),
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::String(s) => quote!(#s.to_owned()),
|
|
|
|
Value::TextComponent(txt) => {
|
|
|
|
assert!(txt.is_empty());
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_core::text::Text::default())
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::OptionalTextComponent(t) => {
|
|
|
|
assert!(t.is_none());
|
|
|
|
quote!(None)
|
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::ItemStack(stack) => {
|
2023-06-14 07:38:55 +10:00
|
|
|
assert_eq!(stack, "0 air");
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_core::item::ItemStack::default())
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
Value::Boolean(b) => quote!(#b),
|
|
|
|
Value::Rotation { pitch, yaw, roll } => quote! {
|
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-22 07:43:59 +10:00
|
|
|
crate::EulerAngle {
|
2022-07-28 00:10:35 +10:00
|
|
|
pitch: #pitch,
|
|
|
|
yaw: #yaw,
|
|
|
|
roll: #roll,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Value::BlockPos(BlockPos { x, y, z }) => {
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_core::block_pos::BlockPos { x: #x, y: #y, z: #z })
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
|
|
|
Value::OptionalBlockPos(pos) => {
|
|
|
|
assert!(pos.is_none());
|
|
|
|
quote!(None)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::Facing(f) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(f.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_core::direction::Direction::#variant)
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
|
|
|
Value::OptionalUuid(uuid) => {
|
|
|
|
assert!(uuid.is_none());
|
|
|
|
quote!(None)
|
|
|
|
}
|
2023-04-01 08:58:47 +11:00
|
|
|
Value::BlockState(_) => {
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_block::BlockState::default())
|
2023-04-01 08:58:47 +11:00
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::OptionalBlockState(bs) => {
|
|
|
|
assert!(bs.is_none());
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_block::BlockState::default())
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
|
|
|
Value::NbtCompound(s) => {
|
|
|
|
assert_eq!(s, "{}");
|
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-22 07:43:59 +10:00
|
|
|
quote!(valence_nbt::Compound::default())
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::Particle(p) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
2023-05-29 18:36:11 +10:00
|
|
|
quote!(valence_core::particle::Particle::#variant)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::VillagerData {
|
|
|
|
typ,
|
|
|
|
profession,
|
|
|
|
level,
|
|
|
|
} => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let typ = ident(typ.replace('.', "_").to_pascal_case());
|
|
|
|
let profession = ident(profession.replace('.', "_").to_pascal_case());
|
2023-03-22 17:29:38 +11:00
|
|
|
quote! {
|
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-22 07:43:59 +10:00
|
|
|
crate::VillagerData {
|
|
|
|
kind: crate::VillagerKind::#typ,
|
|
|
|
profession: crate::VillagerProfession::#profession,
|
2023-03-22 17:29:38 +11:00
|
|
|
level: #level,
|
|
|
|
}
|
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::OptionalInt(i) => {
|
|
|
|
assert!(i.is_none());
|
2023-03-22 17:29:38 +11:00
|
|
|
quote!(None)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::EntityPose(p) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(crate::Pose::#variant)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::CatVariant(c) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(c.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(crate::CatKind::#variant)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::FrogVariant(f) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(f.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(crate::FrogKind::#variant)
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
Value::OptionalGlobalPos(_) => quote!(()),
|
|
|
|
Value::PaintingVariant(p) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let variant = ident(p.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(crate::PaintingKind::#variant)
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
2023-04-01 08:58:47 +11:00
|
|
|
Value::SnifferState(s) => {
|
2023-04-28 21:53:10 +10:00
|
|
|
let state = ident(s.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
quote!(crate::SnifferState::#state)
|
2023-04-01 08:58:47 +11:00
|
|
|
}
|
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-22 07:43:59 +10:00
|
|
|
Value::Vector3f { x, y, z } => quote!(glam::f32::Vec3::new(#x, #y, #z)),
|
2023-04-01 08:58:47 +11:00
|
|
|
Value::Quaternionf { x, y, z, w } => quote! {
|
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-22 07:43:59 +10:00
|
|
|
glam::f32::Quat::from_xyzw(#x, #y, #z, #w)
|
2023-04-01 08:58:47 +11:00
|
|
|
},
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
pub fn encodable_expr(&self, self_lvalue: TokenStream) -> TokenStream {
|
|
|
|
match self {
|
|
|
|
Value::Integer(_) => quote!(VarInt(#self_lvalue)),
|
2023-03-22 17:29:38 +11:00
|
|
|
Value::OptionalInt(_) => quote!(OptionalInt(#self_lvalue)),
|
|
|
|
Value::ItemStack(_) => quote!(Some(&#self_lvalue)),
|
|
|
|
_ => quote!(&#self_lvalue),
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2022-07-28 00:10:35 +10:00
|
|
|
type Entities = BTreeMap<String, Entity>;
|
2022-04-29 17:48:41 +10:00
|
|
|
|
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-22 07:43:59 +10:00
|
|
|
pub fn main() -> anyhow::Result<()> {
|
|
|
|
rerun_if_changed(["../../extracted/misc.json", "../../extracted/entities.json"]);
|
|
|
|
|
|
|
|
write_generated_file(build()?, "entity.rs")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn build() -> anyhow::Result<TokenStream> {
|
2023-03-22 17:29:38 +11:00
|
|
|
let entity_types =
|
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-22 07:43:59 +10:00
|
|
|
serde_json::from_str::<EntityTypes>(include_str!("../../extracted/misc.json"))
|
2023-04-01 08:58:47 +11:00
|
|
|
.context("failed to deserialize misc.json")?
|
|
|
|
.entity_type;
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
let entities: Entities =
|
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-22 07:43:59 +10:00
|
|
|
serde_json::from_str::<Entities>(include_str!("../../extracted/entities.json"))
|
2023-04-01 08:58:47 +11:00
|
|
|
.context("failed to deserialize entities.json")?
|
2022-12-30 11:51:05 +11:00
|
|
|
.into_iter()
|
2023-03-22 17:29:38 +11:00
|
|
|
.collect();
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
let mut entity_kind_consts = TokenStream::new();
|
|
|
|
let mut entity_kind_fmt_args = TokenStream::new();
|
|
|
|
let mut translation_key_arms = TokenStream::new();
|
|
|
|
let mut modules = TokenStream::new();
|
|
|
|
let mut systems = TokenStream::new();
|
|
|
|
let mut system_names = vec![];
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
for (entity_name, entity) in entities.clone() {
|
|
|
|
let entity_name_ident = ident(&entity_name);
|
2023-04-28 21:53:10 +10:00
|
|
|
let stripped_shouty_entity_name = strip_entity_suffix(&entity_name)
|
|
|
|
.replace('.', "_")
|
|
|
|
.to_shouty_snake_case();
|
2023-04-01 08:58:47 +11:00
|
|
|
let stripped_shouty_entity_name_ident = ident(&stripped_shouty_entity_name);
|
|
|
|
let stripped_snake_entity_name = strip_entity_suffix(&entity_name).to_snake_case();
|
|
|
|
let stripped_snake_entity_name_ident = ident(&stripped_snake_entity_name);
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
let mut module_body = TokenStream::new();
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
if let Some(parent_name) = entity.parent {
|
2023-04-01 08:58:47 +11:00
|
|
|
let stripped_snake_parent_name = strip_entity_suffix(&parent_name).to_snake_case();
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-04-01 08:58:47 +11:00
|
|
|
let module_doc = format!(
|
|
|
|
"Parent class: \
|
|
|
|
[`{stripped_snake_parent_name}`][super::{stripped_snake_parent_name}]."
|
|
|
|
);
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
module_body.extend([quote! {
|
|
|
|
#![doc = #module_doc]
|
|
|
|
}]);
|
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
// Is this a concrete entity type?
|
|
|
|
if let Some(entity_type) = entity.typ {
|
|
|
|
let entity_type_id = entity_types[&entity_type];
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
entity_kind_consts.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
pub const #stripped_shouty_entity_name_ident: EntityKind = EntityKind(#entity_type_id);
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
|
|
|
|
|
|
|
entity_kind_fmt_args.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
EntityKind::#stripped_shouty_entity_name_ident => write!(f, "{} ({})", #entity_type_id, #stripped_shouty_entity_name),
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
|
|
|
|
|
|
|
let translation_key_expr = if let Some(key) = entity.translation_key {
|
|
|
|
quote!(Some(#key))
|
2022-07-28 00:10:35 +10:00
|
|
|
} else {
|
2023-03-22 17:29:38 +11:00
|
|
|
quote!(None)
|
|
|
|
};
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
translation_key_arms.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
EntityKind::#stripped_shouty_entity_name_ident => #translation_key_expr,
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
// Create bundle type.
|
|
|
|
let mut bundle_fields = TokenStream::new();
|
|
|
|
let mut bundle_init_fields = TokenStream::new();
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
for marker_or_field in collect_bundle_fields(&entity_name, &entities) {
|
|
|
|
match marker_or_field {
|
|
|
|
MarkerOrField::Marker { entity_name } => {
|
2023-04-01 08:58:47 +11:00
|
|
|
let stripped_entity_name = strip_entity_suffix(entity_name);
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
let snake_entity_name_ident = ident(entity_name.to_snake_case());
|
2023-04-01 08:58:47 +11:00
|
|
|
let stripped_snake_entity_name_ident =
|
|
|
|
ident(stripped_entity_name.to_snake_case());
|
2023-04-28 21:53:10 +10:00
|
|
|
let pascal_entity_name_ident =
|
|
|
|
ident(entity_name.replace('.', "_").to_pascal_case());
|
2022-06-30 06:00:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
bundle_fields.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
pub #snake_entity_name_ident: super::#stripped_snake_entity_name_ident::#pascal_entity_name_ident,
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
bundle_init_fields.extend([quote! {
|
|
|
|
#snake_entity_name_ident: Default::default(),
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
MarkerOrField::Field { entity_name, field } => {
|
|
|
|
let snake_field_name = field.name.to_snake_case();
|
2023-04-28 21:53:10 +10:00
|
|
|
let pascal_field_name = field.name.replace('.', "_").to_pascal_case();
|
2023-03-22 17:29:38 +11:00
|
|
|
let pascal_field_name_ident = ident(&pascal_field_name);
|
2023-04-01 08:58:47 +11:00
|
|
|
let stripped_entity_name = strip_entity_suffix(entity_name);
|
|
|
|
let stripped_snake_entity_name = stripped_entity_name.to_snake_case();
|
|
|
|
let stripped_snake_entity_name_ident = ident(&stripped_snake_entity_name);
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
let field_name_ident =
|
2023-04-01 08:58:47 +11:00
|
|
|
ident(format!("{stripped_snake_entity_name}_{snake_field_name}"));
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
bundle_fields.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
pub #field_name_ident: super::#stripped_snake_entity_name_ident::#pascal_field_name_ident,
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
|
|
|
|
|
|
|
bundle_init_fields.extend([quote! {
|
|
|
|
#field_name_ident: Default::default(),
|
|
|
|
}]);
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
bundle_fields.extend([quote! {
|
|
|
|
pub kind: super::EntityKind,
|
|
|
|
pub id: super::EntityId,
|
|
|
|
pub uuid: super::UniqueId,
|
|
|
|
pub location: super::Location,
|
|
|
|
pub old_location: super::OldLocation,
|
|
|
|
pub position: super::Position,
|
|
|
|
pub old_position: super::OldPosition,
|
|
|
|
pub look: super::Look,
|
|
|
|
pub head_yaw: super::HeadYaw,
|
|
|
|
pub on_ground: super::OnGround,
|
|
|
|
pub velocity: super::Velocity,
|
|
|
|
pub statuses: super::EntityStatuses,
|
|
|
|
pub animations: super::EntityAnimations,
|
|
|
|
pub object_data: super::ObjectData,
|
|
|
|
pub tracked_data: super::TrackedData,
|
|
|
|
pub packet_byte_range: super::PacketByteRange,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
bundle_init_fields.extend([quote! {
|
2023-04-01 08:58:47 +11:00
|
|
|
kind: super::EntityKind::#stripped_shouty_entity_name_ident,
|
2023-03-22 17:29:38 +11:00
|
|
|
id: Default::default(),
|
|
|
|
uuid: Default::default(),
|
|
|
|
location: Default::default(),
|
|
|
|
old_location: Default::default(),
|
|
|
|
position: Default::default(),
|
|
|
|
old_position: Default::default(),
|
|
|
|
look: Default::default(),
|
|
|
|
head_yaw: Default::default(),
|
|
|
|
on_ground: Default::default(),
|
|
|
|
velocity: Default::default(),
|
|
|
|
statuses: Default::default(),
|
|
|
|
animations: Default::default(),
|
|
|
|
object_data: Default::default(),
|
|
|
|
tracked_data: Default::default(),
|
|
|
|
packet_byte_range: Default::default(),
|
|
|
|
}]);
|
|
|
|
|
|
|
|
let bundle_name_ident = ident(format!("{entity_name}Bundle"));
|
2023-04-01 08:58:47 +11:00
|
|
|
let bundle_doc = format!(
|
|
|
|
"The bundle of components for spawning `{stripped_snake_entity_name}` entities."
|
|
|
|
);
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
module_body.extend([quote! {
|
|
|
|
#[doc = #bundle_doc]
|
|
|
|
#[derive(bevy_ecs::bundle::Bundle, Debug)]
|
|
|
|
pub struct #bundle_name_ident {
|
|
|
|
#bundle_fields
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
impl Default for #bundle_name_ident {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
#bundle_init_fields
|
|
|
|
}
|
2022-06-30 06:00:41 +10:00
|
|
|
}
|
2022-07-06 11:08:40 +10:00
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
for field in &entity.fields {
|
2023-04-28 21:53:10 +10:00
|
|
|
let pascal_field_name_ident = ident(field.name.replace('.', "_").to_pascal_case());
|
2023-03-22 17:29:38 +11:00
|
|
|
let snake_field_name = field.name.to_snake_case();
|
|
|
|
let inner_type = field.default_value.field_type();
|
|
|
|
let default_expr = field.default_value.default_expr();
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
module_body.extend([quote! {
|
|
|
|
#[derive(bevy_ecs::component::Component, PartialEq, Clone, Debug)]
|
|
|
|
pub struct #pascal_field_name_ident(pub #inner_type);
|
2022-07-28 00:10:35 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
#[allow(clippy::derivable_impls)]
|
|
|
|
impl Default for #pascal_field_name_ident {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self(#default_expr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
2023-04-01 08:58:47 +11:00
|
|
|
let system_name_ident = ident(format!(
|
|
|
|
"update_{stripped_snake_entity_name}_{snake_field_name}"
|
|
|
|
));
|
|
|
|
let component_path =
|
|
|
|
quote!(#stripped_snake_entity_name_ident::#pascal_field_name_ident);
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
system_names.push(quote!(#system_name_ident));
|
|
|
|
|
|
|
|
let data_index = field.index;
|
|
|
|
let data_type = field.default_value.type_id();
|
|
|
|
let encodable_expr = field.default_value.encodable_expr(quote!(value.0));
|
|
|
|
|
|
|
|
systems.extend([quote! {
|
|
|
|
#[allow(clippy::needless_borrow)]
|
|
|
|
fn #system_name_ident(
|
|
|
|
mut query: Query<(&#component_path, &mut TrackedData), Changed<#component_path>>
|
|
|
|
) {
|
|
|
|
for (value, mut tracked_data) in &mut query {
|
|
|
|
if *value == Default::default() {
|
|
|
|
tracked_data.remove_init_value(#data_index);
|
|
|
|
} else {
|
|
|
|
tracked_data.insert_init_value(#data_index, #data_type, #encodable_expr);
|
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
if !tracked_data.is_added() {
|
|
|
|
tracked_data.append_update_value(#data_index, #data_type, #encodable_expr);
|
|
|
|
}
|
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
|
|
|
|
2023-04-01 08:58:47 +11:00
|
|
|
let marker_doc = format!("Marker component for `{stripped_snake_entity_name}` entities.");
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
module_body.extend([quote! {
|
|
|
|
#[doc = #marker_doc]
|
|
|
|
#[derive(bevy_ecs::component::Component, Copy, Clone, Default, Debug)]
|
|
|
|
pub struct #entity_name_ident;
|
|
|
|
}]);
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
modules.extend([quote! {
|
|
|
|
#[allow(clippy::module_inception)]
|
2023-04-01 08:58:47 +11:00
|
|
|
pub mod #stripped_snake_entity_name_ident {
|
2023-03-22 17:29:38 +11:00
|
|
|
#module_body
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
}]);
|
|
|
|
}
|
2022-05-16 19:36:14 +10:00
|
|
|
|
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-22 07:43:59 +10:00
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
struct MiscEntityData {
|
|
|
|
entity_status: BTreeMap<String, u8>,
|
|
|
|
entity_animation: BTreeMap<String, u8>,
|
|
|
|
}
|
|
|
|
|
|
|
|
let misc_entity_data: MiscEntityData =
|
|
|
|
serde_json::from_str(include_str!("../../extracted/misc.json"))?;
|
|
|
|
|
|
|
|
let entity_status_variants = misc_entity_data
|
|
|
|
.entity_status
|
|
|
|
.into_iter()
|
|
|
|
.map(|(name, code)| {
|
2023-04-28 21:53:10 +10:00
|
|
|
let name = ident(name.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
let code = code as isize;
|
|
|
|
|
|
|
|
quote! {
|
|
|
|
#name = #code,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
let entity_animation_variants =
|
|
|
|
misc_entity_data
|
|
|
|
.entity_animation
|
|
|
|
.into_iter()
|
|
|
|
.map(|(name, code)| {
|
2023-04-28 21:53:10 +10:00
|
|
|
let name = ident(name.replace('.', "_").to_pascal_case());
|
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-22 07:43:59 +10:00
|
|
|
let code = code as isize;
|
|
|
|
|
|
|
|
quote! {
|
|
|
|
#name = #code,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
Ok(quote! {
|
|
|
|
#modules
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
/// Identifies the type of an entity.
|
|
|
|
/// As a component, the entity kind should not be modified.
|
|
|
|
#[derive(Component, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
|
|
|
pub struct EntityKind(i32);
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
impl EntityKind {
|
|
|
|
#entity_kind_consts
|
|
|
|
|
|
|
|
pub const fn new(inner: i32) -> Self {
|
|
|
|
Self(inner)
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
pub const fn get(self) -> i32 {
|
|
|
|
self.0
|
|
|
|
}
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
pub const fn translation_key(self) -> Option<&'static str> {
|
2022-05-16 19:36:14 +10:00
|
|
|
match self {
|
2023-03-22 17:29:38 +11:00
|
|
|
#translation_key_arms
|
|
|
|
_ => None,
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
|
|
|
}
|
2023-03-22 17:29:38 +11:00
|
|
|
}
|
2022-05-16 19:36:14 +10:00
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
impl std::fmt::Debug for EntityKind {
|
|
|
|
#[allow(clippy::write_literal)]
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
match *self {
|
|
|
|
#entity_kind_fmt_args
|
|
|
|
EntityKind(other) => write!(f, "{other}"),
|
2022-05-16 19:36:14 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-29 17:48:41 +10:00
|
|
|
|
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-22 07:43:59 +10:00
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub enum EntityStatus {
|
|
|
|
#(#entity_status_variants)*
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub enum EntityAnimation {
|
|
|
|
#(#entity_animation_variants)*
|
|
|
|
}
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
fn add_tracked_data_systems(app: &mut App) {
|
|
|
|
#systems
|
|
|
|
|
|
|
|
#(
|
|
|
|
app.add_system(
|
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-22 07:43:59 +10:00
|
|
|
#system_names
|
|
|
|
.in_set(UpdateTrackedDataSet)
|
|
|
|
.ambiguous_with(UpdateTrackedDataSet)
|
2023-03-22 17:29:38 +11:00
|
|
|
);
|
|
|
|
)*
|
|
|
|
}
|
2022-07-28 00:10:35 +10:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
enum MarkerOrField<'a> {
|
|
|
|
Marker {
|
|
|
|
entity_name: &'a str,
|
|
|
|
},
|
|
|
|
Field {
|
|
|
|
entity_name: &'a str,
|
|
|
|
field: &'a Field,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fn collect_bundle_fields<'a>(
|
|
|
|
mut entity_name: &'a str,
|
|
|
|
entities: &'a Entities,
|
|
|
|
) -> Vec<MarkerOrField<'a>> {
|
|
|
|
let mut res = vec![];
|
|
|
|
|
|
|
|
loop {
|
2022-07-28 00:10:35 +10:00
|
|
|
let e = &entities[entity_name];
|
2023-03-22 17:29:38 +11:00
|
|
|
|
|
|
|
res.push(MarkerOrField::Marker { entity_name });
|
|
|
|
res.extend(
|
|
|
|
e.fields
|
|
|
|
.iter()
|
|
|
|
.map(|field| MarkerOrField::Field { entity_name, field }),
|
|
|
|
);
|
2022-07-28 00:10:35 +10:00
|
|
|
|
|
|
|
if let Some(parent) = &e.parent {
|
2023-03-22 17:29:38 +11:00
|
|
|
entity_name = parent;
|
|
|
|
} else {
|
|
|
|
break;
|
2022-07-28 00:10:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 17:29:38 +11:00
|
|
|
res
|
2022-04-29 17:48:41 +10:00
|
|
|
}
|
2023-04-01 08:58:47 +11:00
|
|
|
|
|
|
|
fn strip_entity_suffix(string: &str) -> String {
|
|
|
|
let stripped = string.strip_suffix("Entity").unwrap_or(string);
|
|
|
|
|
|
|
|
if stripped.is_empty() {
|
|
|
|
string
|
|
|
|
} else {
|
|
|
|
stripped
|
|
|
|
}
|
|
|
|
.to_owned()
|
|
|
|
}
|