Bukkit
1.4.7-R1.0
Main Page
Related Pages
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Enumerator
Pages
Lever.java
Go to the documentation of this file.
1
package
org.bukkit.material;
2
3
import
org.bukkit.block.BlockFace;
4
import
org.bukkit.Material;
5
9
public
class
Lever
extends
SimpleAttachableMaterialData
implements
Redstone
{
10
public
Lever
() {
11
super(
Material
.
LEVER
);
12
}
13
14
public
Lever
(
final
int
type) {
15
super(type);
16
}
17
18
public
Lever
(
final
Material
type) {
19
super(type);
20
}
21
22
public
Lever
(
final
int
type,
final
byte data) {
23
super(type, data);
24
}
25
26
public
Lever
(
final
Material
type,
final
byte data) {
27
super(type, data);
28
}
29
36
public
boolean
isPowered
() {
37
return
(
getData
() & 0x8) == 0x8;
38
}
39
45
public
void
setPowered
(
boolean
isPowered
) {
46
setData
((byte) (isPowered ? (
getData
() | 0x8) : (
getData
() & ~0x8)));
47
}
48
54
public
BlockFace
getAttachedFace
() {
55
byte data = (byte) (
getData
() & 0x7);
56
57
switch
(data) {
58
case
0x1:
59
return
BlockFace
.
WEST
;
60
61
case
0x2:
62
return
BlockFace
.
EAST
;
63
64
case
0x3:
65
return
BlockFace
.
NORTH
;
66
67
case
0x4:
68
return
BlockFace
.
SOUTH
;
69
70
case
0x5:
71
case
0x6:
72
return
BlockFace
.
DOWN
;
73
74
case
0x0:
75
case
0x7:
76
return
BlockFace
.
UP
;
77
78
}
79
80
return
null;
81
}
82
86
public
void
setFacingDirection
(
BlockFace
face) {
87
byte data = (byte) (
getData
() & 0x8);
88
BlockFace
attach =
getAttachedFace
();
89
90
if
(attach ==
BlockFace
.
DOWN
) {
91
switch
(face) {
92
case
SOUTH:
93
case
NORTH:
94
data |= 0x5;
95
break
;
96
97
case
EAST:
98
case
WEST:
99
data |= 0x6;
100
break
;
101
}
102
}
else
if
(attach ==
BlockFace
.
UP
) {
103
switch
(face) {
104
case
SOUTH:
105
case
NORTH:
106
data |= 0x7;
107
break
;
108
109
case
EAST:
110
case
WEST:
111
data |= 0x0;
112
break
;
113
}
114
}
else
{
115
switch
(face) {
116
case
EAST:
117
data |= 0x1;
118
break
;
119
120
case
WEST:
121
data |= 0x2;
122
break
;
123
124
case
SOUTH:
125
data |= 0x3;
126
break
;
127
128
case
NORTH:
129
data |= 0x4;
130
break
;
131
}
132
}
133
setData
(data);
134
}
135
136
@Override
137
public
String
toString
() {
138
return
super.toString() +
" facing "
+
getFacing
() +
" "
+ (
isPowered
() ?
""
:
"NOT "
) +
"POWERED"
;
139
}
140
141
@Override
142
public
Lever
clone
() {
143
return
(
Lever
) super.
clone
();
144
}
145
}
org
bukkit
material
Lever.java
Generated on Thu May 23 2013 04:16:34 for Bukkit by
1.8.2