Server-thread clients animate warden, sniffer, breeze, camel and shulker
A client of a server (single player's window included) never got the animation state these mobs compute on the server: no pose, no sniffer state, no shulker peek or wall face, no camel sit or dash, no warden tendril, attack or sonic boom events. Send Entity.DATA_POSE and the species' synched data from mob_meta, broadcast the warden's entity events 4, 61 and 62, read both in the remote mob code, and run the client animation steps in mobs::sync::client_tick.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//! own simulation, which a client of a server doesn't run.
|
||||
use super::Game;
|
||||
use horizon_client::mobs::render::{PROFESSIONS, VILLAGER_TYPES};
|
||||
use horizon_client::mobs::{Mob, Species, Who, bat, tame};
|
||||
use horizon_client::mobs::{Mob, Species, Who, bat, camel, sniffer, sync, tame};
|
||||
use horizon_protocol::entity_data::Value;
|
||||
use horizon_protocol::registry::Builtin;
|
||||
|
||||
@@ -20,6 +20,8 @@ fn apply(m: &mut Mob, values: &[(u8, i32, Value)], builtin: &Builtin, local_enti
|
||||
// client, which draws the flames. A client doesn't count the
|
||||
// fire down: the flag goes off when the server's fire is out.
|
||||
(0, Value::Byte(flags)) => m.fire_ticks = i32::from(flags & 1),
|
||||
// Entity.DATA_POSE: the pose the species animates by.
|
||||
(6, Value::Id(pose)) => sync::set_pose(m, (*pose).clamp(0, 17) as u8),
|
||||
// LivingEntity.DATA_LIVING_ENTITY_FLAGS: using an item 1, in the
|
||||
// off hand 2. The flag starts and stops the use; the client ticks
|
||||
// the count itself (a bow's pull follows it).
|
||||
@@ -79,6 +81,29 @@ fn apply(m: &mut Mob, values: &[(u8, i32, Value)], builtin: &Builtin, local_enti
|
||||
(Species::Slime | Species::MagmaCube, 18, Value::Int(size)) => {
|
||||
m.extra.size = (*size).clamp(1, 127);
|
||||
}
|
||||
// Warden.CLIENT_ANGER_LEVEL: the heartbeat's pace.
|
||||
(Species::Warden, 16, Value::Int(anger)) => {
|
||||
if let Some(st) = m.extra.warden.as_mut() {
|
||||
st.client_anger = *anger;
|
||||
}
|
||||
}
|
||||
// Sniffer.DATA_STATE (after AgeableMob's two): the animation
|
||||
// follows it in `sync::client_tick`.
|
||||
(Species::Sniffer, 18, Value::Id(state)) => {
|
||||
sniffer::set_state(m, (*state).clamp(0, 6) as u8);
|
||||
}
|
||||
// Shulker.DATA_ATTACH_FACE_ID, DATA_PEEK_ID and DATA_COLOR_ID.
|
||||
(Species::Shulker, 16, Value::Id(face)) => m.extra.variant3 = (*face).clamp(0, 5) as u8,
|
||||
(Species::Shulker, 17, Value::Byte(peek)) => m.extra.counter = i32::from(*peek),
|
||||
(Species::Shulker, 18, Value::Byte(color)) => m.extra.color = *color as u8,
|
||||
// Camel.DASH and LAST_POSE_CHANGE_TICK (after AbstractHorse's
|
||||
// flags).
|
||||
(Species::Camel | Species::CamelHusk, 19, Value::Bool(dashing)) => {
|
||||
camel::set_dashing(m, *dashing);
|
||||
}
|
||||
(Species::Camel | Species::CamelHusk, 20, Value::Long(tick)) => {
|
||||
camel::set_synced_pose_tick(m, *tick);
|
||||
}
|
||||
// Pillager.IS_CHARGING_CROSSBOW: the charge pose (Raider's
|
||||
// IS_CELEBRATING takes 16).
|
||||
(Species::Pillager, 17, Value::Bool(charging)) => m.extra.flag = *charging,
|
||||
|
||||
Reference in New Issue
Block a user