56 $position = $block->getPosition();
58 $world = $position->getWorld();
59 $baseX = $position->getFloorX();
60 $baseY = $position->getFloorY();
61 $baseZ = $position->getFloorZ();
63 $farmland = $world->getBlockAt($baseX, $baseY - 1, $baseZ);
66 $result += $farmland->getWetness() > 0 ? self::ON_HYDRATED_FARMLAND_BONUS : self::ON_DRY_FARMLAND_BONUS;
71 $improperArrangement =
false;
73 for($x = -1; $x <= 1; $x++){
74 for($z = -1; $z <= 1; $z++){
75 if($x === 0 && $z === 0){
78 $nextFarmland = $world->getBlockAt($baseX + $x, $baseY - 1, $baseZ + $z);
80 if(!$nextFarmland instanceof
Farmland){
84 $result += $nextFarmland->getWetness() > 0 ? self::ADJACENT_HYDRATED_FARMLAND_BONUS : self::ADJACENT_DRY_FARMLAND_BONUS;
86 if(!$improperArrangement){
87 $nextCrop = $world->getBlockAt($baseX + $x, $baseY, $baseZ + $z);
88 if($nextCrop->hasSameTypeId($block)){
90 $x => $zRow ? $improperArrangement = true : $xRow =
true,
91 $z => $xRow ? $improperArrangement = true : $zRow =
true,
92 default => $improperArrangement =
true,
100 if($improperArrangement){
101 $result /= self::IMPROPER_ARRANGEMENT_DIVISOR;
107 public static function hasEnoughLight(Block $block,
int $minLevel = self::MIN_LIGHT_LEVEL) : bool{