diff --git a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java index c7632ac08c..c500c96c7b 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java +++ b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java @@ -347,7 +347,7 @@ private void check(PositionUpdate update) { player.packetStateData.lastRiptide = currentTime; } - SimpleCollisionBox steppingOnBB = GetBoundingBox.getCollisionBoxForPlayer(player, player.x, player.y, player.z).expand(0.03).offset(0, -1, 0); + SimpleCollisionBox steppingOnBB = GetBoundingBox.getCollisionBoxForPlayer(player, player.x, player.y, player.z).expand(player.getMovementThreshold()).offset(0, -1, 0); Collisions.hasMaterial(player, steppingOnBB, (pair) -> { WrappedBlockState data = pair.first(); if (data.getType() == StateTypes.SLIME_BLOCK && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8)) { @@ -411,8 +411,8 @@ private void check(PositionUpdate update) { player.uncertaintyHandler.lastUnderwaterFlyingHack.reset(); } - boolean couldBeStuckSpeed = Collisions.checkStuckSpeed(player, 0.03); - boolean couldLeaveStuckSpeed = player.isPointThree() && Collisions.checkStuckSpeed(player, -0.03); + boolean couldBeStuckSpeed = Collisions.checkStuckSpeed(player, player.getMovementThreshold()); + boolean couldLeaveStuckSpeed = player.isPointThree() && Collisions.checkStuckSpeed(player, -player.getMovementThreshold()); player.uncertaintyHandler.claimingLeftStuckSpeed = !player.compensatedEntities.getSelf().inVehicle() && player.stuckSpeedMultiplier.getX() < 1 && !couldLeaveStuckSpeed; if (couldBeStuckSpeed) { diff --git a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java index 9369ab39fd..0dcc9228ab 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java @@ -268,13 +268,14 @@ public void updateSwimming() { private void moveTowardsClosestSpace(double xPosition, double zPosition) { - player.boundingBox = player.boundingBox.expand(0.03, 0, 0.03); // 0.03... thanks mojang! + double movementThreshold = player.getMovementThreshold(); + player.boundingBox = player.boundingBox.expand(movementThreshold, 0, movementThreshold); // 0.03... thanks mojang! if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_14)) { moveTowardsClosestSpaceModern(xPosition, zPosition); } else { moveTowardsClosestSpaceLegacy(xPosition, zPosition); } - player.boundingBox = player.boundingBox.expand(-0.03, 0, -0.03); + player.boundingBox = player.boundingBox.expand(-movementThreshold, 0, -movementThreshold); } // Mojang is incompetent and this will push the player out a lot when using elytras diff --git a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java index e07882b7b8..70a1d3f017 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java @@ -127,12 +127,13 @@ public void handleChangeBlock(int x, int y, int z, WrappedBlockState state) { // Calculate head hitters. Take a shortcut by checking if the player doesn't intersect with this block, but does // when the player vertically moves upwards by 0.03! This is equivalent to the move method, but MUCH faster. - SimpleCollisionBox slightlyExpanded = normalBox.copy().expand(0.03, 0, 0.03); - if (!slightlyExpanded.isIntersected(data) && slightlyExpanded.offset(0, 0.03, 0).isIntersected(data)) { + double movementThreshold = player.getMovementThreshold(); + SimpleCollisionBox slightlyExpanded = normalBox.copy().expand(movementThreshold, 0, movementThreshold); + if (!slightlyExpanded.isIntersected(data) && slightlyExpanded.offset(0, movementThreshold, 0).isIntersected(data)) { headHitter = true; } - SimpleCollisionBox pointThreeBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.x, player.y - 0.03, player.z, 0.66f, 1.86f); + SimpleCollisionBox pointThreeBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.x, player.y - movementThreshold, player.z, 0.66f, 1.86f); if ((Materials.isWater(player.getClientVersion(), state) || stateType == StateTypes.LAVA) && pointThreeBox.isIntersected(new SimpleCollisionBox(x, y, z))) { @@ -212,7 +213,8 @@ public void updatePlayerGravity() { } public void endOfTickTick() { - SimpleCollisionBox pointThreeBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.x, player.y - 0.03, player.z, 0.66f, 1.86f); + double movementThreshold = player.getMovementThreshold(); + SimpleCollisionBox pointThreeBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.x, player.y - movementThreshold, player.z, 0.66f, 1.86f); // Determine the head hitter using the current Y position SimpleCollisionBox oldBB = player.boundingBox; @@ -222,7 +224,7 @@ public void endOfTickTick() { for (float sizes : (player.skippedTickInActualMovement ? new float[]{0.6f, 1.5f, 1.8f} : new float[]{player.pose.height})) { // Try to limit collisions to be as small as possible, for maximum performance player.boundingBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.x, player.y + (sizes - 0.01f), player.z, 0.6f, 0.01f); - headHitter = headHitter || Collisions.collide(player, 0, 0.03, 0).getY() != 0.03; + headHitter = headHitter || Collisions.collide(player, 0, movementThreshold, 0).getY() != movementThreshold; } player.boundingBox = oldBB; diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java b/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java index ef85a67b7f..323da20ff3 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java @@ -61,13 +61,14 @@ public static boolean slowCouldPointThreeHitGround(GrimPlayer player, double x, SimpleCollisionBox oldBB = player.boundingBox; player.boundingBox = GetBoundingBox.getBoundingBoxFromPosAndSize(player, x, y, z, 0.6f, 0.06f); - double posXZ = Collisions.collide(player, 0.03, -0.03, 0.03).getY(); - double negXNegZ = Collisions.collide(player, -0.03, -0.03, -0.03).getY(); - double posXNegZ = Collisions.collide(player, 0.03, -0.03, -0.03).getY(); - double posZNegX = Collisions.collide(player, -0.03, -0.03, 0.03).getY(); + double movementThreshold = player.getMovementThreshold(); + double posXZ = Collisions.collide(player, movementThreshold, -movementThreshold, movementThreshold).getY(); + double negXNegZ = Collisions.collide(player, -movementThreshold, -movementThreshold, -movementThreshold).getY(); + double posXNegZ = Collisions.collide(player, movementThreshold, -movementThreshold, -movementThreshold).getY(); + double posZNegX = Collisions.collide(player, -movementThreshold, -movementThreshold, movementThreshold).getY(); player.boundingBox = oldBB; - return negXNegZ != -0.03 || posXNegZ != -0.03 || posXZ != -0.03 || posZNegX != -0.03; + return negXNegZ != -movementThreshold || posXNegZ != -movementThreshold || posXZ != -movementThreshold || posZNegX != -movementThreshold; } // Call this when there isn't uncertainty on the Y axis