1 |
torben |
1723 |
package dk.thoerup.bukkit.hoeruputils.creative; |
2 |
|
|
|
3 |
torben |
1724 |
import org.bukkit.ChatColor; |
4 |
torben |
1723 |
import org.bukkit.Location; |
5 |
|
|
import org.bukkit.Material; |
6 |
|
|
import org.bukkit.World; |
7 |
|
|
import org.bukkit.command.Command; |
8 |
|
|
import org.bukkit.command.CommandExecutor; |
9 |
|
|
import org.bukkit.command.CommandSender; |
10 |
|
|
import org.bukkit.entity.Player; |
11 |
|
|
|
12 |
torben |
1731 |
import java.util.Arrays; |
13 |
torben |
1729 |
import java.util.HashMap; |
14 |
torben |
3133 |
import java.util.HashSet; |
15 |
|
|
import java.util.Set; |
16 |
torben |
1724 |
|
17 |
torben |
1723 |
public class GeneralContractorCommands implements CommandExecutor{ |
18 |
|
|
|
19 |
torben |
1729 |
class StoredCommand { |
20 |
|
|
public StoredCommand(String l, String a[]) { |
21 |
|
|
this.label = l; |
22 |
|
|
this.args = a; |
23 |
|
|
} |
24 |
|
|
public String label; |
25 |
|
|
public String args[]; |
26 |
|
|
} |
27 |
|
|
|
28 |
torben |
1723 |
final static int Y_MAX = 255; |
29 |
torben |
3133 |
final Material valid_block_array[] = { |
30 |
|
|
Material.STONE, |
31 |
|
|
Material.GRASS, |
32 |
|
|
Material.DIRT, |
33 |
torben |
3141 |
Material.COBBLESTONE, |
34 |
torben |
3239 |
|
35 |
|
|
//Material.WOOD, |
36 |
|
|
Material.ACACIA_WOOD, |
37 |
|
|
Material.BIRCH_WOOD, |
38 |
|
|
Material.DARK_OAK_WOOD, |
39 |
|
|
Material.JUNGLE_WOOD, |
40 |
|
|
Material.OAK_WOOD, |
41 |
|
|
Material.SPRUCE_WOOD, |
42 |
|
|
|
43 |
torben |
3141 |
Material.BEDROCK, |
44 |
|
|
Material.WATER, |
45 |
|
|
Material.SAND, |
46 |
|
|
Material.GRAVEL, |
47 |
|
|
Material.GOLD_ORE, |
48 |
|
|
Material.IRON_ORE, |
49 |
|
|
Material.COAL_ORE, |
50 |
torben |
3239 |
|
51 |
|
|
//Material.LOG, |
52 |
|
|
Material.ACACIA_LOG, |
53 |
|
|
Material.BIRCH_LOG, |
54 |
|
|
Material.DARK_OAK_LOG, |
55 |
|
|
Material.JUNGLE_LOG, |
56 |
|
|
Material.OAK_LOG, |
57 |
|
|
Material.SPRUCE_LOG, |
58 |
|
|
//Material.LEAVES, |
59 |
|
|
Material.ACACIA_LEAVES, |
60 |
|
|
Material.BIRCH_LEAVES, |
61 |
|
|
Material.DARK_OAK_LEAVES, |
62 |
|
|
Material.JUNGLE_LEAVES, |
63 |
|
|
Material.OAK_LEAVES, |
64 |
|
|
Material.SPRUCE_LEAVES, |
65 |
|
|
|
66 |
torben |
3141 |
Material.GLASS, |
67 |
|
|
Material.LAPIS_ORE, |
68 |
|
|
Material.LAPIS_BLOCK, |
69 |
|
|
Material.SANDSTONE, |
70 |
torben |
3239 |
//Material.WOOL, |
71 |
|
|
Material.BLACK_WOOL, |
72 |
|
|
Material.WHITE_WOOL, |
73 |
|
|
Material.GRAY_WOOL, |
74 |
|
|
|
75 |
torben |
3141 |
Material.GOLD_BLOCK, |
76 |
|
|
Material.IRON_BLOCK, |
77 |
|
|
Material.BRICK, |
78 |
|
|
Material.MOSSY_COBBLESTONE, |
79 |
|
|
Material.OBSIDIAN, |
80 |
|
|
Material.DIAMOND_ORE, |
81 |
|
|
Material.DIAMOND_BLOCK, |
82 |
|
|
Material.ICE, |
83 |
|
|
Material.SNOW, |
84 |
|
|
Material.CLAY, |
85 |
|
|
Material.NETHERRACK, |
86 |
|
|
Material.SOUL_SAND |
87 |
torben |
3133 |
}; |
88 |
|
|
//4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 35, 41, 42, 43, 44, 45, 48, 49, 56, 57, 73, 74, 79, 80, 82} ; |
89 |
torben |
1729 |
|
90 |
torben |
3133 |
final Set<Material> valid_materials = new HashSet<Material>(); |
91 |
|
|
|
92 |
torben |
1729 |
HashMap<String,StoredCommand> commands = new HashMap<String,StoredCommand>(); |
93 |
torben |
1730 |
|
94 |
|
|
|
95 |
torben |
1731 |
public GeneralContractorCommands() { |
96 |
|
|
Arrays.sort(valid_block_array); |
97 |
torben |
3133 |
|
98 |
|
|
for (Material mat : valid_block_array) { |
99 |
|
|
valid_materials.add( mat ); |
100 |
|
|
} |
101 |
torben |
1731 |
} |
102 |
torben |
1723 |
|
103 |
|
|
//@Override |
104 |
|
|
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
105 |
|
|
|
106 |
|
|
if (! (sender instanceof Player) ) { |
107 |
|
|
return false; |
108 |
|
|
} |
109 |
|
|
Player player = (Player) sender; |
110 |
|
|
|
111 |
|
|
Location loc = player.getLocation(); |
112 |
|
|
|
113 |
|
|
if ( ! loc.getWorld().getName().equals("creative")) { |
114 |
|
|
player.sendMessage( ChatColor.RED + "This command may only be used in creative world" ); |
115 |
|
|
return true; |
116 |
|
|
} |
117 |
torben |
1729 |
|
118 |
|
|
|
119 |
torben |
1730 |
if ( command.getLabel().equals("replay") ) { |
120 |
torben |
1729 |
StoredCommand cmd = commands.get(player.getName() ); |
121 |
|
|
if (cmd != null) { |
122 |
|
|
label = cmd.label; |
123 |
|
|
args = cmd.args; |
124 |
|
|
} |
125 |
torben |
1730 |
} else { |
126 |
|
|
commands.put(player.getName(), new StoredCommand(label,args) ); |
127 |
torben |
1729 |
} |
128 |
torben |
1723 |
|
129 |
|
|
//System.out.println( ">>" + label); //DEBUG |
130 |
|
|
|
131 |
|
|
if ( label.equals("levelarea") ) { |
132 |
torben |
1726 |
if (validateLevelOrFill(player, label, args) ) { |
133 |
torben |
1723 |
levelArea(player, loc, args); |
134 |
|
|
} |
135 |
|
|
return true; |
136 |
|
|
} |
137 |
|
|
|
138 |
torben |
1751 |
if ( label.equals("createcave") ) { |
139 |
|
|
if (validateLevelOrFill(player, label, args) ) { |
140 |
|
|
createCave(player, loc, args); |
141 |
|
|
} |
142 |
|
|
return true; |
143 |
|
|
} |
144 |
torben |
1723 |
|
145 |
|
|
if ( label.equals("fillarea") ) { |
146 |
torben |
1726 |
if (validateLevelOrFill(player, label, args) ) { |
147 |
torben |
1723 |
fillArea(player, loc, args); |
148 |
|
|
} |
149 |
|
|
return true; |
150 |
|
|
} |
151 |
torben |
3196 |
|
152 |
|
|
if (label.equals("levelandfillarea") ) { |
153 |
|
|
if (validateLevelOrFill(player, label, args) ) { |
154 |
|
|
|
155 |
|
|
levelArea(player, loc, args); |
156 |
|
|
fillArea(player, loc, args); |
157 |
|
|
setSurface(player, loc, args); |
158 |
|
|
|
159 |
|
|
} |
160 |
|
|
} |
161 |
torben |
1723 |
|
162 |
|
|
if ( label.equals("slopearea") ) { |
163 |
|
|
slopeArea(player, loc, args); |
164 |
|
|
return true; |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
|
168 |
|
|
if ( label.equals("setsurface") ) { |
169 |
|
|
setSurface(player, loc, args); |
170 |
|
|
return true; |
171 |
|
|
} |
172 |
torben |
1730 |
|
173 |
|
|
if (label.equals("platform") ) { |
174 |
|
|
platform(player,loc,args); |
175 |
|
|
return true; |
176 |
|
|
} |
177 |
torben |
1733 |
|
178 |
|
|
if (label.equals("cylinder") ) { |
179 |
|
|
if (validateLevelOrFill(player, label, args) ) { |
180 |
|
|
cylinder(player,loc,args); |
181 |
|
|
} |
182 |
|
|
return true; |
183 |
|
|
} |
184 |
torben |
3196 |
|
185 |
|
|
|
186 |
torben |
1723 |
|
187 |
|
|
|
188 |
|
|
return false; |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
|
192 |
torben |
1725 |
void slopeArea(Player player, Location loc, String[] split) { |
193 |
|
|
int radius; |
194 |
|
|
try { |
195 |
|
|
radius = Integer.parseInt(split[0]); |
196 |
|
|
} catch (Exception e) { |
197 |
|
|
player.sendMessage("setsurface: radius must be an integer"); |
198 |
|
|
return; |
199 |
|
|
} |
200 |
torben |
1723 |
|
201 |
|
|
System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius); |
202 |
|
|
|
203 |
|
|
|
204 |
|
|
int playerX = loc.getBlockX(); |
205 |
|
|
int playerY = loc.getBlockY(); |
206 |
|
|
int playerZ = loc.getBlockZ(); |
207 |
|
|
|
208 |
|
|
World world = loc.getWorld(); |
209 |
|
|
|
210 |
|
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
211 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
212 |
|
|
|
213 |
|
|
|
214 |
|
|
int xdist = Math.abs(playerX-x); |
215 |
|
|
int zdist = Math.abs(playerZ-z); |
216 |
|
|
|
217 |
|
|
int dist = Math.max(xdist,zdist); |
218 |
|
|
|
219 |
|
|
//for (int y=playerY; y<=playerY+radius; y++) { |
220 |
|
|
for (int y=(playerY+dist); y<=Y_MAX; y++) { |
221 |
|
|
world.getBlockAt(x, y, z).setType(Material.AIR); |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
} |
225 |
|
|
|
226 |
|
|
} |
227 |
|
|
} |
228 |
|
|
|
229 |
torben |
1730 |
private void platform(Player player, Location loc, String[] split) { |
230 |
torben |
1723 |
|
231 |
torben |
1730 |
if (split.length != 2) { |
232 |
torben |
3133 |
player.sendMessage("Usage /platform [radius] [material]"); |
233 |
torben |
1730 |
return; |
234 |
|
|
} |
235 |
torben |
1723 |
|
236 |
torben |
1730 |
int radius; |
237 |
|
|
try { |
238 |
|
|
radius = Integer.parseInt(split[0]); |
239 |
|
|
} catch (Exception e) { |
240 |
|
|
player.sendMessage("platform: radius must be an integer"); |
241 |
|
|
return; |
242 |
|
|
} |
243 |
torben |
1723 |
|
244 |
torben |
3196 |
if (radius > 25) { |
245 |
|
|
player.sendMessage("platform: radius may not exceed 25"); |
246 |
torben |
1730 |
return; |
247 |
|
|
} |
248 |
|
|
|
249 |
torben |
3133 |
Material material = Material.matchMaterial( split[1] ); |
250 |
|
|
if (material == null) { |
251 |
torben |
3140 |
player.sendMessage("platform: unknown material: " + split[1] ); |
252 |
torben |
1730 |
return; |
253 |
|
|
} |
254 |
|
|
/* |
255 |
|
|
boolean validblock = false; |
256 |
|
|
for (int i=0; i<valid_block_array.length; i++) { |
257 |
|
|
if (valid_block_array[i] == blockid) { |
258 |
|
|
validblock = true; |
259 |
|
|
break; |
260 |
|
|
} |
261 |
|
|
} |
262 |
|
|
|
263 |
|
|
if ( !validblock ) { |
264 |
|
|
player.sendMessage("setsurface: block now allowed"); |
265 |
|
|
return; |
266 |
|
|
}*/ |
267 |
|
|
|
268 |
|
|
int playerX = loc.getBlockX(); |
269 |
|
|
int playerY = loc.getBlockY(); |
270 |
|
|
int playerZ = loc.getBlockZ(); |
271 |
|
|
|
272 |
|
|
|
273 |
|
|
World world = loc.getWorld(); |
274 |
|
|
|
275 |
|
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
276 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
277 |
|
|
int y = playerY - 1; |
278 |
|
|
|
279 |
torben |
3133 |
world.getBlockAt(x, y, z).setType( material ); |
280 |
torben |
1730 |
} |
281 |
|
|
} |
282 |
|
|
} |
283 |
|
|
|
284 |
|
|
private void setSurface(Player player, Location loc, String[] split) { |
285 |
|
|
|
286 |
torben |
1725 |
if (split.length != 2) { |
287 |
torben |
1723 |
player.sendMessage("Usage /setsurface [radius] [blockID]"); |
288 |
|
|
return; |
289 |
|
|
} |
290 |
|
|
|
291 |
|
|
int radius; |
292 |
|
|
try { |
293 |
torben |
1725 |
radius = Integer.parseInt(split[0]); |
294 |
torben |
1723 |
} catch (Exception e) { |
295 |
|
|
player.sendMessage("setsurface: radius must be an integer"); |
296 |
|
|
return; |
297 |
|
|
} |
298 |
|
|
|
299 |
torben |
3196 |
if (radius > 25) { |
300 |
|
|
player.sendMessage("setsurface: radius may not exceed 25"); |
301 |
torben |
1723 |
return; |
302 |
|
|
} |
303 |
|
|
|
304 |
torben |
3133 |
Material material = Material.matchMaterial( split[1] ); |
305 |
|
|
if (material == null) { |
306 |
torben |
3140 |
player.sendMessage("setsurface: unknown material: " + split[1] ); |
307 |
torben |
1723 |
return; |
308 |
|
|
} |
309 |
|
|
|
310 |
torben |
1731 |
//check if the blockid is in the array of valid blocks |
311 |
torben |
3133 |
if ( ! valid_materials.contains(material) ) { |
312 |
torben |
1723 |
player.sendMessage("setsurface: block now allowed"); |
313 |
|
|
return; |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
int playerX = loc.getBlockX(); |
317 |
|
|
int playerY = loc.getBlockY(); |
318 |
|
|
int playerZ = loc.getBlockZ(); |
319 |
|
|
|
320 |
torben |
3133 |
if(playerY <= 2 && material != Material.BEDROCK ) { |
321 |
torben |
1723 |
player.sendMessage("setsurface: at this level you may only use bedrock(id=7)"); |
322 |
|
|
return; |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
World world = loc.getWorld(); |
326 |
|
|
|
327 |
|
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
328 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
329 |
|
|
//int y = getGroundLevel(x,z) - 1; |
330 |
torben |
1729 |
int y = world.getHighestBlockYAt(x, z) ; |
331 |
torben |
3139 |
y -= 1; |
332 |
torben |
1723 |
|
333 |
torben |
3133 |
world.getBlockAt(x, y, z).setType(material); |
334 |
torben |
1723 |
} |
335 |
|
|
} |
336 |
|
|
} |
337 |
|
|
|
338 |
torben |
1725 |
private boolean validateLevelOrFill(Player player, String label, String[] split) { |
339 |
|
|
if (split.length < 1 || split.length > 2) { |
340 |
|
|
player.sendMessage("Usage: " + label + " [radius]"); |
341 |
torben |
1723 |
return false; |
342 |
|
|
} |
343 |
|
|
|
344 |
|
|
int radius; |
345 |
|
|
try { |
346 |
torben |
1725 |
radius = Integer.parseInt(split[0]); |
347 |
torben |
1723 |
} catch (Exception e) { |
348 |
torben |
1725 |
player.sendMessage(label + ": radius must be an integer"); |
349 |
torben |
1723 |
return false; |
350 |
|
|
} |
351 |
|
|
|
352 |
torben |
3196 |
if (radius > 25) { |
353 |
|
|
player.sendMessage(label + ": radius may not exceed 25"); |
354 |
torben |
1723 |
return false; |
355 |
|
|
} |
356 |
|
|
|
357 |
torben |
1725 |
if (split.length == 2) { |
358 |
torben |
3139 |
Material material = Material.matchMaterial( split[1] ); |
359 |
|
|
if (material == null) { |
360 |
torben |
3140 |
player.sendMessage(label + ": unknown material: " + split[1] ); |
361 |
torben |
1723 |
return false; |
362 |
|
|
} |
363 |
torben |
3139 |
if ( material == Material.TNT) { |
364 |
torben |
1723 |
player.sendMessage("Sorry dave, i can't do that"); |
365 |
|
|
return false; |
366 |
|
|
} |
367 |
|
|
|
368 |
|
|
} |
369 |
|
|
|
370 |
|
|
return true; |
371 |
|
|
} |
372 |
|
|
|
373 |
|
|
private void fillArea(Player player, Location loc, String[] split) { |
374 |
torben |
1725 |
int radius = Integer.parseInt(split[0]); |
375 |
torben |
1723 |
|
376 |
torben |
3133 |
Material material = Material.DIRT; |
377 |
|
|
|
378 |
torben |
1723 |
|
379 |
torben |
1725 |
if (split.length == 2) { |
380 |
torben |
3133 |
material = Material.matchMaterial( split[1] ); |
381 |
|
|
if (material == null) { |
382 |
|
|
player.sendMessage("Unknown material: " + split[1] ); |
383 |
|
|
return; |
384 |
|
|
} |
385 |
torben |
1723 |
} |
386 |
|
|
|
387 |
|
|
System.out.println("Player " + player.getName() + " used fillarea with radius=" + radius); |
388 |
|
|
|
389 |
|
|
|
390 |
|
|
int playerX = loc.getBlockX(); |
391 |
|
|
int playerY = loc.getBlockY(); |
392 |
|
|
int playerZ = loc.getBlockZ(); |
393 |
|
|
|
394 |
|
|
World world = loc.getWorld(); |
395 |
|
|
|
396 |
|
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
397 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
398 |
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
for (int y=world.getHighestBlockYAt(x, z); y<playerY; y++) { |
402 |
torben |
3133 |
world.getBlockAt(x, y, z).setType( material ); |
403 |
torben |
1723 |
} |
404 |
|
|
|
405 |
|
|
} |
406 |
|
|
|
407 |
|
|
} |
408 |
|
|
} |
409 |
|
|
|
410 |
torben |
1751 |
private void createCave(Player player, Location loc, String[] split) { |
411 |
|
|
|
412 |
|
|
int radius = Integer.parseInt(split[0]); |
413 |
|
|
|
414 |
|
|
System.out.println("Player " + player.getName() + " used levelarea with radius=" + radius); |
415 |
|
|
|
416 |
|
|
|
417 |
|
|
int playerX = loc.getBlockX(); |
418 |
|
|
int playerY = loc.getBlockY(); |
419 |
|
|
int playerZ = loc.getBlockZ(); |
420 |
|
|
|
421 |
|
|
|
422 |
|
|
World world = loc.getWorld(); |
423 |
|
|
|
424 |
torben |
3204 |
|
425 |
torben |
1751 |
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
426 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
427 |
|
|
|
428 |
|
|
int y_max = playerY+radius; |
429 |
|
|
//for (int y=playerY; y<=playerY+radius; y++) { |
430 |
|
|
for (int y=playerY; y<=y_max; y++) { |
431 |
torben |
3204 |
|
432 |
torben |
1751 |
world.getBlockAt(x, y, z).setType(Material.AIR); |
433 |
|
|
|
434 |
|
|
} |
435 |
|
|
|
436 |
|
|
} |
437 |
|
|
|
438 |
|
|
} |
439 |
|
|
} |
440 |
|
|
|
441 |
torben |
1723 |
private void levelArea(Player player, Location loc, String[] split) { |
442 |
|
|
|
443 |
torben |
1725 |
int radius = Integer.parseInt(split[0]); |
444 |
torben |
1723 |
|
445 |
|
|
System.out.println("Player " + player.getName() + " used levelarea with radius=" + radius); |
446 |
|
|
|
447 |
|
|
|
448 |
|
|
int playerX = loc.getBlockX(); |
449 |
|
|
int playerY = loc.getBlockY(); |
450 |
|
|
int playerZ = loc.getBlockZ(); |
451 |
|
|
|
452 |
|
|
|
453 |
|
|
World world = loc.getWorld(); |
454 |
|
|
|
455 |
|
|
for (int x=(playerX-radius); x<=(playerX+radius); x++) { |
456 |
|
|
for (int z=(playerZ-radius); z<=(playerZ+radius); z++) { |
457 |
|
|
|
458 |
|
|
//for (int y=playerY; y<=playerY+radius; y++) { |
459 |
|
|
for (int y=playerY; y<=Y_MAX; y++) { |
460 |
|
|
world.getBlockAt(x, y, z).setType(Material.AIR); |
461 |
|
|
|
462 |
|
|
} |
463 |
|
|
|
464 |
|
|
} |
465 |
|
|
|
466 |
|
|
} |
467 |
|
|
} |
468 |
torben |
1751 |
|
469 |
torben |
1733 |
|
470 |
|
|
|
471 |
|
|
private void resetMap(boolean[][] map) { |
472 |
|
|
for (int x=0; x<map.length; x++) { |
473 |
|
|
for (int z=0; z<map[0].length; z++) { |
474 |
|
|
map[x][z] = false; |
475 |
|
|
} |
476 |
|
|
} |
477 |
|
|
} |
478 |
|
|
|
479 |
|
|
private void cylinder(Player player, Location loc, String[] split) { |
480 |
|
|
if (split.length != 2) { |
481 |
|
|
player.sendMessage("Usage: /cylinder [radius] [material] "); |
482 |
|
|
return; |
483 |
|
|
} |
484 |
|
|
|
485 |
torben |
3133 |
Material material = Material.matchMaterial( split[1] ); |
486 |
|
|
if ( material == null) { |
487 |
|
|
player.sendMessage("/cylinder: unknown material: " + split[1]); |
488 |
|
|
return; |
489 |
|
|
} |
490 |
|
|
|
491 |
torben |
1733 |
int radius = Integer.parseInt(split[0]); |
492 |
|
|
int diameter = (radius*2) + 1; |
493 |
|
|
|
494 |
|
|
boolean map[][] = new boolean[diameter][diameter]; |
495 |
|
|
resetMap( map ); |
496 |
|
|
|
497 |
|
|
/* map[0][0] = true; |
498 |
|
|
map[0][diameter-1] = true; |
499 |
|
|
map[diameter-1][0] = true; |
500 |
|
|
map[diameter-1][diameter-1] = true;*/ |
501 |
|
|
|
502 |
|
|
for (int r=0; r<360; r++) { |
503 |
|
|
double rad = Math.toRadians( r ); |
504 |
|
|
|
505 |
|
|
double a = (double) radius * Math.sin( rad); |
506 |
|
|
double b = (double) radius * Math.cos( rad); |
507 |
|
|
|
508 |
|
|
int x = radius + (int)Math.round(a); |
509 |
|
|
int y = radius + (int)Math.round(b); |
510 |
|
|
|
511 |
|
|
map[x][y] = true; |
512 |
|
|
} |
513 |
|
|
|
514 |
torben |
1723 |
|
515 |
torben |
1733 |
drawMap( loc, map, material ); |
516 |
|
|
} |
517 |
|
|
|
518 |
torben |
3133 |
private void drawMap(Location loc, boolean[][] map, Material material) { |
519 |
torben |
1733 |
int playerX = loc.getBlockX(); |
520 |
|
|
int playerY = loc.getBlockY(); |
521 |
|
|
int playerZ = loc.getBlockZ(); |
522 |
|
|
|
523 |
|
|
World world = loc.getWorld(); |
524 |
|
|
|
525 |
|
|
for (int i=0; i<map.length; i++) { |
526 |
|
|
for (int j=0; j<map[0].length; j++) { |
527 |
|
|
|
528 |
|
|
int x = playerX + i + 1; |
529 |
|
|
int z = playerZ + j; |
530 |
|
|
|
531 |
|
|
if (map[i][j] == true) { |
532 |
|
|
for (int y=world.getHighestBlockYAt(x, z); y<playerY; y++) { |
533 |
torben |
3133 |
world.getBlockAt(x, y, z).setType(material); |
534 |
torben |
1733 |
} |
535 |
|
|
} |
536 |
|
|
|
537 |
|
|
} |
538 |
|
|
} |
539 |
|
|
} |
540 |
|
|
|
541 |
torben |
1723 |
|
542 |
torben |
1733 |
|
543 |
torben |
1723 |
} |