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

@ -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;
}

View file

@ -1,48 +0,0 @@
<?php
//TODO remove
class Java_String{
private $value = "", $count = 0, $hash = 0;
public function __construct($string = false){
if($string !== false){
$this->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];
}
}

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;
}
}