diff --git a/protocol/src/protocol/mod.rs b/protocol/src/protocol/mod.rs index 6461200..3ffa6e2 100644 --- a/protocol/src/protocol/mod.rs +++ b/protocol/src/protocol/mod.rs @@ -940,14 +940,15 @@ impl Serializable for Position { let pos = buf.read_u64::()?; Ok(Position::new( ((pos as i64) >> 38) as i32, - (((pos as i64) >> 26) & 0xFFF) as i32, - ((pos as i64) << 38 >> 38) as i32, + (((pos as i64)) & 0xFFF) as i32, + ((pos as i64) << 26 >> 38) as i32 )) } fn write_to(&self, buf: &mut W) -> Result<(), Error> { let pos = (((self.x as u64) & 0x3FFFFFF) << 38) - | (((self.y as u64) & 0xFFF) << 26) - | ((self.z as u64) & 0x3FFFFFF); + | ((self.y as u64) & 0xFFF) + | (((self.z as u64) & 0x3FFFFFF) << 12); + buf.write_u64::(pos)?; Result::Ok(()) } diff --git a/protocol/src/protocol/packet.rs b/protocol/src/protocol/packet.rs index edf490a..336e66e 100644 --- a/protocol/src/protocol/packet.rs +++ b/protocol/src/protocol/packet.rs @@ -473,6 +473,15 @@ state_packets!( field cursor_y: u8 =, field cursor_z: u8 =, } + packet PlayerBlockPlacement_insideblock { + field hand: VarInt =, + field location: Position =, + field face: VarInt =, + field cursor_x: f32 =, + field cursor_y: f32 =, + field cursor_z: f32 =, + field inside_block: bool =, //1.14 added insideblock + } /// UseItem is sent when the client tries to use an item. packet UseItem { @@ -523,6 +532,20 @@ state_packets!( field velocity_y: i16 = when(|p: &SpawnObject_i32_NoUUID| p.data != 0), field velocity_z: i16 = when(|p: &SpawnObject_i32_NoUUID| p.data != 0), } + packet SpawnObject_VarInt { + field entity_id: VarInt =, + field uuid: UUID =, + field ty: VarInt =, //1.14 changed u8 to VarInt + field x: f64 =, + field y: f64 =, + field z: f64 =, + field pitch: i8 =, + field yaw: i8 =, + field data: i32 =, + field velocity_x: i16 =, + field velocity_y: i16 =, + field velocity_z: i16 =, + } /// SpawnExperienceOrb spawns a single experience orb into the world when /// it is in range of the client. The count controls the amount of experience /// gained when collected. diff --git a/protocol/src/protocol/versions/v1_14.rs b/protocol/src/protocol/versions/v1_14.rs index bd21510..89b0bc4 100644 --- a/protocol/src/protocol/versions/v1_14.rs +++ b/protocol/src/protocol/versions/v1_14.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_WithMeta diff --git a/protocol/src/protocol/versions/v1_14_1.rs b/protocol/src/protocol/versions/v1_14_1.rs index bd21510..89b0bc4 100644 --- a/protocol/src/protocol/versions/v1_14_1.rs +++ b/protocol/src/protocol/versions/v1_14_1.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_WithMeta diff --git a/protocol/src/protocol/versions/v1_14_2.rs b/protocol/src/protocol/versions/v1_14_2.rs index bd21510..89b0bc4 100644 --- a/protocol/src/protocol/versions/v1_14_2.rs +++ b/protocol/src/protocol/versions/v1_14_2.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_WithMeta diff --git a/protocol/src/protocol/versions/v1_14_3.rs b/protocol/src/protocol/versions/v1_14_3.rs index 5b05fde..d39165c 100644 --- a/protocol/src/protocol/versions/v1_14_3.rs +++ b/protocol/src/protocol/versions/v1_14_3.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_WithMeta diff --git a/protocol/src/protocol/versions/v1_14_4.rs b/protocol/src/protocol/versions/v1_14_4.rs index 820c60f..573749a 100644 --- a/protocol/src/protocol/versions/v1_14_4.rs +++ b/protocol/src/protocol/versions/v1_14_4.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_WithMeta diff --git a/protocol/src/protocol/versions/v1_15_1.rs b/protocol/src/protocol/versions/v1_15_1.rs index e5ae7dd..81312be 100644 --- a/protocol/src/protocol/versions/v1_15_1.rs +++ b/protocol/src/protocol/versions/v1_15_1.rs @@ -52,11 +52,11 @@ protocol_packet_ids!( 0x29 => SetSign 0x2a => ArmSwing 0x2b => SpectateTeleport - 0x2c => PlayerBlockPlacement_f32 + 0x2c => PlayerBlockPlacement_insideblock 0x2d => UseItem } clientbound Clientbound { - 0x00 => SpawnObject + 0x00 => SpawnObject_VarInt 0x01 => SpawnExperienceOrb 0x02 => SpawnGlobalEntity 0x03 => SpawnMob_NoMeta