diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/Passable.java b/src/fr/neatmonster/nocheatplus/checks/moving/Passable.java index 7ee8edb6..a7cf3104 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/Passable.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/Passable.java @@ -33,10 +33,14 @@ public class Passable extends Check { if (blockMiddle.distanceSquared(from.getVector()) < blockMiddle.distanceSquared(to.getVector())) { // Further check for the players location as possible set back. loc = player.getLocation(); - if (!BlockProperties.isPassable(from.getBlockAccess(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))){ + if (to.isSamePos(loc) ){ + loc = null; + } + else if (!BlockProperties.isPassable(from.getBlockAccess(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))){ // Allow the move return null; } + // else is passable: use the location instead of from. } } } @@ -50,7 +54,7 @@ public class Passable extends Check { if (!from.isPassable() && loc == null){ // Check if passable. loc = player.getLocation(); - if (!BlockProperties.isPassable(from.getBlockAccess(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(from.getBlockX(), from.getBlockY(), from.getBlockZ()))){ + if (to.isSamePos(loc) || !BlockProperties.isPassable(from.getBlockAccess(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(from.getBlockX(), from.getBlockY(), from.getBlockZ()))){ loc = null; } } diff --git a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index a644d188..478bd46f 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -175,10 +175,32 @@ public class PlayerLocation { return blockZ; } + /** + * Compares block coordinates (not the world). + * @param other + * @return + */ public final boolean isSameBlock(final PlayerLocation other) { - // Maybe make block coordinate fields later. return blockX == other.getBlockX() && blockZ == other.getBlockZ() && blockY == other.getBlockY(); } + + /** + * Compares exact coordinates (not the world). + * @param loc + * @return + */ + public boolean isSamePos(final PlayerLocation loc) { + return x == loc.getX() && z == loc.getZ() && y == loc.getY(); + } + + /** + * Compares exact coordinates (not the world). + * @param loc + * @return + */ + public boolean isSamePos(final Location loc) { + return x == loc.getX() && z == loc.getZ() && y == loc.getY(); + } /** * Checks if the player is above stairs.