Skip to content

Commit ff6fb7f

Browse files
committed
fix1: phpstan
1 parent 9b196c2 commit ff6fb7f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/world/generator/object/NetherGrass.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
class NetherGrass{
3434
public static function growGrass(ChunkManager $world, Vector3 $pos, Random $random, int $count = 8, int $radius = 5) : void{
35-
$nyliumType = $world->getBlockAt($pos->x, $pos->y, $pos->z)->getTypeId();
35+
$nyliumType = $world->getBlockAt((int) $pos->x, (int) $pos->y, (int) $pos->z)->getTypeId();
3636
$blocksToGrow = [];
3737

3838
//Todo: Add more blocks to grow on nether nylium
@@ -56,17 +56,19 @@ public static function growGrass(ChunkManager $world, Vector3 $pos, Random $rand
5656
$blocksCount = count($blocksToGrow) - 1;
5757
if ($blocksCount >= 0) {
5858
for ($c = 0; $c < $count; ++$c) {
59-
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
60-
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
61-
$blockBelow = $world->getBlockAt($x, $pos->y, $z);
62-
if ($world->getBlockAt($x, $pos->y + 1, $z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {
63-
$blockToGrow = $blocksToGrow[$random->nextRange(0, $blocksCount)];
64-
if ($blockToGrow === VanillaBlocks::CRIMSON_ROOTS()) {
65-
if ($random->nextFloat() < 0.1) { // 10% chance for rare blocks
66-
$world->setBlockAt($x, $pos->y + 1, $z, $blockToGrow);
59+
$x = $random->nextRange((int) ($pos->x - $radius), (int) ($pos->x + $radius));
60+
$z = $random->nextRange((int) ($pos->z - $radius), (int) ($pos->z + $radius));
61+
$blockBelow = $world->getBlockAt($x, (int) $pos->y, $z);
62+
if ($world->getBlockAt($x, (int) ($pos->y + 1), $z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {
63+
if (isset($blocksToGrow[$random->nextRange(0, $blocksCount)])) {
64+
$blockToGrow = $blocksToGrow[$random->nextRange(0, $blocksCount)];
65+
if ($blockToGrow === VanillaBlocks::CRIMSON_ROOTS()) {
66+
if ($random->nextFloat() < 0.1) { // 10% chance for rare blocks
67+
$world->setBlockAt($x, (int) ($pos->y + 1), $z, $blockToGrow);
68+
}
69+
} else {
70+
$world->setBlockAt($x, (int) ($pos->y + 1), $z, $blockToGrow);
6771
}
68-
} else {
69-
$world->setBlockAt($x, $pos->y + 1, $z, $blockToGrow);
7072
}
7173
}
7274
}

0 commit comments

Comments
 (0)