diff --git a/protocol/src/protocol/mod.rs b/protocol/src/protocol/mod.rs index d1b3d02..6bc14c8 100644 --- a/protocol/src/protocol/mod.rs +++ b/protocol/src/protocol/mod.rs @@ -34,7 +34,7 @@ use flate2; use time; use shared::Position; -pub const SUPPORTED_PROTOCOL: i32 = 210; +pub const SUPPORTED_PROTOCOL: i32 = 315; /// Helper macro for defining packets @@ -200,7 +200,9 @@ impl Serializable for Option where T : Serializable { impl Serializable for String { fn read_from(buf: &mut R) -> Result { - let len = try!(VarInt::read_from(buf)).0; + let len = VarInt::read_from(buf)?.0; + debug_assert!(len >= 0, "Negative string length: {}", len); + debug_assert!(len <= 65536, "String length too big: {}", len); let mut ret = String::new(); try!(buf.take(len as u64).read_to_string(&mut ret)); Result::Ok(ret) diff --git a/protocol/src/protocol/packet.rs b/protocol/src/protocol/packet.rs index 2b5f8aa..fb4613f 100644 --- a/protocol/src/protocol/packet.rs +++ b/protocol/src/protocol/packet.rs @@ -231,9 +231,9 @@ state_packets!( field location: Position =, field face: VarInt =, field hand: VarInt =, - field cursor_x: u8 =, - field cursor_y: u8 =, - field cursor_z: u8 =, + field cursor_x: f32 =, + field cursor_y: f32 =, + field cursor_z: f32 =, } /// UseItem is sent when the client tries to use an item. packet UseItem { @@ -281,7 +281,7 @@ state_packets!( packet SpawnMob { field entity_id: VarInt =, field uuid: UUID =, - field ty: u8 =, + field ty: VarInt =, field x: f64 =, field y: f64 =, field z: f64 =, @@ -780,9 +780,10 @@ state_packets!( field action: VarInt =, field title: Option = when(|p: &Title| p.action.0 == 0), field sub_title: Option = when(|p: &Title| p.action.0 == 1), - field fade_in: Option = when(|p: &Title| p.action.0 == 2), - field fade_stay: Option = when(|p: &Title| p.action.0 == 2), - field fade_out: Option = when(|p: &Title| p.action.0 == 2), + field action_bar_text: Option = when(|p: &Title| p.action.0 == 2), + field fade_in: Option = when(|p: &Title| p.action.0 == 3), + field fade_stay: Option = when(|p: &Title| p.action.0 == 3), + field fade_out: Option = when(|p: &Title| p.action.0 == 3), } /// SoundEffect plays the named sound at the target location. packet SoundEffect { @@ -804,6 +805,7 @@ state_packets!( packet CollectItem { field collected_entity_id: VarInt =, field collector_entity_id: VarInt =, + field number_of_items: VarInt =, } /// EntityTeleport teleports the entity to the target location. This is /// sent if the entity moves further than EntityMove allows.