Skip to content

Commit

Permalink
Reset fall distance and NoFall data on a fly-nofly transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Jan 11, 2016
1 parent ec2c631 commit 3bcfeff
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -672,7 +672,7 @@ else if (data.verticalBounce != null) {

// Hack: Add velocity for transitions between creativefly and survivalfly.
if (lastMove.toIsValid && lastMove.flyCheck == CheckType.MOVING_CREATIVEFLY) {
workaroundFlyNoFlyTransition(tick, data);
workaroundFlyNoFlyTransition(player, tick, data);
}

// Actual check.
Expand Down Expand Up @@ -784,13 +784,17 @@ else if (checkCf) {
* @param tick
* @param data
*/
private static void workaroundFlyNoFlyTransition(final int tick, final MovingData data) {
private static void workaroundFlyNoFlyTransition(final Player player, final int tick, final MovingData data) {
final MoveData lastMove = data.moveData.getFirst();
final double amount = lastMove.hDistance * Magic.FRICTION_MEDIUM_AIR;
data.addHorizontalVelocity(new AccountEntry(tick, amount, 1, MovingData.getHorVelValCount(amount)));
data.addVerticalVelocity(new SimpleEntry(lastMove.yDistance, 2));
data.addVerticalVelocity(new SimpleEntry(0.0, 2));
data.setFrictionJumpPhase();
// Reset fall height.
// TODO: Later (e.g. 1.9) check for the ModelFlying, if fall damage is intended.
data.clearNoFallData();
player.setFallDistance(0f);
}

/**
Expand Down Expand Up @@ -1202,6 +1206,7 @@ else if (to == null) {
// TODO: Log?
if (!event.isCancelled()) {
// TODO: Log!
// TODO: Reset yaw rate, such as to accept any yaw to start with (!).
}
data.resetTeleported();
return;
Expand Down

0 comments on commit 3bcfeff

Please sign in to comment.