From d28dad2a07b6318e3c845f80aa8e47985aed29f2 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Wed, 4 Jun 2025 17:54:25 +0300 Subject: [PATCH] fixed mobs sending damage animation to player when they spawn --- src/entity/Creature.php | 2 +- src/entity/animal/Chicken.php | 2 +- src/entity/animal/Cow.php | 2 +- src/entity/animal/Pig.php | 2 +- src/entity/animal/Sheep.php | 2 +- src/entity/monster/Creeper.php | 2 +- src/entity/monster/PigZombie.php | 2 +- src/entity/monster/Skeleton.php | 2 +- src/entity/monster/Spider.php | 2 +- src/entity/monster/Zombie.php | 2 +- src/entity/object/FallingSand.php | 2 +- src/entity/object/ItemEntity.php | 2 +- src/entity/object/Minecart.php | 2 +- src/entity/object/PrimedTNT.php | 2 +- src/entity/object/TripodCamera.php | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/entity/Creature.php b/src/entity/Creature.php index d6e50024..b472686d 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -11,7 +11,7 @@ abstract class Creature extends Living{ public function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->inPanic = false; //force for now parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 1, "generic"); + $this->setHealth($this->data["Health"] ?? 1, "generic", allowHarm: false); $this->enableAutojump = true; $this->searchForClosestPlayers = true; } diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php index 2b19cd1a..65072669 100644 --- a/src/entity/animal/Chicken.php +++ b/src/entity/animal/Chicken.php @@ -7,7 +7,7 @@ class Chicken extends Animal{ $this->timeUntilEgg = mt_rand(0,6000) + 6000; $this->setSize(0.4, 0.7); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 4, "generic"); + $this->setHealth($this->data["Health"] ?? 4, "generic", allowHarm: false); $this->setName('Chicken'); $this->setSpeed(0.25); diff --git a/src/entity/animal/Cow.php b/src/entity/animal/Cow.php index e8a18386..5abf467e 100644 --- a/src/entity/animal/Cow.php +++ b/src/entity/animal/Cow.php @@ -5,7 +5,7 @@ class Cow extends Animal{ function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.9, 1.3); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 10, "generic"); + $this->setHealth($this->data["Health"] ?? 10, "generic", allowHarm: false); $this->setName("Cow"); $this->setSpeed(0.2); $this->ai->addTask(new TaskRandomWalk(0.8)); diff --git a/src/entity/animal/Pig.php b/src/entity/animal/Pig.php index 46cd725b..f7156bfa 100644 --- a/src/entity/animal/Pig.php +++ b/src/entity/animal/Pig.php @@ -5,7 +5,7 @@ class Pig extends Animal implements Rideable{ public function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.9, 0.9); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 10, "generic"); + $this->setHealth($this->data["Health"] ?? 10, "generic", allowHarm: false); $this->server = ServerAPI::request(); $this->setName("Pig"); $this->setSpeed(0.25); diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index 3a7fe09f..4ce3e6ab 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -7,7 +7,7 @@ class Sheep extends Animal{ function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.9, 1.3); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 8, "generic"); + $this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false); $this->setName("Sheep"); $this->data["Sheared"] = $this->data["Sheared"] ?? 0; $this->data["Color"] = $this->data["Color"] ?? $this->sheepColor(); diff --git a/src/entity/monster/Creeper.php b/src/entity/monster/Creeper.php index 12bd50e6..d3da8f38 100644 --- a/src/entity/monster/Creeper.php +++ b/src/entity/monster/Creeper.php @@ -7,7 +7,7 @@ class Creeper extends Monster{ function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.6, 1.7); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 16, "generic"); + $this->setHealth($this->data["Health"] ?? 16, "generic", allowHarm: false); $this->setName("Creeper"); $this->ignited = 0; $this->setSpeed(0.25); diff --git a/src/entity/monster/PigZombie.php b/src/entity/monster/PigZombie.php index 812901ce..8d58edc5 100644 --- a/src/entity/monster/PigZombie.php +++ b/src/entity/monster/PigZombie.php @@ -4,7 +4,7 @@ class PigZombie extends Monster{ //TODO extends zombie function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.3, 1.95); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 12, "generic"); + $this->setHealth($this->data["Health"] ?? 12, "generic", allowHarm: false); $this->setName("Pigman"); $this->setSpeed(0.25); $this->isImmuneToFire = true; diff --git a/src/entity/monster/Skeleton.php b/src/entity/monster/Skeleton.php index 52543a31..246a6bc1 100644 --- a/src/entity/monster/Skeleton.php +++ b/src/entity/monster/Skeleton.php @@ -4,7 +4,7 @@ class Skeleton extends Monster{ function __construct(Level $level, $eid, $class, $type = 0, $data = []){ $this->setSize(0.6, 1.99); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 10, "generic"); + $this->setHealth($this->data["Health"] ?? 10, "generic", allowHarm: false); $this->setName("Skeleton"); $this->ai->removeTask("TaskAttackPlayer"); $this->setSpeed(0.25); diff --git a/src/entity/monster/Spider.php b/src/entity/monster/Spider.php index 1752638f..65360334 100644 --- a/src/entity/monster/Spider.php +++ b/src/entity/monster/Spider.php @@ -5,7 +5,7 @@ class Spider extends Monster{ function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ $this->setSize(1.4, 0.9); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 8, "generic"); + $this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false); $this->setName("Spider"); $this->setSpeed(0.3); $this->ai->addTask(new TaskRandomWalk(1.2)); diff --git a/src/entity/monster/Zombie.php b/src/entity/monster/Zombie.php index bc38cf3a..95315008 100644 --- a/src/entity/monster/Zombie.php +++ b/src/entity/monster/Zombie.php @@ -4,7 +4,7 @@ class Zombie extends Monster{ function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ $this->setSize(0.6, 1.85); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth($this->data["Health"] ?? 12, "generic"); + $this->setHealth($this->data["Health"] ?? 12, "generic", allowHarm: false); $this->setName("Zombie"); $this->setSpeed(0.23); diff --git a/src/entity/object/FallingSand.php b/src/entity/object/FallingSand.php index ce3ddfe7..3c040340 100644 --- a/src/entity/object/FallingSand.php +++ b/src/entity/object/FallingSand.php @@ -8,7 +8,7 @@ class FallingSand extends Entity{ public function __construct($level, $eid, $class, $type = 0, $data = []){ parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth(PHP_INT_MAX, "generic"); + $this->setHealth(PHP_INT_MAX, "generic", allowHarm: false); $this->height = 0.98; $this->width = 0.98; $this->yOffset = $this->height / 2; diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php index d645b43c..2f44ee25 100644 --- a/src/entity/object/ItemEntity.php +++ b/src/entity/object/ItemEntity.php @@ -22,7 +22,7 @@ class ItemEntity extends Entity{ $this->itemID = (int) $data["itemID"]; } $this->hasGravity = true; - $this->setHealth(5, "generic"); + $this->setHealth(5, "generic", allowHarm: false); $this->gravity = 0.04; $this->delayBeforePickup = 40; //in vanilla it is 0 by default $this->stepHeight = 0; diff --git a/src/entity/object/Minecart.php b/src/entity/object/Minecart.php index fa39affa..ab48a67a 100644 --- a/src/entity/object/Minecart.php +++ b/src/entity/object/Minecart.php @@ -62,7 +62,7 @@ class Minecart extends Vehicle{ $this->x = $this->data["TileX"] ?? $this->x; $this->y = $this->data["TileY"] ?? $this->y; $this->z = $this->data["TileZ"] ?? $this->z; - $this->setHealth(1, "generic"); //orig: 3 + $this->setHealth(1, "generic", allowHarm: false); //orig: 3 $this->setSize(0.98, 0.7); $this->yOffset = $this->height / 2; $this->stepHeight = 0; diff --git a/src/entity/object/PrimedTNT.php b/src/entity/object/PrimedTNT.php index 3bc5f03d..75a8825d 100644 --- a/src/entity/object/PrimedTNT.php +++ b/src/entity/object/PrimedTNT.php @@ -12,7 +12,7 @@ class PrimedTNT extends Entity{ $this->gravity = 0.04; $this->setSize(0.98, 0.98); $this->yOffset = $this->height / 2; - $this->setHealth(10000000, "generic"); + $this->setHealth(10000000, "generic", allowHarm: false); } public function isPickable(){ diff --git a/src/entity/object/TripodCamera.php b/src/entity/object/TripodCamera.php index 6855cd3c..58344052 100644 --- a/src/entity/object/TripodCamera.php +++ b/src/entity/object/TripodCamera.php @@ -5,7 +5,7 @@ class TripodCamera extends Entity{ function __construct(Level $level, $eid, $class, $type = 0, $data = []){ parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth(PHP_INT_MAX, "generic"); + $this->setHealth(PHP_INT_MAX, "generic", allowHarm: false); } public function isPickable(){