Fix processingEvents use. Reorder conditions for bounce. Comments.

This commit is contained in:
asofold 2015-10-22 02:06:39 +02:00
parent 6ee9528fe7
commit 16698090fb
3 changed files with 24 additions and 8 deletions

View File

@ -263,7 +263,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (sfCheck && cc.sfSetBackPolicyFallDamage && noFall.isEnabled(player)) {
// Check if to deal damage.
double y = loc.getY();
if (data.hasSetBack()) y = Math.min(y, data.getSetBackY());
if (data.hasSetBack()) {
y = Math.min(y, data.getSetBackY());
}
noFall.checkDamage(player, data, y);
}
// Cleanup
@ -417,7 +419,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Split move 1 (from -> loc):");
}
moveInfo.set(player, from, loc, cc.yOnGround);
if (!checkPlayerMove(player, from, loc, true, moveInfo, data, cc, event) && processingEvents.containsKey(event)) {
if (!checkPlayerMove(player, from, loc, true, moveInfo, data, cc, event) && processingEvents.containsKey(player.getName())) {
// Between -> set data accordingly (compare: onPlayerMoveMonitor).
onMoveMonitorNotCancelled(player, from, loc, System.currentTimeMillis(), TickTask.getTick(), CombinedData.getData(player), data);
data.joinOrRespawn = false;
@ -576,11 +578,21 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
boolean verticalBounce = false;
if (checkSf || checkCf) {
// Check jumping on things like slime blocks.
if (to.getY() < from.getY()
// Detect potential bounce.
if (
// Common conditions.
to.getY() < from.getY()
&& (BlockProperties.getBlockFlags(pTo.getTypeIdBelow()) & BlockProperties.F_BOUNCE25) != 0L
&& !survivalFly.isReallySneaking(player)
&& (to.getY() - to.getBlockY() <= Math.max(cc.yOnGround, cc.noFallyOnGround) && player.getFallDistance() > 1f
|| to.getY() - to.getBlockY() < 0.286 && to.getY() - from.getY() > -0.5 && to.getY() - from.getY() < -SurvivalFly.GRAVITY_MAX - SurvivalFly.GRAVITY_SPAN && !pTo.isOnGround())
&& (
// Normal envelope (forestall NoFall).
to.getY() - to.getBlockY() <= Math.max(cc.yOnGround, cc.noFallyOnGround)
&& player.getFallDistance() > 1f
// Within wobble-distance.
|| to.getY() - to.getBlockY() < 0.286 && to.getY() - from.getY() > -0.5
&& to.getY() - from.getY() < -SurvivalFly.GRAVITY_MAX - SurvivalFly.GRAVITY_SPAN
&& !pTo.isOnGround()
)
) {
// Prepare bounce: The center of the player must be above the block.
// TODO: Check other side conditions (fluids, web, max. distance to the block top (!))
@ -589,6 +601,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
checkNf = false;
}
else if (data.verticalBounce != null) {
// Prepared bounce support.
if (to.getY() > from.getY()) {
// Apply bounce.
checkNf = false;
@ -741,9 +754,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (data.noFallMaxY >= from.getY() ) {
fallDistance = data.noFallMaxY - to.getY();
} else {
fallDistance = from.getY() - to.getY();
fallDistance = from.getY() - to.getY(); // Skip to avoid exploits: + player.getFallDistance()
}
} else {
// TODO: This would ignore the first split move, if this is the second one.
fallDistance = player.getFallDistance() + from.getY() - to.getY();
}
final double effect = Math.min(3.14, Math.sqrt(fallDistance) / 3.3 + SurvivalFly.GRAVITY_MAX); // Ancient Greek technology with gravity added.

View File

@ -127,7 +127,6 @@ public class NoFall extends Check {
final double fromY = from.getY();
final double toY = to.getY();
// TODO: account for player.getLocation.getY (how exactly ?)
final double yDiff = toY - fromY;
final double oldNFDist = data.noFallFallDistance;

View File

@ -1091,6 +1091,10 @@ public class SurvivalFly extends Check {
|| yDistChange > -GRAVITY_MIN && yDistChange < -GRAVITY_ODD
&& data.lastYDist < 0.5 && data.lastYDist > 0.4
)
// // Small distance to set.back. .
// || data.hasSetBack() && Math.abs(data.getSetBackY() - from.getY()) < 1.0
// // Bounce without velocity set.
// && data.lastYDist == 0.0 && yDistance > -GRAVITY_MIN && yDistance < GRAVITY_SPAN
// Jump-effect-specific
// TODO: Jump effect at reduced lift off envelope -> skip this?
|| data.jumpAmplifier > 0 && data.lastYDist < GRAVITY_MAX + GRAVITY_MIN / 2.0 && data.lastYDist > -2.0 * GRAVITY_MAX - 0.5 * GRAVITY_MIN
@ -1718,7 +1722,6 @@ public class SurvivalFly extends Check {
if (data.lastYDist < 0.0) { // TODO: <= ?
// Generic could step.
// TODO: Possibly confine margin depending on side, moving direction (see client code).
// TODO: Consider player.getLocation too (!).
// TODO: Should this also be checked vs. last from?
if (BlockProperties.isOnGroundShuffled(to.getBlockCache(), from.getX(), from.getY() + cc.sfStepHeight, from.getZ(), to.getX(), to.getY(), to.getZ(), 0.1 + (double) Math.round(from.getWidth() * 500.0) / 1000.0, to.getyOnGround(), 0.0)) {
// TODO: Set a data property, so vdist does not trigger (currently: scan for tag)