PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
tile/Sign.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17  * @link http://www.pocketmine.net/
18  *
19  *
20 */
21 
22 namespace pocketmine\tile;
23 
28 
29 class Sign extends Spawnable{
30 
31  public function __construct(FullChunk $chunk, Compound $nbt){
32  if(!isset($nbt->Text1)){
33  $nbt->Text1 = new String("Text1", "");
34  }
35  if(!isset($nbt->Text2)){
36  $nbt->Text2 = new String("Text2", "");
37  }
38  if(!isset($nbt->Text3)){
39  $nbt->Text3 = new String("Text3", "");
40  }
41  if(!isset($nbt->Text4)){
42  $nbt->Text4 = new String("Text4", "");
43  }
44 
45  parent::__construct($chunk, $nbt);
46  }
47 
48  public function saveNBT(){
49  parent::saveNBT();
50  unset($this->namedtag->Creator);
51  }
52 
53  public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
54  $this->namedtag->Text1 = new String("Text1", $line1);
55  $this->namedtag->Text2 = new String("Text2", $line2);
56  $this->namedtag->Text3 = new String("Text3", $line3);
57  $this->namedtag->Text4 = new String("Text4", $line4);
58  $this->spawnToAll();
59 
60  return true;
61  }
62 
63  public function getText(){
64  return [
65  $this->namedtag["Text1"],
66  $this->namedtag["Text2"],
67  $this->namedtag["Text3"],
68  $this->namedtag["Text4"]
69  ];
70  }
71 
72  public function getSpawnCompound(){
73  return new Compound("", [
74  new String("id", Tile::SIGN),
75  $this->namedtag->Text1,
76  $this->namedtag->Text2,
77  $this->namedtag->Text3,
78  $this->namedtag->Text4,
79  new Int("x", (int) $this->x),
80  new Int("y", (int) $this->y),
81  new Int("z", (int) $this->z)
82  ]);
83  }
84 
85 }