diff options
| author | mat <git@matdoes.dev> | 2025-12-22 21:43:54 -1400 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-12-22 21:43:54 -1400 |
| commit | 82e3d46ca319badcbc584cf902aeebcbd30948b9 (patch) | |
| tree | 4afb8c6135caacbdf9f1f04d451cb2bae1c488b6 /azalea-client/tests/simulation/move_despawned_entity.rs | |
| parent | 0429a81d706da7c45600d357f9f9a14cef6113b4 (diff) | |
| download | azalea-drasl-82e3d46ca319badcbc584cf902aeebcbd30948b9.tar.xz | |
run azalea-client integration tests as one binary
per https://corrode.dev/blog/tips-for-faster-rust-compile-times/\#combine-all-integration-tests-into-a-single-binary <3
Diffstat (limited to 'azalea-client/tests/simulation/move_despawned_entity.rs')
| -rw-r--r-- | azalea-client/tests/simulation/move_despawned_entity.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/azalea-client/tests/simulation/move_despawned_entity.rs b/azalea-client/tests/simulation/move_despawned_entity.rs new file mode 100644 index 00000000..7a171dae --- /dev/null +++ b/azalea-client/tests/simulation/move_despawned_entity.rs @@ -0,0 +1,45 @@ +use azalea_client::test_utils::prelude::*; +use azalea_core::position::ChunkPos; +use azalea_entity::metadata::Cow; +use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundMoveEntityRot}; +use azalea_registry::builtin::EntityKind; +use azalea_world::MinecraftEntityId; +use bevy_ecs::query::With; +use tracing::Level; + +#[test] +fn test_move_despawned_entity() { + let _lock = init_with_level(Level::ERROR); // a warning is expected here + + let mut simulation = Simulation::new(ConnectionProtocol::Game); + simulation.receive_packet(default_login_packet()); + + simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16)); + simulation.tick(); + // spawn a cow + simulation.receive_packet(make_basic_add_entity(EntityKind::Cow, 123, (0.5, 64., 0.5))); + simulation.tick(); + + // make sure it's spawned + let mut cow_query = simulation.app.world_mut().query_filtered::<(), With<Cow>>(); + let cow_iter = cow_query.iter(simulation.app.world()); + assert_eq!(cow_iter.count(), 1, "cow should be spawned"); + + // despawn the cow by receiving a login packet + simulation.receive_packet(default_login_packet()); + simulation.tick(); + + // make sure it's despawned + let mut cow_query = simulation.app.world_mut().query_filtered::<(), With<Cow>>(); + let cow_iter = cow_query.iter(simulation.app.world()); + assert_eq!(cow_iter.count(), 0, "cow should be despawned"); + + // send a move_entity_rot + simulation.receive_packet(ClientboundMoveEntityRot { + entity_id: MinecraftEntityId(123), + y_rot: 0, + x_rot: 0, + on_ground: false, + }); + simulation.tick(); +} |
