diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MediumLiftOff.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MediumLiftOff.java new file mode 100644 index 00000000..ae458648 --- /dev/null +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MediumLiftOff.java @@ -0,0 +1,17 @@ +package fr.neatmonster.nocheatplus.checks.moving; + +/** + * This is for tracking what medium a player has been in before lift-off. + * @author mc_dev + * + */ +public enum MediumLiftOff { + /** Ordinary ground, normal jumping. */ + GROUND, + /** + * Used for reduced jumping height. Until known better this is used for fluids, cobweb. + */ + LIMIT_JUMP, + + // TODO: Might add NO_JUMP (web?). +} diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index a9801618..96ef33a2 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -69,6 +69,11 @@ public class MovingData extends ACheckData { playersMap.clear(); } + /** + * Assume the player has to move on ground or so to lift off. TODO: Test, might be better ground. + */ + private static final MediumLiftOff defaultMediumLiftOff = MediumLiftOff.LIMIT_JUMP; + // Violation levels. public double creativeFlyVL = 0D; public double morePacketsVL = 0D; @@ -90,6 +95,7 @@ public class MovingData extends ACheckData { public double toX = Double.MAX_VALUE, toY, toZ; /** To/from was ground or web or assumed to be etc. */ public boolean toWasReset, fromWasReset; + public MediumLiftOff mediumLiftOff = defaultMediumLiftOff; // Data of the creative check. public boolean creativeFlyPreviousRefused; @@ -165,6 +171,7 @@ public class MovingData extends ACheckData { toWasReset = fromWasReset = false; // TODO: true maybe sfHoverTicks = -1; sfDirty = false; + mediumLiftOff = defaultMediumLiftOff; } /** @@ -192,7 +199,32 @@ public class MovingData extends ACheckData { toWasReset = fromWasReset = false; // TODO: true maybe sfHoverTicks = -1; sfDirty = false; + mediumLiftOff = defaultMediumLiftOff; } + + /** + * Just reset the "last locations" references. + * @param loc + */ + public void resetPositions(final Location loc){ + if (loc == null) resetPositions(Double.MAX_VALUE, 0, 0); + else resetPositions(loc.getX(), loc.getY(), loc.getZ()); + } + + /** + * Just reset the "last locations" references. + * @param x + * @param y + * @param z + */ + public void resetPositions(final double x, final double y, final double z) { + fromX = toX = x; + fromY = toY = y; + fromZ = toZ = z; + sfLastYDist = Double.MAX_VALUE; + sfDirty = false; + mediumLiftOff = defaultMediumLiftOff; + } /** * Clear accounting data. @@ -223,29 +255,6 @@ public class MovingData extends ACheckData { noFallSkipAirCheck = false; } - /** - * Just reset the "last locations" references. - * @param loc - */ - public void resetPositions(final Location loc){ - if (loc == null) resetPositions(Double.MAX_VALUE, 0, 0); - else resetPositions(loc.getX(), loc.getY(), loc.getZ()); - } - - /** - * Just reset the "last locations" references. - * @param x - * @param y - * @param z - */ - public void resetPositions(final double x, final double y, final double z) { - fromX = toX = x; - fromY = toY = y; - fromZ = toZ = z; - sfLastYDist = Double.MAX_VALUE; - sfDirty = false; - } - /** * Convenience method. * @param loc diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 638368c0..8d32543e 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -277,8 +277,11 @@ public class SurvivalFly extends Check { else{ // Check traveled y-distance, orientation is air + jumping + velocity (as far as it gets). vAllowedDistance = (!(fromOnGround || data.noFallAssumeGround) && !toOnGround ? 1.45D : 1.35D) + data.verticalFreedom; - final int maxJumpPhase; - if (data.jumpAmplifier > 0){ + int maxJumpPhase; + if (data.mediumLiftOff == MediumLiftOff.LIMIT_JUMP){ + maxJumpPhase = 3; + } + else if (data.jumpAmplifier > 0){ vAllowedDistance += 0.5 + data.jumpAmplifier - 1.0; maxJumpPhase = (int) (9 + (data.jumpAmplifier - 1.0) * 6); } @@ -340,6 +343,27 @@ public class SurvivalFly extends Check { } // Set data for normal move or violation without cancel (cancel would have returned above) + + // Check lift-off medium. + // TODO: Web might be NO_JUMP ! + if (to.isInLiquid() || to.isInWeb()){ + data.mediumLiftOff = MediumLiftOff.LIMIT_JUMP; + } + else if (resetTo){ + // TODO: This might allow jumping on vines etc., but should do for the moment. + data.mediumLiftOff = MediumLiftOff.GROUND; + } + else if (from.isInLiquid() || from.isInWeb()){ + data.mediumLiftOff = MediumLiftOff.LIMIT_JUMP; + } + else if (resetFrom || data.noFallAssumeGround){ + // TODO: Where exactly to put noFallAssumeGround ? + data.mediumLiftOff = MediumLiftOff.GROUND; + } + else{ + // Keep medium. + // TODO: Is above stairs ? + } // Apply reset conditions. data.toWasReset = resetTo || data.noFallAssumeGround;