fixed hurt sound playing when spawning player

This commit is contained in:
GameHerobrine 2024-11-15 10:52:38 +03:00
parent 6e6dc3eb4c
commit 053ac5abb9
2 changed files with 3 additions and 3 deletions

View file

@ -1742,7 +1742,7 @@ class Player{
$pos = new Position($this->entity->x, $this->entity->y, $this->entity->z, $this->level);
$pData = $this->data->get("position");
$this->teleport($pos, $pData["yaw"] ?? false, $pData["pitch"] ?? false, true, true);
$this->entity->setHealth($this->data->get("health"), "spawn", true);
$this->entity->setHealth($this->data->get("health"), "spawn", true, false);
$this->spawned = true;
$this->server->api->player->spawnAllPlayers($this);
$this->server->api->player->spawnToAllPlayers($this);

View file

@ -1534,7 +1534,7 @@ class Entity extends Position
return $damage;
}
public function setHealth($health, $cause = "generic", $force = false)
public function setHealth($health, $cause = "generic", $force = false, $allowHarm = true)
{
$health = (int) $health;
$harm = false;
@ -1558,7 +1558,7 @@ class Entity extends Position
"cause" => $cause
)) !== false or $force === true){
$this->health = min(127, max(- 127, $health));
if($harm === true){
if($harm === true && $allowHarm){
$pk = new EntityEventPacket;
$pk->eid = $this->eid;
$pk->event = EntityEventPacket::ENTITY_DAMAGE;