Abstracted natural blocktype checking to BlockType.isNaturalBlock

Dieser Commit ist enthalten in:
zml2008 2011-08-17 13:24:27 -07:00
Ursprung 93620ec168
Commit 59ade7a386
2 geänderte Dateien mit 31 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -2369,7 +2369,6 @@ public class EditSession {
/** /**
* Returns the highest solid 'terrain' block which can occur naturally. * Returns the highest solid 'terrain' block which can occur naturally.
* Looks at: 1, 2, 3, 7, 12, 13, 14, 15, 16, 56, 73, 74, 87, 88, 89, 82
* *
* @param x * @param x
* @param z * @param z
@ -2377,32 +2376,14 @@ public class EditSession {
* minimal height * minimal height
* @param maxY * @param maxY
* maximal height * maximal height
* @param naturalOnly look at natural blocks or all blocks
* @return height of highest block found or 'minY' * @return height of highest block found or 'minY'
*/ */
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean naturalOnly) { public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean naturalOnly) {
for (int y = maxY; y >= minY; --y) { for (int y = maxY; y >= minY; --y) {
Vector pt = new Vector(x, y, z); Vector pt = new Vector(x, y, z);
int id = getBlockType(pt); int id = getBlockType(pt);
if (naturalOnly ? if (naturalOnly ? BlockType.isNaturalBlock(id) : !BlockType.canPassThrough(id)) {
id == 1 // stone
|| id == 2 // grass
|| id == 3 // dirt
|| id == 7 // bedrock
|| id == 12 // sand
|| id == 13 // gravel
|| id == 82 // clay
// hell
|| id == 87 // netherstone
|| id == 88 // slowsand
|| id == 89 // lightstone
// ores
|| id == 14 // coal ore
|| id == 15 // iron ore
|| id == 16 // gold ore
|| id == 56 // diamond ore
|| id == 73 // redstone ore
|| id == 74 // redstone ore (active)
: !BlockType.canPassThrough(id)) {
return y; return y;
} }
} }

Datei anzeigen

@ -594,4 +594,32 @@ public enum BlockType {
} }
return dropped; return dropped;
} }
/**
* Checks if the block type is "natural"
*
* @param id
* @return
*/
public static boolean isNaturalBlock(int id) {
return id == 1 // stone
|| id == 2 // grass
|| id == 3 // dirt
|| id == 7 // bedrock
|| id == 12 // sand
|| id == 13 // gravel
|| id == 82 // clay
// hell
|| id == 87 // netherstone
|| id == 88 // slowsand
|| id == 89 // lightstone
// ores
|| id == 14 // coal ore
|| id == 15 // iron ore
|| id == 16 // gold ore
|| id == 21 // lapis ore
|| id == 56 // diamond ore
|| id == 73 // redstone ore
|| id == 74; // redstone ore (active)
}
} }