diff options
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | azalea-core/src/game_type.rs | 2 | ||||
| -rw-r--r-- | azalea-protocol/src/common/recipe.rs | 16 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/c_player_info_update.rs | 50 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/c_update_attributes.rs | 2 |
5 files changed, 49 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1376e4d8..2ab10f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ is breaking anyways, semantic versioning is not followed. - Fixed several panics, OOMs, and memory leaks in `azalea-protocol`. - Click events in chat messages were missing. - `ClientboundSetEquipment` failed to deserialize if a packet used animal armor slots. +- Incorrect protocol implementations for `ClientboundPlayerInfoUpdate` and recipe data. ## [0.15.1+mc1.21.11] - 2026-02-03 diff --git a/azalea-core/src/game_type.rs b/azalea-core/src/game_type.rs index a8c73a41..9113e382 100644 --- a/azalea-core/src/game_type.rs +++ b/azalea-core/src/game_type.rs @@ -87,7 +87,7 @@ impl GameMode { impl GameMode { /// Whether the player can't interact with blocks while in this game mode. /// - /// (Returns true if you're in adventure or spectator.) + /// Returns true if you're in adventure or spectator. pub fn is_block_placing_restricted(&self) -> bool { matches!(self, GameMode::Adventure | GameMode::Spectator) } diff --git a/azalea-protocol/src/common/recipe.rs b/azalea-protocol/src/common/recipe.rs index 9a59cc4b..e0e10ecc 100644 --- a/azalea-protocol/src/common/recipe.rs +++ b/azalea-protocol/src/common/recipe.rs @@ -1,8 +1,8 @@ use azalea_buf::AzBuf; use azalea_inventory::ItemStack; -use azalea_registry::{HolderSet, builtin::ItemKind, identifier::Identifier}; +use azalea_registry::{HolderSet, builtin::ItemKind, data::TrimPattern, identifier::Identifier}; -/// [`azalea_registry::RecipeDisplay`] +/// [`azalea_registry::builtin::RecipeDisplay`] #[derive(AzBuf, Clone, Debug, PartialEq)] pub enum RecipeDisplayData { Shapeless(ShapelessCraftingRecipeDisplay), @@ -58,21 +58,21 @@ pub struct Ingredient { pub allowed: HolderSet<ItemKind, Identifier>, } -/// [`azalea_registry::SlotDisplay`] +/// [`azalea_registry::builtin::SlotDisplay`] #[derive(AzBuf, Clone, Debug, PartialEq)] pub enum SlotDisplayData { Empty, AnyFuel, - ItemKind(ItemStackDisplay), + Item(ItemSlotDisplay), ItemStack(ItemStackSlotDisplay), - Tag(Identifier), + Tag(TagSlotDisplay), SmithingTrim(Box<SmithingTrimDemoSlotDisplay>), WithRemainder(Box<WithRemainderSlotDisplay>), Composite(CompositeSlotDisplay), } #[derive(AzBuf, Clone, Debug, PartialEq)] -pub struct ItemStackDisplay { +pub struct ItemSlotDisplay { pub item: ItemKind, } #[derive(AzBuf, Clone, Debug, PartialEq)] @@ -81,13 +81,13 @@ pub struct ItemStackSlotDisplay { } #[derive(AzBuf, Clone, Debug, PartialEq)] pub struct TagSlotDisplay { - pub tag: ItemKind, + pub tag: Identifier, } #[derive(AzBuf, Clone, Debug, PartialEq)] pub struct SmithingTrimDemoSlotDisplay { pub base: SlotDisplayData, pub material: SlotDisplayData, - pub pattern: SlotDisplayData, + pub pattern: TrimPattern, } #[derive(AzBuf, Clone, Debug, PartialEq)] pub struct WithRemainderSlotDisplay { diff --git a/azalea-protocol/src/packets/game/c_player_info_update.rs b/azalea-protocol/src/packets/game/c_player_info_update.rs index 0bce5724..8f74084d 100644 --- a/azalea-protocol/src/packets/game/c_player_info_update.rs +++ b/azalea-protocol/src/packets/game/c_player_info_update.rs @@ -21,13 +21,13 @@ pub struct ClientboundPlayerInfoUpdate { #[derive(Clone, Debug, Default, PartialEq)] pub struct PlayerInfoEntry { pub profile: GameProfile, + pub chat_session: Option<RemoteChatSessionData>, + pub game_mode: GameMode, pub listed: bool, pub latency: i32, - pub game_mode: GameMode, pub display_name: Option<Box<FormattedText>>, pub list_order: i32, pub update_hat: bool, - pub chat_session: Option<RemoteChatSessionData>, } #[derive(AzBuf, Clone, Debug)] @@ -102,14 +102,14 @@ impl AzBuf for ClientboundPlayerInfoUpdate { let action = UpdateDisplayNameAction::azalea_read(buf)?; entry.display_name = action.display_name; } - if actions.update_hat { - let action = UpdateHatAction::azalea_read(buf)?; - entry.update_hat = action.update_hat; - } if actions.update_list_order { let action = UpdateListOrderAction::azalea_read(buf)?; entry.list_order = action.list_order; } + if actions.update_hat { + let action = UpdateHatAction::azalea_read(buf)?; + entry.update_hat = action.update_hat; + } entries.push(entry); } @@ -174,8 +174,8 @@ pub struct ActionEnumSet { pub update_listed: bool, pub update_latency: bool, pub update_display_name: bool, - pub update_hat: bool, pub update_list_order: bool, + pub update_hat: bool, } impl AzBuf for ActionEnumSet { @@ -188,8 +188,8 @@ impl AzBuf for ActionEnumSet { update_listed: set.index(3), update_latency: set.index(4), update_display_name: set.index(5), - update_hat: set.index(6), - update_list_order: set.index(7), + update_list_order: set.index(6), + update_hat: set.index(7), }) } fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { @@ -212,10 +212,10 @@ impl AzBuf for ActionEnumSet { if self.update_display_name { set.set(5); } - if self.update_hat { + if self.update_list_order { set.set(6); } - if self.update_list_order { + if self.update_hat { set.set(7); } set.azalea_write(buf)?; @@ -236,8 +236,8 @@ mod tests { update_listed: false, update_latency: true, update_display_name: false, - update_hat: false, update_list_order: true, + update_hat: false, }; let mut buf = Vec::new(); data.azalea_write(&mut buf).unwrap(); @@ -317,4 +317,30 @@ mod tests { ); let _packet = ClientboundPlayerInfoUpdate::azalea_read(&mut bytes).unwrap(); } + + #[test] + fn read_player_info_update_packet2() { + tracing_subscriber::fmt::init(); + + // from donutsmp.net + #[rustfmt::skip] + let contents = [253, 1, 143, 67, 23, 207, 27, 226, 78, 160, 174, 99, 203, 156, 133, 34, 245, 147, 5, 65, 113, 117, 110, 49, 1, 8, 116, 101, 120, 116, 117, 114, 101, 115, 224, 3, 101, 119, 111, 103, 73, 67, 74, 48, 97, 87, 49, 108, 99, 51, 82, 104, 98, 88, 65, 105, 73, 68, 111, 103, 77, 84, 99, 51, 77, 84, 81, 122, 79, 68, 81, 51, 78, 106, 81, 53, 79, 83, 119, 75, 73, 67, 65, 105, 99, 72, 74, 118, 90, 109, 108, 115, 90, 85, 108, 107, 73, 105, 65, 54, 73, 67, 73, 52, 90, 106, 81, 122, 77, 84, 100, 106, 90, 106, 70, 105, 90, 84, 73, 48, 90, 87, 69, 119, 89, 87, 85, 50, 77, 50, 78, 105, 79, 87, 77, 52, 78, 84, 73, 121, 90, 106, 85, 53, 77, 121, 73, 115, 67, 105, 65, 103, 73, 110, 66, 121, 98, 50, 90, 112, 98, 71, 86, 79, 89, 87, 49, 108, 73, 105, 65, 54, 73, 67, 74, 66, 99, 88, 86, 117, 77, 83, 73, 115, 67, 105, 65, 103, 73, 110, 78, 112, 90, 50, 53, 104, 100, 72, 86, 121, 90, 86, 74, 108, 99, 88, 86, 112, 99, 109, 86, 107, 73, 105, 65, 54, 73, 72, 82, 121, 100, 87, 85, 115, 67, 105, 65, 103, 73, 110, 82, 108, 101, 72, 82, 49, 99, 109, 86, 122, 73, 105, 65, 54, 73, 72, 115, 75, 73, 67, 65, 103, 73, 67, 74, 84, 83, 48, 108, 79, 73, 105, 65, 54, 73, 72, 115, 75, 73, 67, 65, 103, 73, 67, 65, 103, 73, 110, 86, 121, 98, 67, 73, 103, 79, 105, 65, 105, 97, 72, 82, 48, 99, 68, 111, 118, 76, 51, 82, 108, 101, 72, 82, 49, 99, 109, 86, 122, 76, 109, 49, 112, 98, 109, 86, 106, 99, 109, 70, 109, 100, 67, 53, 117, 90, 88, 81, 118, 100, 71, 86, 52, 100, 72, 86, 121, 90, 83, 56, 50, 78, 50, 89, 53, 79, 68, 89, 120, 78, 87, 70, 107, 78, 122, 85, 119, 89, 84, 90, 107, 77, 122, 99, 52, 78, 84, 89, 53, 79, 68, 103, 48, 78, 122, 65, 49, 89, 122, 65, 49, 90, 71, 73, 49, 79, 84, 70, 109, 78, 84, 99, 52, 77, 71, 69, 119, 89, 106, 107, 120, 78, 50, 69, 52, 78, 106, 85, 49, 79, 71, 81, 48, 78, 122, 78, 104, 77, 71, 85, 122, 78, 84, 73, 120, 73, 105, 119, 75, 73, 67, 65, 103, 73, 67, 65, 103, 73, 109, 49, 108, 100, 71, 70, 107, 89, 88, 82, 104, 73, 105, 65, 54, 73, 72, 115, 75, 73, 67, 65, 103, 73, 67, 65, 103, 73, 67, 65, 105, 98, 87, 57, 107, 90, 87, 119, 105, 73, 68, 111, 103, 73, 110, 78, 115, 97, 87, 48, 105, 67, 105, 65, 103, 73, 67, 65, 103, 73, 72, 48, 75, 73, 67, 65, 103, 73, 72, 48, 75, 73, 67, 66, 57, 67, 110, 48, 61, 1, 172, 5, 76, 55, 90, 72, 79, 73, 54, 104, 121, 104, 71, 69, 116, 84, 82, 51, 87, 81, 47, 118, 49, 111, 54, 82, 112, 80, 85, 79, 80, 112, 89, 119, 72, 50, 113, 116, 74, 51, 100, 106, 71, 67, 78, 89, 89, 99, 86, 80, 102, 70, 53, 111, 83, 118, 52, 97, 72, 52, 70, 121, 74, 74, 76, 121, 122, 68, 89, 122, 115, 84, 118, 119, 47, 78, 107, 80, 43, 68, 100, 113, 81, 103, 54, 65, 70, 110, 71, 86, 76, 112, 101, 48, 118, 111, 111, 120, 119, 49, 100, 47, 84, 105, 108, 54, 106, 115, 114, 78, 69, 86, 113, 90, 88, 104, 102, 71, 48, 72, 82, 80, 105, 66, 77, 74, 81, 82, 84, 72, 68, 78, 116, 80, 74, 74, 120, 110, 69, 57, 79, 116, 119, 52, 70, 74, 78, 79, 86, 80, 119, 118, 109, 68, 97, 65, 80, 106, 89, 104, 89, 100, 88, 106, 85, 77, 70, 115, 52, 69, 106, 81, 106, 87, 56, 69, 88, 97, 114, 71, 69, 107, 52, 105, 86, 54, 106, 107, 52, 84, 105, 102, 47, 81, 115, 54, 102, 51, 101, 105, 88, 51, 76, 52, 107, 49, 99, 47, 79, 53, 43, 57, 48, 88, 103, 102, 43, 103, 70, 97, 49, 118, 102, 67, 114, 81, 83, 110, 75, 109, 68, 100, 118, 57, 116, 82, 56, 88, 105, 99, 99, 74, 114, 80, 67, 54, 81, 81, 102, 52, 102, 113, 47, 52, 101, 80, 80, 54, 102, 86, 119, 54, 88, 70, 105, 82, 79, 90, 57, 53, 70, 90, 107, 110, 73, 97, 67, 66, 117, 104, 67, 82, 47, 99, 100, 84, 74, 121, 50, 99, 55, 107, 118, 113, 67, 111, 54, 105, 120, 52, 90, 118, 66, 106, 115, 90, 83, 115, 97, 103, 100, 56, 79, 71, 50, 79, 108, 89, 53, 43, 113, 68, 86, 48, 77, 103, 101, 54, 89, 103, 77, 107, 57, 117, 116, 86, 69, 79, 97, 53, 107, 82, 82, 117, 87, 48, 65, 98, 73, 47, 70, 97, 98, 89, 53, 65, 51, 90, 56, 116, 89, 56, 79, 56, 86, 73, 69, 77, 102, 118, 83, 105, 116, 122, 107, 99, 47, 68, 78, 82, 86, 47, 112, 115, 119, 67, 89, 119, 77, 109, 99, 105, 48, 87, 98, 114, 109, 98, 85, 67, 75, 85, 106, 75, 73, 55, 111, 121, 83, 82, 76, 57, 83, 80, 84, 118, 53, 117, 52, 68, 110, 72, 78, 87, 110, 66, 66, 111, 82, 113, 49, 43, 115, 76, 48, 87, 121, 48, 65, 90, 101, 89, 83, 81, 47, 104, 56, 72, 65, 50, 114, 66, 67, 89, 103, 120, 80, 70, 107, 54, 50, 117, 97, 83, 51, 66, 97, 110, 74, 43, 82, 83, 114, 67, 102, 104, 107, 68, 114, 81, 98, 55, 51, 54, 65, 76, 50, 47, 76, 82, 102, 85, 75, 76, 53, 67, 71, 43, 53, 98, 52, 68, 53, 112, 121, 83, 50, 116, 111, 76, 50, 83, 101, 108, 49, 77, 90, 122, 102, 115, 74, 49, 97, 80, 97, 79, 49, 52, 103, 106, 55, 77, 76, 87, 106, 121, 106, 48, 51, 88, 106, 84, 69, 113, 82, 65, 68, 104, 82, 55, 47, 78, 73, 67, 75, 117, 106, 69, 50, 57, 52, 43, 80, 114, 115, 47, 55, 67, 97, 103, 87, 118, 82, 90, 119, 90, 101, 100, 56, 90, 56, 107, 98, 52, 97, 115, 54, 102, 85, 83, 112, 90, 117, 109, 70, 89, 77, 108, 84, 65, 109, 99, 57, 110, 67, 78, 102, 72, 118, 77, 56, 109, 65, 86, 70, 73, 48, 101, 83, 98, 89, 114, 49, 77, 52, 101, 120, 116, 106, 70, 107, 76, 101, 68, 47, 99, 86, 99, 66, 100, 48, 54, 89, 109, 65, 122, 50, 51, 77, 84, 49, 115, 113, 121, 89, 100, 67, 75, 52, 105, 79, 117, 99, 98, 121, 72, 111, 84, 48, 68, 117, 72, 110, 52, 76, 105, 88, 56, 82, 67, 86, 43, 70, 56, 48, 61, 0, 1, 0, 1, 10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 3, 8, 0, 5, 99, 111, 108, 111, 114, 0, 7, 35, 70, 70, 48, 48, 65, 54, 1, 0, 10, 117, 110, 100, 101, 114, 108, 105, 110, 101, 100, 0, 1, 0, 4, 98, 111, 108, 100, 0, 1, 0, 13, 115, 116, 114, 105, 107, 101, 116, 104, 114, 111, 117, 103, 104, 0, 8, 0, 4, 116, 101, 120, 116, 0, 6, 237, 160, 189, 237, 179, 185, 1, 0, 6, 105, 116, 97, 108, 105, 99, 0, 1, 0, 10, 111, 98, 102, 117, 115, 99, 97, 116, 101, 100, 0, 0, 8, 0, 5, 99, 111, 108, 111, 114, 0, 7, 35, 48, 48, 65, 54, 70, 70, 1, 0, 10, 117, 110, 100, 101, 114, 108, 105, 110, 101, 100, 0, 1, 0, 4, 98, 111, 108, 100, 0, 1, 0, 13, 115, 116, 114, 105, 107, 101, 116, 104, 114, 111, 117, 103, 104, 0, 8, 0, 4, 116, 101, 120, 116, 0, 1, 43, 1, 0, 6, 105, 116, 97, 108, 105, 99, 0, 1, 0, 10, 111, 98, 102, 117, 115, 99, 97, 116, 101, 100, 0, 0, 8, 0, 5, 99, 111, 108, 111, 114, 0, 7, 35, 65, 52, 65, 66, 66, 55, 1, 0, 10, 117, 110, 100, 101, 114, 108, 105, 110, 101, 100, 0, 1, 0, 4, 98, 111, 108, 100, 0, 1, 0, 13, 115, 116, 114, 105, 107, 101, 116, 104, 114, 111, 117, 103, 104, 0, 8, 0, 4, 116, 101, 120, 116, 0, 5, 65, 113, 117, 110, 49, 1, 0, 6, 105, 116, 97, 108, 105, 99, 0, 1, 0, 10, 111, 98, 102, 117, 115, 99, 97, 116, 101, 100, 0, 0, 8, 0, 4, 116, 101, 120, 116, 0, 0, 0, 151, 141, 6, 1]; + let mut buf = Cursor::new(contents.as_slice()); + let _packet = ClientboundPlayerInfoUpdate::azalea_read(&mut buf).unwrap(); + + assert_eq!(buf.position(), contents.len() as u64); + } + + #[test] + fn read_player_info_update_packet3() { + tracing_subscriber::fmt::init(); + + // from donutsmp.net + #[rustfmt::skip] + let contents = [64, 1, 203, 169, 246, 238, 217, 134, 76, 40, 144, 100, 113, 219, 69, 183, 255, 63, 145, 141, 6]; + let mut buf = Cursor::new(contents.as_slice()); + let _packet = ClientboundPlayerInfoUpdate::azalea_read(&mut buf).unwrap(); + + assert_eq!(buf.position(), contents.len() as u64); + } } diff --git a/azalea-protocol/src/packets/game/c_update_attributes.rs b/azalea-protocol/src/packets/game/c_update_attributes.rs index 7c8e9e12..ed7b69f6 100644 --- a/azalea-protocol/src/packets/game/c_update_attributes.rs +++ b/azalea-protocol/src/packets/game/c_update_attributes.rs @@ -1,8 +1,8 @@ use azalea_buf::AzBuf; +use azalea_core::entity_id::MinecraftEntityId; use azalea_inventory::components::AttributeModifier; use azalea_protocol_macros::ClientboundGamePacket; use azalea_registry::builtin::Attribute; -use azalea_core::entity_id::MinecraftEntityId; #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] pub struct ClientboundUpdateAttributes { |
