Updated to extension 0.0.2

This commit is contained in:
Shoghi Cervantes 2014-04-09 00:56:36 +02:00
parent 71737c3e53
commit db15ae49a1
4 changed files with 50 additions and 36 deletions

View File

@ -9,7 +9,7 @@ READLINE_VERSION="6.3"
NCURSES_VERSION="5.9" NCURSES_VERSION="5.9"
PHPNCURSES_VERSION="1.0.2" PHPNCURSES_VERSION="1.0.2"
PTHREADS_VERSION="2.0.4" PTHREADS_VERSION="2.0.4"
PHP_POCKETMINE_VERSION="0.0.1" PHP_POCKETMINE_VERSION="0.0.2"
UOPZ_VERSION="2.0.3" UOPZ_VERSION="2.0.3"
WEAKREF_VERSION="0.2.2" WEAKREF_VERSION="0.2.2"
PHPYAML_VERSION="1.1.1" PHPYAML_VERSION="1.1.1"

View File

@ -328,9 +328,14 @@ namespace pocketmine {
//console("[NOTICE] Couldn't find the uopz extension. Some functions may be limited", true, true, 0); //console("[NOTICE] Couldn't find the uopz extension. Some functions may be limited", true, true, 0);
} }
if(extension_loaded("pocketmine") and version_compare(phpversion("pocketmine"), "0.0.1") < 0){ if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.1.", true, true, 0); console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.1.", true, true, 0);
++$errors; ++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.2") > 0){
console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.2.", true, true, 0);
++$errors;
}
} }
if(!extension_loaded("curl")){ if(!extension_loaded("curl")){

View File

@ -21,9 +21,13 @@
namespace pocketmine\math; namespace pocketmine\math;
/**
* WARNING: This class is available on the PocketMine-MP Zephir project.
* If this class is modified, remember to modify the PHP C extension.
*/
class Vector2{ class Vector2{
public $x, $y; public $x;
public $y;
public function __construct($x = 0, $y = 0){ public function __construct($x = 0, $y = 0){
$this->x = $x; $this->x = $x;
@ -46,16 +50,16 @@ class Vector2{
return (int) $this->y; return (int) $this->y;
} }
public function add($x = 0, $y = 0){ public function add($x, $y = 0){
if(($x instanceof Vector2) === true){ if($x instanceof Vector2){
return $this->add($x->x, $x->y); return $this->add($x->x, $x->y);
}else{ }else{
return new Vector2($this->x + $x, $this->y + $y); return new Vector2($this->x + $x, $this->y + $y);
} }
} }
public function subtract($x = 0, $y = 0){ public function subtract($x, $y = 0){
if(($x instanceof Vector2) === true){ if($x instanceof Vector2){
return $this->add(-$x->x, -$x->y); return $this->add(-$x->x, -$x->y);
}else{ }else{
return $this->add(-$x, -$y); return $this->add(-$x, -$y);
@ -86,16 +90,16 @@ class Vector2{
return new Vector2($this->x / $number, $this->y / $number); return new Vector2($this->x / $number, $this->y / $number);
} }
public function distance($x = 0, $y = 0){ public function distance($x, $y = 0){
if(($x instanceof Vector2) === true){ if($x instanceof Vector2){
return sqrt($this->distanceSquared($x->x, $x->y)); return sqrt($this->distanceSquared($x->x, $x->y));
}else{ }else{
return sqrt($this->distanceSquared($x, $y)); return sqrt($this->distanceSquared($x, $y));
} }
} }
public function distanceSquared($x = 0, $y = 0){ public function distanceSquared($x, $y = 0){
if(($x instanceof Vector2) === true){ if($x instanceof Vector2){
return $this->distanceSquared($x->x, $x->y); return $this->distanceSquared($x->x, $x->y);
}else{ }else{
return pow($this->x - $x, 2) + pow($this->y - $y, 2); return pow($this->x - $x, 2) + pow($this->y - $y, 2);

View File

@ -21,7 +21,10 @@
namespace pocketmine\math; namespace pocketmine\math;
/**
* WARNING: This class is available on the PocketMine-MP Zephir project.
* If this class is modified, remember to modify the PHP C extension.
*/
class Vector3{ class Vector3{
public $x; public $x;
public $y; public $y;
@ -58,27 +61,27 @@ class Vector3{
} }
public function getRight(){ public function getRight(){
return $this->getX(); return $this->x;
} }
public function getUp(){ public function getUp(){
return $this->getY(); return $this->y;
} }
public function getForward(){ public function getForward(){
return $this->getZ(); return $this->z;
} }
public function getSouth(){ public function getSouth(){
return $this->getX(); return $this->x;
} }
public function getWest(){ public function getWest(){
return $this->getZ(); return $this->z;
} }
public function add($x = 0, $y = 0, $z = 0){ public function add($x, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){ if($x instanceof Vector3){
return $this->add($x->x, $x->y, $x->z); return $this->add($x->x, $x->y, $x->z);
}else{ }else{
return new Vector3($this->x + $x, $this->y + $y, $this->z + $z); return new Vector3($this->x + $x, $this->y + $y, $this->z + $z);
@ -86,7 +89,7 @@ class Vector3{
} }
public function subtract($x = 0, $y = 0, $z = 0){ public function subtract($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){ if($x instanceof Vector3){
return $this->add(-$x->x, -$x->y, -$x->z); return $this->add(-$x->x, -$x->y, -$x->z);
}else{ }else{
return $this->add(-$x, -$y, -$z); return $this->add(-$x, -$y, -$z);
@ -117,20 +120,20 @@ class Vector3{
return new Vector3(abs($this->x), abs($this->y), abs($this->z)); return new Vector3(abs($this->x), abs($this->y), abs($this->z));
} }
public function getSide($side){ public function getSide($side, $step = 1){
switch((int) $side){ switch((int) $side){
case 0: case 0:
return new Vector3($this->x, $this->y - 1, $this->z); return new Vector3($this->x, $this->y - (int) $step, $this->z);
case 1: case 1:
return new Vector3($this->x, $this->y + 1, $this->z); return new Vector3($this->x, $this->y + (int) $step, $this->z);
case 2: case 2:
return new Vector3($this->x, $this->y, $this->z - 1); return new Vector3($this->x, $this->y, $this->z - (int) $step);
case 3: case 3:
return new Vector3($this->x, $this->y, $this->z + 1); return new Vector3($this->x, $this->y, $this->z + (int) $step);
case 4: case 4:
return new Vector3($this->x - 1, $this->y, $this->z); return new Vector3($this->x - (int) $step, $this->y, $this->z);
case 5: case 5:
return new Vector3($this->x + 1, $this->y, $this->z); return new Vector3($this->x + (int) $step, $this->y, $this->z);
default: default:
return $this; return $this;
} }
@ -145,8 +148,10 @@ class Vector3{
} }
public function maxPlainDistance($x = 0, $z = 0){ public function maxPlainDistance($x = 0, $z = 0){
if(($x instanceof Vector3) === true){ if($x instanceof Vector3){
return $this->maxPlainDistance($x->x, $x->z); return $this->maxPlainDistance($x->x, $x->z);
}elseif($x instanceof Vector2){
return $this->maxPlainDistance($x->x, $x->y);
}else{ }else{
return max(abs($this->x - $x), abs($this->z - $z)); return max(abs($this->x - $x), abs($this->z - $z));
} }