From 40e4096d2435533eacb817ad5a5e12c7ced8fa5c Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Wed, 23 Oct 2024 00:08:13 -0500 Subject: 1.21.2 (#171) * partially implement 24w35a * start updating to 24w39a + itemcomponent codegen * fix codegen and broken packets to finish updating to 24w39a :D * update to 1.21.2 except for blocks * update ServerboundPlayerInputPacket impl --- azalea-protocol/src/packets/common.rs | 2 + .../serverbound_client_information_packet.rs | 11 + .../clientbound_custom_report_details_packet.rs | 14 + .../clientbound_entity_position_sync_packet.rs | 19 ++ .../game/clientbound_move_minecart_packet.rs | 19 ++ .../game/clientbound_player_info_update_packet.rs | 13 + .../game/clientbound_player_position_packet.rs | 14 +- .../game/clientbound_player_rotation_packet.rs | 8 + .../game/clientbound_projectile_power_packet.rs | 8 + .../game/clientbound_recipe_book_add_packet.rs | 79 +++++ .../game/clientbound_recipe_book_remove_packet.rs | 15 + .../clientbound_recipe_book_settings_packet.rs | 22 ++ .../src/packets/game/clientbound_recipe_packet.rs | 77 ----- .../game/clientbound_server_links_packet.rs | 34 +++ .../game/clientbound_set_carried_item_packet.rs | 8 - .../game/clientbound_set_cursor_item_packet.rs | 8 + .../game/clientbound_set_held_slot_packet.rs | 7 + .../clientbound_set_player_inventory_packet.rs | 10 + .../packets/game/clientbound_set_time_packet.rs | 1 + .../game/clientbound_update_recipes_packet.rs | 247 +++------------- azalea-protocol/src/packets/game/mod.rs | 320 +++++++++++---------- .../game/serverbound_client_tick_end_packet.rs | 5 + .../game/serverbound_player_input_packet.rs | 49 ++-- .../game/serverbound_select_bundle_item_packet.rs | 10 + .../login/clientbound_game_profile_packet.rs | 9 - .../login/clientbound_login_finished_packet.rs | 8 + azalea-protocol/src/packets/login/mod.rs | 4 +- azalea-protocol/src/packets/mod.rs | 2 +- 28 files changed, 550 insertions(+), 473 deletions(-) create mode 100644 azalea-protocol/src/packets/game/clientbound_custom_report_details_packet.rs create mode 100755 azalea-protocol/src/packets/game/clientbound_entity_position_sync_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_move_minecart_packet.rs create mode 100755 azalea-protocol/src/packets/game/clientbound_player_rotation_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_projectile_power_packet.rs create mode 100755 azalea-protocol/src/packets/game/clientbound_recipe_book_add_packet.rs create mode 100755 azalea-protocol/src/packets/game/clientbound_recipe_book_remove_packet.rs create mode 100755 azalea-protocol/src/packets/game/clientbound_recipe_book_settings_packet.rs delete mode 100755 azalea-protocol/src/packets/game/clientbound_recipe_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_server_links_packet.rs delete mode 100755 azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_set_cursor_item_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_set_held_slot_packet.rs create mode 100644 azalea-protocol/src/packets/game/clientbound_set_player_inventory_packet.rs create mode 100644 azalea-protocol/src/packets/game/serverbound_client_tick_end_packet.rs create mode 100644 azalea-protocol/src/packets/game/serverbound_select_bundle_item_packet.rs delete mode 100755 azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs create mode 100755 azalea-protocol/src/packets/login/clientbound_login_finished_packet.rs (limited to 'azalea-protocol/src/packets') diff --git a/azalea-protocol/src/packets/common.rs b/azalea-protocol/src/packets/common.rs index 82f6be70..173e15fc 100644 --- a/azalea-protocol/src/packets/common.rs +++ b/azalea-protocol/src/packets/common.rs @@ -17,4 +17,6 @@ pub struct CommonPlayerSpawnInfo { pub last_death_location: Option, #[var] pub portal_cooldown: u32, + #[var] + pub sea_level: i32, } diff --git a/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs b/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs index fb980a46..d00c30ec 100644 --- a/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs +++ b/azalea-protocol/src/packets/configuration/serverbound_client_information_packet.rs @@ -30,6 +30,7 @@ pub struct ClientInformation { /// Whether the client should show up as "Anonymous Player" in the server /// list. pub allows_listing: bool, + pub particle_status: ParticleStatus, } impl Default for ClientInformation { @@ -43,6 +44,7 @@ impl Default for ClientInformation { main_hand: HumanoidArm::Right, text_filtering_enabled: false, allows_listing: false, + particle_status: ParticleStatus::default(), } } } @@ -77,6 +79,14 @@ pub struct ModelCustomization { pub hat: bool, } +#[derive(McBuf, Clone, Copy, Debug, PartialEq, Eq, Default)] +pub enum ParticleStatus { + #[default] + All, + Decreased, + Minimal, +} + impl Default for ModelCustomization { fn default() -> Self { Self { @@ -169,6 +179,7 @@ mod tests { main_hand: HumanoidArm::Left, text_filtering_enabled: true, allows_listing: true, + particle_status: ParticleStatus::Decreased, }; let mut buf = Vec::new(); data.write_into(&mut buf).unwrap(); diff --git a/azalea-protocol/src/packets/game/clientbound_custom_report_details_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_report_details_packet.rs new file mode 100644 index 00000000..a098f915 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_custom_report_details_packet.rs @@ -0,0 +1,14 @@ +use std::collections::HashMap; + +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundCustomReportDetailsPacket { + // azalea doesn't implement max lengths yet + + // max length = 32 + // key string is limited to 128 bytes + // value string is limited to 4096 bytes + pub details: HashMap, +} diff --git a/azalea-protocol/src/packets/game/clientbound_entity_position_sync_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_position_sync_packet.rs new file mode 100755 index 00000000..0125eeb4 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_entity_position_sync_packet.rs @@ -0,0 +1,19 @@ +use azalea_buf::McBuf; +use azalea_core::position::Vec3; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundEntityPositionSyncPacket { + #[var] + pub id: u32, + pub values: PositionMoveRotation, + pub on_ground: bool, +} + +#[derive(McBuf, Clone, Debug)] +pub struct PositionMoveRotation { + pub position: Vec3, + pub delta_movement: Vec3, + pub y_rot: f32, + pub x_rot: f32, +} diff --git a/azalea-protocol/src/packets/game/clientbound_move_minecart_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_minecart_packet.rs new file mode 100644 index 00000000..014e2aaa --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_move_minecart_packet.rs @@ -0,0 +1,19 @@ +use azalea_buf::McBuf; +use azalea_core::position::Vec3; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundMoveMinecartPacket { + #[var] + pub entity_id: u32, + pub lerp_steps: Vec, +} + +#[derive(Clone, Debug, McBuf)] +pub struct MinecartStep { + pub position: Vec3, + pub movement: Vec3, + pub y_rot: u8, + pub x_rot: u8, + pub weight: f32, +} diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs index 345c22f2..d334d783 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs @@ -26,6 +26,7 @@ pub struct PlayerInfoEntry { pub latency: i32, pub game_mode: GameMode, pub display_name: Option, + pub list_order: i32, pub chat_session: Option, } @@ -55,6 +56,11 @@ pub struct UpdateLatencyAction { pub struct UpdateDisplayNameAction { pub display_name: Option, } +#[derive(Clone, Debug, McBuf)] +pub struct UpdateListOrderAction { + #[var] + pub list_order: i32, +} impl McBufReadable for ClientboundPlayerInfoUpdatePacket { fn read_from(buf: &mut Cursor<&[u8]>) -> Result { @@ -92,6 +98,10 @@ impl McBufReadable for ClientboundPlayerInfoUpdatePacket { let action = UpdateDisplayNameAction::read_from(buf)?; entry.display_name = action.display_name; } + if actions.update_list_order { + let action = UpdateListOrderAction::read_from(buf)?; + entry.list_order = action.list_order; + } entries.push(entry); } @@ -159,6 +169,7 @@ pub struct ActionEnumSet { pub update_listed: bool, pub update_latency: bool, pub update_display_name: bool, + pub update_list_order: bool, } impl McBufReadable for ActionEnumSet { @@ -171,6 +182,7 @@ impl McBufReadable for ActionEnumSet { update_listed: set.index(3), update_latency: set.index(4), update_display_name: set.index(5), + update_list_order: set.index(6), }) } } @@ -214,6 +226,7 @@ mod tests { update_listed: false, update_latency: true, update_display_name: false, + update_list_order: true, }; let mut buf = Vec::new(); data.write_into(&mut buf).unwrap(); 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 d63108da..2a9cebc6 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs @@ -1,19 +1,18 @@ use std::io::{Cursor, Write}; use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; -use azalea_core::bitset::FixedBitSet; +use azalea_core::{bitset::FixedBitSet, position::Vec3}; use azalea_protocol_macros::ClientboundGamePacket; #[derive(Clone, Debug, McBuf, ClientboundGamePacket)] pub struct ClientboundPlayerPositionPacket { - pub x: f64, - pub y: f64, - pub z: f64, + #[var] + pub id: u32, + pub pos: Vec3, + pub delta_movement: Vec3, pub y_rot: f32, pub x_rot: f32, pub relative_arguments: RelativeMovements, - #[var] - pub id: u32, } #[derive(Debug, Clone)] @@ -27,7 +26,8 @@ pub struct RelativeMovements { impl McBufReadable for RelativeMovements { fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - let set = FixedBitSet::<5>::read_from(buf)?; + // yes minecraft seriously wastes that many bits, smh + let set = FixedBitSet::<32>::read_from(buf)?; Ok(RelativeMovements { x: set.index(0), y: set.index(1), diff --git a/azalea-protocol/src/packets/game/clientbound_player_rotation_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_rotation_packet.rs new file mode 100755 index 00000000..a1ad9bbe --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_player_rotation_packet.rs @@ -0,0 +1,8 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundPlayerRotationPacket { + pub y_rot: f32, + pub x_rot: f32, +} diff --git a/azalea-protocol/src/packets/game/clientbound_projectile_power_packet.rs b/azalea-protocol/src/packets/game/clientbound_projectile_power_packet.rs new file mode 100644 index 00000000..a665a2aa --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_projectile_power_packet.rs @@ -0,0 +1,8 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundProjectilePowerPacket { + pub id: u32, + pub acceleration_power: f64, +} diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_book_add_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_book_add_packet.rs new file mode 100755 index 00000000..e025da7d --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_recipe_book_add_packet.rs @@ -0,0 +1,79 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +use super::clientbound_update_recipes_packet::{Ingredient, SlotDisplayData}; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundRecipeBookAddPacket { + pub entries: Vec, + pub replace: bool, +} + +#[derive(Clone, Debug, McBuf)] +pub struct Entry { + pub contents: RecipeDisplayEntry, + pub flags: u8, +} + +#[derive(Clone, Debug, McBuf)] +pub struct RecipeDisplayEntry { + #[var] + pub id: u32, + pub display: RecipeDisplayData, + // ByteBufCodecs.OPTIONAL_VAR_INT + #[var] + pub group: u32, + pub category: azalea_registry::RecipeBookCategory, + pub crafting_requirements: Option>, +} + +/// [`azalea_registry::RecipeDisplay`] +#[derive(Clone, Debug, McBuf)] +pub enum RecipeDisplayData { + Shapeless(ShapelessCraftingRecipeDisplay), + Shaped(ShapedCraftingRecipeDisplay), + Furnace(FurnaceRecipeDisplay), + Stonecutter(StonecutterRecipeDisplay), + Smithing(SmithingRecipeDisplay), +} + +#[derive(Clone, Debug, McBuf)] +pub struct ShapelessCraftingRecipeDisplay { + pub ingredients: Vec, + pub result: SlotDisplayData, + pub crafting_station: SlotDisplayData, +} +#[derive(Clone, Debug, McBuf)] +pub struct ShapedCraftingRecipeDisplay { + #[var] + pub width: u32, + #[var] + pub height: u32, + pub ingredients: Vec, + pub result: SlotDisplayData, + pub crafting_station: SlotDisplayData, +} +#[derive(Clone, Debug, McBuf)] +pub struct FurnaceRecipeDisplay { + pub ingredient: SlotDisplayData, + pub fuel: SlotDisplayData, + pub result: SlotDisplayData, + pub crafting_station: SlotDisplayData, + #[var] + pub duration: u32, + pub experience: f32, +} +#[derive(Clone, Debug, McBuf)] +pub struct StonecutterRecipeDisplay { + pub input: SlotDisplayData, + pub result: SlotDisplayData, + pub crafting_station: SlotDisplayData, +} +#[derive(Clone, Debug, McBuf)] +pub struct SmithingRecipeDisplay { + pub template: SlotDisplayData, + pub base: SlotDisplayData, + pub addition: SlotDisplayData, + pub result: SlotDisplayData, + pub crafting_station: SlotDisplayData, +} diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_book_remove_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_book_remove_packet.rs new file mode 100755 index 00000000..678537ca --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_recipe_book_remove_packet.rs @@ -0,0 +1,15 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +use super::{ + clientbound_entity_position_sync_packet::PositionMoveRotation, + clientbound_player_position_packet::RelativeMovements, +}; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundRecipeBookRemovePacket { + #[var] + pub id: u32, + pub change: PositionMoveRotation, + pub relatives: RelativeMovements, +} diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_book_settings_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_book_settings_packet.rs new file mode 100755 index 00000000..1180bd26 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_recipe_book_settings_packet.rs @@ -0,0 +1,22 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundRecipeBookSettingsPacket { + pub book_settings: RecipeBookSettings, +} + +#[derive(Clone, Debug, McBuf)] +pub struct RecipeBookSettings { + pub gui_open: bool, + pub filtering_craftable: bool, + + pub furnace_gui_open: bool, + pub furnace_filtering_craftable: bool, + + pub blast_furnace_gui_open: bool, + pub blast_furnace_filtering_craftable: bool, + + pub smoker_gui_open: bool, + pub smoker_filtering_craftable: bool, +} diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs deleted file mode 100755 index e948e53c..00000000 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ /dev/null @@ -1,77 +0,0 @@ -use azalea_buf::{ - BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, -}; -use azalea_core::resource_location::ResourceLocation; -use azalea_protocol_macros::ClientboundGamePacket; -use std::io::{Cursor, Write}; - -#[derive(Clone, Debug, ClientboundGamePacket)] -pub struct ClientboundRecipePacket { - pub action: State, - pub settings: RecipeBookSettings, - pub recipes: Vec, -} - -impl McBufWritable for ClientboundRecipePacket { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - match self.action { - State::Init { .. } => 0, - State::Add => 1, - State::Remove => 2, - } - .var_write_into(buf)?; - self.settings.write_into(buf)?; - self.recipes.write_into(buf)?; - if let State::Init { to_highlight } = &self.action { - to_highlight.write_into(buf)?; - } - Ok(()) - } -} -impl McBufReadable for ClientboundRecipePacket { - fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - let action_id = u32::var_read_from(buf)?; - let settings = RecipeBookSettings::read_from(buf)?; - let recipes = Vec::::read_from(buf)?; - let action = match action_id { - 0 => State::Init { - to_highlight: Vec::::read_from(buf)?, - }, - 1 => State::Add, - 2 => State::Remove, - _ => { - return Err(BufReadError::UnexpectedEnumVariant { - id: action_id as i32, - }) - } - }; - - Ok(ClientboundRecipePacket { - action, - settings, - recipes, - }) - } -} - -#[derive(Clone, Debug, McBuf)] -pub struct RecipeBookSettings { - pub gui_open: bool, - pub filtering_craftable: bool, - - pub furnace_gui_open: bool, - pub furnace_filtering_craftable: bool, - - pub blast_furnace_gui_open: bool, - pub blast_furnace_filtering_craftable: bool, - - pub smoker_gui_open: bool, - pub smoker_filtering_craftable: bool, -} - -#[derive(Clone, Debug)] -pub enum State { - Init { to_highlight: Vec }, - Add, - Remove, -} diff --git a/azalea-protocol/src/packets/game/clientbound_server_links_packet.rs b/azalea-protocol/src/packets/game/clientbound_server_links_packet.rs new file mode 100644 index 00000000..4b24a519 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_server_links_packet.rs @@ -0,0 +1,34 @@ +use azalea_buf::McBuf; +use azalea_chat::FormattedText; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundServerLinksPacket { + pub links: Vec, +} + +#[derive(Clone, Debug, McBuf)] +pub struct ServerLinkEntry { + pub kind: ServerLinkKind, + pub link: String, +} + +#[derive(Clone, Debug, McBuf)] +pub enum ServerLinkKind { + Known(KnownLinkKind), + Component(FormattedText), +} + +#[derive(Clone, Copy, Debug, McBuf)] +pub enum KnownLinkKind { + BugReport, + CommunityGuidelines, + Support, + Status, + Feedback, + Community, + Website, + Forums, + News, + Announcements, +} 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 deleted file mode 100755 index 0eff02a8..00000000 --- a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs +++ /dev/null @@ -1,8 +0,0 @@ -use azalea_buf::McBuf; -use azalea_protocol_macros::ClientboundGamePacket; - -/// Sent to change the player's slot selection. -#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] -pub struct ClientboundSetCarriedItemPacket { - pub slot: u8, -} diff --git a/azalea-protocol/src/packets/game/clientbound_set_cursor_item_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_cursor_item_packet.rs new file mode 100644 index 00000000..6a67b71c --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_set_cursor_item_packet.rs @@ -0,0 +1,8 @@ +use azalea_buf::McBuf; +use azalea_inventory::ItemSlot; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundSetCursorItemPacket { + pub contents: Option, +} diff --git a/azalea-protocol/src/packets/game/clientbound_set_held_slot_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_held_slot_packet.rs new file mode 100644 index 00000000..a83ae3cb --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_set_held_slot_packet.rs @@ -0,0 +1,7 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundSetHeldSlotPacket { + pub slot: u8, +} diff --git a/azalea-protocol/src/packets/game/clientbound_set_player_inventory_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_player_inventory_packet.rs new file mode 100644 index 00000000..c17fd310 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_set_player_inventory_packet.rs @@ -0,0 +1,10 @@ +use azalea_buf::McBuf; +use azalea_inventory::ItemSlot; +use azalea_protocol_macros::ClientboundGamePacket; + +#[derive(Clone, Debug, McBuf, ClientboundGamePacket)] +pub struct ClientboundSetPlayerInventoryPacket { + #[var] + pub slot: i32, + pub contents: Option, +} 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 dd8a0daa..b73f082d 100755 --- a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs @@ -5,4 +5,5 @@ use azalea_protocol_macros::ClientboundGamePacket; pub struct ClientboundSetTimePacket { pub game_time: u64, pub day_time: u64, + pub tick_day_time: bool, } 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 99f4ab05..4c950f90 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -1,239 +1,74 @@ -use azalea_buf::{ - BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, -}; +use std::collections::HashMap; + +use azalea_buf::McBuf; use azalea_core::resource_location::ResourceLocation; use azalea_inventory::ItemSlot; use azalea_protocol_macros::ClientboundGamePacket; +use azalea_registry::HolderSet; -use std::io::{Cursor, Write}; - -#[derive(Clone, Debug, McBuf, PartialEq, ClientboundGamePacket)] +#[derive(Clone, Debug, PartialEq, McBuf, ClientboundGamePacket)] pub struct ClientboundUpdateRecipesPacket { - pub recipes: Vec, -} - -#[derive(Clone, Debug, PartialEq, McBuf)] -pub struct RecipeHolder { - pub id: ResourceLocation, - pub data: RecipeData, + pub item_sets: HashMap, + pub stonecutter_recipes: Vec, } #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct ShapelessRecipe { - /// Used to group similar recipes together in the recipe book. - /// Nbt is present in recipe JSON - pub group: String, - pub category: CraftingBookCategory, - pub ingredients: Vec, - pub result: ItemSlot, +pub struct SingleInputEntry { + pub input: Ingredient, + pub recipe: SelectableRecipe, } #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct ShapedRecipe { - pub group: String, - pub category: CraftingBookCategory, - pub pattern: ShapedRecipePattern, - pub result: ItemSlot, - pub show_notification: bool, -} - -#[derive(Clone, Debug, PartialEq)] -pub struct ShapedRecipePattern { - pub width: usize, - pub height: usize, - pub ingredients: Vec, -} - -impl McBufWritable for ShapedRecipePattern { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - (self.width as u32).var_write_into(buf)?; - (self.height as u32).var_write_into(buf)?; - debug_assert_eq!(self.width * self.height, self.ingredients.len()); - for ingredient in &self.ingredients { - ingredient.write_into(buf)?; - } - Ok(()) - } -} - -impl McBufReadable for ShapedRecipePattern { - fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - let width = u32::var_read_from(buf)? as usize; - let height = u32::var_read_from(buf)? as usize; - let mut ingredients = Vec::with_capacity(width * height); - for _ in 0..width * height { - ingredients.push(Ingredient::read_from(buf)?); - } - Ok(ShapedRecipePattern { - width, - height, - ingredients, - }) - } +pub struct SelectableRecipe { + pub option_display: SlotDisplayData, } -#[derive(Clone, Debug, Copy, PartialEq, McBuf)] -pub enum CraftingBookCategory { - Building = 0, - Redstone, - Equipment, - Misc, +/// [`azalea_registry::SlotDisplay`] +#[derive(Clone, Debug, PartialEq, McBuf)] +pub enum SlotDisplayData { + Empty, + AnyFuel, + Item(ItemSlotDisplay), + ItemStack(ItemStackSlotDisplay), + Tag(ResourceLocation), + SmithingTrim(Box), + WithRemainder(Box), + Composite(CompositeSlotDisplay), } #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct CookingRecipe { - pub group: String, - pub category: CraftingBookCategory, - pub ingredient: Ingredient, - pub result: ItemSlot, - pub experience: f32, - #[var] - pub cooking_time: u32, +pub struct ItemSlotDisplay { + pub item: azalea_registry::Item, } #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct StoneCutterRecipe { - pub group: String, - pub ingredient: Ingredient, - pub result: ItemSlot, +pub struct ItemStackSlotDisplay { + pub stack: ItemSlot, } #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct SmithingRecipe { - pub base: Ingredient, - pub addition: Ingredient, - pub result: ItemSlot, +pub struct TagSlotDisplay { + pub tag: azalea_registry::Item, } - #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct SimpleRecipe { - pub category: CraftingBookCategory, +pub struct SmithingTrimDemoSlotDisplay { + pub base: SlotDisplayData, + pub material: SlotDisplayData, + pub pattern: SlotDisplayData, } - #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct SmithingTransformRecipe { - pub template: Ingredient, - pub base: Ingredient, - pub addition: Ingredient, - pub result: ItemSlot, +pub struct WithRemainderSlotDisplay { + pub input: SlotDisplayData, + pub remainder: SlotDisplayData, } - #[derive(Clone, Debug, PartialEq, McBuf)] -pub struct SmithingTrimRecipe { - pub template: Ingredient, - pub base: Ingredient, - pub addition: Ingredient, +pub struct CompositeSlotDisplay { + pub contents: Vec, } #[derive(Clone, Debug, PartialEq, McBuf)] -pub enum RecipeData { - CraftingShaped(ShapedRecipe), - CraftingShapeless(ShapelessRecipe), - CraftingSpecialArmorDye(SimpleRecipe), - CraftingSpecialBookCloning(SimpleRecipe), - CraftingSpecialMapCloning(SimpleRecipe), - CraftingSpecialMapExtending(SimpleRecipe), - CraftingSpecialFireworkRocket(SimpleRecipe), - CraftingSpecialFireworkStar(SimpleRecipe), - CraftingSpecialFireworkStarFade(SimpleRecipe), - CraftingSpecialRepairItem(SimpleRecipe), - CraftingSpecialTippedArrow(SimpleRecipe), - CraftingSpecialBannerDuplicate(SimpleRecipe), - CraftingSpecialShieldDecoration(SimpleRecipe), - CraftingSpecialShulkerBoxColoring(SimpleRecipe), - CraftingSpecialSuspiciousStew(SimpleRecipe), - Smelting(CookingRecipe), - Blasting(CookingRecipe), - Smoking(CookingRecipe), - CampfireCooking(CookingRecipe), - Stonecutting(StoneCutterRecipe), - SmithingTransform(SmithingTransformRecipe), - SmithingTrim(SmithingTrimRecipe), - CraftingDecoratedPot(SimpleRecipe), +pub struct RecipePropertySet { + pub items: Vec, } #[derive(Clone, Debug, PartialEq, McBuf)] pub struct Ingredient { - pub allowed: Vec, -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_crafting_shaped() { - let mut buf = Vec::new(); - let recipe = RecipeHolder { - id: ResourceLocation::new("minecraft:crafting_shaped"), - data: RecipeData::CraftingShaped(ShapedRecipe { - group: String::new(), - category: CraftingBookCategory::Building, - pattern: ShapedRecipePattern { - width: 2, - height: 2, - ingredients: vec![ - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - ], - }, - result: ItemSlot::Empty, - show_notification: false, - }), - }; - recipe.write_into(&mut buf).unwrap(); - let decoded_recipe = RecipeHolder::read_from(&mut Cursor::new(&buf[..])).unwrap(); - assert_eq!(recipe, decoded_recipe); - } - - #[test] - fn test_crafting_shapeless() { - let mut buf = Vec::new(); - let recipe = RecipeHolder { - id: ResourceLocation::new("minecraft:crafting_shapeless"), - data: RecipeData::CraftingShapeless(ShapelessRecipe { - group: String::new(), - category: CraftingBookCategory::Building, - ingredients: vec![ - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - Ingredient { - allowed: vec![ItemSlot::Empty], - }, - ], - result: ItemSlot::Empty, - }), - }; - recipe.write_into(&mut buf).unwrap(); - let decoded_recipe = RecipeHolder::read_from(&mut Cursor::new(&buf[..])).unwrap(); - assert_eq!(recipe, decoded_recipe); - } - - #[test] - fn test_crafting_special_armordye() { - let mut buf = Vec::new(); - let recipe = RecipeHolder { - id: ResourceLocation::new("minecraft:crafting_special_armordye"), - data: RecipeData::CraftingSpecialArmorDye(SimpleRecipe { - category: CraftingBookCategory::Building, - }), - }; - recipe.write_into(&mut buf).unwrap(); - let decoded_recipe = RecipeHolder::read_from(&mut Cursor::new(&buf[..])).unwrap(); - assert_eq!(recipe, decoded_recipe); - } + pub allowed: HolderSet, } diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 533dec8b..55d6faaf 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -24,12 +24,14 @@ pub mod clientbound_cookie_request_packet; pub mod clientbound_cooldown_packet; pub mod clientbound_custom_chat_completions_packet; pub mod clientbound_custom_payload_packet; +pub mod clientbound_custom_report_details_packet; pub mod clientbound_damage_event_packet; pub mod clientbound_debug_sample_packet; pub mod clientbound_delete_chat_packet; pub mod clientbound_disconnect_packet; pub mod clientbound_disguised_chat_packet; pub mod clientbound_entity_event_packet; +pub mod clientbound_entity_position_sync_packet; pub mod clientbound_explode_packet; pub mod clientbound_forget_level_chunk_packet; pub mod clientbound_game_event_packet; @@ -47,6 +49,7 @@ pub mod clientbound_merchant_offers_packet; pub mod clientbound_move_entity_pos_packet; pub mod clientbound_move_entity_pos_rot_packet; pub mod clientbound_move_entity_rot_packet; +pub mod clientbound_move_minecart_packet; pub mod clientbound_move_vehicle_packet; pub mod clientbound_open_book_packet; pub mod clientbound_open_screen_packet; @@ -62,8 +65,12 @@ pub mod clientbound_player_info_remove_packet; pub mod clientbound_player_info_update_packet; pub mod clientbound_player_look_at_packet; pub mod clientbound_player_position_packet; +pub mod clientbound_player_rotation_packet; pub mod clientbound_pong_response_packet; -pub mod clientbound_recipe_packet; +pub mod clientbound_projectile_power_packet; +pub mod clientbound_recipe_book_add_packet; +pub mod clientbound_recipe_book_remove_packet; +pub mod clientbound_recipe_book_settings_packet; pub mod clientbound_remove_entities_packet; pub mod clientbound_remove_mob_effect_packet; pub mod clientbound_reset_score_packet; @@ -74,6 +81,7 @@ pub mod clientbound_rotate_head_packet; pub mod clientbound_section_blocks_update_packet; pub mod clientbound_select_advancements_tab_packet; pub mod clientbound_server_data_packet; +pub mod clientbound_server_links_packet; pub mod clientbound_set_action_bar_text_packet; pub mod clientbound_set_border_center_packet; pub mod clientbound_set_border_lerp_size_packet; @@ -81,9 +89,9 @@ pub mod clientbound_set_border_size_packet; pub mod clientbound_set_border_warning_delay_packet; pub mod clientbound_set_border_warning_distance_packet; pub mod clientbound_set_camera_packet; -pub mod clientbound_set_carried_item_packet; pub mod clientbound_set_chunk_cache_center_packet; pub mod clientbound_set_chunk_cache_radius_packet; +pub mod clientbound_set_cursor_item_packet; pub mod clientbound_set_default_spawn_position_packet; pub mod clientbound_set_display_objective_packet; pub mod clientbound_set_entity_data_packet; @@ -92,8 +100,10 @@ pub mod clientbound_set_entity_motion_packet; pub mod clientbound_set_equipment_packet; pub mod clientbound_set_experience_packet; pub mod clientbound_set_health_packet; +pub mod clientbound_set_held_slot_packet; pub mod clientbound_set_objective_packet; pub mod clientbound_set_passengers_packet; +pub mod clientbound_set_player_inventory_packet; pub mod clientbound_set_player_team_packet; pub mod clientbound_set_score_packet; pub mod clientbound_set_simulation_distance_packet; @@ -130,6 +140,7 @@ pub mod serverbound_chat_session_update_packet; pub mod serverbound_chunk_batch_received_packet; pub mod serverbound_client_command_packet; pub mod serverbound_client_information_packet; +pub mod serverbound_client_tick_end_packet; pub mod serverbound_command_suggestion_packet; pub mod serverbound_configuration_acknowledged_packet; pub mod serverbound_container_button_click_packet; @@ -164,6 +175,7 @@ pub mod serverbound_recipe_book_seen_recipe_packet; pub mod serverbound_rename_item_packet; pub mod serverbound_resource_pack_packet; pub mod serverbound_seen_advancements_packet; +pub mod serverbound_select_bundle_item_packet; pub mod serverbound_select_trade_packet; pub mod serverbound_set_beacon_packet; pub mod serverbound_set_carried_item_packet; @@ -180,67 +192,71 @@ pub mod serverbound_use_item_packet; use azalea_protocol_macros::declare_state_packets; +// see GameProtocols.java in the decompiled vanilla source + declare_state_packets!( GamePacket, Serverbound => { 0x00: serverbound_accept_teleportation_packet::ServerboundAcceptTeleportationPacket, 0x01: serverbound_block_entity_tag_query_packet::ServerboundBlockEntityTagQueryPacket, - 0x02: serverbound_change_difficulty_packet::ServerboundChangeDifficultyPacket, - 0x03: serverbound_chat_ack_packet::ServerboundChatAckPacket, - 0x04: serverbound_chat_command_packet::ServerboundChatCommandPacket, - 0x05: serverbound_chat_command_signed_packet::ServerboundChatCommandSignedPacket, - 0x06: serverbound_chat_packet::ServerboundChatPacket, - 0x07: serverbound_chat_session_update_packet::ServerboundChatSessionUpdatePacket, - 0x08: serverbound_chunk_batch_received_packet::ServerboundChunkBatchReceivedPacket, - 0x09: serverbound_client_command_packet::ServerboundClientCommandPacket, - 0x0a: serverbound_client_information_packet::ServerboundClientInformationPacket, - 0x0b: serverbound_command_suggestion_packet::ServerboundCommandSuggestionPacket, - 0x0c: serverbound_configuration_acknowledged_packet::ServerboundConfigurationAcknowledgedPacket, - 0x0d: serverbound_container_button_click_packet::ServerboundContainerButtonClickPacket, - 0x0e: serverbound_container_click_packet::ServerboundContainerClickPacket, - 0x0f: serverbound_container_close_packet::ServerboundContainerClosePacket, - 0x10: serverbound_container_slot_state_changed_packet::ServerboundContainerSlotStateChangedPacket, - 0x11: serverbound_cookie_response_packet::ServerboundCookieResponsePacket, - 0x12: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket, - 0x13: serverbound_debug_sample_subscription::ServerboundDebugSampleSubscription, - 0x14: serverbound_edit_book_packet::ServerboundEditBookPacket, - 0x15: serverbound_entity_tag_query_packet::ServerboundEntityTagQueryPacket, - 0x16: serverbound_interact_packet::ServerboundInteractPacket, - 0x17: serverbound_jigsaw_generate_packet::ServerboundJigsawGeneratePacket, - 0x18: serverbound_keep_alive_packet::ServerboundKeepAlivePacket, - 0x19: serverbound_lock_difficulty_packet::ServerboundLockDifficultyPacket, - 0x1a: serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, - 0x1b: serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket, - 0x1c: serverbound_move_player_rot_packet::ServerboundMovePlayerRotPacket, - 0x1d: serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket, - 0x1e: serverbound_move_vehicle_packet::ServerboundMoveVehiclePacket, - 0x1f: serverbound_paddle_boat_packet::ServerboundPaddleBoatPacket, - 0x20: serverbound_pick_item_packet::ServerboundPickItemPacket, - 0x21: serverbound_ping_request_packet::ServerboundPingRequestPacket, - 0x22: serverbound_place_recipe_packet::ServerboundPlaceRecipePacket, - 0x23: serverbound_player_abilities_packet::ServerboundPlayerAbilitiesPacket, - 0x24: serverbound_player_action_packet::ServerboundPlayerActionPacket, - 0x25: serverbound_player_command_packet::ServerboundPlayerCommandPacket, - 0x26: serverbound_player_input_packet::ServerboundPlayerInputPacket, - 0x27: serverbound_pong_packet::ServerboundPongPacket, - 0x28: serverbound_recipe_book_change_settings_packet::ServerboundRecipeBookChangeSettingsPacket, - 0x29: serverbound_recipe_book_seen_recipe_packet::ServerboundRecipeBookSeenRecipePacket, - 0x2a: serverbound_rename_item_packet::ServerboundRenameItemPacket, - 0x2b: serverbound_resource_pack_packet::ServerboundResourcePackPacket, - 0x2c: serverbound_seen_advancements_packet::ServerboundSeenAdvancementsPacket, - 0x2d: serverbound_select_trade_packet::ServerboundSelectTradePacket, - 0x2e: serverbound_set_beacon_packet::ServerboundSetBeaconPacket, - 0x2f: serverbound_set_carried_item_packet::ServerboundSetCarriedItemPacket, - 0x30: serverbound_set_command_block_packet::ServerboundSetCommandBlockPacket, - 0x31: serverbound_set_command_minecart_packet::ServerboundSetCommandMinecartPacket, - 0x32: serverbound_set_creative_mode_slot_packet::ServerboundSetCreativeModeSlotPacket, - 0x33: serverbound_set_jigsaw_block_packet::ServerboundSetJigsawBlockPacket, - 0x34: serverbound_set_structure_block_packet::ServerboundSetStructureBlockPacket, - 0x35: serverbound_sign_update_packet::ServerboundSignUpdatePacket, - 0x36: serverbound_swing_packet::ServerboundSwingPacket, - 0x37: serverbound_teleport_to_entity_packet::ServerboundTeleportToEntityPacket, - 0x38: serverbound_use_item_on_packet::ServerboundUseItemOnPacket, - 0x39: serverbound_use_item_packet::ServerboundUseItemPacket, + 0x02: serverbound_select_bundle_item_packet::ServerboundSelectBundleItemPacket, + 0x03: serverbound_change_difficulty_packet::ServerboundChangeDifficultyPacket, + 0x04: serverbound_chat_ack_packet::ServerboundChatAckPacket, + 0x05: serverbound_chat_command_packet::ServerboundChatCommandPacket, + 0x06: serverbound_chat_command_signed_packet::ServerboundChatCommandSignedPacket, + 0x07: serverbound_chat_packet::ServerboundChatPacket, + 0x08: serverbound_chat_session_update_packet::ServerboundChatSessionUpdatePacket, + 0x09: serverbound_chunk_batch_received_packet::ServerboundChunkBatchReceivedPacket, + 0x0a: serverbound_client_command_packet::ServerboundClientCommandPacket, + 0x0b: serverbound_client_tick_end_packet::ServerboundTickEndPacket, + 0x0c: serverbound_client_information_packet::ServerboundClientInformationPacket, + 0x0d: serverbound_command_suggestion_packet::ServerboundCommandSuggestionPacket, + 0x0e: serverbound_configuration_acknowledged_packet::ServerboundConfigurationAcknowledgedPacket, + 0x0f: serverbound_container_button_click_packet::ServerboundContainerButtonClickPacket, + 0x10: serverbound_container_click_packet::ServerboundContainerClickPacket, + 0x11: serverbound_container_close_packet::ServerboundContainerClosePacket, + 0x12: serverbound_container_slot_state_changed_packet::ServerboundContainerSlotStateChangedPacket, + 0x13: serverbound_cookie_response_packet::ServerboundCookieResponsePacket, + 0x14: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket, + 0x15: serverbound_debug_sample_subscription::ServerboundDebugSampleSubscription, + 0x16: serverbound_edit_book_packet::ServerboundEditBookPacket, + 0x17: serverbound_entity_tag_query_packet::ServerboundEntityTagQueryPacket, + 0x18: serverbound_interact_packet::ServerboundInteractPacket, + 0x19: serverbound_jigsaw_generate_packet::ServerboundJigsawGeneratePacket, + 0x1a: serverbound_keep_alive_packet::ServerboundKeepAlivePacket, + 0x1b: serverbound_lock_difficulty_packet::ServerboundLockDifficultyPacket, + 0x1c: serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, + 0x1d: serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket, + 0x1e: serverbound_move_player_rot_packet::ServerboundMovePlayerRotPacket, + 0x1f: serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket, + 0x20: serverbound_move_vehicle_packet::ServerboundMoveVehiclePacket, + 0x21: serverbound_paddle_boat_packet::ServerboundPaddleBoatPacket, + 0x22: serverbound_pick_item_packet::ServerboundPickItemPacket, + 0x23: serverbound_ping_request_packet::ServerboundPingRequestPacket, + 0x24: serverbound_place_recipe_packet::ServerboundPlaceRecipePacket, + 0x25: serverbound_player_abilities_packet::ServerboundPlayerAbilitiesPacket, + 0x26: serverbound_player_action_packet::ServerboundPlayerActionPacket, + 0x27: serverbound_player_command_packet::ServerboundPlayerCommandPacket, + 0x28: serverbound_player_input_packet::ServerboundPlayerInputPacket, + 0x29: serverbound_pong_packet::ServerboundPongPacket, + 0x2a: serverbound_recipe_book_change_settings_packet::ServerboundRecipeBookChangeSettingsPacket, + 0x2b: serverbound_recipe_book_seen_recipe_packet::ServerboundRecipeBookSeenRecipePacket, + 0x2c: serverbound_rename_item_packet::ServerboundRenameItemPacket, + 0x2d: serverbound_resource_pack_packet::ServerboundResourcePackPacket, + 0x2e: serverbound_seen_advancements_packet::ServerboundSeenAdvancementsPacket, + 0x2f: serverbound_select_trade_packet::ServerboundSelectTradePacket, + 0x30: serverbound_set_beacon_packet::ServerboundSetBeaconPacket, + 0x31: serverbound_set_carried_item_packet::ServerboundSetCarriedItemPacket, + 0x32: serverbound_set_command_block_packet::ServerboundSetCommandBlockPacket, + 0x33: serverbound_set_command_minecart_packet::ServerboundSetCommandMinecartPacket, + 0x34: serverbound_set_creative_mode_slot_packet::ServerboundSetCreativeModeSlotPacket, + 0x35: serverbound_set_jigsaw_block_packet::ServerboundSetJigsawBlockPacket, + 0x36: serverbound_set_structure_block_packet::ServerboundSetStructureBlockPacket, + 0x37: serverbound_sign_update_packet::ServerboundSignUpdatePacket, + 0x38: serverbound_swing_packet::ServerboundSwingPacket, + 0x39: serverbound_teleport_to_entity_packet::ServerboundTeleportToEntityPacket, + 0x3a: serverbound_use_item_on_packet::ServerboundUseItemOnPacket, + 0x3b: serverbound_use_item_packet::ServerboundUseItemPacket, }, Clientbound => { 0x00: clientbound_bundle_packet::ClientboundBundlePacket, @@ -275,94 +291,104 @@ declare_state_packets!( 0x1d: clientbound_disconnect_packet::ClientboundDisconnectPacket, 0x1e: clientbound_disguised_chat_packet::ClientboundDisguisedChatPacket, 0x1f: clientbound_entity_event_packet::ClientboundEntityEventPacket, - 0x20: clientbound_explode_packet::ClientboundExplodePacket, - 0x21: clientbound_forget_level_chunk_packet::ClientboundForgetLevelChunkPacket, - 0x22: clientbound_game_event_packet::ClientboundGameEventPacket, - 0x23: clientbound_horse_screen_open_packet::ClientboundHorseScreenOpenPacket, - 0x24: clientbound_hurt_animation_packet::ClientboundHurtAnimationPacket, - 0x25: clientbound_initialize_border_packet::ClientboundInitializeBorderPacket, - 0x26: clientbound_keep_alive_packet::ClientboundKeepAlivePacket, - 0x27: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket, - 0x28: clientbound_level_event_packet::ClientboundLevelEventPacket, - 0x29: clientbound_level_particles_packet::ClientboundLevelParticlesPacket, - 0x2a: clientbound_light_update_packet::ClientboundLightUpdatePacket, - 0x2b: clientbound_login_packet::ClientboundLoginPacket, - 0x2c: clientbound_map_item_data_packet::ClientboundMapItemDataPacket, - 0x2d: clientbound_merchant_offers_packet::ClientboundMerchantOffersPacket, - 0x2e: clientbound_move_entity_pos_packet::ClientboundMoveEntityPosPacket, - 0x2f: clientbound_move_entity_pos_rot_packet::ClientboundMoveEntityPosRotPacket, - 0x30: clientbound_move_entity_rot_packet::ClientboundMoveEntityRotPacket, - 0x31: clientbound_move_vehicle_packet::ClientboundMoveVehiclePacket, - 0x32: clientbound_open_book_packet::ClientboundOpenBookPacket, - 0x33: clientbound_open_screen_packet::ClientboundOpenScreenPacket, - 0x34: clientbound_open_sign_editor_packet::ClientboundOpenSignEditorPacket, - 0x35: clientbound_ping_packet::ClientboundPingPacket, - 0x36: clientbound_pong_response_packet::ClientboundPongResponsePacket, - 0x37: clientbound_place_ghost_recipe_packet::ClientboundPlaceGhostRecipePacket, - 0x38: clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, - 0x39: clientbound_player_chat_packet::ClientboundPlayerChatPacket, - 0x3a: clientbound_player_combat_end_packet::ClientboundPlayerCombatEndPacket, - 0x3b: clientbound_player_combat_enter_packet::ClientboundPlayerCombatEnterPacket, - 0x3c: clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, - 0x3d: clientbound_player_info_remove_packet::ClientboundPlayerInfoRemovePacket, - 0x3e: clientbound_player_info_update_packet::ClientboundPlayerInfoUpdatePacket, - 0x3f: clientbound_player_look_at_packet::ClientboundPlayerLookAtPacket, - 0x40: clientbound_player_position_packet::ClientboundPlayerPositionPacket, - 0x41: clientbound_recipe_packet::ClientboundRecipePacket, - 0x42: clientbound_remove_entities_packet::ClientboundRemoveEntitiesPacket, - 0x43: clientbound_remove_mob_effect_packet::ClientboundRemoveMobEffectPacket, - 0x44: clientbound_reset_score_packet::ClientboundResetScorePacket, - 0x45: clientbound_resource_pack_pop_packet::ClientboundResourcePackPopPacket, - 0x46: clientbound_resource_pack_push_packet::ClientboundResourcePackPushPacket, - 0x47: clientbound_respawn_packet::ClientboundRespawnPacket, - 0x48: clientbound_rotate_head_packet::ClientboundRotateHeadPacket, - 0x49: clientbound_section_blocks_update_packet::ClientboundSectionBlocksUpdatePacket, - 0x4a: clientbound_select_advancements_tab_packet::ClientboundSelectAdvancementsTabPacket, - 0x4b: clientbound_server_data_packet::ClientboundServerDataPacket, - 0x4c: clientbound_set_action_bar_text_packet::ClientboundSetActionBarTextPacket, - 0x4d: clientbound_set_border_center_packet::ClientboundSetBorderCenterPacket, - 0x4e: clientbound_set_border_lerp_size_packet::ClientboundSetBorderLerpSizePacket, - 0x4f: clientbound_set_border_size_packet::ClientboundSetBorderSizePacket, - 0x50: clientbound_set_border_warning_delay_packet::ClientboundSetBorderWarningDelayPacket, - 0x51: clientbound_set_border_warning_distance_packet::ClientboundSetBorderWarningDistancePacket, - 0x52: clientbound_set_camera_packet::ClientboundSetCameraPacket, - 0x53: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket, - 0x54: clientbound_set_chunk_cache_center_packet::ClientboundSetChunkCacheCenterPacket, - 0x55: clientbound_set_chunk_cache_radius_packet::ClientboundSetChunkCacheRadiusPacket, - 0x56: clientbound_set_default_spawn_position_packet::ClientboundSetDefaultSpawnPositionPacket, - 0x57: clientbound_set_display_objective_packet::ClientboundSetDisplayObjectivePacket, - 0x58: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket, - 0x59: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket, - 0x5a: clientbound_set_entity_motion_packet::ClientboundSetEntityMotionPacket, - 0x5b: clientbound_set_equipment_packet::ClientboundSetEquipmentPacket, - 0x5c: clientbound_set_experience_packet::ClientboundSetExperiencePacket, - 0x5d: clientbound_set_health_packet::ClientboundSetHealthPacket, - 0x5e: clientbound_set_objective_packet::ClientboundSetObjectivePacket, - 0x5f: clientbound_set_passengers_packet::ClientboundSetPassengersPacket, - 0x60: clientbound_set_player_team_packet::ClientboundSetPlayerTeamPacket, - 0x61: clientbound_set_score_packet::ClientboundSetScorePacket, - 0x62: clientbound_set_simulation_distance_packet::ClientboundSetSimulationDistancePacket, - 0x63: clientbound_set_subtitle_text_packet::ClientboundSetSubtitleTextPacket, - 0x64: clientbound_set_time_packet::ClientboundSetTimePacket, - 0x65: clientbound_set_title_text_packet::ClientboundSetTitleTextPacket, - 0x66: clientbound_set_titles_animation_packet::ClientboundSetTitlesAnimationPacket, - 0x67: clientbound_sound_entity_packet::ClientboundSoundEntityPacket, - 0x68: clientbound_sound_packet::ClientboundSoundPacket, - 0x69: clientbound_start_configuration_packet::ClientboundStartConfigurationPacket, - 0x6a: clientbound_stop_sound_packet::ClientboundStopSoundPacket, - 0x6b: clientbound_store_cookie_packet::ClientboundStoreCookiePacket, - 0x6c: clientbound_system_chat_packet::ClientboundSystemChatPacket, - 0x6d: clientbound_tab_list_packet::ClientboundTabListPacket, - 0x6e: clientbound_tag_query_packet::ClientboundTagQueryPacket, - 0x6f: clientbound_take_item_entity_packet::ClientboundTakeItemEntityPacket, - 0x70: clientbound_teleport_entity_packet::ClientboundTeleportEntityPacket, - 0x71: clientbound_ticking_state_packet::ClientboundTickingStatePacket, - 0x72: clientbound_ticking_step_packet::ClientboundTickingStepPacket, - 0x73: clientbound_transfer_packet::ClientboundTransferPacket, - 0x74: clientbound_update_advancements_packet::ClientboundUpdateAdvancementsPacket, - 0x75: clientbound_update_attributes_packet::ClientboundUpdateAttributesPacket, - 0x76: clientbound_update_mob_effect_packet::ClientboundUpdateMobEffectPacket, - 0x77: clientbound_update_recipes_packet::ClientboundUpdateRecipesPacket, - 0x78: clientbound_update_tags_packet::ClientboundUpdateTagsPacket, + 0x20: clientbound_entity_position_sync_packet::ClientboundEntityPositionSyncPacket, + 0x21: clientbound_explode_packet::ClientboundExplodePacket, + 0x22: clientbound_forget_level_chunk_packet::ClientboundForgetLevelChunkPacket, + 0x23: clientbound_game_event_packet::ClientboundGameEventPacket, + 0x24: clientbound_horse_screen_open_packet::ClientboundHorseScreenOpenPacket, + 0x25: clientbound_hurt_animation_packet::ClientboundHurtAnimationPacket, + 0x26: clientbound_initialize_border_packet::ClientboundInitializeBorderPacket, + 0x27: clientbound_keep_alive_packet::ClientboundKeepAlivePacket, + 0x28: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket, + 0x29: clientbound_level_event_packet::ClientboundLevelEventPacket, + 0x2a: clientbound_level_particles_packet::ClientboundLevelParticlesPacket, + 0x2b: clientbound_light_update_packet::ClientboundLightUpdatePacket, + 0x2c: clientbound_login_packet::ClientboundLoginPacket, + 0x2d: clientbound_map_item_data_packet::ClientboundMapItemDataPacket, + 0x2e: clientbound_merchant_offers_packet::ClientboundMerchantOffersPacket, + 0x2f: clientbound_move_entity_pos_packet::ClientboundMoveEntityPosPacket, + 0x30: clientbound_move_entity_pos_rot_packet::ClientboundMoveEntityPosRotPacket, + 0x31: clientbound_move_minecart_packet::ClientboundMoveMinecartPacket, + 0x32: clientbound_move_entity_rot_packet::ClientboundMoveEntityRotPacket, + 0x33: clientbound_move_vehicle_packet::ClientboundMoveVehiclePacket, + 0x34: clientbound_open_book_packet::ClientboundOpenBookPacket, + 0x35: clientbound_open_screen_packet::ClientboundOpenScreenPacket, + 0x36: clientbound_open_sign_editor_packet::ClientboundOpenSignEditorPacket, + 0x37: clientbound_ping_packet::ClientboundPingPacket, + 0x38: clientbound_pong_response_packet::ClientboundPongResponsePacket, + 0x39: clientbound_place_ghost_recipe_packet::ClientboundPlaceGhostRecipePacket, + 0x3a: clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, + 0x3b: clientbound_player_chat_packet::ClientboundPlayerChatPacket, + 0x3c: clientbound_player_combat_end_packet::ClientboundPlayerCombatEndPacket, + 0x3d: clientbound_player_combat_enter_packet::ClientboundPlayerCombatEnterPacket, + 0x3e: clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, + 0x3f: clientbound_player_info_remove_packet::ClientboundPlayerInfoRemovePacket, + 0x40: clientbound_player_info_update_packet::ClientboundPlayerInfoUpdatePacket, + 0x41: clientbound_player_look_at_packet::ClientboundPlayerLookAtPacket, + 0x42: clientbound_player_position_packet::ClientboundPlayerPositionPacket, + 0x43: clientbound_player_rotation_packet::ClientboundPlayerRotationPacket, + 0x44: clientbound_recipe_book_add_packet::ClientboundRecipeBookAddPacket, + 0x45: clientbound_recipe_book_remove_packet::ClientboundRecipeBookRemovePacket, + 0x46: clientbound_recipe_book_settings_packet::ClientboundRecipeBookSettingsPacket, + 0x47: clientbound_remove_entities_packet::ClientboundRemoveEntitiesPacket, + 0x48: clientbound_remove_mob_effect_packet::ClientboundRemoveMobEffectPacket, + 0x49: clientbound_reset_score_packet::ClientboundResetScorePacket, + 0x4a: clientbound_resource_pack_pop_packet::ClientboundResourcePackPopPacket, + 0x4b: clientbound_resource_pack_push_packet::ClientboundResourcePackPushPacket, + 0x4c: clientbound_respawn_packet::ClientboundRespawnPacket, + 0x4d: clientbound_rotate_head_packet::ClientboundRotateHeadPacket, + 0x4e: clientbound_section_blocks_update_packet::ClientboundSectionBlocksUpdatePacket, + 0x4f: clientbound_select_advancements_tab_packet::ClientboundSelectAdvancementsTabPacket, + 0x50: clientbound_server_data_packet::ClientboundServerDataPacket, + 0x51: clientbound_set_action_bar_text_packet::ClientboundSetActionBarTextPacket, + 0x52: clientbound_set_border_center_packet::ClientboundSetBorderCenterPacket, + 0x53: clientbound_set_border_lerp_size_packet::ClientboundSetBorderLerpSizePacket, + 0x54: clientbound_set_border_size_packet::ClientboundSetBorderSizePacket, + 0x55: clientbound_set_border_warning_delay_packet::ClientboundSetBorderWarningDelayPacket, + 0x56: clientbound_set_border_warning_distance_packet::ClientboundSetBorderWarningDistancePacket, + 0x57: clientbound_set_camera_packet::ClientboundSetCameraPacket, + 0x58: clientbound_set_chunk_cache_center_packet::ClientboundSetChunkCacheCenterPacket, + 0x59: clientbound_set_chunk_cache_radius_packet::ClientboundSetChunkCacheRadiusPacket, + 0x5a: clientbound_set_cursor_item_packet::ClientboundSetCursorItemPacket, + 0x5b: clientbound_set_default_spawn_position_packet::ClientboundSetDefaultSpawnPositionPacket, + 0x5c: clientbound_set_display_objective_packet::ClientboundSetDisplayObjectivePacket, + 0x5d: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket, + 0x5e: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket, + 0x5f: clientbound_set_entity_motion_packet::ClientboundSetEntityMotionPacket, + 0x60: clientbound_set_equipment_packet::ClientboundSetEquipmentPacket, + 0x61: clientbound_set_experience_packet::ClientboundSetExperiencePacket, + 0x62: clientbound_set_health_packet::ClientboundSetHealthPacket, + 0x63: clientbound_set_held_slot_packet::ClientboundSetHeldSlotPacket, + 0x64: clientbound_set_objective_packet::ClientboundSetObjectivePacket, + 0x65: clientbound_set_passengers_packet::ClientboundSetPassengersPacket, + 0x66: clientbound_set_player_inventory_packet::ClientboundSetPlayerInventoryPacket, + 0x67: clientbound_set_player_team_packet::ClientboundSetPlayerTeamPacket, + 0x68: clientbound_set_score_packet::ClientboundSetScorePacket, + 0x69: clientbound_set_simulation_distance_packet::ClientboundSetSimulationDistancePacket, + 0x6a: clientbound_set_subtitle_text_packet::ClientboundSetSubtitleTextPacket, + 0x6b: clientbound_set_time_packet::ClientboundSetTimePacket, + 0x6c: clientbound_set_title_text_packet::ClientboundSetTitleTextPacket, + 0x6d: clientbound_set_titles_animation_packet::ClientboundSetTitlesAnimationPacket, + 0x6e: clientbound_sound_entity_packet::ClientboundSoundEntityPacket, + 0x6f: clientbound_sound_packet::ClientboundSoundPacket, + 0x70: clientbound_start_configuration_packet::ClientboundStartConfigurationPacket, + 0x71: clientbound_stop_sound_packet::ClientboundStopSoundPacket, + 0x72: clientbound_store_cookie_packet::ClientboundStoreCookiePacket, + 0x73: clientbound_system_chat_packet::ClientboundSystemChatPacket, + 0x74: clientbound_tab_list_packet::ClientboundTabListPacket, + 0x75: clientbound_tag_query_packet::ClientboundTagQueryPacket, + 0x76: clientbound_take_item_entity_packet::ClientboundTakeItemEntityPacket, + 0x77: clientbound_teleport_entity_packet::ClientboundTeleportEntityPacket, + 0x78: clientbound_ticking_state_packet::ClientboundTickingStatePacket, + 0x79: clientbound_ticking_step_packet::ClientboundTickingStepPacket, + 0x7a: clientbound_transfer_packet::ClientboundTransferPacket, + 0x7b: clientbound_update_advancements_packet::ClientboundUpdateAdvancementsPacket, + 0x7c: clientbound_update_attributes_packet::ClientboundUpdateAttributesPacket, + 0x7d: clientbound_update_mob_effect_packet::ClientboundUpdateMobEffectPacket, + 0x7e: clientbound_update_recipes_packet::ClientboundUpdateRecipesPacket, + 0x7f: clientbound_update_tags_packet::ClientboundUpdateTagsPacket, + 0x80: clientbound_projectile_power_packet::ClientboundProjectilePowerPacket, + 0x81: clientbound_custom_report_details_packet::ClientboundCustomReportDetailsPacket, + 0x82: clientbound_server_links_packet::ClientboundServerLinksPacket } ); diff --git a/azalea-protocol/src/packets/game/serverbound_client_tick_end_packet.rs b/azalea-protocol/src/packets/game/serverbound_client_tick_end_packet.rs new file mode 100644 index 00000000..c843066e --- /dev/null +++ b/azalea-protocol/src/packets/game/serverbound_client_tick_end_packet.rs @@ -0,0 +1,5 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ServerboundGamePacket; + +#[derive(Clone, Debug, McBuf, ServerboundGamePacket)] +pub struct ServerboundTickEndPacket {} diff --git a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs index db6e51a9..a461ddf5 100755 --- a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs @@ -7,37 +7,54 @@ use azalea_protocol_macros::ServerboundGamePacket; #[derive(Clone, Debug, ServerboundGamePacket)] pub struct ServerboundPlayerInputPacket { - pub xxa: f32, - pub zza: f32, - pub is_jumping: bool, - pub is_shift_key_down: bool, + pub forward: bool, + pub backward: bool, + pub left: bool, + pub right: bool, + pub jump: bool, + pub shift: bool, + pub sprint: bool, } impl McBufReadable for ServerboundPlayerInputPacket { fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - let xxa = f32::read_from(buf)?; - let zza = f32::read_from(buf)?; - let set = FixedBitSet::<2>::read_from(buf)?; + let set = FixedBitSet::<7>::read_from(buf)?; Ok(Self { - xxa, - zza, - is_jumping: set.index(0), - is_shift_key_down: set.index(1), + forward: set.index(0), + backward: set.index(1), + left: set.index(2), + right: set.index(3), + jump: set.index(4), + shift: set.index(5), + sprint: set.index(6), }) } } impl McBufWritable for ServerboundPlayerInputPacket { fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { - self.xxa.write_into(buf)?; - self.zza.write_into(buf)?; - let mut set = FixedBitSet::<2>::new(); - if self.is_jumping { + let mut set = FixedBitSet::<7>::new(); + if self.forward { set.set(0); } - if self.is_shift_key_down { + if self.backward { set.set(1); } + if self.left { + set.set(2); + } + if self.right { + set.set(3); + } + if self.jump { + set.set(4); + } + if self.shift { + set.set(5); + } + if self.sprint { + set.set(6); + } set.write_into(buf) } } diff --git a/azalea-protocol/src/packets/game/serverbound_select_bundle_item_packet.rs b/azalea-protocol/src/packets/game/serverbound_select_bundle_item_packet.rs new file mode 100644 index 00000000..3a315183 --- /dev/null +++ b/azalea-protocol/src/packets/game/serverbound_select_bundle_item_packet.rs @@ -0,0 +1,10 @@ +use azalea_buf::McBuf; +use azalea_protocol_macros::ServerboundGamePacket; + +#[derive(Clone, Debug, McBuf, ServerboundGamePacket)] +pub struct ServerboundSelectBundleItemPacket { + #[var] + pub slot_id: i32, + #[var] + pub selected_item_index: u32, +} diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs deleted file mode 100755 index 51f486d0..00000000 --- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs +++ /dev/null @@ -1,9 +0,0 @@ -use azalea_auth::game_profile::GameProfile; -use azalea_buf::McBuf; -use azalea_protocol_macros::ClientboundLoginPacket; - -#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)] -pub struct ClientboundGameProfilePacket { - pub game_profile: GameProfile, - pub strict_error_handling: bool, -} diff --git a/azalea-protocol/src/packets/login/clientbound_login_finished_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_finished_packet.rs new file mode 100755 index 00000000..f885f67f --- /dev/null +++ b/azalea-protocol/src/packets/login/clientbound_login_finished_packet.rs @@ -0,0 +1,8 @@ +use azalea_auth::game_profile::GameProfile; +use azalea_buf::McBuf; +use azalea_protocol_macros::ClientboundLoginPacket; + +#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)] +pub struct ClientboundLoginFinishedPacket { + pub game_profile: GameProfile, +} diff --git a/azalea-protocol/src/packets/login/mod.rs b/azalea-protocol/src/packets/login/mod.rs index 2037f2c1..3d218cc1 100755 --- a/azalea-protocol/src/packets/login/mod.rs +++ b/azalea-protocol/src/packets/login/mod.rs @@ -1,9 +1,9 @@ pub mod clientbound_cookie_request_packet; pub mod clientbound_custom_query_packet; -pub mod clientbound_game_profile_packet; pub mod clientbound_hello_packet; pub mod clientbound_login_compression_packet; pub mod clientbound_login_disconnect_packet; +pub mod clientbound_login_finished_packet; pub mod serverbound_cookie_response_packet; pub mod serverbound_custom_query_answer_packet; pub mod serverbound_hello_packet; @@ -24,7 +24,7 @@ declare_state_packets!( Clientbound => { 0x00: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket, 0x01: clientbound_hello_packet::ClientboundHelloPacket, - 0x02: clientbound_game_profile_packet::ClientboundGameProfilePacket, + 0x02: clientbound_login_finished_packet::ClientboundLoginFinishedPacket, 0x03: clientbound_login_compression_packet::ClientboundLoginCompressionPacket, 0x04: clientbound_custom_query_packet::ClientboundCustomQueryPacket, 0x05: clientbound_cookie_request_packet::ClientboundCookieRequestPacket, diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 41d37c7b..6cec015f 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -12,7 +12,7 @@ use std::io::{Cursor, Write}; // TODO: rename the packet files to just like clientbound_add_entity instead of // clientbound_add_entity_packet -pub const PROTOCOL_VERSION: i32 = 767; +pub const PROTOCOL_VERSION: i32 = 768; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { -- cgit v1.2.3