aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/s_interact.rs3
-rw-r--r--azalea-protocol/src/packets/game/s_use_item.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_use_item_on.rs17
3 files changed, 21 insertions, 3 deletions
diff --git a/azalea-protocol/src/packets/game/s_interact.rs b/azalea-protocol/src/packets/game/s_interact.rs
index 89fc896f..a3007749 100644
--- a/azalea-protocol/src/packets/game/s_interact.rs
+++ b/azalea-protocol/src/packets/game/s_interact.rs
@@ -80,8 +80,9 @@ impl AzaleaRead for ActionType {
}
}
-#[derive(AzBuf, Clone, Copy, Debug)]
+#[derive(AzBuf, Clone, Copy, Debug, Default)]
pub enum InteractionHand {
+ #[default]
MainHand = 0,
OffHand = 1,
}
diff --git a/azalea-protocol/src/packets/game/s_use_item.rs b/azalea-protocol/src/packets/game/s_use_item.rs
index ac8ae217..d6ccca87 100644
--- a/azalea-protocol/src/packets/game/s_use_item.rs
+++ b/azalea-protocol/src/packets/game/s_use_item.rs
@@ -8,6 +8,6 @@ pub struct ServerboundUseItem {
pub hand: InteractionHand,
#[var]
pub sequence: u32,
- pub yaw: f32,
- pub pitch: f32,
+ pub y_rot: f32,
+ pub x_rot: f32,
}
diff --git a/azalea-protocol/src/packets/game/s_use_item_on.rs b/azalea-protocol/src/packets/game/s_use_item_on.rs
index 4c87cb72..967fb5e9 100644
--- a/azalea-protocol/src/packets/game/s_use_item_on.rs
+++ b/azalea-protocol/src/packets/game/s_use_item_on.rs
@@ -3,6 +3,7 @@ use std::io::{Cursor, Write};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use azalea_core::{
direction::Direction,
+ hit_result::BlockHitResult,
position::{BlockPos, Vec3},
};
use azalea_protocol_macros::ServerboundGamePacket;
@@ -77,3 +78,19 @@ impl AzaleaRead for BlockHit {
})
}
}
+
+impl From<BlockHitResult> for BlockHit {
+ /// Converts a [`BlockHitResult`] to a [`BlockHit`].
+ ///
+ /// The only difference is that the `miss` field is not present in
+ /// [`BlockHit`].
+ fn from(hit_result: BlockHitResult) -> Self {
+ Self {
+ block_pos: hit_result.block_pos,
+ direction: hit_result.direction,
+ location: hit_result.location,
+ inside: hit_result.inside,
+ world_border: hit_result.world_border,
+ }
+ }
+}