Fixed #453 multiple refs to the same cached NBT object tree

This commit is contained in:
Dylan K. Taylor 2017-03-23 11:40:33 +00:00
parent c040579e09
commit 96801be3d3
2 changed files with 15 additions and 5 deletions

View File

@ -65,13 +65,19 @@ class Item implements ItemIds, \JsonSerializable{
/** @var \SplFixedArray */
public static $list = null;
/** @var Block|null */
protected $block;
/** @var int */
protected $id;
/** @var int */
protected $meta;
/** @var string */
private $tags = "";
/** @var CompoundTag|null */
private $cachedNBT = null;
/** @var int */
public $count;
protected $durability = 0;
/** @var string */
protected $name;
public function canBeActivated(){
@ -1007,4 +1013,12 @@ class Item implements ItemIds, \JsonSerializable{
return $item;
}
public function __clone(){
if($this->block !== null){
$this->block = clone $this->block;
}
$this->cachedNBT = null;
}
}

View File

@ -37,10 +37,6 @@ class ItemBlock extends Item{
$this->block->setDamage($this->meta !== -1 ? $this->meta : 0);
}
public function __clone(){
$this->block = clone $this->block;
}
public function getBlock() : Block{
return $this->block;
}