Add: Basic Combat

This commit is contained in:
Snowiiii committed 2024-08-13 09:16:00 +02:00
1 parent c2bde2f73e
commit 9fc86e260b
15 files changed
+163 -55

No files matched your search

@@ -0,0 +1,17 @@
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[packet(0x24)]
pub struct CHurtAnimation {
entitiy_id: VarInt,
yaw: f32,
}
impl CHurtAnimation {
pub fn new(entitiy_id: VarInt, yaw: f32) -> Self {
Self { entitiy_id, yaw }
}
}
+2
View File
@@ -7,6 +7,7 @@ mod c_entity_animation;
mod c_entity_metadata;
mod c_game_event;
mod c_head_rot;
mod c_hurt_animation;
mod c_login;
mod c_open_screen;
mod c_play_disconnect;
@@ -35,6 +36,7 @@ pub use c_entity_animation::*;
pub use c_entity_metadata::*;
pub use c_game_event::*;
pub use c_head_rot::*;
pub use c_hurt_animation::*;
pub use c_login::*;
pub use c_open_screen::*;
pub use c_play_disconnect::*;
@@ -0,0 +1,25 @@
use pumpkin_macros::packet;
use serde::Deserialize;
use crate::{ServerPacket, VarInt};
#[packet(0x16)]
pub struct SInteract {
pub entity_id: VarInt,
pub typ: VarInt,
pub target_x: Option<f32>,
// don't ask me why, adding more values does not work :c
}
// TODO
impl ServerPacket for SInteract {
fn read(
bytebuf: &mut crate::bytebuf::ByteBuffer,
) -> Result<Self, crate::bytebuf::DeserializerError> {
Ok(Self {
entity_id: bytebuf.get_var_int(),
typ: bytebuf.get_var_int(),
target_x: bytebuf.get_option(|v| v.get_f32()),
})
}
}
+2
View File
@@ -1,4 +1,5 @@
mod c_client_information;
mod c_interact;
mod s_chat_command;
mod s_chat_message;
mod s_confirm_teleport;
@@ -9,6 +10,7 @@ mod s_player_rotation;
mod s_swing_arm;
pub use c_client_information::*;
pub use c_interact::*;
pub use s_chat_command::*;
pub use s_chat_message::*;
pub use s_confirm_teleport::*;
@@ -16,6 +16,7 @@ pub struct SChatMessage {
// acknowledged: BitSet,
}
// TODO
impl ServerPacket for SChatMessage {
fn read(bytebuf: &mut ByteBuffer) -> Result<Self, DeserializerError> {
Ok(Self {