diff --git a/server/player/player.go b/server/player/player.go index da23c7c7e..c222dab97 100644 --- a/server/player/player.go +++ b/server/player/player.go @@ -1644,9 +1644,15 @@ func (p *Player) UseItemOnEntity(e world.Entity) bool { // have. // If the player cannot reach the entity at its position, the method returns immediately. func (p *Player) AttackEntity(e world.Entity) bool { - if !p.canReach(e.Position()) { + if !p.canReach(e.Position()) || p.Dead() { + return false + } + + living, ok := e.(entity.Living) + if !ok || living.Dead() { return false } + var ( force, height = 0.45, 0.3608 _, slowFalling = p.Effect(effect.SlowFalling) @@ -1661,10 +1667,6 @@ func (p *Player) AttackEntity(e world.Entity) bool { p.SwingArm() i, _ := p.HeldItems() - living, ok := e.(entity.Living) - if !ok { - return false - } dmg := i.AttackDamage() if strength, ok := p.Effect(effect.Strength); ok {