From 589dc77510ff87a1b1f5ff584a519ebdc16e7dfb Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 17 Aug 2014 22:46:55 +0200 Subject: [PATCH] Change quick-exit check for passable. * Include the case for manhattan == 1. * Use BlockProperties.isPassable. --- .../nocheatplus/checks/moving/Passable.java | 17 ++++++++++++----- .../nocheatplus/utilities/BlockProperties.java | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java index 1e44ece0..d24d9fd5 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java @@ -28,13 +28,20 @@ public class Passable extends Check { String tags = ""; // Block distances (sum, max) for from-to (not for loc!). final int manhattan = from.manhattan(to); - // Skip moves inside of ignored blocks right away. - if (manhattan == 0 && (BlockProperties.getBlockFlags(from.getTypeId()) & BlockProperties.F_IGN_PASSABLE) != 0) { - return null; - } + // Skip moves inside of ignored blocks right away [works as long as we only check between foot-locations]. + if (manhattan <= 1 && BlockProperties.isPassable(from.getTypeId())) { + // TODO: Monitor: BlockProperties.isPassable checks slightly different than before. + if (manhattan == 0){ + return null; + } else { + // manhattan == 1 + if (BlockProperties.isPassable(to.getTypeId())) { + return null; + } + } + } boolean toPassable = to.isPassable(); // General condition check for using ray-tracing. - // TODO: Optimize: manhattan <= 1 and all blocks are completely passable. if (toPassable && cc.passableRayTracingCheck && (!cc.passableRayTracingBlockChangeOnly || manhattan > 0)) { rayTracing.set(from, to); rayTracing.loop(); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index e88f458b..3741d808 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -1379,13 +1379,14 @@ public class BlockProperties { } /** - * Just check if a position is not inside of a block that has a bounding box.
+ * Just check if a block type is fully passable by default.
* This is an inaccurate check, it also returns false for doors etc. * @param id * @return */ public static final boolean isPassable(final int id){ final long flags = blockFlags[id]; + // TODO: What with non-solid blocks that are not passable ? if ((flags & (F_LIQUID | F_IGN_PASSABLE)) != 0) return true; else return (flags & F_SOLID) == 0; }