Unchecked attempt at fixing 1.8 compat issues

This commit is contained in:
Rammelkast committed 2020-08-04 10:16:21 +02:00
1 parent 7caf7376ba
commit a59a4baf28
5 files changed
+26 -13

No files matched your search

@@ -66,9 +66,8 @@ public class FlightCheck {
return PASS;
int minAirTicks = 13;
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
minAirTicks += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 3;
}
if (player.hasPotionEffect(PotionEffectType.JUMP))
minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3;
if (movementManager.halfMovementHistoryCounter > 25)
minAirTicks += 5;
@@ -86,10 +86,10 @@ public class SpeedCheck {
}
// Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED))
predict += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D;
predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
// Adjust for jump boost effects
if (player.hasPotionEffect(PotionEffectType.JUMP))
predict += (player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.05D;
predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
// Adjust for custom walking speed
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
@@ -136,7 +136,7 @@ public class SpeedCheck {
limit *= 1.05D;
// Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.0225D;
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
// Adjust for slabs
if (movementManager.halfMovementHistoryCounter > 15)
limit *= 2.0D;
@@ -183,7 +183,7 @@ public class SpeedCheck {
limit *= 1.1D;
// Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.06D;
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice
if (!Utilities.couldBeOnIce(movingTowards))
@@ -258,7 +258,7 @@ public class SpeedCheck {
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
if (player.hasPotionEffect(PotionEffectType.JUMP))
base += (player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.2D;
base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
return base;
}
@@ -68,7 +68,7 @@ public class WaterWalkCheck {
double minAbsMotionY = 0.12D;
if (player.hasPotionEffect(PotionEffectType.SPEED))
minAbsMotionY += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D;
minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
@@ -227,10 +227,12 @@ public final class Utilities {
}
public static boolean isHalfblock(Block block) {
BoundingBox box = block.getBoundingBox();
double height = box.getMaxY() - box.getMinY();
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
return true;
if (!VersionUtil.isBountifulUpdate()) {
BoundingBox box = block.getBoundingBox();
double height = box.getMaxY() - box.getMinY();
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
return true;
}
return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW;
}
@@ -134,4 +134,16 @@ public class VersionUtil {
return effect.getType().equals(PotionEffectType.LEVITATION);
}
public static int getPotionLevel(Player player, PotionEffectType type) {
if (isBountifulUpdate()) {
for (PotionEffect effect : player.getActivePotionEffects())
if (effect.getType() == type)
return effect.getAmplifier() + 1;
return 0;
}
if (player.hasPotionEffect(PotionEffectType.JUMP))
return player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1;
return 0;
}
}