mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
removed Java + cleanup
This commit is contained in:
parent
d43f9173d5
commit
f00df9cc43
3 changed files with 13 additions and 68 deletions
|
|
@ -29,25 +29,20 @@ abstract class Structure{
|
||||||
return isset($this->mapSymToID[$sym]) ? $this->mapSymToID[$sym] : Structure::MAP_NO_KEY;
|
return isset($this->mapSymToID[$sym]) ? $this->mapSymToID[$sym] : Structure::MAP_NO_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function placeBlock($level, $sym, &$tv){
|
protected function placeBlock($level, $sym, $tv){
|
||||||
//console("@@@");
|
|
||||||
if($level instanceof Level){
|
if($level instanceof Level){
|
||||||
$idm = $this->getMappingFor($sym);
|
$idm = $this->getMappingFor($sym);
|
||||||
if(!isset($idm[1])) $idm[1] = 0;
|
if(!isset($idm[1])) $idm[1] = 0;
|
||||||
//var_dump($idm);
|
|
||||||
if($idm === Structure::MAP_NO_KEY){
|
if($idm === Structure::MAP_NO_KEY){
|
||||||
//console("Failed to receive id");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$block = $this->api->block->get($idm[0], $idm[1], $tv); //TODO: meta
|
$block = $this->api->block->get($idm[0], $idm[1], $tv);
|
||||||
//console($block);
|
|
||||||
$level->setBlock($tv, $block, true, false, true);
|
$level->setBlock($tv, $block, true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build($level, $centerX, $centerY, $centerZ){
|
public function build($level, $centerX, $centerY, $centerZ){
|
||||||
//console("b");
|
|
||||||
$tempVector = new Vector3(0,0,0);
|
$tempVector = new Vector3(0,0,0);
|
||||||
$x = $centerX - $this->radius;
|
$x = $centerX - $this->radius;
|
||||||
$z = $centerZ - $this->radius;
|
$z = $centerZ - $this->radius;
|
||||||
|
|
@ -55,7 +50,6 @@ abstract class Structure{
|
||||||
foreach($blocksXZ as $blocks){
|
foreach($blocksXZ as $blocks){
|
||||||
foreach(str_split($blocks) as $block){
|
foreach(str_split($blocks) as $block){
|
||||||
$tempVector->setXYZ($x, $centerY + $offsetY, $z);
|
$tempVector->setXYZ($x, $centerY + $offsetY, $z);
|
||||||
//console("6#&_+7$:373-");
|
|
||||||
$this->placeBlock($level, $block, $tempVector);
|
$this->placeBlock($level, $block, $tempVector);
|
||||||
++$x;
|
++$x;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class LightUtils{
|
class LightUtils{
|
||||||
|
/**
|
||||||
/*
|
* @param LightingBlock $source
|
||||||
args: $source: <Block> instanceof LightingBlock, $block: Block
|
* @param Block $block
|
||||||
*/
|
* @return number
|
||||||
|
*/
|
||||||
public static function getLightValueFromNearbySource($source, $block){
|
public static function getLightValueFromNearbySource($source, $block){
|
||||||
if($source === null || $block === null){
|
if($source === null || $block === null){
|
||||||
return 0;
|
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*/
|
$diffX = ($source->x - $block->x);
|
||||||
$result = floor($source->getMaxLightValue() - $distance); //i dont need something like 0.2192032434454...
|
$diffY = ($source->y - $block->y);
|
||||||
return $result <= 0 ? 0 : $result; //if result is smaller or equals 0 then return 0 else return result
|
$diffZ = ($source->z - $block->z);
|
||||||
}
|
$distance = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
||||||
|
$result = floor($source->getMaxLightValue() - $distance);
|
||||||
/* Used only internally for calculating 2^(2) */
|
return $result <= 0 ? 0 : $result;
|
||||||
private static function sqr($val){
|
|
||||||
return pow($val, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue