Bukkit
1.4.7-R1.0
Main Page
Related Pages
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Enumerator
Pages
MaterialData.java
Go to the documentation of this file.
1
package
org.bukkit.material;
2
3
import
org.bukkit.inventory.ItemStack;
4
import
org.bukkit.Material;
5
9
public
class
MaterialData
implements
Cloneable {
10
private
final
int
type;
11
private
byte data = 0;
12
13
public
MaterialData
(
final
int
type) {
14
this
(type, (byte) 0);
15
}
16
17
public
MaterialData
(
final
Material
type) {
18
this
(type, (byte) 0);
19
}
20
21
public
MaterialData
(
final
int
type,
final
byte data) {
22
this.type = type;
23
this.data = data;
24
}
25
26
public
MaterialData
(
final
Material
type,
final
byte data) {
27
this
(type.
getId
(), data);
28
}
29
35
public
byte
getData
() {
36
return
data;
37
}
38
44
public
void
setData
(byte data) {
45
this.data = data;
46
}
47
53
public
Material
getItemType
() {
54
return
Material
.
getMaterial
(type);
55
}
56
62
public
int
getItemTypeId
() {
63
return
type;
64
}
65
71
public
ItemStack
toItemStack
() {
72
return
new
ItemStack
(type, 0, data);
73
}
74
81
public
ItemStack
toItemStack
(
int
amount) {
82
return
new
ItemStack
(type, amount, data);
83
}
84
85
@Override
86
public
String
toString
() {
87
return
getItemType
() +
"("
+
getData
() +
")"
;
88
}
89
90
@Override
91
public
int
hashCode
() {
92
return
((
getItemTypeId
() << 8) ^
getData
());
93
}
94
95
@Override
96
public
boolean
equals
(Object obj) {
97
if
(obj != null && obj instanceof
MaterialData
) {
98
MaterialData md = (
MaterialData
) obj;
99
100
return
(md.
getItemTypeId
() ==
getItemTypeId
() && md.
getData
() ==
getData
());
101
}
else
{
102
return
false
;
103
}
104
}
105
106
@Override
107
public
MaterialData
clone
() {
108
try
{
109
return
(
MaterialData
) super.
clone
();
110
}
catch
(CloneNotSupportedException e) {
111
throw
new
Error(e);
112
}
113
}
114
}
org
bukkit
material
MaterialData.java
Generated on Wed May 22 2013 22:16:34 for Bukkit by
1.8.2