From be81877137df57de26030bceecbef68b9f05b3e5 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 4 Jun 2025 21:53:06 -0600 Subject: fix panic when receiving add_entity and start_configuration in the same update --- ...receive_spawn_entity_and_start_config_packet.rs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs (limited to 'azalea-client') diff --git a/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs new file mode 100644 index 00000000..d64d2209 --- /dev/null +++ b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs @@ -0,0 +1,42 @@ +use azalea_client::{InConfigState, test_simulation::*}; +use azalea_core::{position::Vec3, resource_location::ResourceLocation}; +use azalea_protocol::packets::{ + ConnectionProtocol, + game::{ClientboundAddEntity, ClientboundStartConfiguration}, +}; +use azalea_registry::{DataRegistry, DimensionType, EntityKind}; +use azalea_world::InstanceName; +use bevy_log::tracing_subscriber; +use uuid::Uuid; + +#[test] +fn test_receive_spawn_entity_and_start_config_packet() { + let _ = tracing_subscriber::fmt::try_init(); + + let mut simulation = Simulation::new(ConnectionProtocol::Game); + simulation.receive_packet(make_basic_login_packet( + DimensionType::new_raw(0), + ResourceLocation::new("minecraft:overworld"), + )); + simulation.tick(); + assert!(simulation.has_component::()); + simulation.tick(); + + simulation.receive_packet(ClientboundAddEntity { + id: 123.into(), + uuid: Uuid::new_v4(), + entity_type: EntityKind::ArmorStand, + position: Vec3::ZERO, + x_rot: 0, + y_rot: 0, + y_head_rot: 0, + data: 0, + velocity: Default::default(), + }); + simulation.receive_packet(ClientboundStartConfiguration); + + simulation.tick(); + assert!(simulation.has_component::()); + + // make sure that the entity is despawned +} -- cgit v1.2.3