aboutsummaryrefslogtreecommitdiff
path: root/azalea-client
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-04 21:53:06 -0600
committermat <git@matdoes.dev>2025-06-04 21:53:06 -0600
commitbe81877137df57de26030bceecbef68b9f05b3e5 (patch)
treea90f448668a012ec563b5dd8da28f551cf8fb87b /azalea-client
parent93a96786a8a46068f5d9d7d3e503645d7fc4b830 (diff)
downloadazalea-drasl-be81877137df57de26030bceecbef68b9f05b3e5.tar.xz
fix panic when receiving add_entity and start_configuration in the same update
Diffstat (limited to 'azalea-client')
-rw-r--r--azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs42
1 files changed, 42 insertions, 0 deletions
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::<InstanceName>());
+ 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::<InConfigState>());
+
+ // make sure that the entity is despawned
+}