PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
InventoryType.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17  * @link http://www.pocketmine.net/
18  *
19  *
20 */
21 
22 namespace pocketmine\inventory;
23 
28  const CHEST = 0;
29  const DOUBLE_CHEST = 1;
30  const PLAYER = 2;
31  const FURNACE = 3;
32  const CRAFTING = 4;
33  const WORKBENCH = 5;
34  const STONECUTTER = 6;
35 
36  private static $default = [];
37 
38  private $size;
39  private $title;
40  private $typeId;
41 
47  public static function get($index){
48  return isset(static::$default[$index]) ? static::$default[$index] : null;
49  }
50 
51  public static function init(){
52  if(count(static::$default) > 0){
53  return;
54  }
55 
56  static::$default[static::CHEST] = new InventoryType(27, "Chest", 0);
57  static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "Double Chest", 0);
58  static::$default[static::PLAYER] = new InventoryType(40, "Player", 0); //27 CONTAINER, 4 ARMOR (9 reference HOTBAR slots)
59  static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2);
60  static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT
61  static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
62  static::$default[static::STONECUTTER] = new InventoryType(10, "Crafting", 3); //9 CRAFTING slots, 1 RESULT
63  }
64 
70  private function __construct($defaultSize, $defaultTitle, $typeId = 0){
71  $this->size = $defaultSize;
72  $this->title = $defaultTitle;
73  $this->typeId = $typeId;
74  }
75 
79  public function getDefaultSize(){
80  return $this->size;
81  }
82 
86  public function getDefaultTitle(){
87  return $this->title;
88  }
89 
93  public function getNetworkType(){
94  return $this->typeId;
95  }
96 }