Skip to content

Commit

Permalink
[BLEEDING] Split off untracked moves. Elaborate on slime blocks.
Browse files Browse the repository at this point in the history
MISSING:
* Micro move onto ground, fall distance resets before sf check is run.

Done:
* Split PlayerMoveEvent processing to from -> loc + from -> to. Just if
from isn't the same coordinates as player.getLocation. This
reduces the complexity of workarounds.
* You do take fall damage falling onto slime blocks while sneaking.
* Queue bounce effect, only if the move is valid. Skip NoFall then.
* Apply bounce effect once moving up, to allow overriding.
* Cover more odd cases.

Unrelated:
* Use data.debug instead of cc.debug.
  • Loading branch information
asofold committed Oct 20, 2015
1 parent 537b387 commit 8de7907
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 203 deletions.
Expand Up @@ -74,7 +74,7 @@ public void onPacketSending(final PacketEvent event) {
final Location loc = player.getLocation(useLoc);
final StructureModifier<Integer> ints = packetContainer.getIntegers();
final double dSq = TrigUtil.distanceSquared(ints.read(0) / 8, ints.read(2) / 8, loc.getX(), loc.getZ());
// if (cc.debug) {
// if (data.debug) {
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " SoundDistance(" + soundName + "): " + StringUtil.fdec1.format(Math.sqrt(dSq)));
// }
if (dSq > cc.soundDistanceSq) {
Expand Down
Expand Up @@ -152,7 +152,7 @@ public Location check(final Player player, final PlayerLocation from, final Play

final double result = Math.max(0.0, resultH) + Math.max(0D, resultV);

if (cc.debug) {
if (data.debug) {
outpuDebugMove(player, hDistance, limitH, yDistance, limitV, data);
}

Expand Down
Expand Up @@ -80,8 +80,9 @@ public static MovingConfig getConfig(final String worldName) {

public static final double Y_ON_GROUND_MIN = 0.00001;
public static final double Y_ON_GROUND_MAX = 0.0626;
// TODO: Model workarounds as lost ground ?
public static final double Y_ON_GROUND_DEFAULT = 0.016; // TODO: Jumping upwards while placing blocks (otherwise use MIN).
// TODO: Model workarounds as lost ground, use Y_ON_GROUND_MIN?
public static final double Y_ON_GROUND_DEFAULT = 0.016; // Jump upwards, while placing blocks.
// public static final double Y_ON_GROUND_DEFAULT = 0.029; // Bounce off slime blocks.


public final boolean ignoreCreative;
Expand Down
Expand Up @@ -100,7 +100,7 @@ public static void onReload() {
* TODO: Test, might be better ground.
*/
private static final LiftOffEnvelope defaultLiftOffEnvelope = LiftOffEnvelope.NO_JUMP;

/** Tolerance value for using vertical velocity (the client sends different values than received with fight damage). */
private static final double TOL_VVEL = 0.0625;

Expand Down Expand Up @@ -134,6 +134,9 @@ public static void onReload() {
/** Only used during processing, to keep track of sub-checks using velocity. Reset in velocityTick, before checks run. */
public SimpleEntry verVelUsed = null;

/** Compatibility entry for bouncing of slime blocks and the like. */
public SimpleEntry verticalBounce = null;

/** Tick at which walk/fly speeds got changed last time. */
public int speedTick = 0;
public float walkSpeed = 0.0f;
Expand Down Expand Up @@ -267,6 +270,7 @@ public void clearFlyData() {
vehicleConsistency = MoveConsistency.INCONSISTENT;
lastFrictionHorizontal = lastFrictionVertical = 0.0;
verVelUsed = null;
verticalBounce = null;
}

/**
Expand Down Expand Up @@ -300,6 +304,7 @@ public void onSetBack(final Location setBack) {
removeAllVelocity();
vehicleConsistency = MoveConsistency.INCONSISTENT; // Not entirely sure here.
lastFrictionHorizontal = lastFrictionVertical = 0.0;
verticalBounce = null;
}

/**
Expand All @@ -311,6 +316,7 @@ public void prepareSetBack(final Location loc) {
lastYDist = lastHDist = Double.MAX_VALUE;
toWasReset = false;
fromWasReset = false;
verticalBounce = null;
// Remember where we send the player to.
setTeleported(loc);
// TODO: sfHoverTicks ?
Expand Down Expand Up @@ -366,6 +372,7 @@ public void resetPositions(final double x, final double y, final double z, final
sfLowJump = false;
liftOffEnvelope = defaultLiftOffEnvelope;
lastFrictionHorizontal = lastFrictionVertical = 0.0;
verticalBounce = null;
// TODO: other buffers ?
// No reset of vehicleConsistency.
}
Expand Down Expand Up @@ -616,6 +623,10 @@ public void addVelocity(final Player player, final MovingConfig cc, final double

}

public void prependVerticalVelocity(final SimpleEntry entry) {
verVel.addToFront(entry);
}

public void addVerticalVelocity(final SimpleEntry entry) {
verVel.add(entry);
}
Expand Down Expand Up @@ -982,4 +993,14 @@ public void setFrictionJumpPhase() {
sfDirty = true;
}

public void useVerticalBounce(final Player player) {
// CHEATING: Ensure fall distance is reset.
player.setFallDistance(0f);
noFallMaxY = 0.0;
noFallFallDistance = 0f;
noFallSkipAirCheck = true;
prependVerticalVelocity(verticalBounce);
verticalBounce = null;
}

}

0 comments on commit 8de7907

Please sign in to comment.