From 4fd834ed25f3f4122dca17307ebcb74b8f51300f Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 8 Nov 2015 23:36:10 +0100 Subject: [PATCH] Workarounds for moving down (-stream) in lava. --- .../nocheatplus/checks/moving/SurvivalFly.java | 18 ++++++++++++++++-- .../nocheatplus/utilities/BlockProperties.java | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index a190b9b3..1c961528 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -84,7 +84,7 @@ public class SurvivalFly extends Check { /** Friction for water (default). */ public static final double FRICTION_MEDIUM_WATER = 0.89; /** Friction for lava. */ - public static final double FRICTION_MEDIUM_LAVA = 0.25; // TODO + public static final double FRICTION_MEDIUM_LAVA = 0.25; // TODO: Rather 0.4 ? // TODO: Friction by block to walk on (horizontal only, possibly to be in BlockProperties rather). @@ -1595,7 +1595,7 @@ public class SurvivalFly extends Check { data.sfNoLowJump = true; // Expected envelopes. - final double baseSpeed = swimBaseSpeedV(); + final double baseSpeed = swimBaseSpeedV(); // TODO: Lava? final double yDistAbs = Math.abs(yDistance); // TODO: Later also cover things like a sudden stop. @@ -1658,6 +1658,20 @@ public class SurvivalFly extends Check { ) { return new double[]{yDistance, 0.0}; } + // Lava rather. + else if (data.lastFrictionVertical < 0.65 // (Random, but smaller than water.) + && ( + // Moving downstream. + data.lastYDist < 0.0 && yDistance > -0.5 && yDistance < data.lastYDist + && data.lastYDist - yDistance < GRAVITY_MIN && BlockProperties.isDownStream(from, to) + // Mix of gravity and base speed [careful: relates to water base speed]. + || data.lastYDist < 0.0 && yDistance > -baseSpeed - GRAVITY_MAX && yDistance < data.lastYDist + && data.lastYDist - yDistance > GRAVITY_SPAN + && Math.abs(data.lastYDist + baseSpeed) < 0.25 * baseSpeed + ) + ) { + return new double[]{yDistance, 0.0}; + } } // TODO: Also DOWNSTREAM !? diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index d3bf32c6..ec3253d5 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -2658,6 +2658,20 @@ public class BlockProperties { return true; } + /** + * Check if the move given by from and to is leading downstream. Currently + * only the x-z move is regarded, no envelope/consistency checks are + * performed here, such as checking if the block is liquid at all, nor if + * the move makes sense. performed here. + * + * @param from + * @param to + * @return + */ + public static final boolean isDownStream(final PlayerLocation from, final PlayerLocation to) { + return isDownStream(from.getBlockCache(), from.getBlockX(), from.getBlockY(), from.getBlockZ(), from.getData(), to.getX() - from.getX(), to.getZ() - from.getZ()); + } + /** * Check if a move determined by xDistance and zDistance is leading down stream. * @param access