diff options
| author | mat <git@matdoes.dev> | 2023-07-23 23:21:08 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-07-23 23:21:08 -0500 |
| commit | 22ea8c60fed17e48a591bcbb82808fed55509386 (patch) | |
| tree | a85be1738270f7fb2a133b20629f2db0464e58f2 /azalea-client | |
| parent | 15acf1347727b84472e6a8a1c7a4f51cd3163f01 (diff) | |
| download | azalea-drasl-22ea8c60fed17e48a591bcbb82808fed55509386.tar.xz | |
fix sometimes not receiving chunks
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/events.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/local_player.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling.rs | 24 |
3 files changed, 22 insertions, 14 deletions
diff --git a/azalea-client/src/events.rs b/azalea-client/src/events.rs index b581fcee..d5a32449 100644 --- a/azalea-client/src/events.rs +++ b/azalea-client/src/events.rs @@ -7,11 +7,12 @@ use azalea_protocol::packets::game::{ clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, ClientboundGamePacket, }; use azalea_world::{InstanceName, MinecraftEntityId}; -use bevy_app::{App, FixedUpdate, Plugin, Update}; +use bevy_app::{App, FixedUpdate, Plugin, PreUpdate, Update}; use bevy_ecs::{ component::Component, event::EventReader, query::{Added, With}, + schedule::IntoSystemConfigs, system::Query, }; use derive_more::{Deref, DerefMut}; @@ -110,7 +111,6 @@ impl Plugin for EventPlugin { ( chat_listener, login_listener, - init_listener, packet_listener, add_player_listener, update_player_listener, @@ -119,6 +119,10 @@ impl Plugin for EventPlugin { keepalive_listener, ), ) + .add_systems( + PreUpdate, + init_listener.before(crate::packet_handling::process_packet_events), + ) .add_systems(FixedUpdate, tick_listener); } } diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs index 594513db..8317a72d 100644 --- a/azalea-client/src/local_player.rs +++ b/azalea-client/src/local_player.rs @@ -105,7 +105,9 @@ impl LocalPlayer { world, partial_instance: Arc::new(RwLock::new(PartialInstance::new( - client_information.view_distance.into(), + azalea_world::calculate_chunk_storage_range( + client_information.view_distance.into(), + ), Some(entity), ))), diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs index bf438de0..158fbb83 100644 --- a/azalea-client/src/packet_handling.rs +++ b/azalea-client/src/packet_handling.rs @@ -188,7 +188,7 @@ pub fn send_packet_events( } } -fn process_packet_events(ecs: &mut World) { +pub fn process_packet_events(ecs: &mut World) { let mut events_owned = Vec::new(); let mut system_state: SystemState<EventReader<PacketEvent>> = SystemState::new(ecs); let mut events = system_state.get_mut(ecs); @@ -254,7 +254,9 @@ fn process_packet_events(ecs: &mut World) { // instance_container) *local_player.partial_instance.write() = PartialInstance::new( - client_information.view_distance.into(), + azalea_world::calculate_chunk_storage_range( + client_information.view_distance.into(), + ), // this argument makes it so other clients don't update this // player entity // in a shared world @@ -282,25 +284,25 @@ fn process_packet_events(ecs: &mut World) { )); } - // send the client information that we have set - log::debug!( - "Sending client information because login: {:?}", - client_information - ); - local_player.write_packet(client_information.clone().get()); - // brand let mut brand_data = Vec::new(); - "vanilla".to_string().write_into(&mut brand_data).unwrap(); + // they don't have to know :) + "vanilla".write_into(&mut brand_data).unwrap(); local_player.write_packet( ServerboundCustomPayloadPacket { identifier: ResourceLocation::new("brand"), - // they don't have to know :) data: brand_data.into(), } .get(), ); + // send the client information that we have set + log::debug!( + "Sending client information because login: {:?}", + client_information + ); + local_player.write_packet(client_information.clone().get()); + system_state.apply(ecs); } ClientboundGamePacket::SetChunkCacheRadius(p) => { |
