mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-30 20:37:52 +01:00
Prevent passable from resetting to the "to"- position.
This commit is contained in:
parent
d6d1e319a9
commit
d49aacd231
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user