diff options
| author | mat <git@matdoes.dev> | 2025-06-09 17:15:07 +0900 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-09 17:15:07 +0900 |
| commit | 4a4de819616d620d15680e71fb32390e28ab07cd (patch) | |
| tree | 9bd1159dec3527b07651d0d9c78f96c95d115e7b /azalea-client/tests | |
| parent | 45d73712746fbfd365e8a68a75dfad6ae2e0d174 (diff) | |
| download | azalea-drasl-4a4de819616d620d15680e71fb32390e28ab07cd.tar.xz | |
handle relative teleports correctly and fix entity chunk indexing warnings
Diffstat (limited to 'azalea-client/tests')
| -rw-r--r-- | azalea-client/tests/move_and_despawn_entity.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/azalea-client/tests/move_and_despawn_entity.rs b/azalea-client/tests/move_and_despawn_entity.rs new file mode 100644 index 00000000..080ca903 --- /dev/null +++ b/azalea-client/tests/move_and_despawn_entity.rs @@ -0,0 +1,57 @@ +use azalea_client::test_utils::prelude::*; +use azalea_core::{ + position::{ChunkPos, Vec3}, + resource_location::ResourceLocation, +}; +use azalea_entity::metadata::Cow; +use azalea_protocol::{ + common::movements::{PositionMoveRotation, RelativeMovements}, + packets::{ + ConnectionProtocol, + game::{ClientboundRemoveEntities, ClientboundTeleportEntity}, + }, +}; +use azalea_registry::{DataRegistry, DimensionType, EntityKind}; +use azalea_world::MinecraftEntityId; +use bevy_ecs::query::With; + +#[test] +fn test_move_and_despawn_entity() { + init_tracing(); + + let mut simulation = Simulation::new(ConnectionProtocol::Game); + simulation.receive_packet(make_basic_login_packet( + DimensionType::new_raw(0), + ResourceLocation::new("azalea:overworld"), + )); + + for x in 0..=10 { + simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(x, 0), (384 + 64) / 16)); + } + simulation.tick(); + + simulation.receive_packet(make_basic_add_entity(EntityKind::Cow, 123, (0.5, 64., 0.5))); + simulation.tick(); + + simulation.receive_packet(ClientboundTeleportEntity { + id: MinecraftEntityId(123), + change: PositionMoveRotation { + pos: Vec3::new(16., 0., 0.), + delta: Vec3::ZERO, + look_direction: Default::default(), + }, + relative: RelativeMovements::all_relative(), + on_ground: true, + }); + simulation.receive_packet(ClientboundRemoveEntities { + entity_ids: vec![MinecraftEntityId(123)], + }); + 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"); + + simulation.tick(); +} |
