Skip to content

Commit dec9f75

Browse files
SurvivalFly - Snow Fixes
1 parent 063f9fd commit dec9f75

File tree

1 file changed

+33
-28
lines changed
  • NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player

1 file changed

+33
-28
lines changed

NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/SurvivalFly.java

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public class SurvivalFly extends Check {
7575
private static final int bunnyHopMax = 10;
7676
/** Divisor vs. last hDist for minimum slow down. */
7777
private static final double bunnyDivFriction = 160.0; // Rather in-air, blocks would differ by friction.
78+
79+
public boolean snowFix;
7880

7981

8082

@@ -291,10 +293,15 @@ else if (multiMoveCount == 0 && thisMove.from.onGround && !lastMove.touchedGroun
291293
data.sfNoLowJump = true;
292294
}
293295
if ((from.getBlockFlags() & BlockProperties.F_GROUND_HEIGHT) != 0) {
294-
data.newHDist = true;
296+
data.newHDist = true;
295297
} else {
296-
data.newHDist = false;
298+
data.newHDist = false;
297299
}
300+
if ((from.getBlockFlags() & BlockProperties.F_HEIGHT_8_INC) != 0) {
301+
snowFix = true;
302+
} else {
303+
snowFix = false;
304+
}
298305

299306
//////////////////////
300307
// Horizontal move.
@@ -924,9 +931,12 @@ else if (thisMove.from.inLiquid && thisMove.to.inLiquid) {
924931
}
925932
// (Friction is used as is.)
926933
} else if (data.newHDist) {
927-
hAllowedDistance = 0.345D;
934+
hAllowedDistance = 0.345D;
928935

929-
} else if (player.isRiptiding() || (data.timeRiptiding + 3000 > now)) {
936+
} else if (snowFix) {
937+
hAllowedDistance = 0.377D;
938+
}
939+
else if (player.isRiptiding() || (data.timeRiptiding + 3000 > now)) {
930940
hAllowedDistance = Magic.modRiptide * thisMove.walkSpeed * cc.survivalFlySpeedingSpeed / 100D;
931941
}
932942
// Allows faster speed for player when swimming above water since from -> to does not seem to detect correctly
@@ -1141,12 +1151,15 @@ else if (resetFrom || thisMove.touchedGroundWorkaround) {
11411151
}
11421152
strictVdistRel = false;
11431153
} else if (player.isRiptiding() || (data.timeRiptiding + 3000 > now)) {
1144-
vAllowedDistance = lastMove.yDistance * 5.0D;
1145-
strictVdistRel = false;
1146-
} else if (data.bedLeaveTime + 500 > now && yDistance < 0.45) {
1147-
strictVdistRel = false;
1154+
vAllowedDistance = lastMove.yDistance * 5.0D;
1155+
strictVdistRel = false;
1156+
} else if (data.bedLeaveTime + 500 > now && yDistance < 0.45) {
1157+
strictVdistRel = false;
11481158
vAllowedDistance = yDistance;
1149-
}
1159+
} else if (snowFix) {
1160+
strictVdistRel = false;
1161+
vAllowedDistance = 0.425D;
1162+
}
11501163
else if (lastMove.toIsValid) {
11511164
if (lastMove.yDistance >= -Math.max(Magic.GRAVITY_MAX / 2.0, 1.3 * Math.abs(yDistance)) && lastMove.yDistance <= 0.0
11521165
&& (lastMove.touchedGround || lastMove.to.extraPropertiesValid && lastMove.to.resetCond)) {
@@ -1504,12 +1517,8 @@ private double inAirChecks(final long now, final PlayerLocation from, final Play
15041517
else if (thisMove.verVelUsed == null) { // Only skip if just used.
15051518
// Here yDistance can be negative and positive.
15061519
// if (yDistance != 0.0) {
1507-
if (BlockProperties.isNewLiq(from.getTypeIdBelow())) {
1508-
1509-
} else if (data.timeRiptiding + 500 > now) {
1510-
}
1511-
else if (data.bedLeaveTime + 500 > now && yDistance < 0.45) {
1512-
1520+
if ( (BlockProperties.isNewLiq(from.getTypeIdBelow())) || (data.timeRiptiding + 500 > now) || (data.bedLeaveTime + 500 > now && yDistance < 0.45) || (snowFix) ) {
1521+
// Ignore
15131522
}
15141523
else {
15151524
data.vDistAcc.add((float) yDistance);
@@ -1597,20 +1606,12 @@ private double yDirChange(final PlayerLocation from, final PlayerLocation to,
15971606
// Moving upwards after falling without having touched the ground.
15981607
if (data.bunnyhopDelay < 9 && !((lastMove.touchedGround || lastMove.from.onGroundOrResetCond) && lastMove.yDistance == 0D) && data.getOrUseVerticalVelocity(yDistance) == null) {
15991608
// TODO: adjust limit for bunny-hop.
1600-
if (BlockProperties.isNewLiq(from.getTypeIdBelow())) {
1601-
// Exempts player if they are above a 'newliquid' block (1.13 water blocks)
1602-
// Fixes issue with player swimming above a kelp plant (or related)
1603-
}
1604-
else if (data.timeRiptiding + 1000 > now) {
1605-
1606-
}
1607-
else if (data.bedLeaveTime + 500 > now && yDistance < 0.45) {
1609+
if ( (BlockProperties.isNewLiq(from.getTypeIdBelow())) || (data.timeRiptiding + 500 > now) || (data.bedLeaveTime + 500 > now && yDistance < 0.45) || (snowFix) ) {
16081610

1609-
}
1610-
else {
1611-
vDistanceAboveLimit = Math.max(vDistanceAboveLimit, Math.abs(yDistance));
1611+
} else {
1612+
vDistanceAboveLimit = Math.max(vDistanceAboveLimit, Math.abs(yDistance));
16121613
tags.add("ychincfly");
1613-
}
1614+
}
16141615
}
16151616
else {
16161617
tags.add("ychincair");
@@ -1746,13 +1747,17 @@ else if (Math.abs(zDistance) > 0.485 && Math.abs(zDistance) < 1.025
17461747
// Horizontal buffer.
17471748
// TODO: Consider to confine use to "not in air" and similar.
17481749
if (hDistanceAboveLimit > 0.0 && data.sfHorizontalBuffer > 0.0) {
1749-
// Handle buffer only if moving too far.
1750+
if (snowFix && data.sfHorizontalBuffer == 1) {
1751+
// Ignore
1752+
} else {
1753+
// Handle buffer only if moving too far.
17501754
// Consume buffer.
17511755
tags.add("hbufuse");
17521756
final double amount = Math.min(data.sfHorizontalBuffer, hDistanceAboveLimit);
17531757
hDistanceAboveLimit -= amount;
17541758
// Ensure we never end up below zero.
17551759
data.sfHorizontalBuffer = Math.max(0.0, data.sfHorizontalBuffer - amount);
1760+
}
17561761
}
17571762

17581763
if (player.isRiptiding() || (data.timeRiptiding + 3000 > now)) {

0 commit comments

Comments
 (0)