14 |
final static int NORTH = 2; |
final static int NORTH = 2; |
15 |
final static int SOUTH = 3; |
final static int SOUTH = 3; |
16 |
|
|
17 |
Location leftUpper; |
private Location leftUpper; |
18 |
|
|
19 |
|
|
20 |
Location blocks[][]; // [width][height] - [0][0] == leftUpper |
private Location blocks[][]; // [width][height] - [0][0] == leftUpper |
21 |
|
|
22 |
int material; |
private int material; |
23 |
|
|
24 |
int direction; |
private int direction; |
25 |
|
|
26 |
int width; |
private int width; |
27 |
int height; |
private int height; |
28 |
|
|
29 |
String owner; |
private String owner; |
30 |
|
|
31 |
|
|
32 |
public Door(Block sign, int width, int height, DoorStorage store, String owner) throws ConflictingDoorException{ |
public Door(Block sign, int width, int height, DoorStorage store, String owner) throws ConflictingDoorException{ |
62 |
|
|
63 |
loadBlocks(); |
loadBlocks(); |
64 |
|
|
65 |
|
|
66 |
for (int w=0; w<width; w++) { |
for (int w=0; w<width; w++) { |
67 |
for (int h=0; h<height; h++) { |
for (int h=0; h<height; h++) { |
68 |
Door d = store.findDoor( blocks[w][h] ); |
Door d = store.findDoor( blocks[w][h] ); |
92 |
|
|
93 |
loadBlocks(); |
loadBlocks(); |
94 |
} |
} |
95 |
|
|
96 |
|
public void powerChange(World world, int oldCurrent, int newCurrent ) { |
97 |
|
if (newCurrent != 0 && isPowered() == true) { |
98 |
|
open(); |
99 |
|
} else { |
100 |
|
close(); |
101 |
|
} |
102 |
|
} |
103 |
|
|
104 |
|
public boolean isPowered() { |
105 |
|
for (int w=0; w<width; w++) { |
106 |
|
for (int h=0; h<height; h++) { |
107 |
|
if (blocks[w][h].getBlock().isBlockIndirectlyPowered() == true) |
108 |
|
return true; |
109 |
|
} |
110 |
|
} |
111 |
|
|
112 |
|
return false; |
113 |
|
} |
114 |
|
|
115 |
private void loadBlocks() { |
private void loadBlocks() { |
116 |
|
|
183 |
|
|
184 |
} |
} |
185 |
|
|
186 |
public void open(World world) { |
public void open() { |
187 |
for (int w=0; w<width; w++) { |
for (int w=0; w<width; w++) { |
188 |
for (int h=0; h<height; h++) { |
for (int h=0; h<height; h++) { |
189 |
blocks[w][h].getBlock().setTypeId(0); |
blocks[w][h].getBlock().setTypeId(0, false); |
190 |
} |
} |
191 |
} |
} |
192 |
|
|
193 |
} |
} |
194 |
|
|
195 |
public void close(World world) { |
public void close() { |
196 |
for (int w=0; w<width; w++) { |
for (int w=0; w<width; w++) { |
197 |
for (int h=0; h<height; h++) { |
for (int h=0; h<height; h++) { |
198 |
blocks[w][h].getBlock().setTypeId( material ); |
blocks[w][h].getBlock().setTypeId( material ); |
200 |
} |
} |
201 |
} |
} |
202 |
|
|
203 |
|
|
204 |
|
/////// setters and getters |
205 |
|
public String getOwner() { |
206 |
|
return owner; |
207 |
|
} |
208 |
|
|
209 |
} |
} |