mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Added jsonSerialize() to Item and fixed some crafting data decode issues
This commit is contained in:
@ -38,7 +38,7 @@ use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Config;
|
||||
|
||||
class Item implements ItemIds{
|
||||
class Item implements ItemIds, \JsonSerializable{
|
||||
|
||||
/** @var NBT */
|
||||
private static $cachedParser = null;
|
||||
@ -738,10 +738,6 @@ class Item implements ItemIds{
|
||||
return false;
|
||||
}
|
||||
|
||||
final public function __toString() : string{
|
||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x" . bin2hex($this->getCompoundTag()) : "");
|
||||
}
|
||||
|
||||
public function getDestroySpeed(Block $block, Player $player){
|
||||
return 1;
|
||||
}
|
||||
@ -764,4 +760,17 @@ class Item implements ItemIds{
|
||||
return false;
|
||||
}
|
||||
|
||||
final public function __toString() : string{
|
||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x" . bin2hex($this->getCompoundTag()) : "");
|
||||
}
|
||||
|
||||
final public function jsonSerialize(){
|
||||
return [
|
||||
"id" => $this->id,
|
||||
"damage" => $this->meta,
|
||||
"count" => $this->count, //TODO: separate items and stacks
|
||||
"nbt" => $this->tags
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user