mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
Push the shield before the hit that it only partly blocked
hurtServer runs applyItemBlocking (the shield's knockback) before dealDefaultKnockback (the hit's own), and knockback halves the old motion, so the order decides the direction. Horizon made the hit's push first and the shield's second, which sent a half-blocked defender toward the attacker at twice the speed.
This commit is contained in:
1 parent
2c9b58e72a
commit
c30dc0febf
1 file changed
+14
-6
@@ -3197,6 +3197,9 @@ impl Game<'_> {
|
||||
let owner = owner.filter(|_| projectile);
|
||||
let causing = known.flatten().or(owner).map_or(0, |id| id as i32);
|
||||
let mut outcome = horizon_client::health::BlockOutcome::default();
|
||||
// The hit's own push, held back until after the shield's (`hurtServer`
|
||||
// runs `applyItemBlocking` before `dealDefaultKnockback`).
|
||||
let mut default_push: Option<([f64; 2], HurtSource<'_>)> = None;
|
||||
if let Some(player) = self.player.as_mut()
|
||||
&& let Some(id) = self.motion.health.damage.id(damage_type)
|
||||
&& let Ok(o) = player.hurt_caused_by(
|
||||
@@ -3229,12 +3232,7 @@ impl Game<'_> {
|
||||
causing,
|
||||
direct: 0,
|
||||
};
|
||||
self.knock_back_player(f64::from(0.4_f32), xd, zd, source);
|
||||
if let Some(p) = self.player.as_mut()
|
||||
&& let Some(r) = p.hurt_log.last_mut()
|
||||
{
|
||||
r.knockback = Some([p.velocity.x, p.velocity.y, p.velocity.z]);
|
||||
}
|
||||
default_push = Some(([xd, zd], source));
|
||||
}
|
||||
// The thorns hurt the entity that caused the hit, if there is one.
|
||||
let killed = self.player.as_ref().is_some_and(|p| {
|
||||
@@ -3283,6 +3281,16 @@ impl Game<'_> {
|
||||
};
|
||||
self.after_block(outcome, (attacker, projectile), source);
|
||||
}
|
||||
// `LivingEntity.dealDefaultKnockback`: after the item's block push, so
|
||||
// a half-blocked hit pushes the defender back the way vanilla does.
|
||||
if let Some(([xd, zd], source)) = default_push {
|
||||
self.knock_back_player(f64::from(0.4_f32), xd, zd, source);
|
||||
if let Some(p) = self.player.as_mut()
|
||||
&& let Some(r) = p.hurt_log.last_mut()
|
||||
{
|
||||
r.knockback = Some([p.velocity.x, p.velocity.y, p.velocity.z]);
|
||||
}
|
||||
}
|
||||
outcome.hurt
|
||||
}
|
||||
/// `LivingEntity.knockback` on the player: pushed `power` away from the
|
||||
|
||||
Reference in new issue
Block a user