From ab0b726904b1d653bdafd81b7ca518a04c3d8aeb Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Fri, 23 Dec 2022 08:00:45 +0300 Subject: [PATCH] removed useless loop + fixed explosion error --- src/entity/Entity.php | 32 -------------------------------- src/world/Explosion.php | 9 ++++++--- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index a8a60919..128831d8 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -636,38 +636,6 @@ class Entity extends Position } } - if(!$support){ - for($z = $startZ; $z <= $endZ; ++ $z){ - for($x = $startX; $x <= $endX; ++ $x){ - $v = new Vector3($x, $y, $z); - $v1 = new Vector3($x, $yC, $z); - if($this->isSupport($v, $this->width)){ - $b = $this->level->getBlock($v); - if($b->isSolid === true){ - $support = true; - $isFlying = false; - break; - } elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){ - $isFlying = false; - } - } elseif($this->isSupport($v1, $this->width)){ - $b = $this->level->getBlock($v1); - if($b->isSolid === true){ - $support = true; - $isFlying = false; - break; - } elseif(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL or $b->getID() === IRON_BARS){ - $isFlying = false; - } - } - } - if($support === true){ - break; - } - } - } - - if($this->speedX != 0){ $this->x += $this->speedX; $this->speedX -= $this->speedX * $drag; diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 7b036abf..749a3ac8 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -95,8 +95,11 @@ class Explosion{ $e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); $server->api->entity->spawnToAll($e); }elseif(mt_rand(0, 10000) < ((1 / $this->size) * 10000)){ - foreach($block->getDrops($this->air, $this->nullPlayer) as $drop){ - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($drop[0], $drop[1], $drop[2])); //id, meta, count + $dropz = $block->getDrops($this->air, $this->nullPlayer); + if(is_array($dropz)){ + foreach($dropz as $drop){ + $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($drop[0], $drop[1], $drop[2])); //id, meta, count + } } } $this->level->setBlock($block, new AirBlock(), true); @@ -110,4 +113,4 @@ class Explosion{ $pk->records = $send; $server->api->player->broadcastPacket($this->level->players, $pk); } -} \ No newline at end of file +}