mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-07 00:08:20 +01:00
Test: adapt NoFall for fluids.
This commit is contained in:
parent
6a7f14077c
commit
2e3982e2d4
@ -479,9 +479,10 @@ public class MovingListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
// Don't care if a player isn't inside the vehicle, for movements that are very high distance or to another
|
// Don't care if a player isn't inside the vehicle, for movements that are very high distance or to another
|
||||||
// world (such that it is very likely the event dataFactory was modified by another plugin before we got it).
|
// world (such that it is very likely the event dataFactory was modified by another plugin before we got it).
|
||||||
|
final Location to = event.getTo();
|
||||||
if (event.getVehicle().getPassenger() == null || !(event.getVehicle().getPassenger() instanceof Player)
|
if (event.getVehicle().getPassenger() == null || !(event.getVehicle().getPassenger() instanceof Player)
|
||||||
|| !event.getFrom().getWorld().equals(event.getTo().getWorld())
|
|| !event.getFrom().getWorld().equals(to.getWorld())
|
||||||
|| event.getFrom().distanceSquared(event.getTo()) > 400D)
|
|| event.getFrom().distanceSquared(to) > 400D)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final Player player = (Player) event.getVehicle().getPassenger();
|
final Player player = (Player) event.getVehicle().getPassenger();
|
||||||
@ -492,10 +493,11 @@ public class MovingListener implements Listener {
|
|||||||
final MovingData data = MovingData.getData(player);
|
final MovingData data = MovingData.getData(player);
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
player.setFallDistance(0.0f);
|
player.setFallDistance(0.0f);
|
||||||
|
data.noFallY = to.getY();
|
||||||
|
|
||||||
if (morePacketsVehicle.isEnabled(player))
|
if (morePacketsVehicle.isEnabled(player))
|
||||||
// If the player is handled by the more packets vehicle check, execute it.
|
// If the player is handled by the more packets vehicle check, execute it.
|
||||||
newTo = morePacketsVehicle.check(player, event.getFrom(), event.getTo());
|
newTo = morePacketsVehicle.check(player, event.getFrom(), to);
|
||||||
else
|
else
|
||||||
// Otherwise we need to clear his dataFactory.
|
// Otherwise we need to clear his dataFactory.
|
||||||
data.clearMorePacketsData();
|
data.clearMorePacketsData();
|
||||||
|
@ -55,16 +55,28 @@ public class NoFall extends Check {
|
|||||||
if (player.isInsideVehicle()){
|
if (player.isInsideVehicle()){
|
||||||
// Emergency fix attempt:
|
// Emergency fix attempt:
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
player.setFallDistance(0.0f);
|
data.noFallFallDistance = 0D;
|
||||||
data.noFallY = to.getY();
|
data.noFallY = to.getY();
|
||||||
|
player.setFallDistance(0.0f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the player has just started falling, is falling into a liquid, in web or is on a ladder.
|
// If the player has just started falling, is falling into a liquid, in web or is on a ladder.
|
||||||
if (to.isInLiquid() || to.isInWeb() || to.isOnLadder()){
|
if (to.isInLiquid()){
|
||||||
|
// TODO: check if it is deep liquid
|
||||||
|
final double dist = data.noFallY - to.getY();
|
||||||
|
if (dist > 0 ){
|
||||||
|
// TODO: ? different concept, at least distinguish water, lava, flowing.
|
||||||
|
data.noFallY = to.getY() + dist * 0.7;
|
||||||
|
data.noFallFallDistance *= 0.7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (to.isInWeb() || to.isOnLadder()){
|
||||||
// Reset his fall distance.
|
// Reset his fall distance.
|
||||||
data.noFallFallDistance = 0D;
|
data.noFallFallDistance = 0D;
|
||||||
data.noFallY = to.getY();
|
data.noFallY = to.getY();
|
||||||
|
player.setFallDistance(0.0f);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,8 +94,8 @@ public class NoFall extends Check {
|
|||||||
&& (data.noFallWasOnGroundClient || !data.noFallOnGroundClient)) {
|
&& (data.noFallWasOnGroundClient || !data.noFallOnGroundClient)) {
|
||||||
|
|
||||||
// Calculate the fall damages to be dealt.
|
// Calculate the fall damages to be dealt.
|
||||||
final int fallDamage = (int) data.noFallFallDistance - 2;
|
final int fallDamage = (int) data.noFallFallDistance - 2; // Blocks - 3 ?
|
||||||
// TODO: set accurate fall damage (feather falling etc).
|
// TODO: set accurate fall damage (Boots with feather falling or protection).
|
||||||
|
|
||||||
if (fallDamage > 0) {
|
if (fallDamage > 0) {
|
||||||
// Add the fall distance to the violation level.
|
// Add the fall distance to the violation level.
|
||||||
@ -127,10 +139,9 @@ public class NoFall extends Check {
|
|||||||
} else
|
} else
|
||||||
// Reward the player by lowering his violation level.
|
// Reward the player by lowering his violation level.
|
||||||
data.noFallVL *= 0.95D;
|
data.noFallVL *= 0.95D;
|
||||||
} else
|
} else
|
||||||
// Reward the player by lowering his violation level.
|
// Reward the player by lowering his violation level.
|
||||||
data.noFallVL *= 0.95D;
|
data.noFallVL *= 0.95D;
|
||||||
|
|
||||||
if (data.noFallOnGroundServer){
|
if (data.noFallOnGroundServer){
|
||||||
data.noFallY = to.getY();
|
data.noFallY = to.getY();
|
||||||
data.noFallFallDistance = 0.0;
|
data.noFallFallDistance = 0.0;
|
||||||
@ -161,7 +172,12 @@ public class NoFall extends Check {
|
|||||||
final MovingData data = MovingData.getData(player.getBukkitEntity());
|
final MovingData data = MovingData.getData(player.getBukkitEntity());
|
||||||
|
|
||||||
// Attempt to fix vehicle problems:
|
// Attempt to fix vehicle problems:
|
||||||
if (player.getBukkitEntity().isInsideVehicle()) return;
|
if (player.getBukkitEntity().isInsideVehicle()){
|
||||||
|
// rely on vehicle-move for most.
|
||||||
|
data.noFallFallDistance = 0.0;
|
||||||
|
data.noFallY = player.locY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Suggestion: use reference y position in data and calculate difference to that one!
|
// Suggestion: use reference y position in data and calculate difference to that one!
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user