aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-20 15:22:02 -0600
committermat <github@matdoes.dev>2021-12-20 15:22:02 -0600
commit6ae94b96e6d51e3bf251d4a01f17fa7d41c9500f (patch)
tree3153984562016e703eefd71b4b1de4151d47fdde /azalea-protocol/src/packets
parentcf88c7b7956398eba2e0d6ed86dbf3268fdb512b (diff)
downloadazalea-drasl-6ae94b96e6d51e3bf251d4a01f17fa7d41c9500f.tar.xz
start adding nbt to the protocol
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_login_packet.rs32
1 files changed, 25 insertions, 7 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
index 0e23460e..54205c48 100644
--- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
@@ -1,9 +1,8 @@
use super::GamePacket;
use crate::mc_buf::{Readable, Writable};
use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
-use std::hash::Hash;
-#[derive(Hash, Clone, Debug)]
+#[derive(Clone, Debug)]
pub struct ClientboundLoginPacket {
// private final int playerId;
// private final boolean hardcore;
@@ -27,7 +26,17 @@ pub struct ClientboundLoginPacket {
pub game_type: GameType,
pub previous_game_type: Option<GameType>,
pub levels: Vec<ResourceLocation>,
- // pub registry_holder: azalea_core::registry::RegistryAccess,
+ pub registry_holder: azalea_nbt::Tag,
+ pub dimension_type: azalea_nbt::Tag,
+ pub dimension: ResourceLocation,
+ pub seed: i64,
+ pub max_players: i32,
+ pub chunk_radius: i32,
+ pub simulation_distance: i32,
+ pub reduced_debug_info: bool,
+ pub show_death_screen: bool,
+ pub is_debug: bool,
+ pub is_flat: bool,
}
impl ClientboundLoginPacket {
@@ -35,10 +44,19 @@ impl ClientboundLoginPacket {
GamePacket::ClientboundLoginPacket(self)
}
- pub fn write(&self, buf: &mut Vec<u8>) {
- buf.write_int(self.player_id);
- // buf.write_bool(self.hardcore);
- // buf.write_byte(self.game_type.
+ pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
+ buf.write_int(self.player_id)?;
+ buf.write_boolean(self.hardcore)?;
+ buf.write_byte(self.game_type.to_id())?;
+ buf.write_byte(GameType::to_optional_id(&self.previous_game_type) as u8)?;
+ buf.write_list(&self.levels, |buf, resource_location| {
+ buf.write_utf(&resource_location.to_string())
+ })?;
+ self.registry_holder
+ .write(buf)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "write registry holder"))?;
+
+ Ok(())
}
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(