mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-04 17:37:55 +02:00
Part-repair slime block trampoline support.
Adjust workarounds, confine velocity activation to next tick. Cases missing: * Lost ground cases (yOnGround has been reduced, strikes here). * Two consecutive yDist = 0.
This commit is contained in:
parent
2dd081d118
commit
537b387fbf
@ -594,6 +594,7 @@ public class MovingData extends ACheckData {
|
||||
public void addVelocity(final Player player, final MovingConfig cc, final double vx, final double vy, final double vz) {
|
||||
|
||||
final int tick = TickTask.getTick();
|
||||
// TODO: Slightly odd to call this each time, might switch to a counter-strategy (move - remove).
|
||||
removeInvalidVelocity(tick - cc.velocityActivationTicks);
|
||||
|
||||
if (debug) {
|
||||
@ -611,7 +612,7 @@ public class MovingData extends ACheckData {
|
||||
|
||||
// Set dirty flag here.
|
||||
sfDirty = true; // TODO: Set on using the velocity, due to latency !
|
||||
sfNoLowJump = true; // TODO: Set on using the velocity, due top latency !
|
||||
sfNoLowJump = true; // TODO: Set on using the velocity, due to latency !
|
||||
|
||||
}
|
||||
|
||||
@ -757,8 +758,9 @@ public class MovingData extends ACheckData {
|
||||
public SimpleEntry useVerticalVelocity(final double amount) {
|
||||
final SimpleEntry available = verVel.use(amount, TOL_VVEL);
|
||||
if (available != null) {
|
||||
sfDirty = true;
|
||||
verVelUsed = available;
|
||||
sfDirty = true;
|
||||
// TODO: Consider sfNoLowJump = true;
|
||||
}
|
||||
return available;
|
||||
}
|
||||
|
@ -524,6 +524,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
if (checkSf || checkCf) {
|
||||
// Check jumping on things like slime blocks.
|
||||
// The center of the player must be above the block.
|
||||
// TODO: Apply effects later, if the move has not been not cancelled.
|
||||
if (to.getY() < from.getY() && player.getFallDistance() > 1f
|
||||
&& (BlockProperties.getBlockFlags(pTo.getTypeIdBelow()) & BlockProperties.F_BOUNCE25) != 0L
|
||||
&& to.getY() - to.getBlockY() <= Math.max(cc.yOnGround, cc.noFallyOnGround)) {
|
||||
@ -669,10 +670,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
* @param cc
|
||||
*/
|
||||
private void processTrampoline(final Player player, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc) {
|
||||
|
||||
// TODO: Consider making this just a checking method (use result for applying effects).
|
||||
// CHEATING: Add velocity.
|
||||
// TODO: 1. Confine for direct use (no latency here). 2. Hard set velocity? 3.. Switch to friction based.
|
||||
if (!survivalFly.isReallySneaking(player)) {
|
||||
final double fallDistance;
|
||||
if (noFall.isEnabled(player, cc)) {
|
||||
@ -685,12 +683,12 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
} else {
|
||||
fallDistance = player.getFallDistance() + from.getY() - to.getY();
|
||||
}
|
||||
final double effect = Math.min(3.14, Math.sqrt(fallDistance) / 3.3); // Ancient Greek technology.
|
||||
// (Actually observed max. is near 3.5.)
|
||||
final double effect = Math.min(3.14, Math.sqrt(fallDistance) / 3.3 + SurvivalFly.GRAVITY_MAX); // Ancient Greek technology with gravity added.
|
||||
// (Actually observed max. is near 3.5.) TODO: Why 3.14 then?
|
||||
if (cc.debug) {
|
||||
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Trampoline effect (dY=" + fallDistance + "): " + effect);
|
||||
}
|
||||
data.addVelocity(player, cc, 0.0, effect, 0.0);
|
||||
data.addVerticalVelocity(new SimpleEntry(effect, 2)); // Not logged at present.
|
||||
} else {
|
||||
if (cc.debug) {
|
||||
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Trampoline effect (sneaking).");
|
||||
|
@ -74,7 +74,7 @@ public class SurvivalFly extends Check {
|
||||
public static final double GRAVITY_MAX = 0.0834;
|
||||
public static final double GRAVITY_MIN = 0.0624; // TODO: Special cases go down to 0.05.
|
||||
public static final double GRAVITY_SPAN = GRAVITY_MAX - GRAVITY_MIN;
|
||||
public static final double GRAVITY_ODD = 0.0519; // TODO: This should probably be min. / cleanup.
|
||||
public static final double GRAVITY_ODD = 0.05; // 19; // TODO: This should probably be min. / cleanup.
|
||||
/** Assumed minimal average decrease per move, suitable for regarding 3 moves. */
|
||||
public static final float GRAVITY_VACC = (float) (GRAVITY_MIN * 0.6);
|
||||
|
||||
@ -1056,15 +1056,28 @@ public class SurvivalFly extends Check {
|
||||
// Too big chunk of change, but within reasonable bounds (should be contained in some other generic case?).
|
||||
data.lastYDist < 3.0 * GRAVITY_MAX + GRAVITY_MIN && yDistChange < -GRAVITY_MIN && yDistChange > -2.5 * GRAVITY_MAX -GRAVITY_MIN
|
||||
// Transition to 0.0 yDistance.
|
||||
|| data.lastYDist > GRAVITY_MAX / 2.0 && data.lastYDist < GRAVITY_MIN && yDistance == 0.0
|
||||
|| data.lastYDist > GRAVITY_ODD / 2.0 && data.lastYDist < GRAVITY_MIN && yDistance == 0.0
|
||||
// yDist inversion near 0 (almost). TODO: This actually happens near liquid, but NORMAL env!?
|
||||
|| data.lastYDist <= GRAVITY_MAX + GRAVITY_SPAN && data.lastYDist > GRAVITY_ODD
|
||||
// lastYDist < Gravity max + min happens with dirty phase (slimes),. previously: max + span
|
||||
// TODO: Can all cases be reduced to change sign with max. neg. gain of max + span ?
|
||||
|| data.lastYDist <= GRAVITY_MAX + GRAVITY_MIN && data.lastYDist > GRAVITY_ODD
|
||||
&& yDistance < GRAVITY_ODD && yDistance > -2.0 * GRAVITY_MAX - GRAVITY_ODD / 2.0
|
||||
// Head is obstructed. TODO: Cover this in a more generic way elsewhere (<= friction envelope + obstructed).
|
||||
|| data.lastYDist >= 0.0 && (from.isHeadObstructed(from.getyOnGround()) || data.fromWasReset && from.isHeadObstructed())
|
||||
// Break the block underneath.
|
||||
|| data.lastYDist < 0.0 && data.toWasReset // TODO: Also assumeGround? Should have more precise flags.
|
||||
&& yDistance >= -GRAVITY_MAX - GRAVITY_SPAN && yDistance <= GRAVITY_MIN
|
||||
// Slope with slimes (also near ground without velocityJumpPhase, rather lowjump but not always).
|
||||
|| data.lastYDist < -GRAVITY_MAX && yDistChange < - GRAVITY_ODD / 2.0 && yDistChange > -GRAVITY_MIN
|
||||
)
|
||||
|| data.isVelocityJumpPhase()
|
||||
&& (
|
||||
// Near zero inversion with slimes (rather dirty phase).
|
||||
data.lastYDist > GRAVITY_ODD && data.lastYDist < GRAVITY_MAX + GRAVITY_MIN
|
||||
&& yDistance <= -data.lastYDist && yDistance > -data.lastYDist - GRAVITY_MAX - GRAVITY_ODD
|
||||
// Odd mini-decrease with dirty phase (slime).
|
||||
|| data.lastYDist < -0.204 && yDistance > -0.26
|
||||
&& yDistChange > -GRAVITY_MIN && yDistChange < -GRAVITY_ODD / 4.0
|
||||
)
|
||||
// Jump-effect-specific
|
||||
// TODO: Jump effect at reduced lift off envelope -> skip this?
|
||||
|
Loading…
Reference in New Issue
Block a user