mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
20 lines
No EOL
516 B
PHP
20 lines
No EOL
516 B
PHP
<?php
|
|
|
|
class LightUtils{
|
|
/**
|
|
* @param LightingBlock $source
|
|
* @param Block $block
|
|
* @return number
|
|
*/
|
|
public static function getLightValueFromNearbySource($source, $block){
|
|
if($source === null || $block === null){
|
|
return 0;
|
|
}
|
|
$diffX = ($source->x - $block->x);
|
|
$diffY = ($source->y - $block->y);
|
|
$diffZ = ($source->z - $block->z);
|
|
$distance = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
|
$result = floor($source->getMaxLightValue() - $distance);
|
|
return $result <= 0 ? 0 : $result;
|
|
}
|
|
} |