mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Correct damage calculation for non-arrow projectiles (#5394)
This commit is contained in:
parent
b3ccf41307
commit
a7ac6070dc
@ -38,6 +38,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
|||||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
|
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\world\sound\ArrowHitSound;
|
use pocketmine\world\sound\ArrowHitSound;
|
||||||
|
use function ceil;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
use function sqrt;
|
use function sqrt;
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ class Arrow extends Projectile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getResultDamage() : int{
|
public function getResultDamage() : int{
|
||||||
$base = parent::getResultDamage();
|
$base = (int) ceil($this->motion->length() * parent::getResultDamage());
|
||||||
if($this->isCritical()){
|
if($this->isCritical()){
|
||||||
return ($base + mt_rand(0, (int) ($base / 2) + 1));
|
return ($base + mt_rand(0, (int) ($base / 2) + 1));
|
||||||
}else{
|
}else{
|
||||||
|
@ -128,7 +128,7 @@ abstract class Projectile extends Entity{
|
|||||||
* Returns the amount of damage this projectile will deal to the entity it hits.
|
* Returns the amount of damage this projectile will deal to the entity it hits.
|
||||||
*/
|
*/
|
||||||
public function getResultDamage() : int{
|
public function getResultDamage() : int{
|
||||||
return (int) ceil($this->motion->length() * $this->damage);
|
return (int) ceil($this->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveNBT() : CompoundTag{
|
public function saveNBT() : CompoundTag{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user