Reset sprinting if the player is not set sprinting.

Only give the sprintinggrace time concerning the food level.
Should fix more sprintback issues, potentially.
This commit is contained in:
asofold 2013-07-17 17:33:27 +02:00
parent 63b2cd3156
commit f82a0c084a
2 changed files with 13 additions and 4 deletions

View File

@ -474,11 +474,19 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
return;
}
final long time = System.currentTimeMillis(); // TODO: pass to checks to use one reference time (set in data)?
if (player.isSprinting() && player.getFoodLevel() > 5){
data.timeSprinting = time;
final long time = System.currentTimeMillis();
if (player.isSprinting()){
//
if (player.getFoodLevel() > 5){
data.timeSprinting = time;
}
else if (time < data.timeSprinting){
data.timeSprinting = 0;
}
// else: keep sprinting time.
}
else if (time < data.timeSprinting){
else{
// Reset if not actually sprinting.
data.timeSprinting = 0;
}

View File

@ -171,6 +171,7 @@ public class SurvivalFly extends Check {
// Prevent players from sprinting if they're moving backwards.
if (sprinting) {
// TODO: Check if still necessary with timeSprinting change.
// TODO: Find more ways to confine conditions.
final float yaw = from.getYaw();
if (xDistance < 0D && zDistance > 0D && yaw > 180F && yaw < 270F