From 2cec7468ea2c25b6a775308e5eb95fa485adc176 Mon Sep 17 00:00:00 2001 From: asofold Date: Thu, 29 Nov 2012 15:39:11 +0100 Subject: [PATCH] Add Method to collect flags. Add comment to isOnGround. --- .../utilities/BlockProperties.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index 034f29cf..0a5ab238 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -1241,7 +1241,8 @@ public class BlockProperties { } /** - * Similar to collides(... , F_GROUND), but also checks the block above (against spider). + * Similar to collides(... , F_GROUND), but also checks the block above (against spider).
+ * NOTE: This does not return true if stuck, to check for that use collidesBlock for the players location. * @param access * @param minX * @param minY @@ -1338,4 +1339,33 @@ public class BlockProperties { } return false; } + + /** + * Collect all flags of blocks touched by the bounds, this does not check versus the blocks bounding box. + * @param access + * @param minX + * @param minY + * @param minZ + * @param maxX + * @param maxY + * @param maxZ + * @return + */ + public static final long collectFlagsSimple(final IBlockAccess access, final double minX, double minY, final double minZ, final double maxX, final double maxY, final double maxZ){ + final int iMinX = Location.locToBlock(minX); + final int iMaxX = Location.locToBlock(maxX); + final int iMinY = Location.locToBlock(minY); + final int iMaxY = Location.locToBlock(maxY); + final int iMinZ = Location.locToBlock(minZ); + final int iMaxZ = Location.locToBlock(maxZ); + long flags = 0; + for (int x = iMinX; x <= iMaxX; x++){ + for (int z = iMinZ; z <= iMaxZ; z++){ + for (int y = iMinY; y <= iMaxY; y++){ + flags |= blockFlags[access.getTypeId(x, y, z)]; + } + } + } + return flags; + } }