Fixed /kill not properly killing the player under certain conditions, closes #4680 (#5919)

This occurs if the player had very high levels of Health Boost or other weird modifications.

It doesn't really make sense to apply damage modifiers to suicide anyway.

Really I'm doubtful that suicide should even be considered a damage type (perhaps we should add an EntitySuicideEvent), but that's a discussion for another time.
This commit is contained in:
Dylan T 2023-07-19 16:33:16 +01:00 committed by GitHub
parent 86810c5e1c
commit 24d979bd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -53,7 +53,7 @@ class KillCommand extends VanillaCommand{
return true;
}
$player->attack(new EntityDamageEvent($player, EntityDamageEvent::CAUSE_SUICIDE, 1000));
$player->attack(new EntityDamageEvent($player, EntityDamageEvent::CAUSE_SUICIDE, $player->getHealth()));
if($player === $sender){
$sender->sendMessage(KnownTranslationFactory::commands_kill_successful($sender->getName()));
}else{

View File

@ -517,7 +517,9 @@ abstract class Living extends Entity{
$source->cancel();
}
$this->applyDamageModifiers($source);
if($source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE){
$this->applyDamageModifiers($source);
}
if($source instanceof EntityDamageByEntityEvent && (
$source->getCause() === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION ||