diff options
| author | mat <git@matdoes.dev> | 2025-06-26 15:24:41 +0930 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-25 16:10:15 -1345 |
| commit | f12589ab809ece7dfd34c58b2ddc67dd5801ccb3 (patch) | |
| tree | 7ffef4672378715c92d82749d3ef1a82cc7f9f24 /azalea-client/tests/packet_order.rs | |
| parent | 08c409d04896e7057c31250f2d6f99c75b8af5b5 (diff) | |
| download | azalea-drasl-f12589ab809ece7dfd34c58b2ddc67dd5801ccb3.tar.xz | |
fix invalid look directions on teleport
Diffstat (limited to 'azalea-client/tests/packet_order.rs')
| -rw-r--r-- | azalea-client/tests/packet_order.rs | 72 |
1 files changed, 1 insertions, 71 deletions
diff --git a/azalea-client/tests/packet_order.rs b/azalea-client/tests/packet_order.rs index d4dd2558..014d9f46 100644 --- a/azalea-client/tests/packet_order.rs +++ b/azalea-client/tests/packet_order.rs @@ -1,8 +1,4 @@ -use std::{collections::VecDeque, sync::Arc}; - -use azalea_client::{ - SprintDirection, StartSprintEvent, packet::game::SendPacketEvent, test_utils::prelude::*, -}; +use azalea_client::{SprintDirection, StartSprintEvent, test_utils::prelude::*}; use azalea_core::{ position::{BlockPos, ChunkPos, Vec3}, resource_location::ResourceLocation, @@ -21,8 +17,6 @@ use azalea_protocol::{ }, }; use azalea_registry::{Block, DataRegistry, DimensionType}; -use bevy_ecs::observer::Trigger; -use parking_lot::Mutex; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] @@ -73,13 +67,10 @@ fn test_packet_order() { relative: RelativeMovements::all_absolute(), }); simulation.tick(); - assert_eq!( simulation.get_block_state(BlockPos::new(1, 1, 3)), Some(Block::Stone.into()) ); - - println!("sent_packets: {:?}", sent_packets.list.lock()); sent_packets.expect("AcceptTeleportation", |p| { matches!( p, @@ -160,64 +151,3 @@ fn test_packet_order() { sent_packets.expect_tick_end(); sent_packets.expect_empty(); } - -#[derive(Clone)] -pub struct SentPackets { - list: Arc<Mutex<VecDeque<ServerboundGamePacket>>>, -} -impl SentPackets { - pub fn new(simulation: &mut Simulation) -> Self { - let sent_packets = SentPackets { - list: Default::default(), - }; - - let simulation_entity = simulation.entity; - let sent_packets_clone = sent_packets.clone(); - simulation - .app - .add_observer(move |trigger: Trigger<SendPacketEvent>| { - if trigger.sent_by == simulation_entity { - sent_packets_clone - .list - .lock() - .push_back(trigger.event().packet.clone()) - } - }); - - sent_packets - } - - pub fn clear(&self) { - self.list.lock().clear(); - } - - pub fn expect_tick_end(&self) { - self.expect("TickEnd", |p| { - matches!(p, ServerboundGamePacket::ClientTickEnd(_)) - }); - } - pub fn expect_empty(&self) { - let sent_packet = self.next(); - if let None = sent_packet { - } else { - panic!("Expected no packet, got {sent_packet:?}"); - } - } - pub fn expect( - &self, - expected_formatted: &str, - check: impl FnOnce(&ServerboundGamePacket) -> bool, - ) { - let sent_packet = self.next(); - if let Some(sent_packet) = sent_packet { - if !check(&sent_packet) { - panic!("Expected {expected_formatted}, got {sent_packet:?}"); - } - } else { - panic!("Expected {expected_formatted}, got nothing"); - } - } - pub fn next(&self) -> Option<ServerboundGamePacket> { - self.list.lock().pop_front() - } -} |
