32
32
33
33
class NetherGrass{
34
34
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 ();
36
36
$ blocksToGrow = [];
37
37
38
38
//Todo: Add more blocks to grow on nether nylium
@@ -56,17 +56,19 @@ public static function growGrass(ChunkManager $world, Vector3 $pos, Random $rand
56
56
$ blocksCount = count ($ blocksToGrow ) - 1 ;
57
57
if ($ blocksCount >= 0 ) {
58
58
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 );
67
71
}
68
- } else {
69
- $ world ->setBlockAt ($ x , $ pos ->y + 1 , $ z , $ blockToGrow );
70
72
}
71
73
}
72
74
}
0 commit comments