Skip to content

Commit

Permalink
Workarounds for moving down (-stream) in lava.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Nov 8, 2015
1 parent 5d4c71e commit 4fd834e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Expand Up @@ -84,7 +84,7 @@ public class SurvivalFly extends Check {
/** Friction for water (default). */
public static final double FRICTION_MEDIUM_WATER = 0.89;
/** Friction for lava. */
public static final double FRICTION_MEDIUM_LAVA = 0.25; // TODO
public static final double FRICTION_MEDIUM_LAVA = 0.25; // TODO: Rather 0.4 ?

// TODO: Friction by block to walk on (horizontal only, possibly to be in BlockProperties rather).

Expand Down Expand Up @@ -1595,7 +1595,7 @@ private double[] vDistLiquid(final PlayerLocation from, final PlayerLocation to,
data.sfNoLowJump = true;

// Expected envelopes.
final double baseSpeed = swimBaseSpeedV();
final double baseSpeed = swimBaseSpeedV(); // TODO: Lava?
final double yDistAbs = Math.abs(yDistance);

// TODO: Later also cover things like a sudden stop.
Expand Down Expand Up @@ -1658,6 +1658,20 @@ else if (data.lastYDist >= GRAVITY_MAX / 2.0 && data.lastYDist <= GRAVITY_MAX +
) {
return new double[]{yDistance, 0.0};
}
// Lava rather.
else if (data.lastFrictionVertical < 0.65 // (Random, but smaller than water.)
&& (
// Moving downstream.
data.lastYDist < 0.0 && yDistance > -0.5 && yDistance < data.lastYDist
&& data.lastYDist - yDistance < GRAVITY_MIN && BlockProperties.isDownStream(from, to)
// Mix of gravity and base speed [careful: relates to water base speed].
|| data.lastYDist < 0.0 && yDistance > -baseSpeed - GRAVITY_MAX && yDistance < data.lastYDist
&& data.lastYDist - yDistance > GRAVITY_SPAN
&& Math.abs(data.lastYDist + baseSpeed) < 0.25 * baseSpeed
)
) {
return new double[]{yDistance, 0.0};
}
}

// TODO: Also DOWNSTREAM !?
Expand Down
Expand Up @@ -2658,6 +2658,20 @@ public static final boolean isSameShape(final double[] bounds1, final double[] b
return true;
}

/**
* Check if the move given by from and to is leading downstream. Currently
* only the x-z move is regarded, no envelope/consistency checks are
* performed here, such as checking if the block is liquid at all, nor if
* the move makes sense. performed here.
*
* @param from
* @param to
* @return
*/
public static final boolean isDownStream(final PlayerLocation from, final PlayerLocation to) {
return isDownStream(from.getBlockCache(), from.getBlockX(), from.getBlockY(), from.getBlockZ(), from.getData(), to.getX() - from.getX(), to.getZ() - from.getZ());
}

/**
* Check if a move determined by xDistance and zDistance is leading down stream.
* @param access
Expand Down

0 comments on commit 4fd834e

Please sign in to comment.