Search in sources :

Example 6 with SimpleEntry

use of fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry in project NoCheatPlus by NoCheatPlus.

the class MovingListener method workaroundFlyNoFlyTransition.

/**
 * Add velocity, in order to work around issues with turning off flying,
 * triggering SurvivalFly. Asserts last distances are set.
 *
 * @param tick
 * @param data
 */
private void workaroundFlyNoFlyTransition(final Player player, final int tick, final boolean debug, final MovingData data) {
    final PlayerMoveData lastMove = data.playerMoves.getFirstPastMove();
    final double amount = guessFlyNoFlyVelocity(player, data.playerMoves.getCurrentMove(), lastMove, data);
    // Clear active velocity due to adding actual speed here.
    data.clearActiveHorVel();
    data.addHorizontalVelocity(new AccountEntry(tick, amount, 1, MovingData.getHorVelValCount(amount)));
    data.addVerticalVelocity(new SimpleEntry(lastMove.yDistance, 2));
    data.addVerticalVelocity(new SimpleEntry(0.0, 2));
    data.setFrictionJumpPhase();
    // Reset fall height.
    // TODO: Later (e.g. 1.9) check for the ModelFlying, if fall damage is intended.
    data.clearNoFallData();
    // TODO: Might do without this in case of elytra, needs ensure NoFall doesn't kill the player (...).
    player.setFallDistance(0f);
    if (debug) {
        debug(player, "Fly-nofly transition: Add velocity.");
    }
}
Also used : PlayerMoveData(fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData) SimpleEntry(fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry) AccountEntry(fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry)

Example 7 with SimpleEntry

use of fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry in project NoCheatPlus by NoCheatPlus.

the class MovingListener method processBounce.

/**
 * Adjust data to allow bouncing back and/or removing fall damage.<br>
 * yDistance is < 0, the middle of the player is above a slime block (to) +
 * on ground. This might be a micro-move onto ground.
 *
 * @param player
 * @param verticalBounce
 * @param from
 * @param to
 * @param data
 * @param cc
 */
private void processBounce(final Player player, final double fromY, final double toY, final BounceType bounceType, final int tick, final boolean debug, final MovingData data, final MovingConfig cc, final IPlayerData pData) {
    // Prepare velocity.
    final double fallDistance = MovingUtil.getRealisticFallDistance(player, fromY, toY, data, pData);
    final double base = Math.sqrt(fallDistance) / 3.3;
    // Ancient Greek technology with gravity added.
    double effect = Math.min(Magic.BOUNCE_VERTICAL_MAX_DIST, base + Math.min(base / 10.0, Magic.GRAVITY_MAX));
    final PlayerMoveData lastMove = data.playerMoves.getFirstPastMove();
    if (effect > 0.415 && lastMove.toIsValid) {
        // Extra cap by last y distance(s).
        final double max_gain = Math.abs(lastMove.yDistance < 0.0 ? Math.min(lastMove.yDistance, toY - fromY) : (toY - fromY)) - Magic.GRAVITY_SPAN;
        if (max_gain < effect) {
            effect = max_gain;
            if (debug) {
                debug(player, "Cap bounce effect by recent y-distances.");
            }
        }
    }
    if (bounceType == BounceType.STATIC_PAST_AND_PUSH) {
    /*
             * TODO: Find out if relevant and handle here (still use maximum
             * cap, but not by y-distance.). Could be the push part is only
             * necessary if the player is pushed upwards without prepared
             * bounce.
             */
    }
    // (Actually observed max. is near 3.5.) TODO: Why 3.14 then?
    if (debug) {
        debug(player, "Set bounce effect (dY=" + fallDistance + " / " + bounceType + "): " + effect);
    }
    data.noFallSkipAirCheck = true;
    // Just bounce for now.
    data.verticalBounce = new SimpleEntry(tick, effect, FLAGS_VELOCITY_BOUNCE_BLOCK, 1);
}
Also used : PlayerMoveData(fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData) SimpleEntry(fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry)

Aggregations

SimpleEntry (fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry)7 PlayerMoveData (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData)3 AccountEntry (fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry)3 MovingConfig (fr.neatmonster.nocheatplus.checks.moving.MovingConfig)1 MovingData (fr.neatmonster.nocheatplus.checks.moving.MovingData)1 BlockChangeEntry (fr.neatmonster.nocheatplus.compat.blocks.changetracker.BlockChangeTracker.BlockChangeEntry)1 IPlayerData (fr.neatmonster.nocheatplus.players.IPlayerData)1 RichBoundsLocation (fr.neatmonster.nocheatplus.utilities.location.RichBoundsLocation)1 UUID (java.util.UUID)1 Location (org.bukkit.Location)1