pocketmine\item\Item::__construct PHP Method

__construct() public method

public __construct ( $id, $meta, integer $count = 1, string $name = "Unknown" )
$count integer
$name string
    public function __construct($id, $meta = 0, int $count = 1, string $name = "Unknown")
    {
        if (is_string($id)) {
            $item = Item::fromString($id);
            $id = $item->getId();
            if ($item->getDamage() != $meta) {
                $meta = $item->getDamage();
            }
            $name = $item->getName();
        }
        $this->id = $id & 0xffff;
        $this->meta = $meta !== null ? $meta & 0xffff : null;
        $this->count = $count;
        $this->name = $name;
        if (!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])) {
            $this->block = Block::get($this->id, $this->meta);
            $this->name = $this->block->getName();
        }
    }

Usage Example

 /**
  * @param int $id
  * @param int $meta
  * @param int $count
  * @param string $name
  * @param int|float $perAmount
  * @param int $maxStack
  * @param bool $throwable
  */
 public function __construct($id, $meta = 0, $count = 1, $name, $perAmount, $maxStack, $throwable = true)
 {
     parent::__construct($id, $meta, $count, $name);
     $this->perAmount = $perAmount;
     $this->isActivable = $throwable;
     $this->maxStackSize = $maxStack;
 }
All Usage Examples Of pocketmine\item\Item::__construct