mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Replace disallowed operators in src/world/
This commit is contained in:
@ -75,7 +75,7 @@ class Flat extends Generator{
|
||||
$count = count($structure);
|
||||
for($sy = 0; $sy < $count; $sy += SubChunk::EDGE_LENGTH){
|
||||
$subchunk = $this->chunk->getSubChunk($sy >> SubChunk::COORD_BIT_SIZE);
|
||||
for($y = 0; $y < SubChunk::EDGE_LENGTH and isset($structure[$y | $sy]); ++$y){
|
||||
for($y = 0; $y < SubChunk::EDGE_LENGTH && isset($structure[$y | $sy]); ++$y){
|
||||
$id = $structure[$y | $sy];
|
||||
|
||||
for($Z = 0; $Z < SubChunk::EDGE_LENGTH; ++$Z){
|
||||
|
@ -73,7 +73,7 @@ final class GeneratorManager{
|
||||
Utils::testValidInstance($class, Generator::class);
|
||||
|
||||
$name = strtolower($name);
|
||||
if(!$overwrite and isset($this->list[$name])){
|
||||
if(!$overwrite && isset($this->list[$name])){
|
||||
throw new \InvalidArgumentException("Alias \"$name\" is already assigned");
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class Nether extends Generator{
|
||||
$chunk->setBiomeId($x, $z, BiomeIds::HELL);
|
||||
|
||||
for($y = 0; $y < 128; ++$y){
|
||||
if($y === 0 or $y === 127){
|
||||
if($y === 0 || $y === 127){
|
||||
$chunk->setFullBlock($x, $y, $z, $bedrock);
|
||||
continue;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ abstract class Noise{
|
||||
}
|
||||
|
||||
for($zz = 0; $zz < $zSize; ++$zz){
|
||||
if($xx % $samplingRate !== 0 or $zz % $samplingRate !== 0){
|
||||
if($xx % $samplingRate !== 0 || $zz % $samplingRate !== 0){
|
||||
$nx = (int) ($xx / $samplingRate) * $samplingRate;
|
||||
$nz = (int) ($zz / $samplingRate) * $samplingRate;
|
||||
$noiseArray[$xx][$zz] = Noise::bilinearLerp(
|
||||
@ -320,7 +320,7 @@ abstract class Noise{
|
||||
$dz2 = ($zz - $nz) / ($nnz - $nz);
|
||||
|
||||
for($yy = 0; $yy < $ySize; ++$yy){
|
||||
if($xx % $xSamplingRate !== 0 or $zz % $zSamplingRate !== 0 or $yy % $ySamplingRate !== 0){
|
||||
if($xx % $xSamplingRate !== 0 || $zz % $zSamplingRate !== 0 || $yy % $ySamplingRate !== 0){
|
||||
$ny = (int) ($yy / $ySamplingRate) * $ySamplingRate;
|
||||
$nny = $ny + $ySamplingRate;
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Normal extends Generator{
|
||||
|
||||
$weight = $this->gaussian->kernel[$sx + $this->gaussian->smoothSize][$sz + $this->gaussian->smoothSize];
|
||||
|
||||
if($sx === 0 and $sz === 0){
|
||||
if($sx === 0 && $sz === 0){
|
||||
$adjacent = $biome;
|
||||
}else{
|
||||
$index = World::chunkHash($absoluteX + $sx, $absoluteZ + $sz);
|
||||
|
@ -80,12 +80,12 @@ class Ore{
|
||||
$sizeY = ($yy + 0.5 - $seedY) / $size;
|
||||
$sizeY *= $sizeY;
|
||||
|
||||
if($yy > 0 and ($sizeX + $sizeY) < 1){
|
||||
if($yy > 0 && ($sizeX + $sizeY) < 1){
|
||||
for($zz = $startZ; $zz <= $endZ; ++$zz){
|
||||
$sizeZ = ($zz + 0.5 - $seedZ) / $size;
|
||||
$sizeZ *= $sizeZ;
|
||||
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 and $world->getBlockAt($xx, $yy, $zz)->isSameType($this->type->replaces)){
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 && $world->getBlockAt($xx, $yy, $zz)->isSameType($this->type->replaces)){
|
||||
$world->setBlockAt($xx, $yy, $zz, $this->type->material);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class SpruceTree extends Tree{
|
||||
$xOff = abs($xx - $x);
|
||||
for($zz = $z - $radius; $zz <= $z + $radius; ++$zz){
|
||||
$zOff = abs($zz - $z);
|
||||
if($xOff === $radius and $zOff === $radius and $radius > 0){
|
||||
if($xOff === $radius && $zOff === $radius && $radius > 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TallGrass{
|
||||
for($c = 0; $c < $count; ++$c){
|
||||
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
|
||||
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
|
||||
if($world->getBlockAt($x, $pos->y + 1, $z)->getId() === BlockLegacyIds::AIR and $world->getBlockAt($x, $pos->y, $z)->getId() === BlockLegacyIds::GRASS){
|
||||
if($world->getBlockAt($x, $pos->y + 1, $z)->getId() === BlockLegacyIds::AIR && $world->getBlockAt($x, $pos->y, $z)->getId() === BlockLegacyIds::GRASS){
|
||||
$world->setBlockAt($x, $pos->y + 1, $z, $arr[$random->nextRange(0, $arrC)]);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ abstract class Tree{
|
||||
public function canPlaceObject(ChunkManager $world, int $x, int $y, int $z, Random $random) : bool{
|
||||
$radiusToCheck = 0;
|
||||
for($yy = 0; $yy < $this->treeHeight + 3; ++$yy){
|
||||
if($yy === 1 or $yy === $this->treeHeight){
|
||||
if($yy === 1 || $yy === $this->treeHeight){
|
||||
++$radiusToCheck;
|
||||
}
|
||||
for($xx = -$radiusToCheck; $xx < ($radiusToCheck + 1); ++$xx){
|
||||
@ -105,7 +105,7 @@ abstract class Tree{
|
||||
$xOff = abs($xx - $x);
|
||||
for($zz = $z - $mid; $zz <= $z + $mid; ++$zz){
|
||||
$zOff = abs($zz - $z);
|
||||
if($xOff === $mid and $zOff === $mid and ($yOff === 0 or $random->nextBoundedInt(2) === 0)){
|
||||
if($xOff === $mid && $zOff === $mid && ($yOff === 0 || $random->nextBoundedInt(2) === 0)){
|
||||
continue;
|
||||
}
|
||||
if(!$transaction->fetchBlockAt($xx, $yy, $zz)->isSolid()){
|
||||
@ -117,6 +117,6 @@ abstract class Tree{
|
||||
}
|
||||
|
||||
protected function canOverride(Block $block) : bool{
|
||||
return $block->canBeReplaced() or $block instanceof Sapling or $block instanceof Leaves;
|
||||
return $block->canBeReplaced() || $block instanceof Sapling || $block instanceof Leaves;
|
||||
}
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ class GroundCover implements Populator{
|
||||
}
|
||||
$startY = min(127, $startY + $diffY);
|
||||
$endY = $startY - count($cover);
|
||||
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
||||
for($y = $startY; $y > $endY && $y >= 0; --$y){
|
||||
$b = $cover[$startY - $y];
|
||||
$id = $factory->fromFullBlock($chunk->getFullBlock($x, $y, $z));
|
||||
if($id->getId() === BlockLegacyIds::AIR and $b->isSolid()){
|
||||
if($id->getId() === BlockLegacyIds::AIR && $b->isSolid()){
|
||||
break;
|
||||
}
|
||||
if($b->canBeFlowedInto() and $id instanceof Liquid){
|
||||
if($b->canBeFlowedInto() && $id instanceof Liquid){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class TallGrass implements Populator{
|
||||
$z = $random->nextRange($chunkZ * Chunk::EDGE_LENGTH, $chunkZ * Chunk::EDGE_LENGTH + (Chunk::EDGE_LENGTH - 1));
|
||||
$y = $this->getHighestWorkableBlock($world, $x, $z);
|
||||
|
||||
if($y !== -1 and $this->canTallGrassStay($world, $x, $y, $z)){
|
||||
if($y !== -1 && $this->canTallGrassStay($world, $x, $y, $z)){
|
||||
$world->setBlockAt($x, $y, $z, $block);
|
||||
}
|
||||
}
|
||||
@ -60,13 +60,13 @@ class TallGrass implements Populator{
|
||||
|
||||
private function canTallGrassStay(ChunkManager $world, int $x, int $y, int $z) : bool{
|
||||
$b = $world->getBlockAt($x, $y, $z)->getId();
|
||||
return ($b === BlockLegacyIds::AIR or $b === BlockLegacyIds::SNOW_LAYER) and $world->getBlockAt($x, $y - 1, $z)->getId() === BlockLegacyIds::GRASS;
|
||||
return ($b === BlockLegacyIds::AIR || $b === BlockLegacyIds::SNOW_LAYER) && $world->getBlockAt($x, $y - 1, $z)->getId() === BlockLegacyIds::GRASS;
|
||||
}
|
||||
|
||||
private function getHighestWorkableBlock(ChunkManager $world, int $x, int $z) : int{
|
||||
for($y = 127; $y >= 0; --$y){
|
||||
$b = $world->getBlockAt($x, $y, $z)->getId();
|
||||
if($b !== BlockLegacyIds::AIR and $b !== BlockLegacyIds::LEAVES and $b !== BlockLegacyIds::LEAVES2 and $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
if($b !== BlockLegacyIds::AIR && $b !== BlockLegacyIds::LEAVES && $b !== BlockLegacyIds::LEAVES2 && $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
return $y + 1;
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ class Tree implements Populator{
|
||||
private function getHighestWorkableBlock(ChunkManager $world, int $x, int $z) : int{
|
||||
for($y = 127; $y >= 0; --$y){
|
||||
$b = $world->getBlockAt($x, $y, $z)->getId();
|
||||
if($b === BlockLegacyIds::DIRT or $b === BlockLegacyIds::GRASS){
|
||||
if($b === BlockLegacyIds::DIRT || $b === BlockLegacyIds::GRASS){
|
||||
return $y + 1;
|
||||
}elseif($b !== BlockLegacyIds::AIR and $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
}elseif($b !== BlockLegacyIds::AIR && $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user