mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 09:51:32 +01:00
Double.MIN_VALUE is something else. Should be Double.NEGATIVE_INFINITY.
This commit is contained in:
parent
a123e02251
commit
f4727ad3a2
@ -91,13 +91,13 @@ public interface MCAccess {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return Double.MIN_VALUE if not present.
|
* @return Double.NEGATIVE_INFINITY if not present.
|
||||||
*/
|
*/
|
||||||
public double getJumpAmplifier(Player player);
|
public double getJumpAmplifier(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return Double.MIN_VALUE if not present.
|
* @return Double.NEGATIVE_INFINITY if not present.
|
||||||
*/
|
*/
|
||||||
public double getFasterMovementAmplifier(Player player);
|
public double getFasterMovementAmplifier(Player player);
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ public class PotionUtil {
|
|||||||
* Get amplifier for a potion effect.
|
* Get amplifier for a potion effect.
|
||||||
* @param player
|
* @param player
|
||||||
* @param type
|
* @param type
|
||||||
* @return Double.MIN_VALUE if not present, otherwise the maximal amplifier.
|
* @return Double.NEGATIVE_INFINITY if not present, otherwise the maximal amplifier.
|
||||||
*/
|
*/
|
||||||
public static final double getPotionEffectAmplifier(final Player player, final PotionEffectType type) {
|
public static final double getPotionEffectAmplifier(final Player player, final PotionEffectType type) {
|
||||||
if (!player.hasPotionEffect(type)) return Double.MIN_VALUE;
|
if (!player.hasPotionEffect(type)) return Double.NEGATIVE_INFINITY; // TODO: Might not win anything.
|
||||||
final Collection<PotionEffect> effects = player.getActivePotionEffects();
|
final Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||||
double max = Double.MIN_VALUE;
|
double max = Double.NEGATIVE_INFINITY;
|
||||||
for (final PotionEffect effect : effects){
|
for (final PotionEffect effect : effects){
|
||||||
if (effect.getType() == type){
|
if (effect.getType().equals(type)){
|
||||||
max = Math.max(max, effect.getAmplifier());
|
max = Math.max(max, effect.getAmplifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,14 +111,14 @@ public class MCAccessCB2511 implements MCAccess {
|
|||||||
final net.minecraft.server.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getFasterMovementAmplifier(final Player player) {
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
final net.minecraft.server.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,14 +110,14 @@ public class MCAccessCB2512 implements MCAccess{
|
|||||||
final net.minecraft.server.v1_4_5.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_5.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getFasterMovementAmplifier(final Player player) {
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
final net.minecraft.server.v1_4_5.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_5.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,14 +110,14 @@ public class MCAccessCB2545 implements MCAccess{
|
|||||||
final net.minecraft.server.v1_4_6.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_6.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getFasterMovementAmplifier(final Player player) {
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
final net.minecraft.server.v1_4_6.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_6.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,14 +111,14 @@ public class MCAccessCBDev implements MCAccess{
|
|||||||
final net.minecraft.server.v1_4_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getFasterMovementAmplifier(final Player player) {
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
final net.minecraft.server.v1_4_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
final net.minecraft.server.v1_4_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
else return Double.MIN_VALUE;
|
else return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,7 @@ public class CreativeFly extends Check {
|
|||||||
final double speedModifier = mcAccess.getFasterMovementAmplifier(player);
|
final double speedModifier = mcAccess.getFasterMovementAmplifier(player);
|
||||||
final double fSpeed;
|
final double fSpeed;
|
||||||
|
|
||||||
if (speedModifier == Double.MIN_VALUE) fSpeed = 1D;
|
if (speedModifier == Double.NEGATIVE_INFINITY) fSpeed = 1D;
|
||||||
else fSpeed = 1D + 0.2D * (speedModifier + 1D);
|
else fSpeed = 1D + 0.2D * (speedModifier + 1D);
|
||||||
|
|
||||||
final double limitH = cc.creativeFlyHorizontalSpeed / 100D * HORIZONTAL_SPEED * fSpeed;
|
final double limitH = cc.creativeFlyHorizontalSpeed / 100D * HORIZONTAL_SPEED * fSpeed;
|
||||||
|
@ -134,7 +134,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
*/
|
*/
|
||||||
public static final double getJumpAmplifier(final Player player) {
|
public static final double getJumpAmplifier(final Player player) {
|
||||||
final double amplifier = NoCheatPlus.getMCAccess().getJumpAmplifier(player);
|
final double amplifier = NoCheatPlus.getMCAccess().getJumpAmplifier(player);
|
||||||
if (amplifier == Double.MIN_VALUE) return 0D;
|
if (amplifier == Double.NEGATIVE_INFINITY) return 0D;
|
||||||
else return 1D + amplifier;
|
else return 1D + amplifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,13 +489,18 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
moveInfo.set(player, from, to, cc.yOnGround);
|
moveInfo.set(player, from, to, cc.yOnGround);
|
||||||
|
|
||||||
if (cc.debug) {
|
if (cc.debug) {
|
||||||
StringBuilder builder = new StringBuilder(250);
|
final StringBuilder builder = new StringBuilder(250);
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
builder.append(player.getName());
|
builder.append("\n" + player.getName());
|
||||||
builder.append(" " + from.getWorld().getName() + " " + StringUtil.fdec3.format(from.getX()) + (from.getX() == loc.getX() ? "" : ("(" + StringUtil.fdec3.format(loc.getX()) + ")")));
|
builder.append(" " + from.getWorld().getName() + " " + StringUtil.fdec3.format(from.getX()) + (from.getX() == loc.getX() ? "" : ("(" + StringUtil.fdec3.format(loc.getX()) + ")")));
|
||||||
builder.append(", " + StringUtil.fdec3.format(from.getY()) + (from.getY() == loc.getY() ? "" : ("(" + StringUtil.fdec3.format(loc.getY()) + ")")));
|
builder.append(", " + StringUtil.fdec3.format(from.getY()) + (from.getY() == loc.getY() ? "" : ("(" + StringUtil.fdec3.format(loc.getY()) + ")")));
|
||||||
builder.append(", " + StringUtil.fdec3.format(from.getZ()) + (from.getZ() == loc.getZ() ? "" : ("(" + StringUtil.fdec3.format(loc.getZ()) + ")")));
|
builder.append(", " + StringUtil.fdec3.format(from.getZ()) + (from.getZ() == loc.getZ() ? "" : ("(" + StringUtil.fdec3.format(loc.getZ()) + ")")));
|
||||||
builder.append(" -> " + StringUtil.fdec3.format(to.getX()) + ", " + StringUtil.fdec3.format(to.getY()) + ", " + StringUtil.fdec3.format(to.getZ()));
|
builder.append(" -> " + StringUtil.fdec3.format(to.getX()) + ", " + StringUtil.fdec3.format(to.getY()) + ", " + StringUtil.fdec3.format(to.getZ()));
|
||||||
|
final double jump = mcAccess.getJumpAmplifier(player);
|
||||||
|
final double speed = mcAccess.getFasterMovementAmplifier(player);
|
||||||
|
if (speed != Double.NEGATIVE_INFINITY || jump != Double.NEGATIVE_INFINITY){
|
||||||
|
builder.append(" (" + (speed != Double.NEGATIVE_INFINITY ? ("speed=" + speed) : "") + (jump != Double.NEGATIVE_INFINITY ? ("jump=" + jump) : "") + ")");
|
||||||
|
}
|
||||||
System.out.print(builder.toString());
|
System.out.print(builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,8 +519,8 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
|
|
||||||
// Potion effect "Jump".
|
// Potion effect "Jump".
|
||||||
final double jumpAmplifier = MovingListener.getJumpAmplifier(player);
|
final double jumpAmplifier = MovingListener.getJumpAmplifier(player);
|
||||||
if (jumpAmplifier > 0D && cc.debug) System.out.println(player.getName() + " Jump effect: " + jumpAmplifier);
|
|
||||||
if (jumpAmplifier > data.jumpAmplifier) data.jumpAmplifier = jumpAmplifier;
|
if (jumpAmplifier > data.jumpAmplifier) data.jumpAmplifier = jumpAmplifier;
|
||||||
|
// TODO: same for speed (oncemedium is introduced).
|
||||||
|
|
||||||
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
|
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
|
||||||
// general data modifications one for each event.
|
// general data modifications one for each event.
|
||||||
|
@ -536,7 +536,7 @@ public class SurvivalFly extends Check {
|
|||||||
|
|
||||||
// Speed amplifier.
|
// Speed amplifier.
|
||||||
final double speedAmplifier = mcAccess.getFasterMovementAmplifier(player);
|
final double speedAmplifier = mcAccess.getFasterMovementAmplifier(player);
|
||||||
if (speedAmplifier != Double.MIN_VALUE) hAllowedDistance *= 1.0D + 0.2D * (speedAmplifier + 1);
|
if (speedAmplifier != Double.NEGATIVE_INFINITY) hAllowedDistance *= 1.0D + 0.2D * (speedAmplifier + 1);
|
||||||
|
|
||||||
return hAllowedDistance;
|
return hAllowedDistance;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user