aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/packet_handling
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2024-04-23 10:34:50 -0500
committerGitHub <noreply@github.com>2024-04-23 10:34:50 -0500
commit1d80f531b74bc3b31023753acb81b35efcdadd73 (patch)
tree675635c7c41fbb456e3e0dd7b9f09c7211d356f0 /azalea-client/src/packet_handling
parent0ddad8bd9c7c0e8846aec8bc90c95416418c9a63 (diff)
downloadazalea-drasl-1d80f531b74bc3b31023753acb81b35efcdadd73.tar.xz
1.20.5 (#127)
* 23w51b * make recalculate_near_end_of_path public so other plugins can do .after(recalculate_near_end_of_path) * update to 24w03a i think * start implementing 24w13a * registries work (but a lot of packets are still broken) * fix recipes and commands packets * i love codecs :D i am not going insane :D mojang's java is very readable :D * item components are "implemented" meowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeow * update to 1.20.5-pre3 * fix all the broken packets and clippy (mojang please don't do an update like this again or i will murder someone) * 1.20.5-rc1 * fix failing tests * 1.20.5
Diffstat (limited to 'azalea-client/src/packet_handling')
-rw-r--r--azalea-client/src/packet_handling/configuration.rs55
-rw-r--r--azalea-client/src/packet_handling/game.rs43
2 files changed, 60 insertions, 38 deletions
diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs
index da5ce57f..add36c6e 100644
--- a/azalea-client/src/packet_handling/configuration.rs
+++ b/azalea-client/src/packet_handling/configuration.rs
@@ -1,20 +1,18 @@
use std::io::Cursor;
-use std::sync::Arc;
use azalea_entity::indexing::EntityIdIndex;
use azalea_protocol::packets::configuration::serverbound_finish_configuration_packet::ServerboundFinishConfigurationPacket;
use azalea_protocol::packets::configuration::serverbound_keep_alive_packet::ServerboundKeepAlivePacket;
use azalea_protocol::packets::configuration::serverbound_pong_packet::ServerboundPongPacket;
use azalea_protocol::packets::configuration::serverbound_resource_pack_packet::ServerboundResourcePackPacket;
+use azalea_protocol::packets::configuration::serverbound_select_known_packs_packet::ServerboundSelectKnownPacksPacket;
use azalea_protocol::packets::configuration::{
ClientboundConfigurationPacket, ServerboundConfigurationPacket,
};
use azalea_protocol::packets::ConnectionProtocol;
use azalea_protocol::read::deserialize_packet;
-use azalea_world::Instance;
use bevy_ecs::prelude::*;
use bevy_ecs::system::SystemState;
-use parking_lot::RwLock;
use tracing::{debug, error, warn};
use crate::client::InConfigurationState;
@@ -22,6 +20,7 @@ use crate::disconnect::DisconnectEvent;
use crate::local_player::Hunger;
use crate::packet_handling::game::KeepAliveEvent;
use crate::raw_connection::RawConnection;
+use crate::InstanceHolder;
#[derive(Event, Debug, Clone)]
pub struct ConfigurationPacketEvent {
@@ -80,21 +79,14 @@ pub fn process_packet_events(ecs: &mut World) {
for (player_entity, packet) in events_owned {
match packet {
ClientboundConfigurationPacket::RegistryData(p) => {
- let mut instance = Instance::default();
-
- // override the old registries with the new ones
- // but if a registry wasn't sent, keep the old one
- for (registry_name, registry) in p.registry_holder.map {
- instance.registries.map.insert(registry_name, registry);
- }
+ let mut system_state: SystemState<Query<&mut InstanceHolder>> =
+ SystemState::new(ecs);
+ let mut query = system_state.get_mut(ecs);
+ let instance_holder = query.get_mut(player_entity).unwrap();
+ let mut instance = instance_holder.instance.write();
- let instance_holder = crate::local_player::InstanceHolder::new(
- player_entity,
- // default to an empty world, it'll be set correctly later when we
- // get the login packet
- Arc::new(RwLock::new(instance)),
- );
- ecs.entity_mut(player_entity).insert(instance_holder);
+ // add the new registry data
+ instance.registries.append(p.registry_id, p.entries);
}
ClientboundConfigurationPacket::CustomPayload(p) => {
@@ -200,6 +192,35 @@ pub fn process_packet_events(ecs: &mut World) {
ClientboundConfigurationPacket::UpdateTags(_p) => {
debug!("Got update tags packet");
}
+ ClientboundConfigurationPacket::CookieRequest(p) => {
+ debug!("Got cookie request packet {p:?}");
+ }
+ ClientboundConfigurationPacket::ResetChat(p) => {
+ debug!("Got reset chat packet {p:?}");
+ }
+ ClientboundConfigurationPacket::StoreCookie(p) => {
+ debug!("Got store cookie packet {p:?}");
+ }
+ ClientboundConfigurationPacket::Transfer(p) => {
+ debug!("Got transfer packet {p:?}");
+ }
+ ClientboundConfigurationPacket::SelectKnownPacks(p) => {
+ debug!("Got select known packs packet {p:?}");
+
+ let mut system_state: SystemState<Query<&RawConnection>> = SystemState::new(ecs);
+ let mut query = system_state.get_mut(ecs);
+ let raw_connection = query.get_mut(player_entity).unwrap();
+
+ // resource pack management isn't implemented
+ raw_connection
+ .write_packet(
+ ServerboundSelectKnownPacksPacket {
+ known_packs: vec![],
+ }
+ .get(),
+ )
+ .unwrap();
+ }
}
}
}
diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs
index 1c913ba5..dd2695dc 100644
--- a/azalea-client/src/packet_handling/game.rs
+++ b/azalea-client/src/packet_handling/game.rs
@@ -243,20 +243,20 @@ pub fn process_packet_events(ecs: &mut World) {
.insert(InstanceName(new_instance_name.clone()));
}
- let Some(dimension_type) =
+ let Some(dimension_type_element) =
instance_holder.instance.read().registries.dimension_type()
else {
error!("Server didn't send dimension type registry, can't log in");
continue;
};
- let dimension = &dimension_type
- .value
- .iter()
- .find(|t| t.name == p.common.dimension_type)
- .unwrap_or_else(|| {
- panic!("No dimension_type with name {}", p.common.dimension_type)
- })
- .element;
+
+ let dimension_type =
+ ResourceLocation::new(&p.common.dimension_type.to_string());
+
+ let dimension = dimension_type_element
+ .map
+ .get(&dimension_type)
+ .unwrap_or_else(|| panic!("No dimension_type with name {dimension_type}"));
// add this world to the instance_container (or don't if it's already
// there)
@@ -1288,9 +1288,6 @@ pub fn process_packet_events(ecs: &mut World) {
packet: ServerboundPongPacket { id: p.id }.get(),
});
}
- ClientboundGamePacket::PongResponse(p) => {
- debug!("Got pong response packet {p:?}");
- }
ClientboundGamePacket::PlaceGhostRecipe(_) => {}
ClientboundGamePacket::PlayerCombatEnd(_) => {}
ClientboundGamePacket::PlayerCombatEnter(_) => {}
@@ -1359,21 +1356,20 @@ pub fn process_packet_events(ecs: &mut World) {
{
let new_instance_name = p.common.dimension.clone();
- let Some(dimension_type) =
+ let Some(dimension_type_element) =
instance_holder.instance.read().registries.dimension_type()
else {
error!("Server didn't send dimension type registry, can't log in");
continue;
};
- let dimension = &dimension_type
- .value
- .iter()
- .find(|t| t.name == p.common.dimension_type)
- .unwrap_or_else(|| {
- panic!("No dimension_type with name {}", p.common.dimension_type)
- })
- .element;
+ let dimension_type =
+ ResourceLocation::new(&p.common.dimension_type.to_string());
+
+ let dimension = dimension_type_element
+ .map
+ .get(&dimension_type)
+ .unwrap_or_else(|| panic!("No dimension_type with name {dimension_type}"));
// add this world to the instance_container (or don't if it's already
// there)
@@ -1475,6 +1471,11 @@ pub fn process_packet_events(ecs: &mut World) {
ClientboundGamePacket::TickingStep(_) => {}
ClientboundGamePacket::ResetScore(_) => {}
+ ClientboundGamePacket::CookieRequest(_) => {}
+ ClientboundGamePacket::DebugSample(_) => {}
+ ClientboundGamePacket::PongResponse(_) => {}
+ ClientboundGamePacket::StoreCookie(_) => {}
+ ClientboundGamePacket::Transfer(_) => {}
}
}
}