53 |
return true; |
return true; |
54 |
} |
} |
55 |
|
|
56 |
File templateFile = new File( plugin.getDataFolder(), "template_" + args[0] + ".txt"); |
File templateFile = new File( plugin.getDataFolder(), "templates/" + args[0] + ".txt"); |
57 |
if (! templateFile.exists() ) { |
if (! templateFile.exists() ) { |
58 |
sender.sendMessage( ChatColor.YELLOW + "Template not found" ); |
sender.sendMessage( ChatColor.YELLOW + "Template not found" ); |
59 |
return true; |
return true; |
122 |
|
|
123 |
if (line.charAt(0) == '-') |
if (line.charAt(0) == '-') |
124 |
continue; |
continue; |
125 |
|
|
126 |
|
if ( y >= ysize) { |
127 |
|
throw new Exception( "Template: found more levels in file than specified in header" ); |
128 |
|
} |
129 |
|
|
130 |
String elements[] = line.split(","); |
String elements[] = line.split(","); |
131 |
if (elements.length != zsize) { |
if (elements.length != zsize) { |
181 |
} |
} |
182 |
|
|
183 |
void buildTemplate(Location loc, Pair[][][] template, int pass) { |
void buildTemplate(Location loc, Pair[][][] template, int pass) { |
184 |
|
|
185 |
|
|
186 |
World world = loc.getWorld(); |
World world = loc.getWorld(); |
187 |
for (int i=0; i<template.length; i++ ) { |
for (int i=0; i<template.length; i++ ) { |
188 |
for (int j=0; j<template[0].length; j++) { |
for (int j=0; j<template[0].length; j++) { |
189 |
for (int k=0; k<template[0][0].length; k++) { |
for (int k=0; k<template[0][0].length; k++) { |
190 |
int x = loc.getBlockX() + i + 1; |
int x, y ,z; |
|
int y = loc.getBlockY() + j; |
|
|
int z = loc.getBlockZ() + k; |
|
191 |
|
|
192 |
|
x = z = 0; |
193 |
|
|
194 |
|
y = loc.getBlockY() + j; |
195 |
if (y >= 255) { |
if (y >= 255) { |
196 |
continue; |
continue; |
197 |
|
} |
198 |
|
|
199 |
|
switch ( getFacing(loc) ) { |
200 |
|
case 0: //west |
201 |
|
x = loc.getBlockX() - k; |
202 |
|
z = loc.getBlockZ() + i + 1; |
203 |
|
break; |
204 |
|
case 1: //north |
205 |
|
x = loc.getBlockX() - i - 1; |
206 |
|
z = loc.getBlockZ() - k; |
207 |
|
break; |
208 |
|
case 2: //east |
209 |
|
x = loc.getBlockX() + k; |
210 |
|
z = loc.getBlockZ() - i - 1; |
211 |
|
break; |
212 |
|
case 3: //south |
213 |
|
x = loc.getBlockX() + i + 1; |
214 |
|
z = loc.getBlockZ() + k; |
215 |
|
break; |
216 |
} |
} |
217 |
|
|
218 |
|
|
219 |
int type = template[i][j][k].id; |
int type = template[i][j][k].id; |
220 |
byte data = (byte) template[i][j][k].subId; |
byte data = (byte) template[i][j][k].subId; |
221 |
|
|
228 |
continue; |
continue; |
229 |
if (type == 68) // sign |
if (type == 68) // sign |
230 |
continue; |
continue; |
231 |
|
if (type == 65) // ladder |
232 |
|
continue; |
233 |
|
if (type == 67) // steps |
234 |
|
continue; |
235 |
} |
} |
236 |
|
|
237 |
world.getBlockAt(x, y, z).setTypeIdAndData(type, data, true); |
world.getBlockAt(x, y, z).setTypeIdAndData(type, data, true); |
241 |
} |
} |
242 |
|
|
243 |
} |
} |
244 |
|
|
245 |
|
|
246 |
|
//yaw is left,right looking direction, 0=straight west |
247 |
|
int getFacing(Location loc) { |
248 |
|
int angle = (int) loc.getYaw(); |
249 |
|
|
250 |
|
if (angle < 45) { |
251 |
|
return 0; |
252 |
|
} else if (angle < 135) { |
253 |
|
return 1; |
254 |
|
} else if (angle < 225) { |
255 |
|
return 2; |
256 |
|
} else if (angle < 315) { |
257 |
|
return 3; |
258 |
|
} else { |
259 |
|
return 0; |
260 |
|
} |
261 |
|
} |
262 |
|
|
263 |
} |
} |