Entity::getDirection() method

This commit is contained in:
Shoghi Cervantes Pueyo 2013-03-05 17:03:34 +01:00
parent 3b2a7e68f3
commit 0ab5fc8fcd
2 changed files with 9 additions and 11 deletions

View File

@ -38,7 +38,7 @@ class PocketMinecraftServer{
console("[INFO] \x1b[31;1mThis is a Development version"); console("[INFO] \x1b[31;1mThis is a Development version");
} }
console("[INFO] Starting Minecraft PE Server at ".$this->serverip.":".$this->port); console("[INFO] Starting Minecraft PE Server at ".$this->serverip.":".$this->port);
if($this->port < 19132 or $this->port > 19135){ if($this->port < 19132 or $this->port > 19135){ //Mojang =(
console("[WARNING] You've selected a not-standard port. Normal port range is from 19132 to 19135 included"); console("[WARNING] You've selected a not-standard port. Normal port range is from 19132 to 19135 included");
} }
$this->serverID = $this->serverID === false ? Utils::readLong(Utils::getRandomBytes(8, false)):$this->serverID; $this->serverID = $this->serverID === false ? Utils::readLong(Utils::getRandomBytes(8, false)):$this->serverID;

View File

@ -321,16 +321,14 @@ class Entity extends stdClass{
if ($rotation < 0) { if ($rotation < 0) {
$rotation += 360.0; $rotation += 360.0;
} }
if(0 <= $rotation && $rotation < 45) { if((0 <= $rotation and $rotation < 45) or (315 <= $rotation and $rotation < 360)) {
return 2; return 2; //North
}elseif(45 <= $rotation && $rotation < 135) { }elseif(45 <= $rotation and $rotation < 135) {
return 3; return 3; //East
}elseif(135 <= $rotation && $rotation < 225) { }elseif(135 <= $rotation and $rotation < 225) {
return 0; return 0; //South
}elseif(225 <= $rotation && $rotation < 315) { }elseif(225 <= $rotation and $rotation < 315) {
return 1; return 1; //West
}elseif(315 <= $rotation && $rotation < 360) {
return 2;
}else{ }else{
return null; return null;
} }