1
2
Fork 0
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:
mat 2025-03-13 21:01:37 +00:00
parent 249fa55a53
commit 713b312167
2 changed files with 50 additions and 24 deletions

View file

@ -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 {
as_system::<EventWriter<_>>(self.ecs, |mut events| {
events.send(ResourcePackEvent {
entity: self.player,
id: p.id,
action: s_resource_pack::Action::Accepted,
})
.unwrap();
url: p.url.to_owned(),
hash: p.hash.to_owned(),
required: p.required,
prompt: p.prompt.to_owned(),
});
});
}

View file

@ -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,8 +31,30 @@ 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() {
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 {
@ -46,3 +71,4 @@ fn accept_resource_pack(
));
}
}
}