mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 23:44:38 +00:00
fix panic when receiving add_entity and start_configuration in the same update
This commit is contained in:
parent
93a96786a8
commit
be81877137
2 changed files with 47 additions and 0 deletions
|
@ -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
|
||||||
|
}
|
|
@ -46,6 +46,11 @@ impl Plugin for EntityPlugin {
|
||||||
Update,
|
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::update_entity_chunk_positions,
|
||||||
indexing::insert_entity_chunk_position,
|
indexing::insert_entity_chunk_position,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue