use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData in project NoCheatPlus by NoCheatPlus.
the class VehicleEnvelope method getInAirMaxDescend.
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;
}
use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData in project NoCheatPlus by NoCheatPlus.
the class PassengerUtil method teleportPlayerPassenger.
/**
* Teleport and set as passenger.
*
* @param player
* @param vehicle
* @param location
* @param vehicleTeleported
* @param data
* @return
*/
private final boolean teleportPlayerPassenger(final Player player, final Entity vehicle, final Location location, final boolean vehicleTeleported, final MovingData data, final boolean debug) {
final boolean playerTeleported;
if (player.isOnline() && !player.isDead()) {
// Mask player teleport as a set back.
data.prepareSetBack(location);
playerTeleported = player.teleport(LocUtil.clone(location), BridgeMisc.TELEPORT_CAUSE_CORRECTION_OF_POSITION);
// Cleanup, just in case.
data.resetTeleported();
// Workarounds.
// Allow re-use of certain workarounds. Hack/shouldbedoneelsewhere?
data.ws.resetConditions(WRPT.G_RESET_NOTINAIR);
if (playerTeleported && vehicleTeleported && player.getLocation(useLoc2).distance(vehicle.getLocation(useLoc)) < 1.5) {
// NOTE: VehicleEnter fires, unknown TP fires.
if (!handleVehicle.getHandle().addPassenger(player, vehicle)) {
// TODO: What?
}
// TODO: Set backs get invalidated somewhere, likely on an extra unknown TP. Use data.isVehicleSetBack in MovingListener/teleport.
if (data.vehicleSetBacks.getFirstValidEntry(location) == null) {
// At least ensure one of the entries has to match the location we teleported the vehicle to.
if (debug) {
CheckUtils.debug(player, CheckType.MOVING_VEHICLE, "No set back is matching the vehicle location that it has just been set back to. Reset all lazily to: " + location);
}
data.vehicleSetBacks.resetAllLazily(location);
}
// Set this location as past move.
final VehicleMoveData firstPastMove = data.vehicleMoves.getFirstPastMove();
if (!firstPastMove.valid || firstPastMove.toIsValid || !TrigUtil.isSamePos(firstPastMove.from, location)) {
final MovingConfig cc = DataManager.getGenericInstance(player, MovingConfig.class);
NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class).resetVehiclePositions(vehicle, location, data, cc);
}
}
} else {
playerTeleported = false;
}
data.isVehicleSetBack = false;
return playerTeleported;
}
use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData in project NoCheatPlus by NoCheatPlus.
the class VehicleChecks method checkVehicleMove.
/**
* Uses both useLoc1 and useLoc2, possibly others too.
*
* @param vehicle
* @param vehicleType
* @param from
* May be null, may be ignored anyway. Might be used as
* firstPastMove, in case of data missing.
* @param to
* May be null, may be ignored anyway.
* @param player
* @param fake
* @param data
* @param pData2
* @param debug
*/
private void checkVehicleMove(final Entity vehicle, final EntityType vehicleType, final Location from, final Location to, final Player player, final boolean fake, final MovingData data, final IPlayerData pData, boolean debug) {
// TODO: Detect teleportation and similar.
final MovingConfig cc = pData.getGenericInstance(MovingConfig.class);
// Exclude certain vehicle types.
if (cc.ignoredVehicles.contains(vehicleType)) {
// 100% legit.
data.clearVehicleData();
return;
}
final World world = vehicle.getWorld();
final VehicleMoveInfo moveInfo = aux.useVehicleMoveInfo();
// vehicleLocation: Track when it could become null! -> checkIllegal -> no setback or null location.
final Location vehicleLocation = vehicle.getLocation(moveInfo.useLoc);
final VehicleMoveData firstPastMove = data.vehicleMoves.getFirstPastMove();
// Ensure firstPastMove is valid.
if (!firstPastMove.valid) {
// Determine the best location to use as past move.
// TODO: Could also check the set backs for plausible entries, however that would lead to a violation by default. Could use an indicator.
final Location refLoc = from == null ? vehicleLocation : from;
MovingUtil.ensureChunksLoaded(player, refLoc, "vehicle move (no past move)", data, cc, pData);
aux.resetVehiclePositions(vehicle, refLoc, data, cc);
if (pData.isDebugActive(checkType)) {
// TODO: Might warn instead.
debug(player, "Missing past move data, set to: " + firstPastMove.from);
}
}
// Determine best locations to use.
// (Currently always use firstPastMove and vehicleLocation.)
final Location useFrom = LocUtil.set(useLoc1, world, firstPastMove.toIsValid ? firstPastMove.to : firstPastMove.from);
final Location useTo = vehicleLocation;
// Initialize moveInfo.
if (vehicleType == EntityType.PIG) {
// TODO: Special cases by config rather.
// TODO: Likely will fail with passable.
moveInfo.setExtendFullWidth(0.52);
}
// TODO: Test yOnGround at 0.13 instead of xz-margin
moveInfo.set(vehicle, useFrom, useTo, // TODO: Extra config.
vehicleType == EntityType.PIG ? Math.max(0.13, cc.yOnGround) : cc.yOnGround);
moveInfo.setExtendFullWidth(0.0);
// Check coordinates, just in case.
if (checkIllegal(moveInfo.from, moveInfo.to)) {
// Likely superfluous.
// TODO: Obviously applies under unknown conditions.
SetBackEntry newTo = data.vehicleSetBacks.getValidSafeMediumEntry();
if (newTo == null) {
recoverVehicleSetBack(player, vehicle, vehicleLocation, moveInfo, data, cc);
}
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, CheckType.MOVING_VEHICLE) + "Illegal coordinates on checkVehicleMove: from: " + from + " , to: " + to);
setBack(player, vehicle, newTo, data, cc, pData);
aux.returnVehicleMoveInfo(moveInfo);
return;
}
// Ensure chunks are loaded.
MovingUtil.ensureChunksLoaded(player, useFrom, useTo, firstPastMove, "vehicle move", cc, pData);
// Initialize currentMove.
final VehicleMoveData thisMove = data.vehicleMoves.getCurrentMove();
thisMove.set(moveInfo.from, moveInfo.to);
// Prepare all extra properties by default for now.
MovingUtil.prepareFullCheck(moveInfo.from, moveInfo.to, thisMove, cc.yOnGround);
thisMove.setExtraVehicleProperties(vehicle);
// Call checkVehicleMove for actual checks.
checkVehicleMove(vehicle, vehicleType, vehicleLocation, world, moveInfo, thisMove, firstPastMove, player, fake, data, cc, pData);
// Cleanup.
aux.returnVehicleMoveInfo(moveInfo);
}
use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData in project NoCheatPlus by NoCheatPlus.
the class MovingData method resetVehiclePositions.
/**
* Invalidate all past vehicle moves data and set last position if not null.
*
* @param loc
*/
public void resetVehiclePositions(final RichEntityLocation loc) {
// TODO: Other properties (convenience, e.g. set back?) ?
vehicleMoves.invalidate();
if (loc != null) {
final VehicleMoveData lastMove = vehicleMoves.getFirstPastMove();
// Always set with extra properties.
lastMove.setWithExtraProperties(loc);
final Entity entity = loc.getEntity();
lastMove.vehicleId = entity.getUniqueId();
lastMove.vehicleType = entity.getType();
}
}
Aggregations