From 053ac5abb924033924f00f8698d4b073b8c72d34 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Fri, 15 Nov 2024 10:52:38 +0300 Subject: [PATCH] fixed hurt sound playing when spawning player --- src/Player.php | 2 +- src/entity/Entity.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Player.php b/src/Player.php index d4c74740..ff5ccc79 100755 --- a/src/Player.php +++ b/src/Player.php @@ -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); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index e3d70fa1..5b80a66b 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -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;