Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
AzaleeX committed Nov 9, 2024
1 parent 215db35 commit 9b196c2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/world/generator/object/NetherGrass.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class NetherGrass{
public static function growGrass(ChunkManager $world, Vector3 $pos, Random $random, int $count = 8, int $radius = 5) : void{
$nyliumType = $world->getBlockAt((int) $pos->x, (int) $pos->y, (int) $pos->z)->getTypeId();
$nyliumType = $world->getBlockAt($pos->x, $pos->y, $pos->z)->getTypeId();

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #1 $x of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #3 $z of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #1 $x of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #3 $z of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #1 $x of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 35 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #3 $z of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.
$blocksToGrow = [];

//Todo: Add more blocks to grow on nether nylium
Expand All @@ -56,17 +56,17 @@ public static function growGrass(ChunkManager $world, Vector3 $pos, Random $rand
$blocksCount = count($blocksToGrow) - 1;
if ($blocksCount >= 0) {
for ($c = 0; $c < $count; ++$c) {
$x = $random->nextRange((int)($pos->x - $radius), (int)($pos->x + $radius));
$z = $random->nextRange((int)($pos->z - $radius), (int)($pos->z + $radius));
$blockBelow = $world->getBlockAt((int)$x, (int)$pos->y, (int)$z);
if ($world->getBlockAt((int)$x, (int)($pos->y + 1), (int)$z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 59 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #1 $start of method pocketmine\utils\Random::nextRange() expects int, float|int given.

Check failure on line 60 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $end of method pocketmine\utils\Random::nextRange() expects int, float|int given.
$blockBelow = $world->getBlockAt($x, $pos->y, $z);

Check failure on line 61 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 61 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 61 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.
if ($world->getBlockAt($x, $pos->y + 1, $z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {

Check failure on line 62 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 62 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.

Check failure on line 62 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Parameter #2 $y of method pocketmine\world\ChunkManager::getBlockAt() expects int, float|int given.
$blockToGrow = $blocksToGrow[$random->nextRange(0, $blocksCount)];

Check failure on line 63 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Offset int does not exist on array{}|array{0: pocketmine\block\NetherRoots, 1?: pocketmine\block\NetherRoots}.

Check failure on line 63 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Offset int does not exist on array{}|array{0: pocketmine\block\NetherRoots, 1?: pocketmine\block\NetherRoots}.

Check failure on line 63 in src/world/generator/object/NetherGrass.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Offset int does not exist on array{}|array{0: pocketmine\block\NetherRoots, 1?: pocketmine\block\NetherRoots}.
if ($blockToGrow === VanillaBlocks::CRIMSON_ROOTS()) {
if ($random->nextFloat() < 0.1) { // 10% chance for rare blocks
$world->setBlockAt((int)$x, (int)($pos->y + 1), (int)$z, $blockToGrow);
$world->setBlockAt($x, $pos->y + 1, $z, $blockToGrow);
}
} else {
$world->setBlockAt((int)$x, (int)($pos->y + 1), (int)$z, $blockToGrow);
$world->setBlockAt($x, $pos->y + 1, $z, $blockToGrow);
}
}
}
Expand Down

0 comments on commit 9b196c2

Please sign in to comment.