Attempt to patch up VehicleEnvelope (in-air, boat).
* Issues remain with "moved too quickly" interfering (TP loop with waterfall/alternating, possible to escape). * Not sure the previous modeling makes sense at all with allowing friction now.
This commit is contained in:
parent
442634793c
commit
e5458465ac
|
@ -45,7 +45,7 @@ public class MagicVehicle {
|
|||
public static final double boatLowGravitySpeed = 0.5;
|
||||
/** Simplistic approach for falling speed more than 0.5. */
|
||||
public static final double boatGravityMinAtSpeed = Magic.GRAVITY_MIN / 12.0;
|
||||
public static final double boatGravityMax = (Magic.GRAVITY_MAX + Magic.GRAVITY_SPAN) / 2.0;
|
||||
public static final double boatGravityMax = (Magic.GRAVITY_MAX + Magic.GRAVITY_MIN) / 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;
|
||||
|
|
|
@ -39,12 +39,16 @@ public class VehicleMoveData extends PlayerMoveData {
|
|||
/** Lazily set for minecarts. */
|
||||
public boolean fromOnRails, toOnRails;
|
||||
|
||||
// Special properties added by checks.
|
||||
/** Special condition, the move coordinates may be wrong. */
|
||||
public boolean specialCondition = false;
|
||||
|
||||
@Override
|
||||
protected void resetBase() {
|
||||
// Vehicle properties.
|
||||
vehicleId = null;
|
||||
vehicleType = null;
|
||||
fromOnRails = toOnRails = false;
|
||||
fromOnRails = toOnRails = specialCondition = false;
|
||||
// Super class last, because it'll set valid to true in the end.
|
||||
super.resetBase();
|
||||
}
|
||||
|
|
|
@ -225,7 +225,8 @@ public class VehicleChecks extends CheckListener {
|
|||
// Treat like VehicleUpdateEvent.
|
||||
onVehicleUpdate(vehicle, vehicleType, player, true, data);
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final Location vLoc = vehicle.getLocation();
|
||||
data.vehicleConsistency = MoveConsistency.getConsistency(from, to, vLoc);
|
||||
// TODO: Consider TeleportUtil.forceMount or similar.
|
||||
|
@ -235,10 +236,12 @@ public class VehicleChecks extends CheckListener {
|
|||
// checks.moving.vehicle.enforcelocation
|
||||
// TODO: Permission + bypass check(s) !
|
||||
return vLoc;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// (Skip chunk loading here.)
|
||||
aux.resetPositionsAndMediumProperties(player, vLoc, data, cc);
|
||||
return null;
|
||||
|
@ -253,7 +256,7 @@ public class VehicleChecks extends CheckListener {
|
|||
* @param event
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onVehicleUpdate(final VehicleUpdateEvent event) {
|
||||
public void b(final VehicleUpdateEvent event) {
|
||||
// TODO: VehicleUpdateEvent. How to track teleporting of the vehicle?
|
||||
// TODO: Track just left vehicle/entity positions otherwise (on tick + vehicle update)?
|
||||
// TODO: No problem: (?) update 'authorized state' if no player passenger.
|
||||
|
@ -517,6 +520,7 @@ public class VehicleChecks extends CheckListener {
|
|||
if (data.timeSinceSetBack == 0 || thisMove.to.hashCode() == data.lastSetBackHash) {
|
||||
// TODO: This is a hot fix, to prevent a set back loop. Depends on having only the morepackets set back for vehicles.
|
||||
// TODO: Perhaps might want to add || !data.equalsAnyVehicleSetBack(to)
|
||||
thisMove.specialCondition = true;
|
||||
if (data.debug) {
|
||||
debug(player, "Skip envelope check on first move after set back acknowledging the set back with an odd starting point (from).");
|
||||
}
|
||||
|
@ -889,25 +893,25 @@ public class VehicleChecks extends CheckListener {
|
|||
useLoc2.setWorld(null);
|
||||
}
|
||||
|
||||
// @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=false)
|
||||
// public void onEntityTeleport(final EntityTeleportEvent event) {
|
||||
// final Entity entity = event.getEntity();
|
||||
// if (entity == null) {
|
||||
// return;
|
||||
// }
|
||||
// final Player player = CheckUtils.getFirstPlayerPassenger(entity);
|
||||
// if (player != null && MovingData.getData(player).debug) {
|
||||
// debug(player, "Entity teleport with player as passenger: " + entity + " from=" + event.getFrom() + " to=" + event.getTo());
|
||||
// }
|
||||
// else {
|
||||
// // Log if the debug config flag is set.
|
||||
// final World world = LocUtil.getFirstWorld(event.getFrom(), event.getTo());
|
||||
// if (world != null && MovingConfig.getConfig(world.getName()).debug) {
|
||||
// // TODO: Keep (expiring) entity data, for recently mounted, possibly for fight checks too?
|
||||
// debug(null, "Entity teleport: " + entity + " from=" + event.getFrom() + " to=" + event.getTo());
|
||||
// @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=false)
|
||||
// public void onEntityTeleport(final EntityTeleportEvent event) {
|
||||
// final Entity entity = event.getEntity();
|
||||
// if (entity == null) {
|
||||
// return;
|
||||
// }
|
||||
// final Player player = passengerUtil.getFirstPlayerPassenger(entity);
|
||||
// if (player != null && MovingData.getData(player).debug) {
|
||||
// debug(player, "Entity teleport with player as passenger: " + entity + " from=" + event.getFrom() + " to=" + event.getTo());
|
||||
// }
|
||||
// else {
|
||||
// // Log if the debug config flag is set.
|
||||
// final World world = LocUtil.getFirstWorld(event.getFrom(), event.getTo());
|
||||
// if (world != null && MovingConfig.getConfig(world.getName()).debug) {
|
||||
// // TODO: Keep (expiring) entity data, for recently mounted, possibly for fight checks too?
|
||||
// debug(null, "Entity teleport: " + entity + " from=" + event.getFrom() + " to=" + event.getTo());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Intended for vehicle-move events.
|
||||
|
|
|
@ -32,6 +32,7 @@ import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
|||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.location.setback.SetBackEntry;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.magic.MagicVehicle;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
|
@ -403,7 +404,7 @@ public class VehicleEnvelope extends Check {
|
|||
// Enforce falling speed (vdist) envelope by in-air phase count.
|
||||
// Slow falling (vdist), do not bind to descending in general.
|
||||
final double minDescend = -(thisMove.yDistance < -MagicVehicle.boatLowGravitySpeed ? MagicVehicle.boatGravityMinAtSpeed : MagicVehicle.boatGravityMin) * (checkDetails.canJump ? Math.max(data.sfJumpPhase - MagicVehicle.maxJumpPhaseAscend, 0) : data.sfJumpPhase);
|
||||
final double maxDescend = -MagicVehicle.boatGravityMax * data.sfJumpPhase - 0.5;
|
||||
final double maxDescend = getInAirMaxDescend(thisMove, data);
|
||||
if (data.sfJumpPhase > (checkDetails.canJump ? MagicVehicle.maxJumpPhaseAscend : 1)
|
||||
&& thisMove.yDistance > Math.max(minDescend, -checkDetails.gravityTargetSpeed)) {
|
||||
tags.add("slow_fall_vdist");
|
||||
|
@ -422,13 +423,30 @@ public class VehicleEnvelope extends Check {
|
|||
checkDetails.checkDescendMuch = checkDetails.checkAscendMuch = false; // (Full envelope has been checked.)
|
||||
}
|
||||
if (data.debug) {
|
||||
debugDetails.add("minDescend: " + minDescend);
|
||||
debugDetails.add("maxDescend: " + maxDescend);
|
||||
}
|
||||
}
|
||||
return violation;
|
||||
}
|
||||
|
||||
private double getInAirMaxDescend(final PlayerMoveData thisMove, final MovingData data) {
|
||||
double maxDescend = -MagicVehicle.boatGravityMax * data.sfJumpPhase - 0.5;
|
||||
final VehicleMoveData firstPastMove = data.vehicleMoves.getFirstPastMove();
|
||||
if (thisMove.yDistance < maxDescend && firstPastMove.toIsValid) {
|
||||
if (firstPastMove.yDistance < maxDescend && firstPastMove.yDistance > maxDescend * 2.5) {
|
||||
// Simply continue with friction.
|
||||
maxDescend = Math.min(maxDescend, firstPastMove.yDistance - (MagicVehicle.boatGravityMax + MagicVehicle.boatGravityMin) / 2.0);
|
||||
debugDetails.add("desc_frict");
|
||||
}
|
||||
else if (firstPastMove.specialCondition && thisMove.yDistance > -1.5) {
|
||||
// After special set-back confirm move, observed ca. -1.1.
|
||||
maxDescend = Math.min(maxDescend, -1.5);
|
||||
debugDetails.add("desc_special");
|
||||
}
|
||||
}
|
||||
return maxDescend;
|
||||
}
|
||||
|
||||
private boolean maxDistHorizontal(final VehicleMoveData thisMove, final double maxDistanceHorizontal) {
|
||||
if (thisMove.hDistance > maxDistanceHorizontal) {
|
||||
tags.add("hdist");
|
||||
|
|
Loading…
Reference in New Issue