From 1d532ef98bb94277fd8ce79cc35f2ed9c0d7dc4d Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Jun 2023 19:51:04 -0700 Subject: [PATCH 1/3] Refactor workspace --- CONTRIBUTING.md | 2 +- Cargo.toml | 85 ++++++++++++++++-- {crates/valence/benches => benches}/anvil.rs | 0 {crates/valence/benches => benches}/block.rs | 0 .../benches => benches}/decode_array.rs | 0 {crates/valence/benches => benches}/idle.rs | 0 {crates/valence/benches => benches}/main.rs | 0 {crates/valence/benches => benches}/packet.rs | 0 .../valence/benches => benches}/var_int.rs | 0 .../valence/benches => benches}/var_long.rs | 0 crates/valence/Cargo.toml | 66 -------------- crates/valence/README.md | 5 -- crates/valence_client/src/command.rs | 58 +++++++------ .../examples => examples}/advancement.rs | 14 +-- .../examples => examples}/anvil_loading.rs | 0 .../examples => examples}/bench_players.rs | 2 - .../valence/examples => examples}/biomes.rs | 0 .../examples => examples}/block_entities.rs | 0 .../valence/examples => examples}/building.rs | 5 +- .../valence/examples => examples}/chest.rs | 5 +- .../valence/examples => examples}/combat.rs | 4 +- .../examples => examples}/cow_sphere.rs | 0 .../valence/examples => examples}/death.rs | 2 +- .../examples => examples}/entity_hitbox.rs | 2 +- .../conway.rs => examples/game_of_life.rs | 2 +- .../valence/examples => examples}/parkour.rs | 0 .../examples => examples}/particles.rs | 0 .../examples => examples}/player_list.rs | 0 .../examples => examples}/resource_pack.rs | 0 .../examples => examples}/server_list_ping.rs | 2 +- .../valence/examples => examples}/terrain.rs | 0 {crates/valence/examples => examples}/text.rs | 0 .../examples => examples}/world_border.rs | 0 {crates/valence/src => src}/lib.rs | 86 ++++++++++--------- {crates/valence/src => src}/tests.rs | 0 {crates/valence/src => src}/tests/client.rs | 0 {crates/valence/src => src}/tests/example.rs | 5 +- .../valence/src => src}/tests/inventory.rs | 0 {crates/valence/src => src}/tests/weather.rs | 0 .../valence/src => src}/tests/world_border.rs | 0 tools/dump_schedule/Cargo.toml | 2 +- tools/packet_inspector/Cargo.toml | 15 ++-- tools/packet_inspector/README.md | 2 +- 43 files changed, 186 insertions(+), 178 deletions(-) rename {crates/valence/benches => benches}/anvil.rs (100%) rename {crates/valence/benches => benches}/block.rs (100%) rename {crates/valence/benches => benches}/decode_array.rs (100%) rename {crates/valence/benches => benches}/idle.rs (100%) rename {crates/valence/benches => benches}/main.rs (100%) rename {crates/valence/benches => benches}/packet.rs (100%) rename {crates/valence/benches => benches}/var_int.rs (100%) rename {crates/valence/benches => benches}/var_long.rs (100%) delete mode 100644 crates/valence/Cargo.toml delete mode 100644 crates/valence/README.md rename {crates/valence/examples => examples}/advancement.rs (96%) rename {crates/valence/examples => examples}/anvil_loading.rs (100%) rename {crates/valence/examples => examples}/bench_players.rs (96%) rename {crates/valence/examples => examples}/biomes.rs (100%) rename {crates/valence/examples => examples}/block_entities.rs (100%) rename {crates/valence/examples => examples}/building.rs (97%) rename {crates/valence/examples => examples}/chest.rs (95%) rename {crates/valence/examples => examples}/combat.rs (97%) rename {crates/valence/examples => examples}/cow_sphere.rs (100%) rename {crates/valence/examples => examples}/death.rs (99%) rename {crates/valence/examples => examples}/entity_hitbox.rs (99%) rename crates/valence/examples/conway.rs => examples/game_of_life.rs (99%) rename {crates/valence/examples => examples}/parkour.rs (100%) rename {crates/valence/examples => examples}/particles.rs (100%) rename {crates/valence/examples => examples}/player_list.rs (100%) rename {crates/valence/examples => examples}/resource_pack.rs (100%) rename {crates/valence/examples => examples}/server_list_ping.rs (95%) rename {crates/valence/examples => examples}/terrain.rs (100%) rename {crates/valence/examples => examples}/text.rs (100%) rename {crates/valence/examples => examples}/world_border.rs (100%) rename {crates/valence/src => src}/lib.rs (72%) rename {crates/valence/src => src}/tests.rs (100%) rename {crates/valence/src => src}/tests/client.rs (100%) rename {crates/valence/src => src}/tests/example.rs (94%) rename {crates/valence/src => src}/tests/inventory.rs (100%) rename {crates/valence/src => src}/tests/weather.rs (100%) rename {crates/valence/src => src}/tests/world_border.rs (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 877044894..2f0b16128 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -227,7 +227,7 @@ where appropriate. Unit tests help your contributions last! They ensure that your code works as expected and that it continues to work in the future. -whole-server unit tests can be found in [`crates/valence/src/tests/`](crates/valence/src/tests). +whole-server unit tests can be found in [`/src/tests/`](/src/tests). ## Naming Quantities diff --git a/Cargo.toml b/Cargo.toml index 962750eaf..0da3447d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,80 @@ +[package] +name = "valence" +version.workspace = true +edition.workspace = true +description = "A framework for building Minecraft servers in Rust." +documentation.workspace = true +repository.workspace = true +readme = "README.md" +license.workspace = true +keywords = ["minecraft", "gamedev", "server", "ecs"] +categories = ["game-engines"] + +[features] +default = [ + "network", + "player_list", + "inventory", + "anvil", + "advancement", + "world_border", +] +network = ["dep:valence_network"] +player_list = ["dep:valence_player_list"] +inventory = ["dep:valence_inventory"] +anvil = ["dep:valence_anvil"] +advancement = ["dep:valence_advancement"] +world_border = ["dep:valence_world_border"] + +[dependencies] +bevy_app.workspace = true +bevy_ecs.workspace = true +glam.workspace = true +uuid.workspace = true +valence_nbt.workspace = true +valence_core.workspace = true +valence_registry.workspace = true +valence_block.workspace = true +valence_biome.workspace = true +valence_dimension.workspace = true +valence_entity.workspace = true +valence_instance.workspace = true +valence_client.workspace = true +valence_network = { workspace = true, optional = true } +valence_player_list = { workspace = true, optional = true } +valence_inventory = { workspace = true, optional = true } +valence_anvil = { workspace = true, optional = true } +valence_advancement = { workspace = true, optional = true } +valence_world_border = { workspace = true, optional = true } + +[dev-dependencies] +anyhow.workspace = true +bytes.workspace = true +clap.workspace = true +criterion.workspace = true +flume.workspace = true +noise.workspace = true # For the terrain example. +rand.workspace = true +tracing-subscriber.workspace = true +tracing.workspace = true + +[dev-dependencies.reqwest] +workspace = true +default-features = false +features = ["rustls-tls", "blocking", "stream"] + +[[bench]] +name = "main" +harness = false + +[profile.dev.package."*"] +opt-level = 3 + +[profile.dev] +opt-level = 1 + [workspace] members = ["crates/*", "tools/*"] -exclude = ["rust-mc-bot"] resolver = "2" [workspace.package] @@ -96,12 +170,5 @@ valence_network.path = "crates/valence_network" valence_player_list.path = "crates/valence_player_list" valence_registry.path = "crates/valence_registry" valence_world_border.path = "crates/valence_world_border" -valence.path = "crates/valence" - +valence.path = "." zip = "0.6.3" - -[profile.dev.package."*"] -opt-level = 3 - -[profile.dev] -opt-level = 1 diff --git a/crates/valence/benches/anvil.rs b/benches/anvil.rs similarity index 100% rename from crates/valence/benches/anvil.rs rename to benches/anvil.rs diff --git a/crates/valence/benches/block.rs b/benches/block.rs similarity index 100% rename from crates/valence/benches/block.rs rename to benches/block.rs diff --git a/crates/valence/benches/decode_array.rs b/benches/decode_array.rs similarity index 100% rename from crates/valence/benches/decode_array.rs rename to benches/decode_array.rs diff --git a/crates/valence/benches/idle.rs b/benches/idle.rs similarity index 100% rename from crates/valence/benches/idle.rs rename to benches/idle.rs diff --git a/crates/valence/benches/main.rs b/benches/main.rs similarity index 100% rename from crates/valence/benches/main.rs rename to benches/main.rs diff --git a/crates/valence/benches/packet.rs b/benches/packet.rs similarity index 100% rename from crates/valence/benches/packet.rs rename to benches/packet.rs diff --git a/crates/valence/benches/var_int.rs b/benches/var_int.rs similarity index 100% rename from crates/valence/benches/var_int.rs rename to benches/var_int.rs diff --git a/crates/valence/benches/var_long.rs b/benches/var_long.rs similarity index 100% rename from crates/valence/benches/var_long.rs rename to benches/var_long.rs diff --git a/crates/valence/Cargo.toml b/crates/valence/Cargo.toml deleted file mode 100644 index b7540897f..000000000 --- a/crates/valence/Cargo.toml +++ /dev/null @@ -1,66 +0,0 @@ -[package] -name = "valence" -version.workspace = true -edition.workspace = true -description = "A framework for building Minecraft servers in Rust." -documentation.workspace = true -repository.workspace = true -readme = "README.md" -license.workspace = true -keywords = ["minecraft", "gamedev", "server", "ecs"] -categories = ["game-engines"] - -[features] -default = ["network", "player_list", "inventory", "anvil", "advancement", "world_border"] -network = ["dep:valence_network"] -player_list = ["dep:valence_player_list"] -inventory = ["dep:valence_inventory"] -anvil = ["dep:valence_anvil"] -advancement = ["dep:valence_advancement"] -world_border = ["dep:valence_world_border"] - -[dependencies] -bevy_app.workspace = true -bevy_ecs.workspace = true -glam.workspace = true -uuid.workspace = true -valence_nbt.workspace = true -valence_core.workspace = true -valence_registry.workspace = true -valence_block.workspace = true -valence_biome.workspace = true -valence_dimension.workspace = true -valence_entity.workspace = true -valence_instance.workspace = true -valence_client.workspace = true -valence_network = { workspace = true, optional = true } -valence_player_list = { workspace = true, optional = true } -valence_inventory = { workspace = true, optional = true } -valence_anvil = { workspace = true, optional = true } -valence_advancement = { workspace = true, optional = true } -valence_world_border = { workspace = true, optional = true } - - -[dev-dependencies] -anyhow.workspace = true -bytes.workspace = true -noise.workspace = true -tracing-subscriber.workspace = true -rand.workspace = true -tracing.workspace = true -flume.workspace = true -clap.workspace = true -criterion.workspace = true -fs_extra.workspace = true -tempfile.workspace = true -zip.workspace = true - -[dev-dependencies.reqwest] -workspace = true -default-features = false -# Avoid OpenSSL dependency on Linux. -features = ["rustls-tls", "blocking", "stream"] - -[[bench]] -name = "main" -harness = false diff --git a/crates/valence/README.md b/crates/valence/README.md deleted file mode 100644 index f9bed2fb8..000000000 --- a/crates/valence/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# valence - -The main Valence crate. This acts primarily as a shell to re-export the other crates and consolidate plugins. Users are expected to use the other crates indirectly through this interface. - -Additionally, project examples and whole-server unit tests are stored in `examples/` and `src/tests/` respectively. diff --git a/crates/valence_client/src/command.rs b/crates/valence_client/src/command.rs index f3d5e4685..e9096fabd 100644 --- a/crates/valence_client/src/command.rs +++ b/crates/valence_client/src/command.rs @@ -8,10 +8,10 @@ use valence_entity::{entity, Pose}; use crate::event_loop::{EventLoopSchedule, EventLoopSet, PacketEvent}; pub(super) fn build(app: &mut App) { - app.add_event::() - .add_event::() - .add_event::() - .add_event::() + app.add_event::() + .add_event::() + .add_event::() + .add_event::() .add_system( handle_client_command .in_schedule(EventLoopSchedule) @@ -20,7 +20,7 @@ pub(super) fn build(app: &mut App) { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub struct Sprinting { +pub struct SprintEvent { pub client: Entity, pub state: SprintState, } @@ -32,7 +32,7 @@ pub enum SprintState { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub struct Sneaking { +pub struct SneakEvent { pub client: Entity, pub state: SneakState, } @@ -44,7 +44,7 @@ pub enum SneakState { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub struct JumpWithHorse { +pub struct JumpWithHorseEvent { pub client: Entity, pub state: JumpWithHorseState, } @@ -59,17 +59,17 @@ pub enum JumpWithHorseState { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub struct LeaveBed { +pub struct LeaveBedEvent { pub client: Entity, } fn handle_client_command( mut packets: EventReader, mut clients: Query<(&mut entity::Pose, &mut Flags)>, - mut sprinting_events: EventWriter, - mut sneaking_events: EventWriter, - mut jump_with_horse_events: EventWriter, - mut leave_bed_events: EventWriter, + mut sprinting_events: EventWriter, + mut sneaking_events: EventWriter, + mut jump_with_horse_events: EventWriter, + mut leave_bed_events: EventWriter, ) { for packet in packets.iter() { if let Some(pkt) = packet.decode::() { @@ -80,7 +80,7 @@ fn handle_client_command( flags.set_sneaking(true); } - sneaking_events.send(Sneaking { + sneaking_events.send(SneakEvent { client: packet.client, state: SneakState::Start, }) @@ -91,12 +91,12 @@ fn handle_client_command( flags.set_sneaking(false); } - sneaking_events.send(Sneaking { + sneaking_events.send(SneakEvent { client: packet.client, state: SneakState::Stop, }) } - ClientCommand::LeaveBed => leave_bed_events.send(LeaveBed { + ClientCommand::LeaveBed => leave_bed_events.send(LeaveBedEvent { client: packet.client, }), ClientCommand::StartSprinting => { @@ -104,7 +104,7 @@ fn handle_client_command( flags.set_sprinting(true); } - sprinting_events.send(Sprinting { + sprinting_events.send(SprintEvent { client: packet.client, state: SprintState::Start, }); @@ -114,21 +114,25 @@ fn handle_client_command( flags.set_sprinting(false); } - sprinting_events.send(Sprinting { + sprinting_events.send(SprintEvent { client: packet.client, state: SprintState::Stop, }) } - ClientCommand::StartJumpWithHorse => jump_with_horse_events.send(JumpWithHorse { - client: packet.client, - state: JumpWithHorseState::Start { - power: pkt.jump_boost.0 as u8, - }, - }), - ClientCommand::StopJumpWithHorse => jump_with_horse_events.send(JumpWithHorse { - client: packet.client, - state: JumpWithHorseState::Stop, - }), + ClientCommand::StartJumpWithHorse => { + jump_with_horse_events.send(JumpWithHorseEvent { + client: packet.client, + state: JumpWithHorseState::Start { + power: pkt.jump_boost.0 as u8, + }, + }) + } + ClientCommand::StopJumpWithHorse => { + jump_with_horse_events.send(JumpWithHorseEvent { + client: packet.client, + state: JumpWithHorseState::Stop, + }) + } ClientCommand::OpenHorseInventory => {} // TODO ClientCommand::StartFlyingWithElytra => { if let Ok((mut pose, _)) = clients.get_mut(packet.client) { diff --git a/crates/valence/examples/advancement.rs b/examples/advancement.rs similarity index 96% rename from crates/valence/examples/advancement.rs rename to examples/advancement.rs index 0801ac7ca..436992cb9 100644 --- a/crates/valence/examples/advancement.rs +++ b/examples/advancement.rs @@ -1,9 +1,8 @@ use std::collections::HashMap; +use valence::advancement::bevy_hierarchy::{BuildChildren, Children, Parent}; +use valence::advancement::ForceTabUpdate; use valence::prelude::*; -use valence_advancement::bevy_hierarchy::{BuildChildren, Children, Parent}; -use valence_advancement::ForceTabUpdate; -use valence_client::SpawnClientsSet; #[derive(Component)] struct RootCriteria; @@ -29,13 +28,14 @@ fn main() { .init_resource::() .add_startup_system(setup) .add_systems(( + load_clients, + apply_system_buffers + .after(load_clients) + .before(init_advancements), init_clients, init_advancements, sneak, tab_change, - load_clients - .after(SpawnClientsSet) - .in_base_set(CoreSet::PreUpdate), )) .run(); } @@ -225,7 +225,7 @@ fn init_advancements( } fn sneak( - mut sneaking: EventReader, + mut sneaking: EventReader, mut client: Query<(&mut AdvancementClientUpdate, &mut RootCriteriaDone)>, root_criteria: Query>, client_uuid: Query<&UniqueId>, diff --git a/crates/valence/examples/anvil_loading.rs b/examples/anvil_loading.rs similarity index 100% rename from crates/valence/examples/anvil_loading.rs rename to examples/anvil_loading.rs diff --git a/crates/valence/examples/bench_players.rs b/examples/bench_players.rs similarity index 96% rename from crates/valence/examples/bench_players.rs rename to examples/bench_players.rs index f526242ac..d337b8f2f 100644 --- a/crates/valence/examples/bench_players.rs +++ b/examples/bench_players.rs @@ -2,9 +2,7 @@ use std::time::Instant; -use valence::instance::{Chunk, Instance}; use valence::prelude::*; -use valence_network::ConnectionMode; const SPAWN_Y: i32 = 64; diff --git a/crates/valence/examples/biomes.rs b/examples/biomes.rs similarity index 100% rename from crates/valence/examples/biomes.rs rename to examples/biomes.rs diff --git a/crates/valence/examples/block_entities.rs b/examples/block_entities.rs similarity index 100% rename from crates/valence/examples/block_entities.rs rename to examples/block_entities.rs diff --git a/crates/valence/examples/building.rs b/examples/building.rs similarity index 97% rename from crates/valence/examples/building.rs rename to examples/building.rs index 9882d32a4..b02cce338 100644 --- a/crates/valence/examples/building.rs +++ b/examples/building.rs @@ -60,7 +60,10 @@ fn init_clients( } } -fn toggle_gamemode_on_sneak(mut clients: Query<&mut GameMode>, mut events: EventReader) { +fn toggle_gamemode_on_sneak( + mut clients: Query<&mut GameMode>, + mut events: EventReader, +) { for event in events.iter() { let Ok(mut mode) = clients.get_mut(event.client) else { continue; diff --git a/crates/valence/examples/chest.rs b/examples/chest.rs similarity index 95% rename from crates/valence/examples/chest.rs rename to examples/chest.rs index 9a4bd48e5..857019d52 100644 --- a/crates/valence/examples/chest.rs +++ b/examples/chest.rs @@ -59,7 +59,10 @@ fn init_clients( } } -fn toggle_gamemode_on_sneak(mut clients: Query<&mut GameMode>, mut events: EventReader) { +fn toggle_gamemode_on_sneak( + mut clients: Query<&mut GameMode>, + mut events: EventReader, +) { for event in events.iter() { let Ok(mut mode) = clients.get_mut(event.client) else { continue; diff --git a/crates/valence/examples/combat.rs b/examples/combat.rs similarity index 97% rename from crates/valence/examples/combat.rs rename to examples/combat.rs index 66198f5a3..4d839adb0 100644 --- a/crates/valence/examples/combat.rs +++ b/examples/combat.rs @@ -95,10 +95,10 @@ struct CombatQuery { fn handle_combat_events( server: Res, mut clients: Query, - mut sprinting: EventReader, + mut sprinting: EventReader, mut interact_entity: EventReader, ) { - for &Sprinting { client, state } in sprinting.iter() { + for &SprintEvent { client, state } in sprinting.iter() { if let Ok(mut client) = clients.get_mut(client) { client.state.has_bonus_knockback = state == SprintState::Start; } diff --git a/crates/valence/examples/cow_sphere.rs b/examples/cow_sphere.rs similarity index 100% rename from crates/valence/examples/cow_sphere.rs rename to examples/cow_sphere.rs diff --git a/crates/valence/examples/death.rs b/examples/death.rs similarity index 99% rename from crates/valence/examples/death.rs rename to examples/death.rs index d65f10ad4..ad0035026 100644 --- a/crates/valence/examples/death.rs +++ b/examples/death.rs @@ -65,7 +65,7 @@ fn init_clients( } } -fn squat_and_die(mut clients: Query<&mut Client>, mut events: EventReader) { +fn squat_and_die(mut clients: Query<&mut Client>, mut events: EventReader) { for event in events.iter() { if event.state == SneakState::Start { if let Ok(mut client) = clients.get_mut(event.client) { diff --git a/crates/valence/examples/entity_hitbox.rs b/examples/entity_hitbox.rs similarity index 99% rename from crates/valence/examples/entity_hitbox.rs rename to examples/entity_hitbox.rs index 47a86c735..e81bb1976 100644 --- a/crates/valence/examples/entity_hitbox.rs +++ b/examples/entity_hitbox.rs @@ -60,7 +60,7 @@ fn init_clients( fn spawn_entity( mut commands: Commands, - mut sneaking: EventReader, + mut sneaking: EventReader, client_query: Query<(&Position, &Location)>, ) { for sneaking in sneaking.iter() { diff --git a/crates/valence/examples/conway.rs b/examples/game_of_life.rs similarity index 99% rename from crates/valence/examples/conway.rs rename to examples/game_of_life.rs index 10aefe667..43e21a8f0 100644 --- a/crates/valence/examples/conway.rs +++ b/examples/game_of_life.rs @@ -185,7 +185,7 @@ fn update_board( } fn pause_on_crouch( - mut events: EventReader, + mut events: EventReader, mut board: ResMut, mut clients: Query<&mut Client>, ) { diff --git a/crates/valence/examples/parkour.rs b/examples/parkour.rs similarity index 100% rename from crates/valence/examples/parkour.rs rename to examples/parkour.rs diff --git a/crates/valence/examples/particles.rs b/examples/particles.rs similarity index 100% rename from crates/valence/examples/particles.rs rename to examples/particles.rs diff --git a/crates/valence/examples/player_list.rs b/examples/player_list.rs similarity index 100% rename from crates/valence/examples/player_list.rs rename to examples/player_list.rs diff --git a/crates/valence/examples/resource_pack.rs b/examples/resource_pack.rs similarity index 100% rename from crates/valence/examples/resource_pack.rs rename to examples/resource_pack.rs diff --git a/crates/valence/examples/server_list_ping.rs b/examples/server_list_ping.rs similarity index 95% rename from crates/valence/examples/server_list_ping.rs rename to examples/server_list_ping.rs index 7ce3793b4..25447b797 100644 --- a/crates/valence/examples/server_list_ping.rs +++ b/examples/server_list_ping.rs @@ -40,7 +40,7 @@ impl NetworkCallbacks for MyCallbacks { }], description: "Your IP address is ".into_text() + remote_addr.to_string().color(Color::GOLD), - favicon_png: include_bytes!("../../../assets/logo-64x64.png"), + favicon_png: include_bytes!("../assets/logo-64x64.png"), } } diff --git a/crates/valence/examples/terrain.rs b/examples/terrain.rs similarity index 100% rename from crates/valence/examples/terrain.rs rename to examples/terrain.rs diff --git a/crates/valence/examples/text.rs b/examples/text.rs similarity index 100% rename from crates/valence/examples/text.rs rename to examples/text.rs diff --git a/crates/valence/examples/world_border.rs b/examples/world_border.rs similarity index 100% rename from crates/valence/examples/world_border.rs rename to examples/world_border.rs diff --git a/crates/valence/src/lib.rs b/src/lib.rs similarity index 72% rename from crates/valence/src/lib.rs rename to src/lib.rs index 9ea686615..9ee2077cd 100644 --- a/crates/valence/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![doc = include_str!("../../../README.md")] // Points to the main project README. +#![doc = include_str!("../README.md")] // Points to the main project README. #![doc( html_logo_url = "https://raw.githubusercontent.com/valence-rs/valence/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/valence-rs/valence/main/assets/logo.svg" @@ -40,7 +40,7 @@ pub use valence_player_list as player_list; #[cfg(feature = "world_border")] pub use valence_world_border as world_border; pub use { - bevy_app as app, bevy_ecs as ecs, glam, valence_biome as biome, valence_block as block, + bevy_app, bevy_ecs, glam, valence_biome as biome, valence_block as block, valence_client as client, valence_dimension as dimension, valence_entity as entity, valence_instance as instance, valence_nbt as nbt, valence_registry as registry, }; @@ -58,62 +58,64 @@ pub use { /// ``` pub mod prelude { pub use ::uuid::Uuid; - pub use app::prelude::*; - pub use bevy_ecs; // Needed for bevy_ecs proc macros to function correctly. - pub use biome::{Biome, BiomeId, BiomeRegistry}; - pub use block::{BlockKind, BlockState, PropName, PropValue}; - pub use block_pos::BlockPos; - pub use chunk_pos::{ChunkPos, ChunkView}; - pub use client::action::*; - pub use client::command::*; - pub use client::event_loop::{EventLoopSchedule, EventLoopSet}; - pub use client::interact_entity::*; - pub use client::title::SetTitle as _; - pub use client::{ + pub use bevy_app::prelude::*; + pub use bevy_ecs; // Needed for bevy_ecs macros to function correctly. + pub use bevy_ecs::prelude::*; + pub use glam::{DVec2, DVec3, Vec2, Vec3}; + pub use ident::Ident; + #[cfg(feature = "advancement")] + pub use valence_advancement::{ + event::AdvancementTabChange, Advancement, AdvancementBundle, AdvancementClientUpdate, + AdvancementCriteria, AdvancementDisplay, AdvancementFrameType, AdvancementRequirements, + }; + pub use valence_biome::{Biome, BiomeId, BiomeRegistry}; + pub use valence_block::{BlockKind, BlockState, PropName, PropValue}; + pub use valence_client::action::{DiggingEvent, DiggingState}; + pub use valence_client::command::{ + ClientCommand, JumpWithHorseEvent, JumpWithHorseState, LeaveBedEvent, SneakEvent, + SneakState, SprintEvent, SprintState, + }; + pub use valence_client::event_loop::{EventLoopSchedule, EventLoopSet}; + pub use valence_client::interact_entity::{EntityInteraction, InteractEntityEvent}; + pub use valence_client::title::SetTitle as _; + pub use valence_client::{ despawn_disconnected_clients, Client, CompassPos, DeathLocation, HasRespawnScreen, HashedSeed, Ip, IsDebug, IsFlat, IsHardcore, OldView, OldViewDistance, PrevGameMode, Properties, ReducedDebugInfo, Username, View, ViewDistance, }; - pub use despawn::Despawned; - pub use dimension::{DimensionType, DimensionTypeRegistry}; - pub use direction::Direction; - pub use ecs::prelude::*; - pub use entity::{ + pub use valence_core::block_pos::BlockPos; + pub use valence_core::chunk_pos::{ChunkPos, ChunkView}; + pub use valence_core::despawn::Despawned; + pub use valence_core::direction::Direction; + pub use valence_core::game_mode::GameMode; + pub use valence_core::hand::Hand; + pub use valence_core::ident; // Export the `ident!` macro. + pub use valence_core::item::{ItemKind, ItemStack}; + pub use valence_core::particle::Particle; + pub use valence_core::text::{Color, Text, TextFormat}; + pub use valence_core::uuid::UniqueId; + pub use valence_core::{translation_key, CoreSettings, Server}; + pub use valence_dimension::{DimensionType, DimensionTypeRegistry}; + pub use valence_entity::hitbox::{Hitbox, HitboxShape}; + pub use valence_entity::{ EntityAnimation, EntityKind, EntityManager, EntityStatus, HeadYaw, Location, Look, OldLocation, OldPosition, Position, }; - pub use game_mode::GameMode; - pub use glam::{DVec2, DVec3, Vec2, Vec3}; - pub use hand::Hand; - pub use ident::Ident; - pub use instance::{Block, BlockMut, BlockRef, Chunk, Instance}; + pub use valence_instance::{Block, BlockMut, BlockRef, Chunk, Instance}; #[cfg(feature = "inventory")] - pub use inventory::{ + pub use valence_inventory::{ CursorItem, Inventory, InventoryKind, InventoryWindow, InventoryWindowMut, OpenInventory, }; - pub use item::{ItemKind, ItemStack}; - pub use nbt::Compound; + pub use valence_nbt::Compound; #[cfg(feature = "network")] - pub use network::{ - ErasedNetworkCallbacks, NetworkCallbacks, NetworkSettings, NewClientInfo, + pub use valence_network::{ + ConnectionMode, ErasedNetworkCallbacks, NetworkCallbacks, NetworkSettings, NewClientInfo, SharedNetworkState, }; - pub use particle::Particle; #[cfg(feature = "player_list")] - pub use player_list::{PlayerList, PlayerListEntry}; - pub use text::{Color, Text, TextFormat}; - #[cfg(feature = "advancement")] - pub use valence_advancement::{ - event::AdvancementTabChange, Advancement, AdvancementBundle, AdvancementClientUpdate, - AdvancementCriteria, AdvancementDisplay, AdvancementFrameType, AdvancementRequirements, - }; - pub use valence_core::ident; // Export the `ident!` macro. - pub use valence_core::uuid::UniqueId; - pub use valence_core::{translation_key, CoreSettings, Server}; - pub use valence_entity::hitbox::{Hitbox, HitboxShape}; + pub use valence_player_list::{PlayerList, PlayerListEntry}; pub use super::DefaultPlugins; - use super::*; } /// This plugin group will add all the default plugins for a Valence diff --git a/crates/valence/src/tests.rs b/src/tests.rs similarity index 100% rename from crates/valence/src/tests.rs rename to src/tests.rs diff --git a/crates/valence/src/tests/client.rs b/src/tests/client.rs similarity index 100% rename from crates/valence/src/tests/client.rs rename to src/tests/client.rs diff --git a/crates/valence/src/tests/example.rs b/src/tests/example.rs similarity index 94% rename from crates/valence/src/tests/example.rs rename to src/tests/example.rs index 35302c6d1..c0c9a1427 100644 --- a/crates/valence/src/tests/example.rs +++ b/src/tests/example.rs @@ -6,11 +6,14 @@ //! Some of the tests in this file may be inferior duplicates of real tests. use bevy_app::App; +use glam::DVec3; use valence_client::movement::PositionAndOnGroundC2s; +use valence_client::Client; +use valence_entity::Position; use valence_inventory::packet::{InventoryS2c, OpenScreenS2c}; +use valence_inventory::{Inventory, InventoryKind, OpenInventory}; use super::*; -use crate::prelude::*; /// The server's tick should increment every update. #[test] diff --git a/crates/valence/src/tests/inventory.rs b/src/tests/inventory.rs similarity index 100% rename from crates/valence/src/tests/inventory.rs rename to src/tests/inventory.rs diff --git a/crates/valence/src/tests/weather.rs b/src/tests/weather.rs similarity index 100% rename from crates/valence/src/tests/weather.rs rename to src/tests/weather.rs diff --git a/crates/valence/src/tests/world_border.rs b/src/tests/world_border.rs similarity index 100% rename from crates/valence/src/tests/world_border.rs rename to src/tests/world_border.rs diff --git a/tools/dump_schedule/Cargo.toml b/tools/dump_schedule/Cargo.toml index 58f6941e0..9a823137d 100644 --- a/tools/dump_schedule/Cargo.toml +++ b/tools/dump_schedule/Cargo.toml @@ -5,4 +5,4 @@ edition.workspace = true [dependencies] bevy_mod_debugdump.workspace = true -valence.path = "../../crates/valence" +valence.workspace = true diff --git a/tools/packet_inspector/Cargo.toml b/tools/packet_inspector/Cargo.toml index 457444007..dd5ca80bf 100644 --- a/tools/packet_inspector/Cargo.toml +++ b/tools/packet_inspector/Cargo.toml @@ -43,12 +43,11 @@ syntect = { workspace = true, default-features = false, optional = true, feature serde = { workspace = true, optional = true, features = ["derive"] } clap = { workspace = true, optional = true, features = ["derive"] } - [build-dependencies] -syn = "2.0.18" -anyhow = "1.0.71" -heck = "0.4.1" -proc-macro2 = "1.0.60" -quote = "1.0.28" -serde = { version = "1.0.164", features = ["derive"] } -serde_json = "1.0.96" +syn.workspace = true +anyhow.workspace = true +heck.workspace = true +proc-macro2.workspace = true +quote.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true diff --git a/tools/packet_inspector/README.md b/tools/packet_inspector/README.md index 1882ed754..5b510a31d 100644 --- a/tools/packet_inspector/README.md +++ b/tools/packet_inspector/README.md @@ -17,7 +17,7 @@ Firstly, we should have a server running that we're going to be proxying/inspecting. ```sh -cargo r -r --example conway +cargo r -r --example game_of_life ``` Next up, we need to run the proxy server, this can be done in 2 different ways, From 772f95b426a8b40d52c1b653249b4cd9bb4c65f4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Jun 2023 19:59:07 -0700 Subject: [PATCH 2/3] Update playground --- tools/playground/src/extras.rs | 4 ++-- tools/playground/src/main.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/playground/src/extras.rs b/tools/playground/src/extras.rs index d1e44d6fd..3415c5a73 100644 --- a/tools/playground/src/extras.rs +++ b/tools/playground/src/extras.rs @@ -1,14 +1,14 @@ //! Put stuff in here if you find that you have to write the same code for //! multiple playgrounds. -use valence::client::command::{SneakState, Sneaking}; +use valence::client::command::{SneakState, SneakEvent}; use valence::prelude::*; /// Toggles client's game mode between survival and creative when they start /// sneaking. pub fn toggle_gamemode_on_sneak( mut clients: Query<&mut GameMode>, - mut events: EventReader, + mut events: EventReader, ) { for event in events.iter() { if event.state == SneakState::Start { diff --git a/tools/playground/src/main.rs b/tools/playground/src/main.rs index 6d9a94f48..27ad0d189 100644 --- a/tools/playground/src/main.rs +++ b/tools/playground/src/main.rs @@ -18,7 +18,7 @@ use clap::Parser; use tracing::Level; -use valence::app::App; +use valence::bevy_app::App; #[allow(dead_code)] mod extras; From 422fd42e50618d3ac259b9dafbcba1ed9879d9dd Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Jun 2023 20:10:50 -0700 Subject: [PATCH 3/3] fmt --- tools/playground/src/extras.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/playground/src/extras.rs b/tools/playground/src/extras.rs index 3415c5a73..3b384d03c 100644 --- a/tools/playground/src/extras.rs +++ b/tools/playground/src/extras.rs @@ -1,7 +1,7 @@ //! Put stuff in here if you find that you have to write the same code for //! multiple playgrounds. -use valence::client::command::{SneakState, SneakEvent}; +use valence::client::command::{SneakEvent, SneakState}; use valence::prelude::*; /// Toggles client's game mode between survival and creative when they start