mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 03:02:11 +01:00
Re-order isOnGround for better overview.
This commit is contained in:
parent
66f2d6d7eb
commit
22974751e6
@ -1504,8 +1504,8 @@ public class BlockProperties {
|
||||
* @param y
|
||||
* @param z
|
||||
* @param id
|
||||
* @param bounds Not null
|
||||
* @param flags
|
||||
* @param bounds Not null: bounds of the block at x, y, z.
|
||||
* @param flags Block flags for the block at x, y, z.
|
||||
* @return
|
||||
*/
|
||||
public static final boolean collidesBlock(final BlockCache access, final double minX, double minY, final double minZ, final double maxX, final double maxY, final double maxZ, final int x, final int y, final int z, final int id, final double[] bounds, final long flags){
|
||||
@ -1595,21 +1595,57 @@ public class BlockProperties {
|
||||
for (int x = iMinX; x <= iMaxX; x++){
|
||||
for (int z = iMinZ; z <= iMaxZ; z++){
|
||||
for (int y = iMinY; y <= iMaxY; y++){
|
||||
|
||||
// TODO: Remember the state of the last block below instead of checking the block above.
|
||||
|
||||
final int id = access.getTypeId(x, y, z);
|
||||
final long flags = blockFlags[id];
|
||||
if ((flags & F_GROUND) != 0 && (flags & ignoreFlags) == 0){
|
||||
|
||||
if ((flags & F_GROUND) == 0 || (flags & ignoreFlags) != 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Might collide.
|
||||
final double[] bounds = access.getBounds(x, y, z);
|
||||
if (collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, x, y, z, id, bounds, flags)){
|
||||
if (y >= maxBlockY) return true;
|
||||
if (!collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, x, y, z, id, bounds, flags)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: Check passable workaround without checking ignore flag.
|
||||
|
||||
// TODO: Shortcut: if bounds[4] > fx return true (careful with fences) ?
|
||||
|
||||
// Check if the block above allows
|
||||
if (y >= maxBlockY){
|
||||
// Only air above.
|
||||
return true;
|
||||
}
|
||||
final int aboveId = access.getTypeId(x, y + 1, z);
|
||||
final long aboveFlags = blockFlags[aboveId];
|
||||
if ((flags & F_IGN_PASSABLE) != 0); // Ignore these.
|
||||
else if ((aboveFlags & F_GROUND) != 0 && (aboveFlags & ignoreFlags) == 0){
|
||||
if ((flags & F_IGN_PASSABLE) != 0){
|
||||
// Ignore these.
|
||||
// TODO: Should this always apply ?
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((aboveFlags & F_GROUND) == 0 || (aboveFlags & ignoreFlags) != 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Might also check for liquid.
|
||||
|
||||
// TODO: check if it is the same id (walls!) and similar.
|
||||
|
||||
// Check against spider type hacks.
|
||||
final double[] aboveBounds = access.getBounds(x, y + 1, z);
|
||||
if (aboveBounds == null) return true;
|
||||
if (collidesBlock(access, minX, minY, minZ, maxX, Math.max(maxY, 1.49 + y), maxZ, x, y + 1, z, aboveId, aboveBounds, aboveFlags)){
|
||||
|
||||
if (!collidesBlock(access, minX, minY, minZ, maxX, Math.max(maxY, 1.49 + y), maxZ, x, y + 1, z, aboveId, aboveBounds, aboveFlags)){
|
||||
return true;
|
||||
}
|
||||
// TODO: Check passable workaround without checking ignore flag.
|
||||
|
||||
// TODO: This might be seen as a violation for many block types.
|
||||
// TODO: More distinction necessary here.
|
||||
if ((flags & F_VARIABLE) != 0 || (aboveFlags & F_VARIABLE) != 0){
|
||||
@ -1646,11 +1682,6 @@ public class BlockProperties {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user