Changed constructor of ItemBlock to allow handling blocks with different item IDs, added more doors

This commit is contained in:
Dylan K. Taylor
2017-10-09 11:58:58 +01:00
parent 6dbdefafdd
commit 2be8b576ef
3 changed files with 20 additions and 17 deletions

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
/**
* Class used for Items that can be Blocks
@ -31,12 +32,13 @@ use pocketmine\block\Block;
class ItemBlock extends Item{
/**
* @param Block $block
* @param int $meta Used in crafting recipes for any-damage ingredients (blocks must have meta values 0-15)
* @param int $blockId
* @param int $meta usually 0-15 (placed blocks may only have meta values 0-15)
* @param int|null $itemId
*/
public function __construct(Block $block, int $meta = 0){
$this->block = $block;
parent::__construct($block->getId(), $meta, $block->getName());
public function __construct(int $blockId, int $meta = 0, int $itemId = null){
$this->block = BlockFactory::get($blockId, $meta & 0xf);
parent::__construct($itemId ?? $this->block->getId(), $meta, $this->block->getName());
}
public function setDamage(int $meta){