aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-23 19:17:04 -0500
committermat <github@matdoes.dev>2022-06-23 19:17:04 -0500
commit37c6618c16319a7f40fd2e165190407472598e84 (patch)
tree6d712df8893041f0e49cfa6ca7adc9a411d39b84 /azalea-protocol
parent1089aa7961bd9af67c94dec9c5dbc6bd9f275225 (diff)
downloadazalea-drasl-37c6618c16319a7f40fd2e165190407472598e84.tar.xz
Fix everything so azalea-buf works
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/Cargo.toml1
-rwxr-xr-xazalea-protocol/packet-macros/src/lib.rs4
-rwxr-xr-xazalea-protocol/src/lib.rs1
-rw-r--r--azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs19
-rw-r--r--azalea-protocol/src/packets/game/clientbound_add_player_packet.rs19
-rw-r--r--azalea-protocol/src/packets/game/clientbound_animate_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_block_update_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs7
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs15
-rw-r--r--azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_game_event_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_event_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_light_update_packet.rs5
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_login_packet.rs7
-rw-r--r--azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_info_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_position_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_recipe_packet.rs7
-rw-r--r--azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_server_data_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs5
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_health_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_time_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_sound_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs6
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs7
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs11
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_tags_packet.rs33
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs7
-rw-r--r--azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_move_player_packet_pos.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_move_player_packet_pos_rot.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_move_player_packet_rot.rs3
-rw-r--r--azalea-protocol/src/packets/game/serverbound_move_player_packet_status_only.rs3
-rwxr-xr-xazalea-protocol/src/packets/handshake/client_intention_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_custom_query_packet.rs6
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_game_profile_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_hello_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_login_compression_packet.rs2
-rw-r--r--azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/login/serverbound_hello_packet.rs3
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs5
-rwxr-xr-xazalea-protocol/src/packets/mod.rs11
-rwxr-xr-xazalea-protocol/src/packets/status/clientbound_status_response_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/status/serverbound_status_request_packet.rs3
-rwxr-xr-xazalea-protocol/src/read.rs7
-rwxr-xr-xazalea-protocol/src/write.rs3
75 files changed, 231 insertions, 132 deletions
diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml
index dadb212c..280879dd 100755
--- a/azalea-protocol/Cargo.toml
+++ b/azalea-protocol/Cargo.toml
@@ -14,6 +14,7 @@ azalea-buf = {path = "../azalea-buf"}
azalea-chat = {path = "../azalea-chat"}
azalea-core = {path = "../azalea-core", optional = true}
azalea-crypto = {path = "../azalea-crypto"}
+azalea-entity = {path = "../azalea-entity"}
azalea-nbt = {path = "../azalea-nbt"}
byteorder = "^1.4.3"
bytes = "^1.1.0"
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs
index 56b5dc52..58487cdd 100755
--- a/azalea-protocol/packet-macros/src/lib.rs
+++ b/azalea-protocol/packet-macros/src/lib.rs
@@ -25,13 +25,13 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
}
pub fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- crate::mc_buf::McBufWritable::write_into(self, buf)
+ azalea_buf::McBufWritable::write_into(self, buf)
}
pub fn read(
buf: &mut impl std::io::Read,
) -> Result<#state, String> {
- use crate::mc_buf::McBufReadable;
+ use azalea_buf::McBufReadable;
Ok(Self::read_into(buf)?.get())
}
}
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs
index cadbb437..b1d1a9c4 100755
--- a/azalea-protocol/src/lib.rs
+++ b/azalea-protocol/src/lib.rs
@@ -5,7 +5,6 @@ use std::str::FromStr;
#[cfg(feature = "connecting")]
pub mod connect;
-pub mod mc_buf;
#[cfg(feature = "packets")]
pub mod packets;
pub mod read;
diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
index 9ef7e05c..0fc7b817 100644
--- a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
@@ -1,4 +1,7 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::EntityPos;
+use azalea_entity::Entity;
+use packet_macros::GamePacket;
use uuid::Uuid;
#[derive(Clone, Debug, McBuf, GamePacket)]
@@ -22,3 +25,17 @@ pub struct ClientboundAddEntityPacket {
pub y_vel: i16,
pub z_vel: i16,
}
+
+impl From<&ClientboundAddEntityPacket> for Entity {
+ fn from(p: &ClientboundAddEntityPacket) -> Self {
+ Self::new(
+ p.id,
+ p.uuid,
+ EntityPos {
+ x: p.x,
+ y: p.y,
+ z: p.z,
+ },
+ )
+ }
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
index 4dae88a5..ddadc73f 100644
--- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
@@ -1,4 +1,7 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::EntityPos;
+use azalea_entity::Entity;
+use packet_macros::GamePacket;
use uuid::Uuid;
/// This packet is sent by the server when a player comes into visible range, not when a player joins.
@@ -13,3 +16,17 @@ pub struct ClientboundAddPlayerPacket {
pub x_rot: i8,
pub y_rot: i8,
}
+
+impl From<&ClientboundAddPlayerPacket> for Entity {
+ fn from(p: &ClientboundAddPlayerPacket) -> Self {
+ Self::new(
+ p.id,
+ p.uuid,
+ EntityPos {
+ x: p.x,
+ y: p.y,
+ z: p.z,
+ },
+ )
+ }
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
index 0bba1a25..e554da0a 100644
--- a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundAnimatePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs
index a580440c..2901cb82 100644
--- a/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_block_changed_ack_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundBlockChangedAckPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs
index f068cc7d..769270ee 100644
--- a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_core::BlockPos;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundBlockUpdatePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs
index edda52d9..57cb1f69 100755
--- a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs
@@ -1,5 +1,6 @@
-use azalea_core::difficulty::Difficulty;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::Difficulty;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundChangeDifficultyPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
index 58dd0722..75bf0cf7 100644
--- a/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundChatPreviewPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs
index d38bbfda..721937a7 100644
--- a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_core::Slot;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundContainerSetContentPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
index b9ccbba4..d01e7459 100755
--- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::UnsizedByteArray;
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::UnsizedByteArray;
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundCustomPayloadPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
index 648ca9e0..bf29a050 100755
--- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
@@ -1,8 +1,9 @@
use super::GamePacket;
-use crate::mc_buf::McBufVarReadable;
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::McBufVarReadable;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
use std::{
hash::Hash,
io::{Read, Write},
@@ -182,10 +183,10 @@ impl McBufReadable for BrigadierParser {
41 => Ok(BrigadierParser::Dimension),
42 => Ok(BrigadierParser::Time),
43 => Ok(BrigadierParser::ResourceOrTag {
- registry_key: buf.read_resource_location()?,
+ registry_key: ResourceLocation::read_into(buf)?,
}),
44 => Ok(BrigadierParser::Resource {
- registry_key: buf.read_resource_location()?,
+ registry_key: ResourceLocation::read_into(buf)?,
}),
45 => Ok(BrigadierParser::TemplateMirror),
46 => Ok(BrigadierParser::TemplateRotation),
@@ -218,7 +219,7 @@ impl McBufReadable for BrigadierNodeStub {
let _name = buf.read_utf()?;
let _parser = BrigadierParser::read_into(buf)?;
let _suggestions_type = if has_suggestions_type {
- Some(buf.read_resource_location()?)
+ Some(ResourceLocation::read_into(buf)?)
} else {
None
};
diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
index c030d512..e5f35dc9 100644
--- a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundDisconnectPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs
index d0cc7222..a6f6e38d 100644
--- a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
// we can't identify the status in azalea-protocol since they vary depending on the entity
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs
index 07218c4e..7e2fa606 100644
--- a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundEntityVelocityPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
index dd5f08f6..f5cb13a1 100644
--- a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundGameEventPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs
index a522eba3..f759cfc9 100644
--- a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundInitializeBorderPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs
index 18628c86..adaca872 100644
--- a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundKeepAlivePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
index 43bda0b6..f105bd6a 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData;
diff --git a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs
index 70926268..42c5f412 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_core::BlockPos;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundLevelEventPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
index 9ed08d8a..df1174b7 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
@@ -1,5 +1,5 @@
-use crate::mc_buf::McBufVarReadable;
-use crate::mc_buf::{McBufReadable, McBufWritable, ParticleData};
+use azalea_buf::{McBufReadable, McBufVarReadable, McBufWritable};
+use azalea_core::ParticleData;
use packet_macros::GamePacket;
use std::io::{Read, Write};
diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
index f04987ac..adb6e33b 100644
--- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
@@ -1,5 +1,6 @@
-use crate::mc_buf::BitSet;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::BitSet;
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundLightUpdatePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
index 6ddc6b5a..6b144bac 100755
--- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
@@ -1,12 +1,13 @@
-use azalea_core::{game_type::GameType, resource_location::ResourceLocation, GlobalPos};
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::{GameType, GlobalPos, OptionalGameType, ResourceLocation};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundLoginPacket {
pub player_id: u32,
pub hardcore: bool,
pub game_type: GameType,
- pub previous_game_type: Option<GameType>,
+ pub previous_game_type: OptionalGameType,
pub levels: Vec<ResourceLocation>,
pub registry_holder: azalea_nbt::Tag,
pub dimension_type: ResourceLocation,
diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs
index 714917b7..3dc789a9 100644
--- a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs
@@ -1,5 +1,6 @@
-use azalea_core::EntityPos;
-use packet_macros::{GamePacket, McBuf};
+use azalea_core::{EntityPos, PositionDelta};
+use packet_macros::GamePacket;
+use azalea_buf::McBuf;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundMoveEntityPosPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs
index b02a2981..dd1d96e1 100644
--- a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs
@@ -1,5 +1,6 @@
-use super::clientbound_move_entity_pos_packet::PositionDelta;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::PositionDelta;
+use packet_macros::GamePacket;
/// This packet is sent by the server when an entity moves less then 8 blocks.
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs
index c8d0170b..85515628 100644
--- a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundMoveEntityRotPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
index c3387f7f..d351ab04 100755
--- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
@@ -1,5 +1,6 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable};
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable};
+use packet_macros::GamePacket;
use std::io::{Read, Write};
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
index e6941f25..4aac93f4 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
@@ -1,6 +1,7 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
use azalea_crypto::SaltSignaturePair;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundPlayerChatPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
index cb17f1f5..f216fde8 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
use std::io::{Read, Write};
use uuid::Uuid;
diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
index 0457269a..2c5504fa 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
@@ -1,5 +1,6 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable};
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable};
+use packet_macros::GamePacket;
use std::io::{Read, Write};
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
index e76504cc..a79bfcf1 100644
--- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
use std::io::{Read, Write};
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs
index 8f51596d..8c76ec15 100644
--- a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundRemoveEntitiesPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs
index 71b485ae..dc7ec881 100644
--- a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundRotateHeadPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
index 6c429edb..6ee27ed1 100644
--- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos};
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
use std::io::{Read, Write};
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
index 4c2d94e6..1dddfc1e 100644
--- a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundServerDataPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs
index 003b6ccc..a4ecaaab 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
/// Sent to change the player's slot selection.
#[derive(Clone, Debug, McBuf, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs
index 7557c16b..ee86ec9d 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetChunkCacheCenterPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs
index 7ac42c5c..9e9a7b87 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_core::BlockPos;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetDefaultSpawnPositionPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs
index 46a0d582..8e2cfe70 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_display_chat_preview_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetDisplayChatPreviewPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
index 8a568689..cc76ddf1 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
@@ -1,5 +1,6 @@
-use crate::mc_buf::EntityMetadata;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_entity::EntityMetadata;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetEntityDataPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs
index e6e3af67..ec1ee0ec 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetEntityLinkPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
index 3acbd58f..aa352189 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
@@ -1,7 +1,8 @@
+use azalea_buf::McBuf;
use azalea_core::Slot;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
-use crate::mc_buf::{McBufReadable, McBufWritable};
+use azalea_buf::{McBufReadable, McBufWritable};
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetEquipmentPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs
index bcb6393d..7387f6dc 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetExperiencePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs
index 6c75cf63..b99fe86a 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetHealthPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs
index 4cad0693..ea4437b7 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSetTimePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
index fbc5830b..a8607599 100644
--- a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSoundPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
index dfa75a5b..c531fa1e 100644
--- a/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBuf};
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundSystemChatPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
index c10db7b9..433b0727 100644
--- a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundTeleportEntityPacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
index daa1ac93..43e4d69f 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
@@ -1,7 +1,7 @@
-use crate::packets::{McBufReadable, McBufWritable};
+use azalea_buf::{McBuf, McBufReadable, McBufWritable};
use azalea_chat::component::Component;
-use azalea_core::{resource_location::ResourceLocation, Slot};
-use packet_macros::{GamePacket, McBuf};
+use azalea_core::{ResourceLocation, Slot};
+use packet_macros::GamePacket;
use std::{
collections::HashMap,
io::{Read, Write},
diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
index d0e7c9ee..3eca2a84 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
use std::io::{Read, Write};
use uuid::Uuid;
diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
index 27839919..05d57695 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
@@ -1,9 +1,10 @@
use std::io::{Read, Write};
-use azalea_core::{resource_location::ResourceLocation, Slot};
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_core::{ResourceLocation, Slot};
+use packet_macros::GamePacket;
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundUpdateRecipesPacket {
@@ -129,8 +130,8 @@ impl McBufWritable for Recipe {
impl McBufReadable for Recipe {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let recipe_type = buf.read_resource_location()?;
- let identifier = buf.read_resource_location()?;
+ let recipe_type = ResourceLocation::read_into(buf)?;
+ let identifier = ResourceLocation::read_into(buf)?;
// rust doesn't let us match ResourceLocation so we have to do a big
// if-else chain :(
diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
index 60794f03..cf3bc069 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
@@ -1,6 +1,8 @@
-use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
+use std::ops::Deref;
use std::{
collections::HashMap,
io::{Read, Write},
@@ -8,7 +10,7 @@ use std::{
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundUpdateTagsPacket {
- pub tags: HashMap<ResourceLocation, Vec<Tags>>,
+ pub tags: TagMap,
}
#[derive(Clone, Debug)]
@@ -17,12 +19,15 @@ pub struct Tags {
pub elements: Vec<i32>,
}
-impl McBufReadable for HashMap<ResourceLocation, Vec<Tags>> {
+#[derive(Clone, Debug)]
+pub struct TagMap(HashMap<ResourceLocation, Vec<Tags>>);
+
+impl McBufReadable for TagMap {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
let length = buf.read_varint()? as usize;
let mut data = HashMap::with_capacity(length);
for _ in 0..length {
- let tag_type = buf.read_resource_location()?;
+ let tag_type = ResourceLocation::read_into(buf)?;
let tags_count = buf.read_varint()? as usize;
let mut tags_vec = Vec::with_capacity(tags_count);
for _ in 0..tags_count {
@@ -31,14 +36,14 @@ impl McBufReadable for HashMap<ResourceLocation, Vec<Tags>> {
}
data.insert(tag_type, tags_vec);
}
- Ok(data)
+ Ok(TagMap(data))
}
}
-impl McBufWritable for HashMap<ResourceLocation, Vec<Tags>> {
+impl McBufWritable for TagMap {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
buf.write_varint(self.len() as i32)?;
- for (k, v) in self {
+ for (k, v) in &self.0 {
k.write_into(buf)?;
v.write_into(buf)?;
}
@@ -47,7 +52,7 @@ impl McBufWritable for HashMap<ResourceLocation, Vec<Tags>> {
}
impl McBufReadable for Tags {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let name = buf.read_resource_location()?;
+ let name = ResourceLocation::read_into(buf)?;
let elements = buf.read_int_id_list()?;
Ok(Tags { name, elements })
}
@@ -60,3 +65,11 @@ impl McBufWritable for Tags {
Ok(())
}
}
+
+impl Deref for TagMap {
+ type Target = HashMap<ResourceLocation, Vec<Tags>>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs
index 8288bd73..c0c40f75 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ClientboundUpdateViewDistancePacket {
diff --git a/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs
index 9ae0b79f..6371463b 100644
--- a/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs
@@ -1,6 +1,7 @@
use std::collections::HashMap;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundChatCommandPacket {
diff --git a/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs
index 60535f69..32711d45 100644
--- a/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_chat_preview_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundChatPreviewPacket {
diff --git a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs
index bef25b59..eecb920b 100644
--- a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs
@@ -1,6 +1,7 @@
-use crate::mc_buf::UnsizedByteArray;
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use azalea_buf::UnsizedByteArray;
+use azalea_core::ResourceLocation;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundCustomPayloadPacket {
diff --git a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs
index c430499e..1edc5a52 100644
--- a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundKeepAlivePacket {
diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos.rs b/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos.rs
index 65b28624..23f4050e 100644
--- a/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos.rs
+++ b/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundMovePlayerPacketPos {
diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos_rot.rs b/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos_rot.rs
index 8070d1bf..9416461c 100644
--- a/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos_rot.rs
+++ b/azalea-protocol/src/packets/game/serverbound_move_player_packet_pos_rot.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundMovePlayerPacketPosRot {
diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_packet_rot.rs b/azalea-protocol/src/packets/game/serverbound_move_player_packet_rot.rs
index 0c444d03..0952483a 100644
--- a/azalea-protocol/src/packets/game/serverbound_move_player_packet_rot.rs
+++ b/azalea-protocol/src/packets/game/serverbound_move_player_packet_rot.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundMovePlayerPacketRot {
diff --git a/azalea-protocol/src/packets/game/serverbound_move_player_packet_status_only.rs b/azalea-protocol/src/packets/game/serverbound_move_player_packet_status_only.rs
index ef762caf..fb765c27 100644
--- a/azalea-protocol/src/packets/game/serverbound_move_player_packet_status_only.rs
+++ b/azalea-protocol/src/packets/game/serverbound_move_player_packet_status_only.rs
@@ -1,4 +1,5 @@
-use packet_macros::{GamePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::GamePacket;
#[derive(Clone, Debug, McBuf, GamePacket)]
pub struct ServerboundMovePlayerPacketStatusOnly {
diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs
index 410c11ab..5f1987e2 100755
--- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs
+++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs
@@ -1,5 +1,6 @@
use crate::packets::ConnectionProtocol;
-use packet_macros::{HandshakePacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::HandshakePacket;
use std::hash::Hash;
#[derive(Hash, Clone, Debug, McBuf, HandshakePacket)]
diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
index 1b1da87a..05310fb0 100755
--- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
@@ -1,6 +1,6 @@
-use crate::mc_buf::UnsizedByteArray;
-use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{LoginPacket, McBuf};
+use azalea_buf::{McBuf, UnsizedByteArray};
+use azalea_core::ResourceLocation;
+use packet_macros::LoginPacket;
use std::hash::Hash;
#[derive(Hash, Clone, Debug, McBuf, LoginPacket)]
diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
index dd11f7f7..bd2edf38 100755
--- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
@@ -1,10 +1,8 @@
use std::io::{Read, Write};
use super::LoginPacket;
-use crate::mc_buf::McBufReadable;
-use crate::mc_buf::{Readable, Writable};
use azalea_auth::game_profile::GameProfile;
-use azalea_core::serializable_uuid::SerializableUuid;
+use azalea_buf::{McBufReadable, Readable, SerializableUuid, Writable};
use uuid::Uuid;
#[derive(Clone, Debug)]
diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
index 58d48ffe..f3724c18 100755
--- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
@@ -1,5 +1,5 @@
+use azalea_buf::McBuf;
use packet_macros::LoginPacket;
-use packet_macros::McBuf;
#[derive(Clone, Debug, McBuf, LoginPacket)]
pub struct ClientboundHelloPacket {
diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
index b1323f50..19b2d58e 100755
--- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
@@ -3,7 +3,7 @@ use std::{
io::{Read, Write},
};
-use crate::mc_buf::{Readable, Writable};
+use azalea_buf::{Readable, Writable};
use super::LoginPacket;
diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
index 9ab09e3b..acc68c82 100644
--- a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
@@ -1,5 +1,6 @@
+use azalea_buf::McBuf;
use azalea_chat::component::Component;
-use packet_macros::{LoginPacket, McBuf};
+use packet_macros::LoginPacket;
#[derive(Clone, Debug, McBuf, LoginPacket)]
pub struct ClientboundLoginDisconnectPacket {
diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
index bed93f04..57a3e4d8 100755
--- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{LoginPacket, McBuf};
+use azalea_buf::McBuf;
+use packet_macros::LoginPacket;
#[derive(Clone, Debug, McBuf, LoginPacket)]
pub struct ServerboundHelloPacket {
diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
index d57b122a..12b7c4ec 100644
--- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -1,8 +1,9 @@
+use azalea_buf::McBuf;
use azalea_crypto::SaltSignaturePair;
-use packet_macros::{LoginPacket, McBuf};
+use packet_macros::LoginPacket;
use std::io::{Read, Write};
-use crate::mc_buf::{McBufReadable, McBufWritable};
+use azalea_buf::{McBufReadable, McBufWritable};
#[derive(Clone, Debug, McBuf, LoginPacket)]
pub struct ServerboundKeyPacket {
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index 1cc79b79..738baa09 100755
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -3,14 +3,11 @@ pub mod handshake;
pub mod login;
pub mod status;
-use std::io::{Read, Write};
-
-use crate::{
- connect::PacketFlow,
- mc_buf::{McBufReadable, McBufWritable, Readable, Writable},
-};
+use crate::connect::PacketFlow;
+use azalea_buf::{McBufReadable, McBufWritable, Readable, Writable};
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
+use std::io::{Read, Write};
pub const PROTOCOL_VERSION: u32 = 759;
@@ -43,7 +40,7 @@ where
fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>;
}
-impl crate::mc_buf::McBufReadable for ConnectionProtocol {
+impl azalea_buf::McBufReadable for ConnectionProtocol {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
ConnectionProtocol::from_i32(buf.read_varint()?)
.ok_or_else(|| "Invalid intention".to_string())
diff --git a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
index 2acdb8c2..e7fb4f2b 100755
--- a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
+++ b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
@@ -4,7 +4,7 @@ use azalea_chat::component::Component;
use serde::Deserialize;
use serde_json::Value;
-use crate::mc_buf::Readable;
+use azalea_buf::Readable;
use super::StatusPacket;
diff --git a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs
index 3369e6a9..c19d7795 100755
--- a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs
+++ b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs
@@ -1,4 +1,5 @@
-use packet_macros::{McBuf, StatusPacket};
+use azalea_buf::McBuf;
+use packet_macros::StatusPacket;
#[derive(Clone, Debug, McBuf, StatusPacket)]
pub struct ServerboundStatusRequestPacket {}
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index b4ba17ea..e19b5538 100755
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -1,8 +1,5 @@
-use crate::{
- connect::PacketFlow,
- mc_buf::{read_varint_async, Readable},
- packets::ProtocolPacket,
-};
+use crate::{connect::PacketFlow, packets::ProtocolPacket};
+use azalea_buf::{read_varint_async, Readable};
use azalea_crypto::Aes128CfbDec;
use flate2::read::ZlibDecoder;
use std::{
diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs
index 9291681c..ae9a6829 100755
--- a/azalea-protocol/src/write.rs
+++ b/azalea-protocol/src/write.rs
@@ -1,5 +1,6 @@
-use crate::{mc_buf::Writable, packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH};
+use crate::{packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH};
use async_compression::tokio::bufread::ZlibEncoder;
+use azalea_buf::Writable;
use azalea_crypto::Aes128CfbEnc;
use std::fmt::Debug;
use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};