Add convenience methods to BlockCache.

This commit is contained in:
asofold 2013-02-17 14:21:23 +01:00
parent 68a807a564
commit 5c3f79c09d

View File

@ -11,6 +11,20 @@ import fr.neatmonster.nocheatplus.utilities.ds.CoordMap;
*
*/
public abstract class BlockCache {
/**
* Convenience method to check if the bounds as returned by getBounds cover a whole block.
* @param bounds Can be null, must have 6 fields.
* @return
*/
public static final boolean isFullBounds(final double[] bounds) {
if (bounds == null) return false;
for (int i = 0; i < 3; i ++){
if (bounds[i] > 0.0) return false;
if (bounds[i + 3] < 1.0) return false;
}
return true;
}
/** Cached type-ids. */
private final CoordMap<Integer> idMap = new CoordMap<Integer>();
@ -131,6 +145,17 @@ public abstract class BlockCache {
return nBounds;
}
/**
* Convenience method to check if the bounds for a block cover the full block.
* @param x
* @param y
* @param z
* @return
*/
public boolean isFullBounds(final int x, final int y, final int z){
return isFullBounds(getBounds(x, y, z));
}
/**
* Get the maximal y coordinate a block can be at (non air).
* @return