Created
October 14, 2011 19:58
-
-
Save Darsstar/1288137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void flatten(Chunk chunk) | |
{ | |
if (current != null) | |
{ | |
// recursion, get out of here! | |
return; | |
} | |
current = chunk; | |
Environment environment = chunk.getWorld().getEnvironment(); | |
for (x = 0; x < 16; x++) | |
{ | |
for (z = 0; z < 16; z++) | |
{ | |
switch (environment) | |
{ | |
case NETHER: | |
nether(); | |
case NORMAL: | |
normal(); | |
case SKYLANDS: | |
skylands(); | |
} | |
} | |
} | |
current = null; | |
} | |
private static void normal() | |
{ | |
current.getBlock(x, 0, z).setType(Material.BEDROCK); | |
for (int y = 1; y < 6; y++) | |
{ | |
Block block = current.getBlock(x, y, z); | |
// I want layers 0-5 all bedrock, not only 0, to protect stuff like RuneCraft's waypoints | |
// for my underground cities/batcaves! | |
if (block.getType() != Material.BEDROCK) | |
{ | |
block.setType(Material.BEDROCK); | |
} | |
} | |
} | |
private static void nether() | |
{ | |
current.getBlock(x, 127, z).setType(Material.BEDROCK); | |
for (int y = 122; y < 127; y++) | |
{ | |
Block block = current.getBlock(x, y, z); | |
if (block.getType() == Material.BEDROCK) | |
{ | |
block.setType(Material.NETHERRACK); | |
} | |
} | |
} | |
private static void skylands() | |
{ | |
if (current.getWorld().getEnvironment() == Environment.SKYLANDS) | |
{ | |
// break out of the for loops | |
x = z = 16; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment