Explosion: cap yield at 100%

this could overflow if the explosion size is less than 1.
While this currently doesn't have any negative effects, if we decided to support >100% yield, this would cause some issues.
This commit is contained in:
Dylan K. Taylor 2022-05-21 22:43:26 +01:00
parent 645c44ae9c
commit 7eaf1246a0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -42,6 +42,7 @@ use pocketmine\world\utils\SubChunkExplorer;
use pocketmine\world\utils\SubChunkExplorerStatus;
use function ceil;
use function floor;
use function min;
use function mt_rand;
use function sqrt;
@ -154,7 +155,7 @@ class Explosion{
*/
public function explodeB() : bool{
$source = (new Vector3($this->source->x, $this->source->y, $this->source->z))->floor();
$yield = (1 / $this->size) * 100;
$yield = min(100, (1 / $this->size) * 100);
if($this->what instanceof Entity){
$ev = new EntityExplodeEvent($this->what, $this->source, $this->affectedBlocks, $yield);