aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs42
-rw-r--r--azalea-entity/src/plugin/mod.rs5
2 files changed, 47 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
+}
diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs
index 03afe7cd..6a6c9615 100644
--- a/azalea-entity/src/plugin/mod.rs
+++ b/azalea-entity/src/plugin/mod.rs
@@ -46,6 +46,11 @@ impl Plugin for EntityPlugin {
Update,
(
(
+ // remove_despawned_entities_from_indexes is done again here to correctly
+ // handle the case where an entity is spawned and then the world is removed at
+ // the same time (like with ClientboundStartConfiguration).
+ indexing::remove_despawned_entities_from_indexes
+ .in_set(EntityUpdateSet::Deindex),
indexing::update_entity_chunk_positions,
indexing::insert_entity_chunk_position,
)