mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-11 22:20:52 +01:00
WTF elytra + end rod.
(Remove wrong pre condition for elytra: have end rod somewhere.) (Prepare using survivalfly for elytra, not sure if will do so.)
This commit is contained in:
parent
48bf891bb4
commit
27abbfc25f
@ -358,7 +358,7 @@ public class MovingConfig extends ACheckConfig {
|
||||
// TODO: INCONSISTENT.
|
||||
return modelGameMode;
|
||||
}
|
||||
if (Bridge1_9.isReadyForElytra(player)) {
|
||||
if (Bridge1_9.isWearingElytra(player)) {
|
||||
return flyingModelElytra;
|
||||
}
|
||||
// Default by game mode.
|
||||
|
@ -966,13 +966,11 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
// Test for exceptions.
|
||||
if (Bridge1_9.isWearingElytra(player) && thisMove.hDistance > defaultAmount) {
|
||||
// Allowing the same speed won't always work on elytra (still increasing, differing modeling on client side with motXYZ).
|
||||
// (Doesn't seem to be overly effective.)
|
||||
final MoveData pastMove1 = data.moveData.get(1);
|
||||
if (pastMove1.toIsValid && lastMove.modelFlying != null && pastMove1.modelFlying != null
|
||||
&& thisMove.yDistance < Magic.GLIDE_DESCEND_PHASE_MIN
|
||||
&& lastMove.yDistance < Magic.GLIDE_DESCEND_PHASE_MIN
|
||||
&& pastMove1.yDistance < Magic.GLIDE_DESCEND_PHASE_MIN
|
||||
&& Math.abs(pastMove1.yDistance - lastMove.yDistance) < Magic.GLIDE_DESCEND_GAIN_MAX
|
||||
&& Math.abs(lastMove.yDistance - thisMove.yDistance) < Magic.GLIDE_DESCEND_GAIN_MAX
|
||||
&& Magic.glideVerticalGainEnvelope(thisMove.yDistance, lastMove.yDistance)
|
||||
&& Magic.glideVerticalGainEnvelope(lastMove.yDistance, pastMove1.yDistance)
|
||||
&& lastMove.hDistance > pastMove1.hDistance && thisMove.hDistance > lastMove.hDistance
|
||||
&& Math.abs(lastMove.hDistance - pastMove1.hDistance) < Magic.GLIDE_HORIZONTAL_GAIN_MAX
|
||||
&& Math.abs(thisMove.hDistance - lastMove.hDistance) < Magic.GLIDE_HORIZONTAL_GAIN_MAX) {
|
||||
|
@ -730,10 +730,22 @@ public class SurvivalFly extends Check {
|
||||
// Consider friction.
|
||||
// TODO: Invalidation mechanics.
|
||||
// TODO: Friction model for high speeds?
|
||||
thisMove.hAllowedDistance = Math.max(hAllowedDistance, lastMove.hDistance * friction);
|
||||
} else {
|
||||
thisMove.hAllowedDistance = hAllowedDistance;
|
||||
hAllowedDistance = Math.max(hAllowedDistance, lastMove.hDistance * friction);
|
||||
}
|
||||
// if (hAllowedDistance < thisMove.hDistance) {
|
||||
// // After failure recovery.
|
||||
// if (lastMove.toIsValid) {
|
||||
// final double hDistDiff = thisMove.hDistance - lastMove.hDistance;
|
||||
// // Elytra.
|
||||
// if (hDistDiff < Magic.GLIDE_HORIZONTAL_GAIN_MAX
|
||||
// && Magic.inAir(thisMove) && Bridge1_9.isWearingElytra(player)) {
|
||||
// // (Abrupt hdist stops aren't covered yet anyway.)
|
||||
// hAllowedDistance = thisMove.hDistance;
|
||||
// data.nextFrictionHorizontal = Magic.FRICTION_MEDIUM_AIR;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
thisMove.hAllowedDistance = hAllowedDistance;
|
||||
return thisMove.hAllowedDistance;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class Magic {
|
||||
/**
|
||||
* Somewhat arbitrary horizontal speed gain maximum for advance glide phase.
|
||||
*/
|
||||
public static final double GLIDE_HORIZONTAL_GAIN_MAX = GRAVITY_SPAN;
|
||||
public static final double GLIDE_HORIZONTAL_GAIN_MAX = GRAVITY_MAX / 2.0;
|
||||
|
||||
// Vertical speeds/modifiers.
|
||||
public static final double climbSpeed = WALK_SPEED * 1.3; // TODO: Check if the factor is needed!
|
||||
@ -59,10 +59,16 @@ public class Magic {
|
||||
*/
|
||||
public static final double GLIDE_DESCEND_PHASE_MIN = -Magic.GRAVITY_MAX - Magic.GRAVITY_SPAN;
|
||||
/**
|
||||
* Somewhat arbitrary, advanced glide phase, maximum descend speed gain.
|
||||
* This value is positive.
|
||||
* Somewhat arbitrary, advanced glide phase, maximum descend speed gain
|
||||
* (absolute value is negative).
|
||||
*/
|
||||
public static final double GLIDE_DESCEND_GAIN_MAX = GRAVITY_MAX;
|
||||
public static final double GLIDE_DESCEND_GAIN_MAX_NEG = -GRAVITY_MAX;
|
||||
/**
|
||||
* Somewhat arbitrary, advanced glide phase, maximum descend speed gain
|
||||
* (absolute value is positive, a negative gain seen in relation to the
|
||||
* moving direction).
|
||||
*/
|
||||
public static final double GLIDE_DESCEND_GAIN_MAX_POS = GRAVITY_ODD / 1.95;
|
||||
|
||||
// On-ground.
|
||||
public static final double Y_ON_GROUND_MIN = 0.00001;
|
||||
@ -176,7 +182,7 @@ public class Magic {
|
||||
* Not strictly the latest move in MovingData.
|
||||
* @return
|
||||
*/
|
||||
static boolean inAir(final MoveData thisMove) {
|
||||
public static boolean inAir(final MoveData thisMove) {
|
||||
return !thisMove.touchedGround && !thisMove.from.resetCond && !thisMove.to.resetCond;
|
||||
}
|
||||
|
||||
@ -271,4 +277,18 @@ public class Magic {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced glide phase vertical gain envelope.
|
||||
* @param yDistance
|
||||
* @param previousYDistance
|
||||
* @return
|
||||
*/
|
||||
public static boolean glideVerticalGainEnvelope(final double yDistance, final double previousYDistance) {
|
||||
return // Sufficient speed of descending.
|
||||
yDistance < GLIDE_DESCEND_PHASE_MIN && previousYDistance < GLIDE_DESCEND_PHASE_MIN
|
||||
// Controlled difference.
|
||||
&& yDistance - previousYDistance > GLIDE_DESCEND_GAIN_MAX_NEG
|
||||
&& yDistance - previousYDistance < GLIDE_DESCEND_GAIN_MAX_POS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.LiftOffEnvelope;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.MoveData;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
|
||||
public class MagicAir {
|
||||
@ -338,6 +337,7 @@ public class MagicAir {
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static boolean oddElytra(final double yDistance, final double yDistDiffEx, final MoveData lastMove, final MovingData data) {
|
||||
// Organize cases differently here, at the cost of reaching some nesting level, in order to see if it's better to overview.
|
||||
final MoveData thisMove = data.thisMove;
|
||||
@ -351,12 +351,12 @@ public class MagicAir {
|
||||
if (yDistChange < 0.0) {
|
||||
// pastMove1 valid, decreasing speed envelope like above.
|
||||
if (pastMove1.toIsValid && pastMove1.yDistance < 0.0) {
|
||||
final double lastDecrease = lastMove.yDistance - pastMove1.yDistance;
|
||||
final double lastYDistChange = lastMove.yDistance - pastMove1.yDistance;
|
||||
// Increase falling speed from past to last.
|
||||
if (lastDecrease < 0.0) {
|
||||
if (lastYDistChange < 0.0) {
|
||||
// Relate sum of decrease to gravity somehow.
|
||||
// TODO: Inaugurate by the one below?
|
||||
if (Math.abs(yDistChange + lastDecrease) > Magic.GRAVITY_ODD / 2.0) {
|
||||
if (Math.abs(yDistChange + lastYDistChange) > Magic.GRAVITY_ODD / 2.0) {
|
||||
// TODO: Might further test for a workaround count down or relate to total gain / jump phase.
|
||||
return true;
|
||||
}
|
||||
@ -365,13 +365,10 @@ public class MagicAir {
|
||||
}
|
||||
// Independently of increasing/decreasing.
|
||||
// Gliding possibly.
|
||||
if (thisMove.yDistance < Magic.GLIDE_DESCEND_PHASE_MIN
|
||||
&& lastMove.yDistance < Magic.GLIDE_DESCEND_PHASE_MIN
|
||||
&& Math.abs(yDistChange) < Magic.GLIDE_DESCEND_GAIN_MAX) {
|
||||
// Restrict to early falling.
|
||||
if (data.sfJumpPhase < 20) {
|
||||
return true;
|
||||
}
|
||||
if (Magic.glideVerticalGainEnvelope(thisMove.yDistance, lastMove.yDistance)) {
|
||||
// Restrict to early falling, or higher speeds.
|
||||
// (Further restrictions hardly grip, observed: jump phase > 40, yDistance at -0.214)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -415,10 +412,10 @@ public class MagicAir {
|
||||
// Odd behavior with moving up or (slightly) down, accounting for more than one past move.
|
||||
return true;
|
||||
}
|
||||
if (Bridge1_9.isWearingElytra(from.getPlayer()) && MagicAir.oddElytra(yDistance, yDistDiffEx, lastMove, data)) {
|
||||
// Odd behavior with/after wearing elytra.
|
||||
return true;
|
||||
}
|
||||
// if (Bridge1_9.isWearingElytra(from.getPlayer()) && MagicAir.oddElytra(yDistance, yDistDiffEx, lastMove, data)) {
|
||||
// // Odd behavior with/after wearing elytra.
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class MovingUtil {
|
||||
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY)
|
||||
&& (Bridge1_9.getLevitationAmplifier(player) == Double.NEGATIVE_INFINITY || fromLocation.isInLiquid())
|
||||
&& (!Bridge1_9.isReadyForElytra(player) || fromLocation.isOnGroundOrResetCond())
|
||||
&& (!Bridge1_9.isWearingElytra(player) || fromLocation.isOnGroundOrResetCond())
|
||||
&& !player.hasPermission(Permissions.MOVING_SURVIVALFLY);
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,6 @@ public class Bridge1_9 {
|
||||
return PotionUtil.getPotionEffectAmplifier(player, LEVITATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has an elytra equipped and is holding an end rod. This
|
||||
* doesn't check for other conditions, like if the player is in air.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static boolean isReadyForElytra(final Player player) {
|
||||
// TODO: Generic jet-pack / potion support (triggers + model configs).
|
||||
return END_ROD != null && ELYTRA != null && isWearingElytra(player) && hasItemInAnyHand(player, END_ROD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just test if the player has elytra equipped in the chest plate slot. The
|
||||
* player may or may not be holding an end rod in either hand.
|
||||
@ -70,8 +58,13 @@ public class Bridge1_9 {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWearingElytra(final Player player) {
|
||||
final ItemStack stack = player.getInventory().getChestplate();
|
||||
return stack != null && stack.getType() == ELYTRA;
|
||||
if (ELYTRA == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
final ItemStack stack = player.getInventory().getChestplate();
|
||||
return stack != null && stack.getType() == ELYTRA;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user