mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
correctly accept resource packs while in config state
This commit is contained in:
parent
249fa55a53
commit
713b312167
2 changed files with 50 additions and 24 deletions
|
@ -12,6 +12,7 @@ use super::as_system;
|
|||
use crate::client::InConfigState;
|
||||
use crate::disconnect::DisconnectEvent;
|
||||
use crate::packet::game::KeepAliveEvent;
|
||||
use crate::packet::game::ResourcePackEvent;
|
||||
use crate::raw_connection::RawConnection;
|
||||
use crate::{InstanceHolder, declare_packet_handlers};
|
||||
|
||||
|
@ -151,16 +152,15 @@ impl ConfigPacketHandler<'_> {
|
|||
pub fn resource_pack_push(&mut self, p: ClientboundResourcePackPush) {
|
||||
debug!("Got resource pack push packet {p:?}");
|
||||
|
||||
as_system::<Query<&RawConnection>>(self.ecs, |query| {
|
||||
let raw_conn = query.get(self.player).unwrap();
|
||||
|
||||
// always accept resource pack
|
||||
raw_conn
|
||||
.write_packet(ServerboundResourcePack {
|
||||
id: p.id,
|
||||
action: s_resource_pack::Action::Accepted,
|
||||
})
|
||||
.unwrap();
|
||||
as_system::<EventWriter<_>>(self.ecs, |mut events| {
|
||||
events.send(ResourcePackEvent {
|
||||
entity: self.player,
|
||||
id: p.id,
|
||||
url: p.url.to_owned(),
|
||||
hash: p.hash.to_owned(),
|
||||
required: p.required,
|
||||
prompt: p.prompt.to_owned(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
use azalea_client::InConfigState;
|
||||
use azalea_client::chunks::handle_chunk_batch_finished_event;
|
||||
use azalea_client::inventory::InventorySet;
|
||||
use azalea_client::packet::config::SendConfigPacketEvent;
|
||||
use azalea_client::packet::game::SendPacketEvent;
|
||||
use azalea_client::packet::{death_event_on_0_health, game::ResourcePackEvent};
|
||||
use azalea_client::respawn::perform_respawn;
|
||||
use azalea_protocol::packets::config;
|
||||
use azalea_protocol::packets::game::s_resource_pack::{self, ServerboundResourcePack};
|
||||
use bevy_app::Update;
|
||||
use bevy_ecs::prelude::*;
|
||||
|
@ -28,21 +31,44 @@ impl Plugin for AcceptResourcePacksPlugin {
|
|||
fn accept_resource_pack(
|
||||
mut events: EventReader<ResourcePackEvent>,
|
||||
mut send_packet_events: EventWriter<SendPacketEvent>,
|
||||
mut send_config_packet_events: EventWriter<SendConfigPacketEvent>,
|
||||
query_in_config_state: Query<Option<&InConfigState>>,
|
||||
) {
|
||||
for event in events.read() {
|
||||
send_packet_events.send(SendPacketEvent::new(
|
||||
event.entity,
|
||||
ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: s_resource_pack::Action::Accepted,
|
||||
},
|
||||
));
|
||||
send_packet_events.send(SendPacketEvent::new(
|
||||
event.entity,
|
||||
ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: s_resource_pack::Action::SuccessfullyLoaded,
|
||||
},
|
||||
));
|
||||
let Ok(in_config_state_option) = query_in_config_state.get(event.entity) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if in_config_state_option.is_some() {
|
||||
send_config_packet_events.send(SendConfigPacketEvent::new(
|
||||
event.entity,
|
||||
config::ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: config::s_resource_pack::Action::Accepted,
|
||||
},
|
||||
));
|
||||
send_config_packet_events.send(SendConfigPacketEvent::new(
|
||||
event.entity,
|
||||
config::ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: config::s_resource_pack::Action::SuccessfullyLoaded,
|
||||
},
|
||||
));
|
||||
} else {
|
||||
send_packet_events.send(SendPacketEvent::new(
|
||||
event.entity,
|
||||
ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: s_resource_pack::Action::Accepted,
|
||||
},
|
||||
));
|
||||
send_packet_events.send(SendPacketEvent::new(
|
||||
event.entity,
|
||||
ServerboundResourcePack {
|
||||
id: event.id,
|
||||
action: s_resource_pack::Action::SuccessfullyLoaded,
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue