Attempt to prevent exploits of a workaround.

This commit is contained in:
asofold 2012-10-06 01:57:06 +02:00
parent 5dff15002a
commit 390fa3f738
4 changed files with 13 additions and 8 deletions

View File

@ -107,6 +107,8 @@ public class MovingData extends ACheckData {
// public boolean noFallWasOnGround;
/** Last y coordinate from when the player was on ground. */
public double noFallMaxY;
/** Indicate that NoFall should assume the player to be on ground. */
public boolean noFallAssumeGround;
// Passable check.
public double passableVL;

View File

@ -305,6 +305,8 @@ public class MovingListener implements Listener {
final MovingData data = MovingData.getData(player);
final MovingConfig cc = MovingConfig.getConfig(player);
data.noFallAssumeGround = false;
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
// general data modifications one for each event.

View File

@ -114,11 +114,11 @@ public class NoFall extends Check {
// Just reset.
data.clearNoFallData();
}
else if (fromOnGround){
else if (fromOnGround || data.noFallAssumeGround){
// Check if to deal damage (fall back damage check).
if (cc.noFallDealDamage) handleOnGround(mcPlayer, data, from.getY(), cc);
else{
mcPlayer.fallDistance = Math.max(mcPlayer.fallDistance, Math.max(data.noFallFallDistance, (float) (data.noFallMaxY - to.getY())));
mcPlayer.fallDistance = Math.max(mcPlayer.fallDistance, Math.max(data.noFallFallDistance, (float) (data.noFallMaxY - from.getY())));
data.clearNoFallData();
}
}

View File

@ -208,17 +208,18 @@ public class SurvivalFly extends Check {
// If the player has touched the ground but it hasn't been noticed by the plugin, the workaround is here.
final double setBackYDistance = to.getY() - data.setBack.getY();
if (!fromOnGround && (from.getY() < data.survivalFlyLastFromY && yDistance > 0D && yDistance < 0.5D
&& setBackYDistance > 0D && setBackYDistance <= 1.5D || !toOnGround && to.isAboveStairs())) {
&& setBackYDistance > 0D && setBackYDistance <= 1.5D && !BlockProperties.isPassable(from.getTypeIdBelow())
|| !toOnGround && to.isAboveStairs())) {
// Set the new setBack and reset the jumpPhase.
// TODO: this allows exploits !
// Maybe don't adapt the setback (unless null)!
data.setBack = from.getLocation();
data.setBack.setY(Math.floor(data.setBack.getY()));
data.survivalFlyJumpPhase = 0;
// Reset the no fall data.
data.clearNoFallData();
if (cc.debug) System.out.println(player.getName() + " RESET NOFALL (WORKAROUND)");
// Tell NoFall that we assume the player to have been on ground somehow.
data.noFallAssumeGround = true;
if (cc.debug) System.out.println(player.getName() + " Y INCONSISTENCY WORKAROUND USED");
}
data.survivalFlyLastFromY = from.getY();