From 535cba9f6fbaf4c3498adf7912ede6fcfc4d3bc6 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 14 Jan 2023 16:20:37 +0300 Subject: [PATCH] pigmans fire resistance added --- src/entity/Entity.php | 32 ++++++++++++++++---------------- src/entity/monster/PigZombie.php | 8 ++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index ec842b74..8d478023 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1257,24 +1257,24 @@ class Entity extends Position public function harm($dmg, $cause = "generic", $force = false) { - if(!$this->canBeAttacked){ - return false; - } - $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force); - - if($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false){ - $d = $entity->x - $this->x; - - for($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (Utils::randomFloat() - Utils::randomFloat()) * 0.01){ - $d = (Utils::randomFloat() - Utils::randomFloat()) * 0.01; + if (! $this->canBeAttacked) { + return false; + } + $ret = $this->setHealth(max(- 128, $this->getHealth() - ((int) $dmg)), $cause, $force); + + if ($ret != false && $this->hasKnockback && is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false) { + $d = $entity->x - $this->x; + + for ($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (Utils::randomFloat() - Utils::randomFloat()) * 0.01) { + $d = (Utils::randomFloat() - Utils::randomFloat()) * 0.01; + } + + // attackedAtYaw = (float)((Math.atan2($d1, $d) * 180D) / 3.1415927410125732D) > + $this->knockBack($d, $d1); + $this->sendMotion(); } - // attackedAtYaw = (float)((Math.atan2($d1, $d) * 180D) / 3.1415927410125732D) > - $this->knockBack($d, $d1); - $this->sendMotion(); - } - - return $ret; + return $ret; } public function setState($v) diff --git a/src/entity/monster/PigZombie.php b/src/entity/monster/PigZombie.php index 8cc4cc8c..5675ed5c 100644 --- a/src/entity/monster/PigZombie.php +++ b/src/entity/monster/PigZombie.php @@ -16,4 +16,12 @@ class PigZombie extends Monster{ [GOLD_INGOT, 0, mt_rand(0,1)] ]; } + + public function harm($dmg, $cause = "generic", $force = false) + { + if($cause === "fire" || $cause === "lava" || $cause === "burning"){ + return false; + } + return parent::harm($dmg, $cause, $force); + } } \ No newline at end of file