mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Added world teleporting
This commit is contained in:
parent
7de0835ad9
commit
33bd66c1da
@ -321,7 +321,7 @@ class BlockAPI{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($item->isActivable === true and $item->onActivate($player, $block, $target, $face, $fx, $fy, $fz)){
|
||||
if($item->isActivable === true and $item->onActivate($player->level, $player, $block, $target, $face, $fx, $fy, $fz)){
|
||||
return $this->cancelAction($block, $player);
|
||||
}
|
||||
|
||||
|
@ -197,11 +197,9 @@ class ConsoleAPI{
|
||||
$end = strpos($line, " ");
|
||||
if($end === false){
|
||||
$end = strlen($line);
|
||||
}else{
|
||||
++$end;
|
||||
}
|
||||
$cmd = strtolower(substr($line, 0, $end - 1));
|
||||
$params = substr($line, $end);
|
||||
$cmd = strtolower(substr($line, 0, $end));
|
||||
$params = substr($line, $end + 1);
|
||||
|
||||
if(isset($this->alias[$cmd])){
|
||||
$this->run($this->alias[$cmd] . " " .$params, $issuer, $cmd);
|
||||
|
@ -60,7 +60,7 @@ class ServerAPI{
|
||||
$this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, array(
|
||||
"server-name" => "Minecraft PE Server",
|
||||
"description" => "Server made using PocketMine-MP",
|
||||
"motd" => "Welcome @username to this server!",
|
||||
"motd" => "Welcome @player to this server!",
|
||||
"server-invisible" => false,
|
||||
"server-ip" => "0.0.0.0",
|
||||
"server-port" => 19132,
|
||||
|
@ -156,7 +156,7 @@ class Player{
|
||||
));
|
||||
}
|
||||
|
||||
$tiles = $this->server->query("SELECT * FROM tileentities WHERE spawnable = 1 AND x >= ".($x - 1)." AND x < ".($x + 17)." AND z >= ".($z - 1)." AND z < ".($z + 17)." AND y >= ".($y - 1)." AND y < ".($y + 17).";");
|
||||
$tiles = $this->server->query("SELECT ID FROM tileentities WHERE spawnable = 1 AND x >= ".($x - 1)." AND x < ".($x + 17)." AND z >= ".($z - 1)." AND z < ".($z + 17)." AND y >= ".($y - 1)." AND y < ".($y + 17).";");
|
||||
if($tiles !== false and $tiles !== true){
|
||||
while(($tile = $tiles->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$this->server->api->tileentity->spawnTo($tile["ID"], $this);
|
||||
@ -511,8 +511,7 @@ class Player{
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->dataPacket(MC_CHAT, array(
|
||||
|
||||
$this->dataPacket(MC_CHAT, array(
|
||||
"message" => $m,
|
||||
));
|
||||
}
|
||||
@ -579,6 +578,7 @@ class Player{
|
||||
if($pos instanceof Position and $pos->level !== $this->level){
|
||||
$this->level = $pos->level;
|
||||
$this->chunksLoaded = array();
|
||||
$terrain = true;
|
||||
}
|
||||
$this->lastCorrect = $pos;
|
||||
$this->entity->fallY = false;
|
||||
@ -899,7 +899,7 @@ class Player{
|
||||
$this->evid[] = $this->server->event("block.change", array($this, "eventHandler"));
|
||||
$this->evid[] = $this->server->event("tile.container.slot", array($this, "eventHandler"));
|
||||
$this->server->schedule(40, array($this, "measureLag"), array(), true);
|
||||
console("[INFO] \x1b[33m".$this->username."\x1b[0m[/".$this->ip.":".$this->port."] logged in with entity id ".$this->eid." at (".round($this->entity->x, 2).", ".round($this->entity->y, 2).", ".round($this->entity->z, 2).")");
|
||||
console("[INFO] \x1b[33m".$this->username."\x1b[0m[/".$this->ip.":".$this->port."] logged in with entity id ".$this->eid." at (".$this->entity->level->getName().", ".round($this->entity->x, 2).", ".round($this->entity->y, 2).", ".round($this->entity->z, 2).")");
|
||||
break;
|
||||
case MC_READY:
|
||||
if($this->loggedIn === false){
|
||||
@ -986,7 +986,7 @@ class Player{
|
||||
if($this->spawned === false){
|
||||
break;
|
||||
}
|
||||
if($this->blocked === true or Utils::distance($this->entity->position, $data) > 8){
|
||||
if($this->blocked === true or $this->entity->distance(new Vector3($data["x"], $data["y"], $data["z"])) > 8){
|
||||
break;
|
||||
}
|
||||
$this->server->api->block->playerBlockBreak($this, new Vector3($data["x"], $data["y"], $data["z"]));
|
||||
@ -1002,7 +1002,7 @@ class Player{
|
||||
if($this->spawned === false){
|
||||
break;
|
||||
}
|
||||
if($this->gamemode !== VIEW and $this->blocked === false and isset($this->server->entities[$data["target"]]) and Utils::distance($this->entity->position, $this->server->entities[$data["target"]]->position) <= 8){
|
||||
if($this->gamemode !== VIEW and $this->blocked === false and isset($this->server->entities[$data["target"]]) and $this->entity->distance($this->server->entities[$data["target"]]) <= 8){
|
||||
$target = $this->server->api->entity->get($data["target"]);
|
||||
$data["targetentity"] = $target;
|
||||
$data["entity"] = $this->entity;
|
||||
|
@ -78,8 +78,8 @@ class PaintingItem extends Item{
|
||||
"yaw" => $faces[$face] * 90,
|
||||
"Motive" => $motive[0],
|
||||
);
|
||||
$e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
|
||||
$server->api->entity->spawnToAll($this->level, $e->eid);
|
||||
$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
|
||||
$server->api->entity->spawnToAll($level, $e->eid);
|
||||
if(($player->gamemode & 0x01) === 0x00){
|
||||
$player->removeItem($this->getID(), $this->getMetadata(), 1);
|
||||
}
|
||||
|
@ -32,6 +32,13 @@ class Position extends Vector3{
|
||||
parent::__construct($x, $y, $z);
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
public function distance($x = 0, $y = 0, $z = 0){
|
||||
if($x instanceof Position and $x->level !== $this->level){
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
return parent::distance($x, $y, $z);
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
return "Position(level=".$this->level->getName().",x=".$this->x.",y=".$this->y.",z=".$this->z.")";
|
||||
|
Loading…
x
Reference in New Issue
Block a user