feat(bedrock) add & send health packet
This commit is contained in:
parent
bb0941bfeb
commit
26da644c1d
@ -18,6 +18,7 @@ pub mod resource_pack_stack;
|
|||||||
pub mod resource_packs_info;
|
pub mod resource_packs_info;
|
||||||
pub mod set_actor_data;
|
pub mod set_actor_data;
|
||||||
pub mod set_actor_motion;
|
pub mod set_actor_motion;
|
||||||
|
pub mod set_health;
|
||||||
pub mod set_player_gamemode;
|
pub mod set_player_gamemode;
|
||||||
pub mod set_time;
|
pub mod set_time;
|
||||||
pub mod set_title;
|
pub mod set_title;
|
||||||
|
|||||||
18
pumpkin-protocol/src/bedrock/client/set_health.rs
Normal file
18
pumpkin-protocol/src/bedrock/client/set_health.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use crate::{codec::var_int::VarInt, serial::PacketWrite};
|
||||||
|
use pumpkin_macros::packet;
|
||||||
|
|
||||||
|
#[derive(PacketWrite)]
|
||||||
|
#[packet(42)]
|
||||||
|
pub struct CSetHealth {
|
||||||
|
// https://mojang.github.io/bedrock-protocol-docs/html/SetHealthPacket.html
|
||||||
|
pub health: VarInt,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CSetHealth {
|
||||||
|
#[must_use]
|
||||||
|
pub const fn new(health: i32) -> Self {
|
||||||
|
Self {
|
||||||
|
health: VarInt(health),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2304,13 +2304,26 @@ impl Player {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.client
|
match &self.client {
|
||||||
.enqueue_packet(&CSetHealth::new(
|
ClientPlatform::Java(client) => {
|
||||||
self.living_entity.health.load(),
|
client
|
||||||
self.hunger_manager.level.load().into(),
|
.enqueue_packet(&CSetHealth::new(
|
||||||
self.hunger_manager.saturation.load(),
|
self.living_entity.health.load(),
|
||||||
))
|
self.hunger_manager.level.load().into(),
|
||||||
.await;
|
self.hunger_manager.saturation.load(),
|
||||||
|
))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
ClientPlatform::Bedrock(client) => {
|
||||||
|
client
|
||||||
|
.send_game_packet(
|
||||||
|
&pumpkin_protocol::bedrock::client::set_health::CSetHealth::new(
|
||||||
|
self.living_entity.health.load() as i32,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn tick_health(&self) {
|
pub async fn tick_health(&self) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user