diff options
| author | mat <github@matdoes.dev> | 2023-04-20 17:11:56 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2023-04-20 17:11:56 +0000 |
| commit | 88b09f7791b51639f8191cc88c98fbd13fa7e3d4 (patch) | |
| tree | de9d1497d51190df26eddf00992658ac7bc47924 /azalea-protocol/src | |
| parent | c4c5edf80b364b9e1281e04b26446cdff499a8b5 (diff) | |
| parent | 821533138152748d3b677afd64f505020d6a83b3 (diff) | |
| download | azalea-drasl-88b09f7791b51639f8191cc88c98fbd13fa7e3d4.tar.xz | |
Merge branch 'main' into 1.20
Diffstat (limited to 'azalea-protocol/src')
| -rw-r--r-- | azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs | 13 | ||||
| -rwxr-xr-x | azalea-protocol/src/packets/game/clientbound_login_packet.rs | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs index 93731445..941ed01f 100644 --- a/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs @@ -16,15 +16,20 @@ pub struct ClientboundDamageEventPacket { } #[derive(Clone, Debug)] -pub struct OptionalEntityId(pub u32); +pub struct OptionalEntityId(pub Option<u32>); impl McBufReadable for OptionalEntityId { fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> { - Ok(OptionalEntityId(u32::var_read_from(buf)? - 1)) + match u32::var_read_from(buf)? { + 0 => Ok(OptionalEntityId(None)), + id => Ok(OptionalEntityId(Some(id - 1))), + } } } impl McBufWritable for OptionalEntityId { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - (self.0 + 1).var_write_into(buf)?; - Ok(()) + match self.0 { + Some(id) => (id + 1).var_write_into(buf), + None => 0u32.var_write_into(buf), + } } } diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs index 42f93c40..a35951a7 100755 --- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs @@ -515,7 +515,7 @@ mod tests { .unwrap() .as_compound() .unwrap(); - let dimension_type = dimension.get("type").unwrap().as_string().unwrap(); + let dimension_type = dimension.get("type").unwrap().as_string().unwrap().as_str(); assert!(dimension_type == "minecraft:dimension_type"); } } |
