From 75efbc83fdc4a47f880e95259a339d41839af01a Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 19 Mar 2025 21:35:47 +0000 Subject: make SendPacketEvent a bevy trigger --- azalea-client/tests/receive_start_config_packet.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 azalea-client/tests/receive_start_config_packet.rs (limited to 'azalea-client/tests') diff --git a/azalea-client/tests/receive_start_config_packet.rs b/azalea-client/tests/receive_start_config_packet.rs new file mode 100644 index 00000000..36762966 --- /dev/null +++ b/azalea-client/tests/receive_start_config_packet.rs @@ -0,0 +1,37 @@ +use azalea_client::{InConfigState, packet::game::SendPacketEvent, test_simulation::*}; +use azalea_core::resource_location::ResourceLocation; +use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundStartConfiguration}; +use azalea_registry::DimensionType; +use azalea_world::InstanceName; +use bevy_ecs::event::Events; +use bevy_log::tracing_subscriber; + +#[test] +fn test_receive_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(); + + // we shouldn't be using the `SendPacketEvent` event directly, we should be + // using the trigger instead + simulation.with_resource_mut::>(|send_packet_events| { + assert_eq!(send_packet_events.len(), 0); + }); + + simulation.receive_packet(ClientboundStartConfiguration); + + simulation.tick(); + assert!(simulation.has_component::()); + + // check again just in case + simulation.with_resource_mut::>(|send_packet_events| { + assert_eq!(send_packet_events.len(), 0); + }); +} -- cgit v1.2.3