Placing signs text

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-30 17:07:43 +01:00
parent b697f1441e
commit 08b67428a0
5 changed files with 27 additions and 16 deletions

View File

@ -640,14 +640,16 @@ class BlockAPI{
if($data["face"] === 1){
$data["block"] = 63;
$data["meta"] = 0;
$this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
$t = $this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
$t->data["creator"] = $entity->player->username;
}else{
return false;
}
}else{
$data["block"] = 68;
$data["meta"] = $faces[$data["face"]];
$this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
$t = $this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
$t->data["creator"] = $entity->player->username;
}
break;
}

View File

@ -53,7 +53,9 @@ class TileEntityAPI{
}
public function getByID($id){
if(isset($this->server->tileEntities[$id])){
if($id instanceof TileEntity){
return $id;
}elseif(isset($this->server->tileEntities[$id])){
return $this->server->tileEntities[$id];
}
return false;

View File

@ -378,7 +378,6 @@ class Player{
break;
case 0x03:
case 0xa9:
break;
case MC_DISCONNECT:
@ -620,6 +619,21 @@ class Player{
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
}
break;
case MC_SIGN_UPDATE:
$t = $this->server->api->tileentity->get($data["x"], $data["y"], $data["z"]);
if(($t[0] instanceof TileEntity) and $t[0]->class === TILE_SIGN){
$t = $t[0];
if($t->data["creator"] !== $this->username){
$t->spawn($this);
}else{
$t->data["Text1"] = $data["line0"];
$t->data["Text2"] = $data["line1"];
$t->data["Text3"] = $data["line2"];
$t->data["Text4"] = $data["line3"];
$this->server->api->tileentity->spawnToAll($t);
}
}
break;
default:
console("[DEBUG] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
break;

View File

@ -115,7 +115,7 @@ class PocketMinecraftServer{
//$this->query("PRAGMA secure_delete = OFF;");
$this->query("CREATE TABLE players (clientID INTEGER PRIMARY KEY, EID NUMERIC, ip TEXT, port NUMERIC, name TEXT UNIQUE);");
$this->query("CREATE TABLE entities (EID INTEGER PRIMARY KEY, type NUMERIC, class NUMERIC, name TEXT, x NUMERIC, y NUMERIC, z NUMERIC, yaw NUMERIC, pitch NUMERIC, health NUMERIC);");
$this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class NUMERIC, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
$this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
$this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");
$this->query("CREATE TABLE events (ID INTEGER PRIMARY KEY, name TEXT);");
$this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);");
@ -337,13 +337,7 @@ class PocketMinecraftServer{
if(!isset($tile["id"])){
break;
}
$class = false;
switch($tile["id"]){
case "Sign":
$class = TILE_SIGN;
break;
}
$t = $this->api->tileentity->add($class, $tile["x"], $tile["y"], $tile["z"], $tile);
$t = $this->api->tileentity->add($tile["id"], $tile["x"], $tile["y"], $tile["z"], $tile);
}
$this->action(1000000 * 60 * 15, '$this->api->chat->broadcast("Forcing save...");$this->save();');
}

View File

@ -26,7 +26,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
define("TILE_SIGN", 0);
define("TILE_SIGN", "Sign");
class TileEntity extends stdClass{
public $name;
@ -44,7 +44,7 @@ class TileEntity extends stdClass{
function __construct(PocketMinecraftServer $server, $id, $class, $x, $y, $z, $data = array()){
$this->server = $server;
$this->normal = true;
$this->class = (int) $class;
$this->class = $class;
$this->data = $data;
$this->closed = false;
if($class === false){
@ -55,14 +55,13 @@ class TileEntity extends stdClass{
$this->x = (int) $x;
$this->y = (int) $y;
$this->z = (int) $z;
$this->server->query("INSERT OR REPLACE INTO tileentities (ID, class, x, y, z) VALUES (".$this->id.", ".$this->class.", ".$this->x.", ".$this->y.", ".$this->z.");");
$this->server->query("INSERT OR REPLACE INTO tileentities (ID, class, x, y, z) VALUES (".$this->id.", '".$this->class."', ".$this->x.", ".$this->y.", ".$this->z.");");
switch($this->class){
case TILE_SIGN:
$this->server->query("UPDATE tileentities SET spawnable = 1 WHERE ID = ".$this->id.";");
break;
}
//$this->server->schedule(40, array($this, "update"), array(), true);
}
public function update(){