Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.genuineminecraft.ores.generator;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.chunk.Chunk;
- public class Utility {
- public static int findHighestBlock(Chunk chunk) {
- // Check once downward.
- int yMax = 255;
- for (int yCheck = yMax; yCheck > 0; yCheck--) {
- if (chunk.getBlock(7, yCheck, 7).equals(Blocks.air))
- yMax--;
- else
- break;
- }
- // Check above first downward test.
- boolean firstTry;
- search:
- for (int y = yMax; y > 0; y--) {
- firstTry = true;
- for (int x = 0; x < 16; x++) {
- for (int z = 0; z < 16; z++) {
- if (chunk.getBlock(x, y, z).equals(Blocks.air))
- if (firstTry) {
- yMax = y + 10;
- // Retry if found on first try of new yMax.
- break search;
- } else
- yMax = y;
- else
- break;
- }
- }
- firstTry = false;
- }
- return yMax;
- }
- }
Advertisement