Skip to content

Commit

Permalink
fix: style
Browse files Browse the repository at this point in the history
  • Loading branch information
AzaleeX committed Nov 9, 2024
1 parent 0ddb106 commit 1f73547
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/block/VanillaBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ public function getBreakTime(Item $item) : float{

$nyliumBreakInfo = BreakInfo::pickaxe(0.4);
self::register("crimson_nylium", new NetherNylium(new BID(Ids::CRIMSON_NYLIUM), "Crimson Nylium", new Info($nyliumBreakInfo, [Tags::NYLIUM])));
self::register("warped_nylium", new NetherNylium(new BID(Ids::WARPED_NYLIUM), "Warped Nylium", new Info($nyliumBreakInfo), [Tags::NYLIUM]));
self::register("warped_nylium", new NetherNylium(new BID(Ids::WARPED_NYLIUM), "Warped Nylium", new Info($nyliumBreakInfo, [Tags::NYLIUM])));

self::register("gravel", new Gravel(new BID(Ids::GRAVEL), "Gravel", new Info(BreakInfo::shovel(0.6))));

Expand Down
16 changes: 8 additions & 8 deletions src/world/generator/object/NetherGrass.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@

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

//Todo: Add more blocks to grow on nether nylium

if ($nyliumType === BlockTypeIds::WARPED_NYLIUM) {
$blocksToGrow = [
VanillaBlocks::CRIMSON_ROOTS(), // Rare
VanillaBlocks::WARPED_ROOTS(),
//VanillaBlocks::NETHER_SPROUTS(),
//VanillaBlocks::WARPED_FUNGUS(),
VanillaBlocks::CRIMSON_ROOTS(), // Rare
//VanillaBlocks::CRIMSON_FUNGUS() // Rare
];
} elseif ($nyliumType === BlockTypeIds::CRIMSON_NYLIUM) {
Expand All @@ -55,17 +55,17 @@ public static function growGrass(ChunkManager $world, Vector3 $pos, Random $rand

$blocksCount = count($blocksToGrow) - 1;
for ($c = 0; $c < $count; ++$c) {
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
$blockBelow = $world->getBlockAt($x, $pos->y, $z);
if ($world->getBlockAt($x, $pos->y + 1, $z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {
$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($x, (int) $pos->y, $z);
if ($world->getBlockAt($x, (int) ($pos->y + 1), $z)->getTypeId() === BlockTypeIds::AIR && $blockBelow->getTypeId() !== BlockTypeIds::AIR) {
$blockToGrow = $blocksToGrow[$random->nextRange(0, $blocksCount)];

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

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

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

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

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

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($x, $pos->y + 1, $z, $blockToGrow);
$world->setBlockAt($x, (int) ($pos->y + 1), $z, $blockToGrow);
}
} else {
$world->setBlockAt($x, $pos->y + 1, $z, $blockToGrow);
$world->setBlockAt($x, (int) ($pos->y + 1), $z, $blockToGrow);
}
}
}
Expand Down

0 comments on commit 1f73547

Please sign in to comment.