diff --git a/src/structure/Structure.php b/src/structure/Structure.php index 2be51bd2..a1e16c85 100644 --- a/src/structure/Structure.php +++ b/src/structure/Structure.php @@ -29,25 +29,20 @@ abstract class Structure{ return isset($this->mapSymToID[$sym]) ? $this->mapSymToID[$sym] : Structure::MAP_NO_KEY; } - protected function placeBlock($level, $sym, &$tv){ - //console("@@@"); + protected function placeBlock($level, $sym, $tv){ if($level instanceof Level){ $idm = $this->getMappingFor($sym); if(!isset($idm[1])) $idm[1] = 0; - //var_dump($idm); if($idm === Structure::MAP_NO_KEY){ - //console("Failed to receive id"); return false; } - $block = $this->api->block->get($idm[0], $idm[1], $tv); //TODO: meta - //console($block); + $block = $this->api->block->get($idm[0], $idm[1], $tv); $level->setBlock($tv, $block, true, false, true); } } public function build($level, $centerX, $centerY, $centerZ){ - //console("b"); $tempVector = new Vector3(0,0,0); $x = $centerX - $this->radius; $z = $centerZ - $this->radius; @@ -55,7 +50,6 @@ abstract class Structure{ foreach($blocksXZ as $blocks){ foreach(str_split($blocks) as $block){ $tempVector->setXYZ($x, $centerY + $offsetY, $z); - //console("6#&_+7$:373-"); $this->placeBlock($level, $block, $tempVector); ++$x; } diff --git a/src/utils/Java.php b/src/utils/Java.php deleted file mode 100644 index 267cb030..00000000 --- a/src/utils/Java.php +++ /dev/null @@ -1,48 +0,0 @@ -value = (string) $string; - $this->count = strlen($this->value); - } - } - - public function __toString(){ - return $this->value; - } - - public function lenght(){ - return $this->count; - } - - public function isEmpty(){ - return $this->count === 0; - } - - public function hashCode(){ - $h = $this->hash; - if($h === 0 and $this->count > 0){ - for($i = 0; $i < $this->count; ++$i){ - $h = (($h << 5) - $h) + ord($this->charAt($i)); - $h = $h & 0xFFFFFFFF; - $this->hash = $h; - } - $this->hash = $h; - } - return $h; - } - - public function charAt($index){ - $index = (int) $index; - if($index < 0 or $index >= $this->count){ - trigger_error("Undefined offset $index", E_USER_WARNING); - return false; - } - return $this->value[$index]; - } -} \ No newline at end of file diff --git a/src/utils/LightUtils.php b/src/utils/LightUtils.php index fb826eb8..876db487 100644 --- a/src/utils/LightUtils.php +++ b/src/utils/LightUtils.php @@ -1,21 +1,20 @@ 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; } } \ No newline at end of file