18 |
|
|
19 |
|
|
20 |
private Location blocks[][]; // [width][height] - [0][0] == leftUpper |
private Location blocks[][]; // [width][height] - [0][0] == leftUpper |
21 |
|
private int material[][]; |
22 |
private int material; |
private byte data[][]; |
23 |
|
|
24 |
private int direction; |
private int direction; |
25 |
|
|
37 |
|
|
38 |
this.owner = owner; |
this.owner = owner; |
39 |
|
|
|
blocks = new Location[width][height]; |
|
40 |
|
|
41 |
direction = sign.getData() - 2; |
direction = sign.getData() - 2; |
42 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
material = leftUpper.getBlock().getTypeId(); |
//material = leftUpper.getBlock().getTypeId(); |
61 |
|
|
62 |
loadBlocks(); |
loadBlocks(); |
63 |
|
|
73 |
|
|
74 |
} |
} |
75 |
|
|
76 |
|
/* |
77 |
|
@Deprecated |
78 |
public Door(String input, Server server) { |
public Door(String input, Server server) { |
79 |
String parts[] = input.split(":"); |
String parts[] = input.split(":"); |
80 |
|
|
82 |
|
|
83 |
leftUpper = new Location(w, Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]) ); |
leftUpper = new Location(w, Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]) ); |
84 |
direction = Integer.parseInt( parts[4] ); |
direction = Integer.parseInt( parts[4] ); |
85 |
material = Integer.parseInt( parts[5] ); |
//material = Integer.parseInt( parts[5] ); |
86 |
|
|
87 |
width = Integer.parseInt( parts[6] ); |
width = Integer.parseInt( parts[6] ); |
88 |
height = Integer.parseInt( parts[7] ); |
height = Integer.parseInt( parts[7] ); |
89 |
owner = parts[8]; |
owner = parts[8]; |
90 |
|
|
|
|
|
|
blocks = new Location[width][height]; |
|
91 |
|
|
92 |
loadBlocks(); |
loadBlocks(); |
93 |
|
}*/ |
94 |
|
|
95 |
|
public Door(Location loc, int direction, int width, int height, String owner) { |
96 |
|
leftUpper = loc; |
97 |
|
this.direction = direction; |
98 |
|
this.width = width; |
99 |
|
this.height = height; |
100 |
|
this.owner = owner; |
101 |
|
|
102 |
|
loadBlocks(); |
103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
public void powerChange(World world, int oldCurrent, int newCurrent ) { |
public void powerChange(World world, int oldCurrent, int newCurrent ) { |
108 |
if (isPowered() == true) { |
if (isPowered() == true) { |
109 |
open(); |
open(); |
126 |
} |
} |
127 |
|
|
128 |
private void loadBlocks() { |
private void loadBlocks() { |
129 |
|
blocks = new Location[width][height]; |
130 |
|
material = new int[width][height]; |
131 |
|
data = new byte[width][height]; |
132 |
|
|
133 |
for (int w=0; w<width; w++) { |
for (int w=0; w<width; w++) { |
134 |
for (int h=0; h<height; h++) { |
for (int h=0; h<height; h++) { |
156 |
//System.out.println("Add block: " + x + ":" + y + ":" + z); |
//System.out.println("Add block: " + x + ":" + y + ":" + z); |
157 |
|
|
158 |
blocks[w][h] = new Location( leftUpper.getWorld(), x, y, z); |
blocks[w][h] = new Location( leftUpper.getWorld(), x, y, z); |
159 |
|
|
160 |
|
material[w][h] = blocks[w][h].getBlock().getTypeId(); |
161 |
|
data[w][h] = blocks[w][h].getBlock().getData(); |
162 |
|
|
163 |
} |
} |
164 |
} |
} |
165 |
|
|
166 |
} |
} |
167 |
|
|
168 |
public String toCsv() { |
/* public String toCsv() { |
169 |
StringBuilder sb = new StringBuilder(); |
StringBuilder sb = new StringBuilder(); |
170 |
sb.append( leftUpper.getWorld().getName() ); |
sb.append( leftUpper.getWorld().getName() ); |
171 |
|
|
175 |
|
|
176 |
sb.append( ":" + direction ); |
sb.append( ":" + direction ); |
177 |
|
|
178 |
sb.append( ":" + material ); |
sb.append( ":" + material[0][0] ); |
179 |
|
|
180 |
sb.append( ":" + width ); |
sb.append( ":" + width ); |
181 |
sb.append( ":" + height ); |
sb.append( ":" + height ); |
182 |
sb.append( ":" + owner); |
sb.append( ":" + owner); |
183 |
|
|
184 |
return sb.toString(); |
return sb.toString(); |
185 |
} |
}*/ |
186 |
|
|
187 |
|
|
188 |
public void registerMap(Map<Location,Door> map) { |
public void registerMap(Map<Location,Door> map) { |
214 |
public void close() { |
public void close() { |
215 |
for (int w=0; w<width; w++) { |
for (int w=0; w<width; w++) { |
216 |
for (int h=0; h<height; h++) { |
for (int h=0; h<height; h++) { |
217 |
blocks[w][h].getBlock().setTypeId( material ); |
blocks[w][h].getBlock().setTypeIdAndData( material[w][h], data[w][h], true ); |
218 |
} |
} |
219 |
} |
} |
220 |
} |
} |
225 |
return owner; |
return owner; |
226 |
} |
} |
227 |
|
|
228 |
|
public Location getLeftUpper() { |
229 |
|
return leftUpper; |
230 |
|
} |
231 |
|
|
232 |
|
public int getWidth() { |
233 |
|
return width; |
234 |
|
} |
235 |
|
|
236 |
|
public int getHeight() { |
237 |
|
return height; |
238 |
|
} |
239 |
|
|
240 |
|
public int getDirection() { |
241 |
|
return direction; |
242 |
|
} |
243 |
|
|
244 |
} |
} |