data.timeSprinting = 0;
}
// Prepare locations for use.
// TODO: Block flags might not be needed if neither sf nor passable get checked.
final PlayerLocation pFrom, pTo;
pFrom = moveInfo.from;
pTo = moveInfo.to;
// HOT FIX - for VehicleLeaveEvent missing.
if (data.wasInVehicle) {
onVehicleLeaveMiss(player, data, cc);
}
// Potion effect "Jump".
final double jumpAmplifier = survivalFly.getJumpAmplifier(player);
if (jumpAmplifier > data.jumpAmplifier) {
data.jumpAmplifier = jumpAmplifier;
}
// TODO: same for speed (once medium is introduced).
// Velocity tick (decrease + invalidation).
// TODO: Rework to generic (?) queued velocity entries: activation + invalidation
final int tick = TickTask.getTick();
data.removeInvalidVelocity(tick - cc.velocityActivationTicks);
data.velocityTick();
// Check passable first to prevent set-back override.
// TODO: Redesign to set set-backs later (queue + invalidate).
boolean mightSkipNoFall = false; // If to skip nofall check (mainly on violation of other checks).
if (newTo == null && cc.passableCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_PASSABLE) && !player.hasPermission(Permissions.MOVING_PASSABLE)) {
// Passable is checked first to get the original set-back locations from the other checks, if needed.
newTo = passable.check(player, loc, pFrom, pTo, data, cc);
if (newTo != null) {
// Check if to skip the nofall check.
mightSkipNoFall = true;
}
}
// Check which fly check to use.
final boolean checkCf;
final boolean checkSf;
if (shouldCheckSurvivalFly(player, data, cc)) {
checkCf = false;
checkSf = true;
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
}
else if (cc.creativeFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY) && !player.hasPermission(Permissions.MOVING_CREATIVEFLY)) {
checkCf = true;
checkSf = false;
data.adjustFlySpeed(player.getFlySpeed(), tick, cc.speedGrace);
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
}
else{
checkCf = checkSf = false;
}
// Flying checks.
if (checkSf) {
// SurvivalFly
// Collect block flags.
// TODO: Could further differentiate if really needed to (newTo / NoFall).
final double maxYNoFall = Math.max(cc.noFallyOnGround, cc.yOnGround);
pFrom.collectBlockFlags(maxYNoFall);
if (pFrom.isSamePos(pTo)) {
// TODO: Could consider pTo = pFrom, set pitch / yaw elsewhere.
// Sets all properties, but only once.
pTo.prepare(pFrom);
}
else{
// Might collect block flags for small distances with the containing bounds for both.
pTo.collectBlockFlags(maxYNoFall);
}
// Actual check.
if (newTo == null) {
// Only check if passable has not already set back.
newTo = survivalFly.check(player, pFrom, pTo, data, cc, time);
}
final boolean checkNf = cc.noFallCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_NOFALL) && !player.hasPermission(Permissions.MOVING_NOFALL);
if (newTo == null) {
// Hover.
// TODO: Could reset for from-on-ground as well, for not too big moves.
if (cc.sfHoverCheck && !data.toWasReset && !pTo.isOnGround()) {
// Start counting ticks.
hoverTicks.add(playerName);
data.sfHoverTicks = 0;
}
else{
data.sfHoverTicks = -1;
}
// NoFall.
if (checkNf) {
noFall.check(player, loc, pFrom, pTo, data, cc);
}
}
else{
if (checkNf && cc.sfFallDamage) {
if (mightSkipNoFall) {
// Check if to really skip.
if (!pFrom.isOnGround() && !pFrom.isResetCond()) {
mightSkipNoFall = false;
}
}
if (!mightSkipNoFall) {
noFall.checkDamage(player, data, Math.min(Math.min(from.getY(), to.getY()), loc.getY()));
}
}
}
}
else if (checkCf) {
// CreativeFly
if (newTo == null) {
newTo = creativeFly.check(player, pFrom, pTo, data, cc, time);
}
data.sfHoverTicks = -1;
data.sfLowJump = false;
}
else{
// No fly checking :(.
data.clearFlyData();
}
// Morepackets.
// TODO: Also update counters if newTo == null?
if (newTo == null && cc.morePacketsCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_MOREPACKETS) && !player.hasPermission(Permissions.MOVING_MOREPACKETS)) {
// If it hasn't been stopped by any other check and is handled by the more packets check, execute it.
newTo = morePackets.check(player, pFrom, pTo, data, cc);
} else {
// Otherwise we need to clear their data.
data.clearMorePacketsData();
}
// Reset jump amplifier if needed.
if ((checkSf || checkCf) && jumpAmplifier != data.jumpAmplifier) {
if (data.noFallAssumeGround || pFrom.isOnGround() || pTo.isOnGround()) {
data.jumpAmplifier = jumpAmplifier;
}
}