Placing Signs

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-28 19:01:41 +01:00
parent df46e241d3
commit 8a5708f47a
5 changed files with 45 additions and 1 deletions

View File

@ -126,11 +126,18 @@ class BlockAPI{
case 107:
case 108:
case 109:
case 114:
case 128:
case 156:
$drop[1] = 0;
break;
case 56:
$drop = array(264, 0, 1);
break;
case 63:
case 68:
$drop = array(323, 0, 1);
break;
case 73:
case 74:
$drop = array(351, 4, mt_rand(4, 5));
@ -619,6 +626,27 @@ class BlockAPI{
return false;
}
break;
case 323: //Signs
$faces = array(
2 => 2,
3 => 3,
4 => 4,
5 => 5,
);
if(!isset($faces[$data["face"]])){
if($data["face"] === 1){
$data["block"] = 63;
$data["meta"] = 0;
$this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
}else{
return false;
}
}else{
$data["block"] = 68;
$data["meta"] = $faces[$data["face"]];
$this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
}
break;
}
$this->server->handle("player.block.place", $data);
return false;

View File

@ -104,7 +104,7 @@ class LevelAPI{
if($tiles === true){
if(($t = $this->server->api->tileentity->get($x, $y, $z)) !== false){
$t[0]->close();
}
}
}
}
return true;

View File

@ -70,8 +70,22 @@ class TileEntityAPI{
public function add($class, $x, $y, $z, $data = array()){
$id = $this->tCnt++;
$this->server->tileEntities[$id] = new TileEntity($this->server, $id, $class, $x, $y, $z, $data);
$this->spawnToAll($id);
return $this->server->tileEntities[$id];
}
public function addSign($x, $y, $z, $lines = array("", "", "", "")){
return $this->add(TILE_SIGN, $x, $y, $z, $data = array(
"id" => "Sign",
"x" => $x,
"y" => $y,
"z" => $z,
"Text1" => $lines[0],
"Text2" => $lines[1],
"Text3" => $lines[2],
"Text4" => $lines[3],
));
}
public function spawnTo($id, $player){
$t = $this->getByID($id);

View File

@ -241,6 +241,7 @@ class Material{
156 => true,
246 => true,
247 => true,
323 => true, //Special case of signs
);
static $blocks = array(
0 => "Air",

View File

@ -479,6 +479,7 @@ class Player{
}
$this->inventory[$s] = array(0, 0, 0);
}
$this->entity->setPosition($this->entity->x, $this->entity->y, $this->entity->z, 0, 0);
break;
case 2://Chunk loaded?
break;