Added handling for tile picking, added API for setting item lore

worked almost out of the box (some W10 equipment bugs though)
This commit is contained in:
Dylan K. Taylor
2017-03-28 18:47:51 +01:00
parent 52f2596dc5
commit 3e76c3a6dd
3 changed files with 54 additions and 1 deletions

View File

@ -660,6 +660,35 @@ class Item implements ItemIds, \JsonSerializable{
return $this;
}
public function getLore() : array{
$tag = $this->getNamedTagEntry("display");
if($tag instanceof CompoundTag and isset($tag->Lore) and $tag->Lore instanceof ListTag){
$lines = [];
foreach($tag->Lore->getValue() as $line){
$lines[] = $line->getValue();
}
return $lines;
}
return [];
}
public function setLore(array $lines){
$tag = $this->getNamedTag();
if(!isset($tag->display)){
$tag->display = new CompoundTag("display", []);
}
$tag->display->Lore = new ListTag("Lore");
$tag->display->Lore->setTagType(NBT::TAG_String);
$count = 0;
foreach($lines as $line){
$tag->display->Lore[$count++] = new StringTag("", $line);
}
$this->setNamedTag($tag);
}
/**
* @param $name
* @return Tag|null