mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Added support for more NBT data, renaming inventories, fixed tags not being saved, added support for tags in /give
This commit is contained in:
@ -25,14 +25,38 @@ use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
use pocketmine\nbt\tag\String;
|
||||
|
||||
class EnchantTable extends Spawnable{
|
||||
class EnchantTable extends Spawnable implements Nameable{
|
||||
|
||||
|
||||
public function getName(){
|
||||
return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Chest";
|
||||
}
|
||||
|
||||
public function hasName(){
|
||||
return isset($this->namedtag->CustomName);
|
||||
}
|
||||
|
||||
public function setName($str){
|
||||
if($str === ""){
|
||||
unset($this->namedtag->CustomName);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->namedtag->CustomName = new String("CustomName", $str);
|
||||
}
|
||||
|
||||
public function getSpawnCompound(){
|
||||
return new Compound("", [
|
||||
$c = new Compound("", [
|
||||
new String("id", Tile::ENCHANT_TABLE),
|
||||
new Int("x", (int) $this->x),
|
||||
new Int("y", (int) $this->y),
|
||||
new Int("z", (int) $this->z)
|
||||
]);
|
||||
|
||||
if($this->hasName()){
|
||||
$c->CustomName = $this->namedtag->CustomName;
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user