Skip to content

Commit 93ae1ce

Browse files
SurvivalFly - Add watermove Check (Jesus)
Attempts to prevent walking directly above water
1 parent 62f598a commit 93ae1ce

File tree

1 file changed

+20
-0
lines changed
  • NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player

1 file changed

+20
-0
lines changed

NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Locale;
2020
import java.util.Set;
2121

22+
import org.bukkit.Bukkit;
2223
import org.bukkit.Location;
2324
import org.bukkit.Material;
2425
import org.bukkit.entity.Player;
@@ -399,6 +400,25 @@ else if (data.liftOffEnvelope == LiftOffEnvelope.LIMIT_LIQUID
399400
hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance);
400401
tags.add("waterwalk");
401402
}
403+
404+
// Detects walking directly above water
405+
Material blockUnder = player.getLocation().subtract(0, 0.12, 0).getBlock().getType();
406+
Material blockAbove = player.getLocation().add(0, 0.12, 0).getBlock().getType();
407+
if (blockUnder != null && blockAbove != null) {
408+
// Checks if the player is above water but not in water.
409+
if (blockUnder == Material.WATER && blockAbove == Material.AIR) {
410+
// hDist and vDist checks, simply checks for horizontal movement with little y distance
411+
if (hDistanceAboveLimit <= 0D && hDistance > 0.1D && yDistance <= 0.1D && !toOnGround && !fromOnGround
412+
&& lastMove.toIsValid && lastMove.yDistance != 0D
413+
&& !from.isHeadObstructed() && !to.isHeadObstructed() && !player.isSwimming()) {
414+
// Prevent being flagged if a player transitions from a block to water and the player falls into the water.
415+
if (!(yDistance < 0 && yDistance != 0 && lastMove.yDistance < 0 && lastMove.yDistance != 0)) {
416+
hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance);
417+
tags.add("watermove");
418+
}
419+
}
420+
}
421+
}
402422

403423
// Prevent players from sprinting if they're moving backwards (allow buffers to cover up !?).
404424
if (sprinting && data.lostSprintCount == 0 && !cc.assumeSprint && hDistance > thisMove.walkSpeed && !data.hasActiveHorVel()) {

0 commit comments

Comments
 (0)