Added TileEntity::setText(1,2,3,4)

This commit is contained in:
Shoghi Cervantes 2013-05-28 23:35:33 +02:00
parent 58fd67d2ed
commit 0d12039623
3 changed files with 33 additions and 22 deletions

View File

@ -117,9 +117,9 @@ class EntityAPI{
$item->count = min($item->getMaxStackSize(), $count);
$count -= $item->count;
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
//$e->speedX = mt_rand(-10, 10) / 100;
//$e->speedY = mt_rand(0, 5) / 100;
//$e->speedZ = mt_rand(-10, 10) / 100;
$e->speedX = mt_rand(-10, 10) / 100;
$e->speedY = mt_rand(0, 5) / 100;
$e->speedZ = mt_rand(-10, 10) / 100;
$this->spawnToAll($pos->level, $e->eid);
}
}

View File

@ -395,20 +395,24 @@ class Player{
public function eventHandler($data, $event){
switch($event){
case "tile.update":
if($data->level === $this->level and $data->class === TILE_FURNACE){
foreach($this->windows as $id => $w){
if($w === $data){
$this->dataPacket(MC_CONTAINER_SET_DATA, array(
"windowid" => $id,
"property" => 0, //Smelting
"value" => floor($data->data["CookTime"]),
));
$this->dataPacket(MC_CONTAINER_SET_DATA, array(
"windowid" => $id,
"property" => 1, //Fire icon
"value" => $data->data["BurnTicks"],
));
if($data->level === $this->level){
if($data->class === TILE_FURNACE){
foreach($this->windows as $id => $w){
if($w === $data){
$this->dataPacket(MC_CONTAINER_SET_DATA, array(
"windowid" => $id,
"property" => 0, //Smelting
"value" => floor($data->data["CookTime"]),
));
$this->dataPacket(MC_CONTAINER_SET_DATA, array(
"windowid" => $id,
"property" => 1, //Fire icon
"value" => $data->data["BurnTicks"],
));
}
}
}elseif($data->class === TILE_SIGN){
$data->spawn($this);
}
}
break;
@ -1241,12 +1245,7 @@ class Player{
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->handle("tile.update", $t);
$this->server->api->tileentity->spawnToAll($this->level, $t);
$t->setText($data["line0"], $data["line1"], $data["line2"], $data["line3"]);
}
}
break;

View File

@ -218,6 +218,18 @@ class TileEntity extends Position{
break;
}
}
public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
if($this->class !== TILE_SIGN){
return false;
}
$this->data["Text1"] = $line1;
$this->data["Text2"] = $line2;
$this->data["Text3"] = $line3;
$this->data["Text4"] = $line4;
$this->server->handle("tile.update", $this);
return true;
}
public function close(){
if($this->closed === false){