Add Clientbound Client Informations (Play)
This commit is contained in:
parent
1ab05e0c00
commit
cfa20776f6
@ -6,5 +6,5 @@ use crate::VarInt;
|
||||
#[packet(0x54)]
|
||||
pub struct CCenterChunk {
|
||||
pub chunk_x: VarInt,
|
||||
pub chunk_z: VarInt
|
||||
pub chunk_z: VarInt,
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
mod c_center_chunk;
|
||||
mod c_actionbar;
|
||||
mod c_center_chunk;
|
||||
mod c_change_difficulty;
|
||||
mod c_chunk_data;
|
||||
mod c_chunk_data_update_light;
|
||||
@ -27,8 +27,8 @@ mod c_update_entity_pos;
|
||||
mod c_update_entity_rot;
|
||||
mod player_action;
|
||||
|
||||
pub use c_center_chunk::*;
|
||||
pub use c_actionbar::*;
|
||||
pub use c_center_chunk::*;
|
||||
pub use c_change_difficulty::*;
|
||||
pub use c_chunk_data::*;
|
||||
pub use c_chunk_data_update_light::*;
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::VarInt;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[packet(0x00)]
|
||||
pub struct SClientInformation {
|
||||
pub struct SClientInformationConfig {
|
||||
pub locale: String, // 16
|
||||
pub view_distance: i8,
|
||||
pub chat_mode: VarInt, // Varint
|
||||
|
||||
16
pumpkin-protocol/src/server/play/c_client_information.rs
Normal file
16
pumpkin-protocol/src/server/play/c_client_information.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use pumpkin_macros::packet;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[packet(0x0A)]
|
||||
pub struct SClientInformationPlay {
|
||||
pub locale: String, // 16
|
||||
pub view_distance: i8,
|
||||
pub chat_mode: VarInt, // Varint
|
||||
pub chat_colors: bool,
|
||||
pub skin_parts: u8,
|
||||
pub main_hand: VarInt,
|
||||
pub text_filtering: bool,
|
||||
pub server_listing: bool,
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
mod c_client_information;
|
||||
mod s_chat_command;
|
||||
mod s_chat_message;
|
||||
mod s_confirm_teleport;
|
||||
@ -7,6 +8,7 @@ mod s_player_position_rotation;
|
||||
mod s_player_rotation;
|
||||
mod s_swing_arm;
|
||||
|
||||
pub use c_client_information::*;
|
||||
pub use s_chat_command::*;
|
||||
pub use s_chat_message::*;
|
||||
pub use s_confirm_teleport::*;
|
||||
|
||||
@ -3,5 +3,5 @@ pub mod dimension;
|
||||
pub const WORLD_HEIGHT: usize = 384;
|
||||
pub const WORLD_Y_START_AT: i32 = -64;
|
||||
pub const DIRECT_PALETTE_BITS: u32 = 15;
|
||||
mod world;
|
||||
mod block_registry;
|
||||
mod world;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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(
|
||||
SAcknowledgeFinishConfig::PACKET_ID => {
|
||||
self.handle_config_acknowledged(
|
||||
server,
|
||||
SAcknowledgeFinishConfig::read(bytebuf).unwrap(),
|
||||
).await,
|
||||
)
|
||||
.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),
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,12 +13,17 @@ use mio::{event::Event, Poll, Token};
|
||||
use num_traits::ToPrimitive;
|
||||
use pumpkin_entity::{entity_type::EntityType, EntityId};
|
||||
use pumpkin_protocol::{
|
||||
bytebuf::ByteBuffer, client::{
|
||||
bytebuf::ByteBuffer,
|
||||
client::{
|
||||
config::CPluginMessage,
|
||||
play::{
|
||||
CCenterChunk, CChunkData, CChunkDataUpdateLight, CGameEvent, CLogin, CPlayerAbilities, CPlayerInfoUpdate, CRemoveEntities, CRemovePlayerInfo, CSetEntityMetadata, CSpawnEntity, Metadata, PlayerAction
|
||||
CCenterChunk, CChunkData, CChunkDataUpdateLight, CGameEvent, CLogin, CPlayerAbilities,
|
||||
CPlayerInfoUpdate, CRemoveEntities, CRemovePlayerInfo, CSetEntityMetadata,
|
||||
CSpawnEntity, Metadata, PlayerAction,
|
||||
},
|
||||
}, uuid::UUID, BitSet, ClientPacket, Players, Sample, StatusResponse, VarInt, Version, CURRENT_MC_PROTOCOL
|
||||
},
|
||||
uuid::UUID,
|
||||
BitSet, ClientPacket, Players, Sample, StatusResponse, VarInt, Version, CURRENT_MC_PROTOCOL,
|
||||
};
|
||||
use pumpkin_world::dimension::Dimension;
|
||||
|
||||
@ -329,9 +334,7 @@ impl Server {
|
||||
let chunks = Dimension::OverWorld
|
||||
.into_level(
|
||||
// TODO: load form config
|
||||
"./world"
|
||||
.parse()
|
||||
.unwrap(),
|
||||
"./world".parse().unwrap(),
|
||||
)
|
||||
.read_chunks(wanted_chunks)
|
||||
.await;
|
||||
@ -342,11 +345,16 @@ impl Server {
|
||||
});
|
||||
|
||||
chunks.iter().for_each(|chunk| {
|
||||
if chunk.0 == (0,0) {
|
||||
if chunk.0 == (0, 0) {
|
||||
let mut test = ByteBuffer::empty();
|
||||
CChunkData(chunk.1.as_ref().unwrap()).write(&mut test);
|
||||
let len = test.buf().len();
|
||||
dbg!("Chunk packet size: {}B {}KB {}MB", len, len/1024, len/(1024*1024));
|
||||
dbg!(
|
||||
"Chunk packet size: {}B {}KB {}MB",
|
||||
len,
|
||||
len / 1024,
|
||||
len / (1024 * 1024)
|
||||
);
|
||||
}
|
||||
match &chunk.1 {
|
||||
Err(err) => println!(
|
||||
@ -354,10 +362,8 @@ impl Server {
|
||||
chunk.0 .0, chunk.0 .1, err
|
||||
),
|
||||
Ok(data) => client.send_packet(&CChunkData(data)),
|
||||
}});
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// let test_chunk = TestChunk::new();
|
||||
// client.send_packet(CChunkDataUpdateLight::new(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user