Add Basic Combat

This commit is contained in:
Snowiiii committed 2024-08-14 22:26:27 +02:00
1 parent 03cc991bfd
commit 6459aef027
12 files changed
+222 -32

No files matched your search

@@ -0,0 +1,24 @@
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[packet(0x5A)]
pub struct CEntityVelocity<'a> {
entitiy_id: &'a VarInt,
velocity_x: i16,
velocity_y: i16,
velocity_z: i16,
}
impl<'a> CEntityVelocity<'a> {
pub fn new(entitiy_id: &'a VarInt, velocity_x: f32, velocity_y: f32, velocity_z: f32) -> Self {
Self {
entitiy_id,
velocity_x: (velocity_x.clamp(-3.9, 3.9) * 8000.0) as i16,
velocity_y: (velocity_y.clamp(-3.9, 3.9) * 8000.0) as i16,
velocity_z: (velocity_z.clamp(-3.9, 3.9) * 8000.0) as i16,
}
}
}
@@ -5,13 +5,13 @@ use crate::VarInt;
#[derive(Serialize)]
#[packet(0x24)]
pub struct CHurtAnimation {
entitiy_id: VarInt,
pub struct CHurtAnimation<'a> {
entitiy_id: &'a VarInt,
yaw: f32,
}
impl CHurtAnimation {
pub fn new(entitiy_id: VarInt, yaw: f32) -> Self {
impl<'a> CHurtAnimation<'a> {
pub fn new(entitiy_id: &'a VarInt, yaw: f32) -> Self {
Self { entitiy_id, yaw }
}
}
+2
View File
@@ -5,6 +5,7 @@ mod c_chunk_data;
mod c_disguised_chat_message;
mod c_entity_animation;
mod c_entity_metadata;
mod c_entity_velocity;
mod c_game_event;
mod c_head_rot;
mod c_hurt_animation;
@@ -34,6 +35,7 @@ pub use c_chunk_data::*;
pub use c_disguised_chat_message::*;
pub use c_entity_animation::*;
pub use c_entity_metadata::*;
pub use c_entity_velocity::*;
pub use c_game_event::*;
pub use c_head_rot::*;
pub use c_hurt_animation::*;