mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
removed Java + cleanup
This commit is contained in:
parent
d43f9173d5
commit
f00df9cc43
3 changed files with 13 additions and 68 deletions
|
|
@ -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
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue