mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
fix(combat): don't apply extra knockback on a plain attack (#2539)
Player attacks added a constant 1.0 to the extra knockback strength, so every hit pushed the victim on top of the base knockback applied by the damage path. Vanilla only adds the Knockback enchantment bonus plus 0.5 for a sprint attack, and skips the push entirely when that total is zero. Armor stands make the difference visible: their damage handling applies no base knockback, so they should only move when the attacker sprints or carries Knockback.
This commit is contained in:
@@ -1585,7 +1585,11 @@ impl Player {
|
||||
);
|
||||
|
||||
if victim.get_living_entity().is_some() {
|
||||
let mut knockback_strength = 1.0 + f64::from(knockback_level);
|
||||
// Vanilla `Player.attack` adds `LivingEntity.getKnockback()` - the Knockback
|
||||
// enchantment bonus, halved - plus 0.5 for a sprint attack, on top of the base
|
||||
// knockback the victim's damage handling applies. A plain hit adds nothing.
|
||||
// `handle_knockback` halves `strength`, so these are twice the vanilla amount.
|
||||
let mut knockback_strength = f64::from(knockback_level);
|
||||
match attack_type {
|
||||
AttackType::Knockback => knockback_strength += 1.0,
|
||||
AttackType::Sweeping => {
|
||||
@@ -1624,7 +1628,10 @@ impl Player {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if config.knockback {
|
||||
// Vanilla only pushes the victim when the extra knockback is non-zero;
|
||||
// `Entity::knockback` halves the current velocity, so calling it with 0.0
|
||||
// would still slow the victim down.
|
||||
if config.knockback && knockback_strength > 0.0 {
|
||||
combat::handle_knockback(attacker_entity, victim.as_ref(), knockback_strength);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user