removed useless loop + fixed explosion error

This commit is contained in:
GameHerobrine 2022-12-23 08:00:45 +03:00
parent be9a9c0c0d
commit ab0b726904
2 changed files with 6 additions and 35 deletions

View file

@ -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;

View file

@ -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);
}
}
}