From eb4c537e650bd2d860a4d3b5f76aaa89817aa664 Mon Sep 17 00:00:00 2001 From: asofold Date: Thu, 7 Mar 2013 03:28:40 +0100 Subject: [PATCH] Revert too fast return, add other, comments, indentation. --- .../utilities/BlockProperties.java | 94 +++++++++++-------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index 00da0389..4a8ae06a 100644 --- a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -376,6 +376,8 @@ public class BlockProperties { /////////////////////////// // Initalize block flags /////////////////////////// + + // Generic initialization. for (int i = 0; i = iMinY; y --){ // TODO: Remember the state of the last block below instead of checking the block above. @@ -1700,7 +1718,7 @@ public class BlockProperties { if ((flags & F_GROUND) == 0 || (flags & ignoreFlags) != 0){ continue; - } + } // Might collide. final double[] bounds = access.getBounds(x, y, z); @@ -1718,6 +1736,7 @@ public class BlockProperties { // Spider ! // Not nice but... // TODO: GROUND_HEIGHT: would have to check passable workaround again ? + // height >= ? if ((flags & F_GROUND_HEIGHT) == 0 || getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){ // Don't break, though could for some cases (?), since a block below still can be ground. continue; @@ -1725,24 +1744,22 @@ public class BlockProperties { } // Don't count as ground if a block contains the foot. -// if (y == iMaxY){ - // TODO: This could be a check before looping. -// if (maxY - y < ((flags & F_HEIGHT150) == 0 ? bounds[4] : 1.5)){ - if (getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){ - // Within block, this x and z is no candidate for ground. - if (isFullBounds(bounds)){ - break; - } - else{ - continue; - } - } -// } -// } - - -// return true; - + // height >= ? + if (getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){ + // Within block, this x and z is no candidate for ground. + if (isFullBounds(bounds)){ + break; + } + else{ + continue; + } + } + + if (maxY - y < 1.0){ + // No need to check the block above (half slabs, stairs). + return true; + } + // Check if the block above allows this to be ground. if (y >= maxBlockY){ @@ -1750,10 +1767,11 @@ public class BlockProperties { return true; } - if (y != iMaxY){ - // Ground found and the block above is passable, no need to check above. - return true; - } + // TODO: This can be a problem with glass panes etc. +// if (y != iMaxY){ +// // Ground found and the block above is passable, no need to check above. +// return true; +// } final int aboveId = access.getTypeId(x, y + 1, z); final long aboveFlags = blockFlags[aboveId];