From 25499d2f0ea0fa3de95a5753b5bb075e2016b859 Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 1 May 2016 15:22:17 +0200 Subject: [PATCH] Corrections and adaptions for moving.vehicle.envelope and boats. * Set-back handling: Use the last safe-medium set back for now. * Parameters/magic. --- .../checks/moving/magic/MagicVehicle.java | 5 +++-- .../moving/vehicle/VehicleEnvelope.java | 20 +++++++++++-------- .../nocheatplus/utilities/TeleportUtil.java | 4 +++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/MagicVehicle.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/MagicVehicle.java index c807d9b0..fccef764 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/MagicVehicle.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/MagicVehicle.java @@ -42,7 +42,7 @@ public class MagicVehicle { public static final double maxAscend = 0.27; public static final double boatGravityMin = Magic.GRAVITY_MIN / 2.0; - public static final double boatGravityMax = Magic.GRAVITY_MAX + Magic.GRAVITY_SPAN; + public static final double boatGravityMax = (Magic.GRAVITY_MAX + Magic.GRAVITY_SPAN) / 2.0; /** The speed up to which gravity mechanics roughly work. */ public static final double boatVerticalFallTarget = 3.7; public static final double boatMaxBackToSurfaceAscend = 3.25; @@ -75,11 +75,12 @@ public class MagicVehicle { private static boolean oddInAirDescend(final VehicleMoveData thisMove, final double minDescend, final double maxDescend, final MovingData data) { // TODO: Guard by past move tracking, instead of minDescend and maxDescend. // (Try individual if this time, let JIT do the rest.) - if (thisMove.vDistance < 2.0 * minDescend && thisMove.vDistance > 2.0 * maxDescend + if (data.sfJumpPhase > 54 && thisMove.vDistance < 2.0 * minDescend && thisMove.vDistance > 2.0 * maxDescend // TODO: Past move tracking. // TODO: Fall distances? && data.ws.use(WRPT.W_M_V_ENV_INAIR_SKIP) ) { + // (In-air count usually > 60.) return true; } return false; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java index 2d167338..ec30f4c6 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java @@ -84,12 +84,12 @@ public class VehicleEnvelope extends Check { final ViolationData vd = new ViolationData(this, player, data.vehicleEnvelopeVL, 1, cc.vehicleEnvelopeActions); vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+")); if (executeActions(vd).willCancel()) { - return data.vehicleSetBacks.getValidMidTermEntry(); + return data.vehicleSetBacks.getValidSafeMediumEntry(); } } else { data.vehicleEnvelopeVL *= 0.99; // Random cool down for now. - data.vehicleSetBacks.setSafeMediumEntry(to); // TODO: Set only if it is safe to set. Set on monitor rather. + // Do not set a set-back here. } return null; } @@ -211,6 +211,7 @@ public class VehicleEnvelope extends Check { final boolean toIsSafeMedium = to.isInWater() || to.isOnGround() || to.isInWeb(); final boolean inAir = !fromIsSafeMedium && !toIsSafeMedium; // TODO: Split code to methods. + // TODO: Get extended liquid specs (allow confine to certain flags, here: water). Contains info if water is only flowing down, surface properties (non liquid blocks?), still water. if (from.isInWeb()) { // TODO: Check anything? if (data.debug) { @@ -276,11 +277,11 @@ public class VehicleEnvelope extends Check { // return true; // } // } - // Slow falling (vdist). + // Enforce falling speed (vdist) envelope by in-air phase count. + // Slow falling (vdist), do not bind to descending in general. final double minDescend = -MagicVehicle.boatGravityMin * data.sfJumpPhase; final double maxDescend = -MagicVehicle.boatGravityMax * data.sfJumpPhase - 0.5; - if (data.sfJumpPhase > 1 && thisMove.vDistance > -MagicVehicle.boatVerticalFallTarget - && thisMove.vDistance > minDescend) { + if (data.sfJumpPhase > 1 && thisMove.vDistance > Math.max(minDescend, -MagicVehicle.boatVerticalFallTarget)) { tags.add("slow_fall_vdist"); violation = true; } @@ -295,6 +296,10 @@ public class VehicleEnvelope extends Check { violation = false; checkDescendMuch = checkAscendMuch = false; // (Full envelope has been checked.) } + if (data.debug) { + debugDetails.add("minDescend: " + minDescend); + debugDetails.add("maxDescend: " + maxDescend); + } } } else { @@ -302,7 +307,8 @@ public class VehicleEnvelope extends Check { if (data.debug) { debugDetails.add("?-?"); } - // TODO: Something needed here? + // TODO: Clearly overlaps other cases. + // TODO: Skipped vehicle move events happen here as well (...). if (!toIsSafeMedium) { // TODO: At least do something here? } @@ -340,8 +346,6 @@ public class VehicleEnvelope extends Check { data.ws.resetConditions(WRPT.G_RESET_NOTINAIR); } data.vehicleSetBacks.setLastMoveEntry(to); - // TODO: Workaround - reset moving set-backs. - } return violation; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TeleportUtil.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TeleportUtil.java index 2e377c22..c9eafddb 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TeleportUtil.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TeleportUtil.java @@ -9,6 +9,7 @@ import org.bukkit.util.Vector; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.moving.MovingData; import fr.neatmonster.nocheatplus.checks.moving.location.LocUtil; +import fr.neatmonster.nocheatplus.checks.workaround.WRPT; public class TeleportUtil { @@ -65,7 +66,8 @@ public class TeleportUtil { data.prepareSetBack(location); playerTeleported = player.teleport(LocUtil.clone(location)); data.resetTeleported(); // Just in case. - // TODO: Consider resetting player set-backs. + // Workarounds. + data.ws.resetConditions(WRPT.G_RESET_NOTINAIR); // Allow re-use of certain workarounds. Hack/shouldbedoneelsewhere? player.setVelocity(new Vector(0.0, 0.0, 0.0)); // TODO: Likely not relevant, should remove. // TODO: Magic 1.0, plus is this valid with horse, dragon... if (playerIsPassenger && playerTeleported && vehicleTeleported && player.getLocation().distance(vehicle.getLocation(useLoc)) < 1.0) {