From 5c3f79c09dc734dacb5521a90af3b940c8fcae83 Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 17 Feb 2013 14:21:23 +0100 Subject: [PATCH] Add convenience methods to BlockCache. --- .../nocheatplus/utilities/BlockCache.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockCache.java b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockCache.java index bd4866d2..ef094747 100644 --- a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockCache.java +++ b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockCache.java @@ -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 idMap = new CoordMap(); @@ -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