mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Item: Removed protected block field, items should now override getBlock()
This commit is contained in:
@ -42,7 +42,6 @@ use pocketmine\nbt\tag\NamedTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Config;
|
||||
|
||||
@ -176,8 +175,6 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** @var Block|null */
|
||||
protected $block;
|
||||
/** @var int */
|
||||
protected $id;
|
||||
/** @var int */
|
||||
@ -206,10 +203,6 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
$this->id = $id & 0xffff;
|
||||
$this->setDamage($meta);
|
||||
$this->name = $name;
|
||||
if(!isset($this->block) and $this->id <= 0xff){
|
||||
$this->block = BlockFactory::get($this->id, $this->meta);
|
||||
$this->name = $this->block->getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -648,7 +641,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* @return bool
|
||||
*/
|
||||
final public function canBePlaced() : bool{
|
||||
return $this->block !== null and $this->block->canBePlaced();
|
||||
return $this->getBlock()->canBePlaced();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -656,11 +649,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock() : Block{
|
||||
if($this->block instanceof Block){
|
||||
return clone $this->block;
|
||||
}else{
|
||||
return BlockFactory::get(self::AIR);
|
||||
}
|
||||
return BlockFactory::get(self::AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -997,10 +986,6 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
}
|
||||
|
||||
public function __clone(){
|
||||
if($this->block !== null){
|
||||
$this->block = clone $this->block;
|
||||
}
|
||||
|
||||
$this->cachedNBT = null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user