mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Updated to extension 0.0.2
This commit is contained in:
parent
71737c3e53
commit
db15ae49a1
@ -9,7 +9,7 @@ READLINE_VERSION="6.3"
|
||||
NCURSES_VERSION="5.9"
|
||||
PHPNCURSES_VERSION="1.0.2"
|
||||
PTHREADS_VERSION="2.0.4"
|
||||
PHP_POCKETMINE_VERSION="0.0.1"
|
||||
PHP_POCKETMINE_VERSION="0.0.2"
|
||||
UOPZ_VERSION="2.0.3"
|
||||
WEAKREF_VERSION="0.2.2"
|
||||
PHPYAML_VERSION="1.1.1"
|
||||
|
@ -328,9 +328,14 @@ namespace pocketmine {
|
||||
//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);
|
||||
++$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")){
|
||||
|
@ -21,9 +21,13 @@
|
||||
|
||||
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{
|
||||
public $x, $y;
|
||||
public $x;
|
||||
public $y;
|
||||
|
||||
public function __construct($x = 0, $y = 0){
|
||||
$this->x = $x;
|
||||
@ -46,16 +50,16 @@ class Vector2{
|
||||
return (int) $this->y;
|
||||
}
|
||||
|
||||
public function add($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
public function add($x, $y = 0){
|
||||
if($x instanceof Vector2){
|
||||
return $this->add($x->x, $x->y);
|
||||
}else{
|
||||
return new Vector2($this->x + $x, $this->y + $y);
|
||||
}
|
||||
}
|
||||
|
||||
public function subtract($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
public function subtract($x, $y = 0){
|
||||
if($x instanceof Vector2){
|
||||
return $this->add(-$x->x, -$x->y);
|
||||
}else{
|
||||
return $this->add(-$x, -$y);
|
||||
@ -86,16 +90,16 @@ class Vector2{
|
||||
return new Vector2($this->x / $number, $this->y / $number);
|
||||
}
|
||||
|
||||
public function distance($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
public function distance($x, $y = 0){
|
||||
if($x instanceof Vector2){
|
||||
return sqrt($this->distanceSquared($x->x, $x->y));
|
||||
}else{
|
||||
return sqrt($this->distanceSquared($x, $y));
|
||||
}
|
||||
}
|
||||
|
||||
public function distanceSquared($x = 0, $y = 0){
|
||||
if(($x instanceof Vector2) === true){
|
||||
public function distanceSquared($x, $y = 0){
|
||||
if($x instanceof Vector2){
|
||||
return $this->distanceSquared($x->x, $x->y);
|
||||
}else{
|
||||
return pow($this->x - $x, 2) + pow($this->y - $y, 2);
|
||||
|
@ -21,7 +21,10 @@
|
||||
|
||||
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{
|
||||
public $x;
|
||||
public $y;
|
||||
@ -58,27 +61,27 @@ class Vector3{
|
||||
}
|
||||
|
||||
public function getRight(){
|
||||
return $this->getX();
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
public function getUp(){
|
||||
return $this->getY();
|
||||
return $this->y;
|
||||
}
|
||||
|
||||
public function getForward(){
|
||||
return $this->getZ();
|
||||
return $this->z;
|
||||
}
|
||||
|
||||
public function getSouth(){
|
||||
return $this->getX();
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
public function getWest(){
|
||||
return $this->getZ();
|
||||
return $this->z;
|
||||
}
|
||||
|
||||
public function add($x = 0, $y = 0, $z = 0){
|
||||
if(($x instanceof Vector3) === true){
|
||||
public function add($x, $y = 0, $z = 0){
|
||||
if($x instanceof Vector3){
|
||||
return $this->add($x->x, $x->y, $x->z);
|
||||
}else{
|
||||
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){
|
||||
if(($x instanceof Vector3) === true){
|
||||
if($x instanceof Vector3){
|
||||
return $this->add(-$x->x, -$x->y, -$x->z);
|
||||
}else{
|
||||
return $this->add(-$x, -$y, -$z);
|
||||
@ -117,20 +120,20 @@ class Vector3{
|
||||
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){
|
||||
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:
|
||||
return new Vector3($this->x, $this->y + 1, $this->z);
|
||||
return new Vector3($this->x, $this->y + (int) $step, $this->z);
|
||||
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:
|
||||
return new Vector3($this->x, $this->y, $this->z + 1);
|
||||
return new Vector3($this->x, $this->y, $this->z + (int) $step);
|
||||
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:
|
||||
return new Vector3($this->x + 1, $this->y, $this->z);
|
||||
return new Vector3($this->x + (int) $step, $this->y, $this->z);
|
||||
default:
|
||||
return $this;
|
||||
}
|
||||
@ -145,8 +148,10 @@ class Vector3{
|
||||
}
|
||||
|
||||
public function maxPlainDistance($x = 0, $z = 0){
|
||||
if(($x instanceof Vector3) === true){
|
||||
if($x instanceof Vector3){
|
||||
return $this->maxPlainDistance($x->x, $x->z);
|
||||
}elseif($x instanceof Vector2){
|
||||
return $this->maxPlainDistance($x->x, $x->y);
|
||||
}else{
|
||||
return max(abs($this->x - $x), abs($this->z - $z));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user