I used to know this, but now that I need it, I can't find it. How do I find the safe hight (Y) at a position (X,Z). By safe, I mean the greatest Y value that's over a block. I could create my code to do this myself, but I was certain that there was something in the API that did it for me. Any help?
Code: world.getHighestBlockAt(int x, int z) // or world.getHighestBlockAt(Location loc) I believe that's what you are looking for
thanks Actually, I thought there was one that gave a location EDIT by Moderator: merged posts, please use the edit button instead of double posting.
It would be getHighestBlockYAt(x, z) EDIT: Ninja'd by the OP himself Also, bear in mind that this will completely disregard caves, or other large openings underground.
Do you have a way that won't disregard caves? I'd like to have a terrain generator set features WITHIN a cave, so the lowest y value that is useable would be preferable. Or the first air space from the bottom.
I don't think there's anything in the api that can do it, but you can use a variant of what I would have used had there not been an api for what I wanted. This function will find the lowest air block in a world. (note, this may or not be a cave. It could be the ground if there is no caves there) You may want one to find ALL caves Code: public int firstAir (World w, int x, int z) { for (int i = 0; i < 128; i++) if (w.getBlockTypeIdAt(x, i, z) == 0) return i; return -1; }