Skip to content

Commit

Permalink
SurvivalFly - Add watermove Check (Jesus)
Browse files Browse the repository at this point in the history
Attempts to prevent walking directly above water
CaptainObvious0 authored Apr 6, 2019
1 parent 62f598a commit 93ae1ce
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import java.util.Locale;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -399,6 +400,25 @@ else if (data.liftOffEnvelope == LiftOffEnvelope.LIMIT_LIQUID
hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance);
tags.add("waterwalk");
}

// Detects walking directly above water
Material blockUnder = player.getLocation().subtract(0, 0.12, 0).getBlock().getType();
Material blockAbove = player.getLocation().add(0, 0.12, 0).getBlock().getType();
if (blockUnder != null && blockAbove != null) {
// Checks if the player is above water but not in water.
if (blockUnder == Material.WATER && blockAbove == Material.AIR) {
// hDist and vDist checks, simply checks for horizontal movement with little y distance
if (hDistanceAboveLimit <= 0D && hDistance > 0.1D && yDistance <= 0.1D && !toOnGround && !fromOnGround
&& lastMove.toIsValid && lastMove.yDistance != 0D
&& !from.isHeadObstructed() && !to.isHeadObstructed() && !player.isSwimming()) {
// Prevent being flagged if a player transitions from a block to water and the player falls into the water.
if (!(yDistance < 0 && yDistance != 0 && lastMove.yDistance < 0 && lastMove.yDistance != 0)) {
hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance);
tags.add("watermove");
}
}
}
}

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

0 comments on commit 93ae1ce

Please sign in to comment.