mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Item: make nbt field non-nullable
This commit is contained in:
parent
7e331c590d
commit
0000783926
@ -68,8 +68,8 @@ class Item implements \JsonSerializable{
|
||||
protected $id;
|
||||
/** @var int */
|
||||
protected $meta;
|
||||
/** @var CompoundTag|null */
|
||||
private $nbt = null;
|
||||
/** @var CompoundTag */
|
||||
private $nbt;
|
||||
/** @var int */
|
||||
protected $count = 1;
|
||||
/** @var string */
|
||||
@ -115,6 +115,7 @@ class Item implements \JsonSerializable{
|
||||
|
||||
$this->canPlaceOn = new Set();
|
||||
$this->canDestroy = new Set();
|
||||
$this->nbt = new CompoundTag();
|
||||
}
|
||||
|
||||
public function hasCustomBlockData() : bool{
|
||||
@ -234,9 +235,6 @@ class Item implements \JsonSerializable{
|
||||
* object is returned to allow the caller to manipulate and apply back to the item.
|
||||
*/
|
||||
public function getNamedTag() : CompoundTag{
|
||||
if($this->nbt === null){
|
||||
$this->nbt = new CompoundTag();
|
||||
}
|
||||
$this->serializeCompoundTag($this->nbt);
|
||||
return $this->nbt;
|
||||
}
|
||||
@ -686,9 +684,7 @@ class Item implements \JsonSerializable{
|
||||
}
|
||||
|
||||
public function __clone(){
|
||||
if($this->nbt !== null){
|
||||
$this->nbt = clone $this->nbt;
|
||||
}
|
||||
$this->nbt = clone $this->nbt;
|
||||
if($this->blockEntityTag !== null){
|
||||
$this->blockEntityTag = clone $this->blockEntityTag;
|
||||
}
|
||||
|
@ -145,11 +145,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/inventory/transaction/CraftingTransaction.php
|
||||
|
||||
-
|
||||
message: "#^Method pocketmine\\\\item\\\\Item\\:\\:getNamedTag\\(\\) should return pocketmine\\\\nbt\\\\tag\\\\CompoundTag but returns pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/item/Item.php
|
||||
|
||||
-
|
||||
message: "#^Cannot clone pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user