|
19 | 19 | import java.util.Locale; |
20 | 20 | import java.util.Set; |
21 | 21 |
|
| 22 | +import org.bukkit.Bukkit; |
22 | 23 | import org.bukkit.Location; |
23 | 24 | import org.bukkit.Material; |
24 | 25 | import org.bukkit.entity.Player; |
@@ -399,6 +400,25 @@ else if (data.liftOffEnvelope == LiftOffEnvelope.LIMIT_LIQUID |
399 | 400 | hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance); |
400 | 401 | tags.add("waterwalk"); |
401 | 402 | } |
| 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 | + } |
402 | 422 |
|
403 | 423 | // Prevent players from sprinting if they're moving backwards (allow buffers to cover up !?). |
404 | 424 | if (sprinting && data.lostSprintCount == 0 && !cc.assumeSprint && hDistance > thisMove.walkSpeed && !data.hasActiveHorVel()) { |
|
0 commit comments