Add Clientbound Client Informations (Play)

This commit is contained in:
Snowiiii committed 2024-08-12 21:26:09 +02:00
1 parent 1ab05e0c00
commit cfa20776f6
11 files changed
+95 -45

No files matched your search

+3 -3
View File
@@ -8,7 +8,7 @@ use pumpkin_protocol::{
status::{CPingResponse, CStatusResponse},
},
server::{
config::{SAcknowledgeFinishConfig, SClientInformation, SKnownPacks, SPluginMessage},
config::{SAcknowledgeFinishConfig, SClientInformationConfig, SKnownPacks, SPluginMessage},
handshake::SHandShake,
login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart},
status::{SPingRequest, SStatusRequest},
@@ -195,10 +195,10 @@ impl Client {
}]));
dbg!("login achnowlaged");
}
pub fn handle_client_information(
pub fn handle_client_information_config(
&mut self,
_server: &mut Server,
client_information: SClientInformation,
client_information: SClientInformationConfig,
) {
dbg!("got client settings");
self.config = Some(PlayerConfig {
+18 -9
View File
@@ -23,12 +23,12 @@ use pumpkin_protocol::{
packet_decoder::PacketDecoder,
packet_encoder::PacketEncoder,
server::{
config::{SAcknowledgeFinishConfig, SClientInformation, SKnownPacks, SPluginMessage},
config::{SAcknowledgeFinishConfig, SClientInformationConfig, SKnownPacks, SPluginMessage},
handshake::SHandShake,
login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart},
play::{
SChatCommand, SChatMessage, SConfirmTeleport, SPlayerCommand, SPlayerPosition,
SPlayerPositionRotation, SPlayerRotation, SSwingArm,
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SPlayerCommand,
SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm,
},
status::{SPingRequest, SStatusRequest},
},
@@ -218,15 +218,20 @@ impl Client {
),
},
pumpkin_protocol::ConnectionState::Config => match packet.id.0 {
SClientInformation::PACKET_ID => self
.handle_client_information(server, SClientInformation::read(bytebuf).unwrap()),
SClientInformationConfig::PACKET_ID => self.handle_client_information_config(
server,
SClientInformationConfig::read(bytebuf).unwrap(),
),
SPluginMessage::PACKET_ID => {
self.handle_plugin_message(server, SPluginMessage::read(bytebuf).unwrap())
}
SAcknowledgeFinishConfig::PACKET_ID => self.handle_config_acknowledged(
server,
SAcknowledgeFinishConfig::read(bytebuf).unwrap(),
).await,
SAcknowledgeFinishConfig::PACKET_ID => {
self.handle_config_acknowledged(
server,
SAcknowledgeFinishConfig::read(bytebuf).unwrap(),
)
.await
}
SKnownPacks::PACKET_ID => {
self.handle_known_packs(server, SKnownPacks::read(bytebuf).unwrap())
}
@@ -273,6 +278,10 @@ impl Client {
SChatMessage::PACKET_ID => {
self.handle_chat_message(server, SChatMessage::read(bytebuf).unwrap())
}
SClientInformationPlay::PACKET_ID => self.handle_client_information_play(
server,
SClientInformationPlay::read(bytebuf).unwrap(),
),
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
}
}
+21 -4
View File
@@ -6,8 +6,8 @@ use pumpkin_protocol::{
CUpdateEntityRot,
},
server::play::{
SChatCommand, SChatMessage, SConfirmTeleport, SPlayerCommand, SPlayerPosition,
SPlayerPositionRotation, SPlayerRotation, SSwingArm,
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SPlayerCommand,
SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm,
},
VarInt,
};
@@ -15,12 +15,12 @@ use pumpkin_text::TextComponent;
use crate::{
commands::{handle_command, CommandSender},
entity::player::Hand,
entity::player::{ChatMode, Hand},
server::Server,
util::math::wrap_degrees,
};
use super::Client;
use super::{Client, PlayerConfig};
/// Handles all Play Packets send by a real Player
impl Client {
@@ -239,4 +239,21 @@ impl Client {
),
) */
}
pub fn handle_client_information_play(
&mut self,
_server: &mut Server,
client_information: SClientInformationPlay,
) {
self.config = Some(PlayerConfig {
locale: client_information.locale,
view_distance: client_information.view_distance,
chat_mode: ChatMode::from_i32(client_information.chat_mode.into()).unwrap(),
chat_colors: client_information.chat_colors,
skin_parts: client_information.skin_parts,
main_hand: Hand::from_i32(client_information.main_hand.into()).unwrap(),
text_filtering: client_information.text_filtering,
server_listing: client_information.server_listing,
});
}
}