mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
Fixed crash when block classes override the constructor but don't specify a fallback name
This commit is contained in:
parent
1b5fed983b
commit
0e2e9aab2e
@ -61,7 +61,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
protected $id;
|
protected $id;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $meta = 0;
|
protected $meta = 0;
|
||||||
/** @var string */
|
/** @var string|null */
|
||||||
protected $fallbackName;
|
protected $fallbackName;
|
||||||
/** @var int|null */
|
/** @var int|null */
|
||||||
protected $itemId;
|
protected $itemId;
|
||||||
@ -70,12 +70,12 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
public $boundingBox = null;
|
public $boundingBox = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id The block type's ID, 0-255
|
* @param int $id The block type's ID, 0-255
|
||||||
* @param int $meta Meta value of the block type
|
* @param int $meta Meta value of the block type
|
||||||
* @param string $name English name of the block type (TODO: implement translations)
|
* @param string|null $name English name of the block type (TODO: implement translations)
|
||||||
* @param int $itemId The item ID of the block type, used for block picking and dropping items.
|
* @param int $itemId The item ID of the block type, used for block picking and dropping items.
|
||||||
*/
|
*/
|
||||||
public function __construct(int $id, int $meta = 0, string $name = "Unknown", int $itemId = null){
|
public function __construct(int $id, int $meta = 0, string $name = null, int $itemId = null){
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
$this->fallbackName = $name;
|
$this->fallbackName = $name;
|
||||||
@ -86,7 +86,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName() : string{
|
public function getName() : string{
|
||||||
return $this->fallbackName;
|
return $this->fallbackName ?? "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user