aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/c_container_set_content.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-12-05 06:30:47 +0000
committermat <git@matdoes.dev>2024-12-05 06:30:47 +0000
commit39f4d68e1ff1f0fa0d45663335d83299d5d37790 (patch)
treeac61d7bf437a1874c91d5c794b732dc599f86259 /azalea-protocol/src/packets/game/c_container_set_content.rs
parent6379035b852f1b619565d27f5cee3b93042c2312 (diff)
downloadazalea-drasl-39f4d68e1ff1f0fa0d45663335d83299d5d37790.tar.xz
fix container_set_content, player_position, and recipe_book_remove packets
Diffstat (limited to 'azalea-protocol/src/packets/game/c_container_set_content.rs')
-rwxr-xr-xazalea-protocol/src/packets/game/c_container_set_content.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/azalea-protocol/src/packets/game/c_container_set_content.rs b/azalea-protocol/src/packets/game/c_container_set_content.rs
index 852ce60f..d4bd9184 100755
--- a/azalea-protocol/src/packets/game/c_container_set_content.rs
+++ b/azalea-protocol/src/packets/game/c_container_set_content.rs
@@ -10,3 +10,29 @@ pub struct ClientboundContainerSetContent {
pub items: Vec<ItemStack>,
pub carried_item: ItemStack,
}
+
+#[cfg(test)]
+mod tests {
+ use std::io::Cursor;
+
+ use super::ClientboundContainerSetContent;
+ use crate::packets::ProtocolPacket;
+
+ #[test]
+ fn test_read_write_container_set_content() {
+ let contents = [
+ 1, 2, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 1, 196, 6, 0, 0, 0,
+ ];
+ let mut buf = Cursor::new(contents.as_slice());
+ let packet = ClientboundContainerSetContent::read(&mut buf).unwrap();
+ println!("{:?}", packet);
+
+ assert_eq!(buf.position(), contents.len() as u64);
+
+ let mut buf = Vec::new();
+ packet.write(&mut buf).unwrap();
+ assert_eq!(buf, contents);
+ }
+}