removed Java + cleanup

This commit is contained in:
GameHerobrine 2023-11-12 04:12:35 +03:00
parent d43f9173d5
commit f00df9cc43
3 changed files with 13 additions and 68 deletions

View file

@ -1,21 +1,20 @@
<?php
class LightUtils{
/*
args: $source: <Block> instanceof LightingBlock, $block: Block
*/
/**
* @param LightingBlock $source
* @param Block $block
* @return number
*/
public static function getLightValueFromNearbySource($source, $block){
if($source === null || $block === null){
return 0;
}
$distance = sqrt(LightUtils::sqr($source->x - $block->x) + LightUtils::sqr($source->y - $block->y) + LightUtils::sqr($source->z - $block->z)); /*Distance between 2 3d objects*/
$result = floor($source->getMaxLightValue() - $distance); //i dont need something like 0.2192032434454...
return $result <= 0 ? 0 : $result; //if result is smaller or equals 0 then return 0 else return result
}
/* Used only internally for calculating 2^(2) */
private static function sqr($val){
return pow($val, 2);
$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;
}
}