mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Removed redundant count parameter from item constructors, added some documentation and tightened safety checks
the count parameter is useless since Item ctor should now only be used for constructing item _types_, not actual items. All item creations for inventories etc, should go through the ItemFactory.
This commit is contained in:
@ -29,13 +29,18 @@ use pocketmine\block\Block;
|
||||
* Class used for Items that can be Blocks
|
||||
*/
|
||||
class ItemBlock extends Item{
|
||||
public function __construct(Block $block, $meta = 0, int $count = 1){
|
||||
|
||||
/**
|
||||
* @param Block $block
|
||||
* @param int $meta Used in crafting recipes for any-damage ingredients (blocks must have meta values 0-15)
|
||||
*/
|
||||
public function __construct(Block $block, int $meta = 0){
|
||||
$this->block = $block;
|
||||
parent::__construct($block->getId(), $block->getDamage(), $count, $block->getName());
|
||||
parent::__construct($block->getId(), $meta, $block->getName());
|
||||
}
|
||||
|
||||
public function setDamage(int $meta){
|
||||
$this->meta = $meta !== -1 ? $meta & 0xf : -1;
|
||||
$this->meta = $meta;
|
||||
$this->block->setDamage($this->meta !== -1 ? $this->meta : 0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user