aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Sacchini <joey@sacchini.net>2020-10-09 19:18:59 -0400
committerJoey Sacchini <joey@sacchini.net>2020-10-09 19:18:59 -0400
commitf80b0ff22a64b3e09454b365df6f461e0849408b (patch)
treee98b6cd554cbfd2ffba60cdc720aa2d276032e07
parent78734b13bad57c68b648802e0d16c0c6303b47e4 (diff)
downloadmcproto-rs-f80b0ff22a64b3e09454b365df6f461e0849408b.tar.gz
mcproto-rs-f80b0ff22a64b3e09454b365df6f461e0849408b.tar.bz2
mcproto-rs-f80b0ff22a64b3e09454b365df6f461e0849408b.zip
interact packet from client has a hand field when action is Interact
-rw-r--r--src/v1_15_2.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/v1_15_2.rs b/src/v1_15_2.rs
index e56bca1..03b3ac4 100644
--- a/src/v1_15_2.rs
+++ b/src/v1_15_2.rs
@@ -2453,7 +2453,7 @@ __protocol_body_def_helper!(InteractAtSpec {
#[derive(Clone, PartialEq, Debug)]
pub enum InteractKind {
- Interact,
+ Interact(Hand),
Attack,
InteractAt(InteractAtSpec),
}
@@ -2462,7 +2462,7 @@ impl InteractKind {
pub fn id(&self) -> VarInt {
use InteractKind::*;
match self {
- Interact => 0x00,
+ Interact(_) => 0x00,
Attack => 0x01,
InteractAt(_) => 0x02,
}
@@ -2478,6 +2478,7 @@ impl Serialize for InteractKind {
use InteractKind::*;
match self {
InteractAt(body) => to.serialize_other(body),
+ Interact(hand) => to.serialize_other(hand),
_ => Ok(()),
}
}
@@ -2489,7 +2490,7 @@ impl Deserialize for InteractKind {
use InteractKind::*;
match id.0 {
- 0x00 => Deserialized::ok(Interact, data),
+ 0x00 => Ok(Hand::mc_deserialize(data)?.map(move |hand| Interact(hand))),
0x01 => Deserialized::ok(Attack, data),
0x02 => Ok(InteractAtSpec::mc_deserialize(data)?.map(move |body| InteractAt(body))),
other => Err(DeserializeErr::CannotUnderstandValue(format!(
@@ -2503,7 +2504,7 @@ impl Deserialize for InteractKind {
#[cfg(test)]
impl TestRandom for InteractKind {
fn test_gen_random() -> Self {
- InteractKind::Attack
+ InteractKind::Interact(Hand::test_gen_random())
}
}