From 4637aae6210d0a2bb3be6679ef0f649dcf4616f3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 19 Jul 2023 11:43:09 +0100 Subject: [PATCH 1/3] Living: do not apply noDamageTicks to suicide damage suicide damage is a voluntary damage source, which noDamageTicks is intended to prevent getting damaged while the player gets their bearings after (re)spawning. --- src/entity/Living.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity/Living.php b/src/entity/Living.php index de433cd12..e615e4148 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -504,7 +504,7 @@ abstract class Living extends Entity{ } public function attack(EntityDamageEvent $source) : void{ - if($this->noDamageTicks > 0){ + if($this->noDamageTicks > 0 && $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE){ $source->cancel(); } From 8414c78969ff76a25f0f86b360b62097be89c5c1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 19 Jul 2023 11:49:52 +0100 Subject: [PATCH 2/3] Fixed netherite items burning in lava --- src/entity/Entity.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index cc7647912..092fcc0fc 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -519,7 +519,12 @@ abstract class Entity{ } public function attack(EntityDamageEvent $source) : void{ - if($this->isFireProof() && ($source->getCause() === EntityDamageEvent::CAUSE_FIRE || $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK)){ + if($this->isFireProof() && ( + $source->getCause() === EntityDamageEvent::CAUSE_FIRE || + $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK || + $source->getCause() === EntityDamageEvent::CAUSE_LAVA + ) + ){ $source->cancel(); } $source->call(); From 763241b11ff74de0b29c9adfcbcd5263accb4277 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 19 Jul 2023 12:32:00 +0100 Subject: [PATCH 3/3] Fixed burning animations for fireproof entities creative players are not technically fireproof; they just don't take any damage from fire --- src/entity/Entity.php | 15 +++++++++------ src/player/Player.php | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 092fcc0fc..8a406924e 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -691,8 +691,10 @@ abstract class Entity{ if($fireTicks < 0 || $fireTicks > 0x7fff){ throw new \InvalidArgumentException("Fire ticks must be in range 0 ... " . 0x7fff . ", got $fireTicks"); } - $this->fireTicks = $fireTicks; - $this->networkPropertiesDirty = true; + if(!$this->isFireProof()){ + $this->fireTicks = $fireTicks; + $this->networkPropertiesDirty = true; + } } public function extinguish() : void{ @@ -705,12 +707,13 @@ abstract class Entity{ } protected function doOnFireTick(int $tickDiff = 1) : bool{ - if($this->isFireProof() && $this->fireTicks > 1){ - $this->fireTicks = 1; - }else{ - $this->fireTicks -= $tickDiff; + if($this->isFireProof() && $this->isOnFire()){ + $this->extinguish(); + return false; } + $this->fireTicks -= $tickDiff; + if(($this->fireTicks % 20 === 0) || $tickDiff > 20){ $this->dealFireDamage(); } diff --git a/src/player/Player.php b/src/player/Player.php index 11dabf7db..ccce2d45e 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -1195,10 +1195,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return !$this->gamemode->equals(GameMode::CREATIVE()); } - public function isFireProof() : bool{ - return $this->isCreative(); - } - public function getDrops() : array{ if($this->hasFiniteResources()){ return parent::getDrops(); @@ -1436,6 +1432,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->entityBaseTick($tickDiff); Timings::$entityBaseTick->stopTiming(); + if($this->isCreative() && $this->fireTicks > 1){ + $this->fireTicks = 1; + } + if(!$this->isSpectator() && $this->isAlive()){ Timings::$playerCheckNearEntities->startTiming(); $this->checkNearEntities();