Prepare ChatType registry
This commit is contained in:
1 parent
41442c5b5d
commit
5b636111e4
10 files changed
+99
-46
No files matched your search
@@ -15,7 +15,6 @@ use pumpkin_protocol::{
|
||||
},
|
||||
ConnectionState, KnownPack, RawBytes,
|
||||
};
|
||||
use pumpkin_registry::Registry;
|
||||
use pumpkin_text::TextComponent;
|
||||
use rsa::Pkcs1v15Encrypt;
|
||||
use sha1::{Digest, Sha1};
|
||||
@@ -150,7 +149,7 @@ impl Client {
|
||||
}
|
||||
|
||||
if let Some(profile) = self.gameprofile.as_ref().cloned() {
|
||||
let packet = CLoginSuccess::new(profile.id, profile.name, &profile.properties, false);
|
||||
let packet = CLoginSuccess::new(profile.id, &profile.name, &profile.properties, false);
|
||||
self.send_packet(packet);
|
||||
} else {
|
||||
self.kick("game profile is none");
|
||||
@@ -225,8 +224,8 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_known_packs(&mut self, _server: &mut Server, _config_acknowledged: SKnownPacks) {
|
||||
for registry in Registry::get_static() {
|
||||
pub fn handle_known_packs(&mut self, server: &mut Server, _config_acknowledged: SKnownPacks) {
|
||||
for registry in &server.cached_registry {
|
||||
self.send_packet(CRegistryData::new(
|
||||
®istry.registry_id,
|
||||
®istry.registry_entries,
|
||||
|
||||
@@ -2,8 +2,8 @@ use num_traits::FromPrimitive;
|
||||
use pumpkin_inventory::WindowType;
|
||||
use pumpkin_protocol::{
|
||||
client::play::{
|
||||
Animation, CEntityAnimation, CHeadRot, COpenScreen, CSystemChatMessge, CUpdateEntityPos,
|
||||
CUpdateEntityPosRot, CUpdateEntityRot,
|
||||
Animation, CEntityAnimation, CHeadRot, COpenScreen, CPlayerChatMessage, CUpdateEntityPos,
|
||||
CUpdateEntityPosRot, CUpdateEntityRot, FilterType,
|
||||
},
|
||||
server::play::{
|
||||
SChatCommand, SChatMessage, SConfirmTeleport, SPlayerCommand, SPlayerPosition,
|
||||
@@ -203,30 +203,30 @@ impl Client {
|
||||
let gameprofile = self.gameprofile.as_ref().unwrap();
|
||||
dbg!("got message");
|
||||
// yeah a "raw system message", the ugly way to do that, but it works
|
||||
// server.broadcast_packet(
|
||||
// self,
|
||||
// CSystemChatMessge::new(
|
||||
// TextComponent::from(format!("{}: {}", gameprofile.name, message)),
|
||||
// false,
|
||||
// ),
|
||||
// );
|
||||
server.broadcast_packet(
|
||||
self,
|
||||
CSystemChatMessge::new(
|
||||
TextComponent::from(format!("{}: {}", gameprofile.name, message)),
|
||||
false,
|
||||
CPlayerChatMessage::new(
|
||||
gameprofile.id,
|
||||
0.into(),
|
||||
None,
|
||||
message.clone(),
|
||||
chat_message.timestamp,
|
||||
chat_message.salt,
|
||||
&[],
|
||||
Some(TextComponent::from(message.clone())),
|
||||
pumpkin_protocol::VarInt(FilterType::PassThrough as i32),
|
||||
0.into(),
|
||||
TextComponent::from(gameprofile.name.clone()),
|
||||
None,
|
||||
),
|
||||
)
|
||||
/*server.broadcast_packet(
|
||||
self,
|
||||
CPlayerChatMessage::new(
|
||||
gameprofile.id,
|
||||
0.into(),
|
||||
None,
|
||||
message.clone(),
|
||||
chat_message.timestamp,
|
||||
chat_message.salt,
|
||||
&[],
|
||||
Some(TextComponent::from(message.clone())),
|
||||
pumpkin_protocol::VarInt(FilterType::PassThrough as i32),
|
||||
0.into(),
|
||||
TextComponent::from(gameprofile.name.clone()),
|
||||
None,
|
||||
),
|
||||
) */
|
||||
/* server.broadcast_packet(
|
||||
self,
|
||||
CDisguisedChatMessage::new(
|
||||
|
||||
@@ -22,6 +22,7 @@ use pumpkin_protocol::{
|
||||
},
|
||||
BitSet, ClientPacket, Players, Sample, StatusResponse, VarInt, Version, CURRENT_MC_PROTOCOL,
|
||||
};
|
||||
use pumpkin_registry::Registry;
|
||||
use pumpkin_world::chunk::TestChunk;
|
||||
use rsa::{traits::PublicKeyParts, RsaPrivateKey, RsaPublicKey};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -50,6 +51,9 @@ pub struct Server {
|
||||
/// Cache the Server brand buffer so we don't have to rebuild them every time a player joins
|
||||
pub cached_server_brand: Vec<u8>,
|
||||
|
||||
/// Cache the registry so we don't have to parse it every time a player joins
|
||||
pub cached_registry: Vec<Registry>,
|
||||
|
||||
pub current_clients: HashMap<Rc<Token>, Rc<RefCell<Client>>>,
|
||||
|
||||
// TODO: replace with HashMap <World, Player>
|
||||
@@ -89,6 +93,7 @@ impl Server {
|
||||
};
|
||||
|
||||
Self {
|
||||
cached_registry: Registry::get_static(),
|
||||
// 0 is invalid
|
||||
entity_id: 2.into(),
|
||||
// world: World::load(""),
|
||||
@@ -123,7 +128,7 @@ impl Server {
|
||||
// todo: put this into the entitiy struct
|
||||
if client.is_player() {
|
||||
let id = client.player.as_ref().unwrap().entity_id();
|
||||
self.broadcast_packet(&mut client, CRemoveEntities::new(vec![id.into()]))
|
||||
self.broadcast_packet(&mut client, CRemoveEntities::new(&[id.into()]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +145,7 @@ impl Server {
|
||||
client.send_packet(CLogin::new(
|
||||
entity_id,
|
||||
self.base_config.hardcore,
|
||||
vec!["minecraft:overworld".into()],
|
||||
&["minecraft:overworld"],
|
||||
self.base_config.max_players.into(),
|
||||
self.base_config.view_distance.into(), // TODO: view distance
|
||||
self.base_config.simulation_distance.into(), // TODO: sim view dinstance
|
||||
@@ -148,7 +153,7 @@ impl Server {
|
||||
false,
|
||||
false,
|
||||
0.into(),
|
||||
"minecraft:overworld".into(),
|
||||
"minecraft:overworld",
|
||||
0, // seed
|
||||
match self.base_config.default_gamemode {
|
||||
GameMode::Undefined => GameMode::Survival,
|
||||
|
||||
Reference in new issue
Block a user