Skip to content

Commit

Permalink
fix: fix the bug that damage that smaller than 1 will never kill an e…
Browse files Browse the repository at this point in the history
…ntity even if the entity has only 1 health.
  • Loading branch information
smartcmd committed Feb 1, 2025
1 parent d63173e commit 024d381
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Unless otherwise specified, any version comparison below is the comparison of se
- Item entity will be despawned immediately instead of having a `dead timer` when its health become 0. It's dead smoke is also removed.
- Fixed the bug that unusable enchantment types may be shown in enchantment table.
- Fixed the bug that `/give` command will stack item that cannot be stacked like sword.
- Fixed the bug that damage that smaller than 1 will never kill an entity even if the entity has only 1 health.

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public void setHealth(float value) {
if (value > 0 && value < 1) {
// Client will think he is dead if the health is less than 1
// But server doesn't think so, which would causes bug
// So we need to set the health to 1 if it's less than 1 and bigger than 0
value = 1;
// So we need to set the health to 0 if it's less than 1 and bigger than 0
value = 0;
} else {
value = max(0, min(value, this.getMaxHealth()));
}
Expand Down

0 comments on commit 024d381

Please sign in to comment.