This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
/
InventoryType.php
102 lines (90 loc) · 2.85 KB
/
InventoryType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\inventory;
/**
* Saves all the information regarding default inventory sizes and types
*/
class InventoryType{
const CHEST = 0;
const DOUBLE_CHEST = 1;
const PLAYER = 2;
const FURNACE = 3;
const CRAFTING = 4;
const WORKBENCH = 5;
const STONECUTTER = 6;
const BREWING_STAND = 7;
const ANVIL = 8;
const ENCHANT_TABLE = 9;
private static $default = [];
private $size;
private $title;
private $typeId;
/**
* @param $index
*
* @return InventoryType
*/
public static function get($index){
return isset(static::$default[$index]) ? static::$default[$index] : null;
}
public static function init(){
if(count(static::$default) > 0){
return;
}
static::$default[static::CHEST] = new InventoryType(27, "Chest", 0);
static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "DoubleTag Chest", 0);
static::$default[static::PLAYER] = new InventoryType(49, "Player", 0); //36 CONTAINER, 4 ARMOR (9 reference HOTBAR slots)
static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2);
static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT
static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
static::$default[static::STONECUTTER] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
static::$default[static::ENCHANT_TABLE] = new InventoryType(2, "Enchant", 4); //1 INPUT/OUTPUT, 1 LAPIS
static::$default[static::BREWING_STAND] = new InventoryType(4, "Brewing", 5); //1 INPUT, 3 POTION
static::$default[static::ANVIL] = new InventoryType(3, "Anvil", 6); //2 INPUT, 1 OUTPUT
}
/**
* @param int $defaultSize
* @param string $defaultTitle
* @param int $typeId
*/
private function __construct($defaultSize, $defaultTitle, $typeId = 0){
$this->size = $defaultSize;
$this->title = $defaultTitle;
$this->typeId = $typeId;
}
/**
* @return int
*/
public function getDefaultSize(){
return $this->size;
}
/**
* @return string
*/
public function getDefaultTitle(){
return $this->title;
}
/**
* @return int
*/
public function getNetworkType(){
return $this->typeId;
}
}