diff options
Diffstat (limited to 'azalea-client/src/test_utils/simulation.rs')
| -rw-r--r-- | azalea-client/src/test_utils/simulation.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/azalea-client/src/test_utils/simulation.rs b/azalea-client/src/test_utils/simulation.rs index aa3cef1b..4eff4454 100644 --- a/azalea-client/src/test_utils/simulation.rs +++ b/azalea-client/src/test_utils/simulation.rs @@ -25,7 +25,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::{Biome, DimensionType, EntityKind}; +use azalea_registry::{Biome, DataRegistry, DimensionType, EntityKind}; use azalea_world::{Chunk, Instance, MinecraftEntityId, Section, palette::PalettedContainer}; use bevy_app::App; use bevy_ecs::{component::Mutable, prelude::*, schedule::ExecutorKind}; @@ -127,6 +127,9 @@ impl Simulation { pub fn has_component<T: Component>(&self) -> bool { self.app.world().get::<T>(self.entity).is_some() } + pub fn with_component<T: Component>(&self, f: impl FnOnce(&T)) { + f(&mut self.app.world().entity(self.entity).get::<T>().unwrap()); + } pub fn with_component_mut<T: Component<Mutability = Mutable>>( &mut self, f: impl FnOnce(&mut T), @@ -293,6 +296,13 @@ fn tick_app(app: &mut App) { app.world_mut().run_schedule(GameTick); } +pub fn default_login_packet() -> ClientboundLogin { + make_basic_login_packet( + DimensionType::new_raw(0), // overworld + ResourceLocation::new("minecraft:overworld"), + ) +} + pub fn make_basic_login_packet( dimension_type: DimensionType, dimension: ResourceLocation, |
