mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user