Workarounds for moving down (-stream) in lava.

This commit is contained in:
asofold 2015-11-08 23:36:10 +01:00
parent 5d4c71eaae
commit 4fd834ed25
2 changed files with 30 additions and 2 deletions

View File

@ -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).
@ -1595,7 +1595,7 @@ public class SurvivalFly extends Check {
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.
@ -1658,6 +1658,20 @@ public class SurvivalFly extends Check {
) {
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 !?

View File

@ -2658,6 +2658,20 @@ public class BlockProperties {
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