Skip to content

Commit

Permalink
Remove the unneccessary fallDistance field
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Jun 28, 2022
1 parent ad279e1 commit b7c300b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class TerrestrialStepSoundGenerator implements StepSoundGenerator {

// Airborne
protected boolean isAirborne;
protected float fallDistance;

protected float lastReference;
protected boolean isImmobile;
Expand Down Expand Up @@ -165,7 +164,6 @@ protected void simulateFootsteps(LivingEntity ply) {
}

dwmYChange = distanceReference;

} else {
distance = variator.DISTANCE_HUMAN;
}
Expand All @@ -189,7 +187,7 @@ protected void simulateFootsteps(LivingEntity ply) {
}
}

public final void produceStep(LivingEntity ply, State event) {
public final void produceStep(LivingEntity ply, @Nullable State event) {
produceStep(ply, event, 0d);
}

Expand Down Expand Up @@ -224,9 +222,6 @@ protected void simulateAirborne(LivingEntity ply) {
isAirborne = !isAirborne;
simulateJumpingLanding(ply);
}
if (isAirborne) {
fallDistance = ply.fallDistance;
}
}

protected boolean isJumping(LivingEntity ply) {
Expand Down Expand Up @@ -268,7 +263,7 @@ protected void simulateJumping(LivingEntity ply) {
}

protected void simulateLanding(LivingEntity ply) {
if (fallDistance > variator.LAND_HARD_DISTANCE_MIN) {
if (ply.fallDistance > variator.LAND_HARD_DISTANCE_MIN) {
playMultifoot(ply, getOffsetMinus(ply), State.LAND);
// Always assume the player lands on their two feet
// Do not toggle foot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ protected void simulateJumpingLanding(LivingEntity ply) {
nextFlapTime = now + variator.WING_JUMPING_REST_TIME;
}

boolean hugeLanding = !isAirborne && fallDistance > variator.HUGEFALL_LANDING_DISTANCE_MIN;
boolean hugeLanding = !isAirborne && ply.fallDistance > variator.HUGEFALL_LANDING_DISTANCE_MIN;
boolean speedingJumpStateChange = speed > variator.MIN_MOTION_HOR;

if (hugeLanding || speedingJumpStateChange) {
if (!isAirborne) {
float volume = speedingJumpStateChange ? 2
: MathUtil.scalex(fallDistance, variator.HUGEFALL_LANDING_DISTANCE_MIN, variator.HUGEFALL_LANDING_DISTANCE_MAX);
: MathUtil.scalex(ply.fallDistance, variator.HUGEFALL_LANDING_DISTANCE_MIN, variator.HUGEFALL_LANDING_DISTANCE_MAX);
acoustics.playAcoustic(ply, "_SWIFT", State.LAND, Options.singular("gliding_volume", volume));
} else {
acoustics.playAcoustic(ply, "_SWIFT", State.JUMP, Options.EMPTY);
Expand Down

0 comments on commit b7c300b

Please sign in to comment.