Skip to content

Add Diagonal Jumps #2142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8c71c13
initial commit
Zephreo Oct 23, 2020
fec227b
preliminary parkour system
Zephreo Oct 24, 2020
d11afc6
wall detection
Zephreo Oct 24, 2020
84107ff
Fix rounding issue
Zephreo Oct 24, 2020
d927115
add setting
Zephreo Oct 26, 2020
80cf1c5
better cost calculations
Zephreo Oct 27, 2020
3ec51e7
various improvements (check desc)
Zephreo Oct 27, 2020
463594c
angle considerations
Zephreo Oct 28, 2020
de78e3b
slab jumps
Zephreo Oct 28, 2020
44d11aa
4 block jumps
Zephreo Oct 29, 2020
08809a6
improved 4 block jump reliability
Zephreo Oct 29, 2020
4c79da2
neos
Zephreo Nov 1, 2020
b046899
soulsand jumps
Zephreo Nov 3, 2020
c0c76c0
add Momentum setting and some adjustments
Zephreo Nov 3, 2020
6b1486b
cleanup comments
Zephreo Nov 3, 2020
88fe5b9
cleanup
Zephreo Nov 3, 2020
a2e7a13
remove old comments
Zephreo Nov 3, 2020
3420f14
comments
Zephreo Nov 3, 2020
b9953f6
various improvements
Zephreo Nov 4, 2020
982b4a6
reduce complexity
Zephreo Nov 4, 2020
09a14d9
cleanup
Zephreo Nov 5, 2020
ed127e0
improve motion prediction
Zephreo Nov 10, 2020
8f495e1
logging fix
Zephreo Nov 10, 2020
3b9372b
general fixes
Zephreo Nov 10, 2020
456fcdb
Momentum/Stairs/Various improvements
Zephreo Nov 13, 2020
cdac863
fixes
Zephreo Nov 16, 2020
e55ffed
fix not sprinting in some cases
Zephreo Nov 16, 2020
da73322
fix neos/speed adjustments/other
Zephreo Nov 17, 2020
9985160
changed momentum cancelling
Zephreo Nov 18, 2020
d4bd136
fix bottom slabs
Zephreo Nov 20, 2020
fc0020a
fix north neos
Zephreo Nov 20, 2020
dd27507
improve jump choice
Zephreo Nov 22, 2020
25c36b8
oops remove log
Zephreo Nov 22, 2020
314f43e
greatly improve momentum jump reliability
Zephreo Nov 25, 2020
05d9566
parkour place compatability
Zephreo Nov 25, 2020
1b86bff
parkour place improvements
Zephreo Nov 25, 2020
80c981b
fix small collision issue
Zephreo Nov 25, 2020
4a489d2
suggestion for zephreo to make multi destination parkour
leijurv Nov 25, 2020
f008299
whoops, that was dumb
leijurv Nov 25, 2020
da4fb0c
changes to 2x1+1 jumps
Zephreo Nov 26, 2020
0860e28
Merge remote-tracking branch 'upstream/zephreo-suggestion'
Zephreo Nov 26, 2020
6b7f4b1
finish merge with multres system
Zephreo Nov 26, 2020
683af2e
fixes
Zephreo Nov 28, 2020
261a871
fix impossible moves during calc
Zephreo Nov 29, 2020
d6a1e34
better Moves.java for multimovements
Zephreo Nov 29, 2020
cd25d87
oops
Zephreo Nov 29, 2020
4e68367
small changes
Zephreo Dec 3, 2020
4e5ae2a
some changes
Zephreo Dec 7, 2020
6d5552f
Entry Locations
Zephreo Dec 21, 2020
500df96
fix 3x1 jumps using EDGE
Zephreo Jan 3, 2021
353bf1b
removed logs
Zephreo Jan 3, 2021
3d8d17f
minor formatting
Zephreo Jan 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ classes/
# Copyright Files
!/.idea/copyright/Baritone.xml
!/.idea/copyright/profiles_settings.xml
/bin/
14 changes: 14 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@ public final class Settings {
*/
public final Setting<Boolean> allowParkourPlace = new Setting<>(false);

/**
* Allows baritone to consider parkour jumps at more angles.
* <p>
* Only takes effect if allowParkour is also enabled.
*/
public final Setting<Boolean> allowParkourAdv = new Setting<>(false);

/**
* Allows baritone to consider 4 block jumps and neo jumps. Unreliable.
* <p>
* Only takes effect if allowParkour and allowParkourAdv is also enabled.
*/
public final Setting<Boolean> allowParkourMomentumOrNeo = new Setting<>(false);

/**
* For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
*/
Expand Down
36 changes: 36 additions & 0 deletions src/api/java/baritone/api/utils/VecUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;

/**
Expand Down Expand Up @@ -113,4 +114,39 @@ public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
return distanceToCenter(pos, entity.posX, pos.getY() + 0.5, entity.posZ);
}

/**
* Adds vec1 and vec2
*
* @param vec1 The initial vector
* @param vec2 The vector to add
* @return A new resultant vector
*/
public static Vec3i add(Vec3i vec1, Vec3i vec2) {
return new Vec3i(vec1.getX() + vec2.getX(), vec1.getY() + vec2.getY(), vec1.getZ() + vec2.getZ());
}

/**
* Adds vec1 and vec2
*
* @param vec1 The initial vector
* @param vec2X The x value to add to the vector
* @param vec2Y The y value to add to the vector
* @param vec2Z The z value to add to the vector
* @return A new resultant vector
*/
public static Vec3i add(Vec3i vec1, int vec2X, int vec2Y, int vec2Z) {
return new Vec3i(vec1.getX() + vec2X, vec1.getY() + vec2Y, vec1.getZ() + vec2Z);
}

/**
* Subtracts vec2 from vec1; vec1 - vec2
*
* @param vec1 The initial vector
* @param vec2 The vector to subtract
* @return A new resultant vector
*/
public static Vec3i subtract(Vec3i vec1, Vec3i vec2) {
return new Vec3i(vec1.getX() - vec2.getX(), vec1.getY() - vec2.getY(), vec1.getZ() - vec2.getZ());
}
}
92 changes: 49 additions & 43 deletions src/main/java/baritone/pathing/calc/AStarPathFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
bestHeuristicSoFar[i] = startNode.estimatedCostToGoal;
bestSoFar[i] = startNode;
}
MutableMoveResult res = new MutableMoveResult();
MutableMoveResult mutableMoveResult = new MutableMoveResult();
BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world.getWorldBorder());
long startTime = System.currentTimeMillis();
boolean slowPath = Baritone.settings().slowPath.value;
Expand Down Expand Up @@ -112,52 +112,58 @@ protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
if (currentNode.y + moves.yOffset > 256 || currentNode.y + moves.yOffset < 0) {
continue;
}
res.reset();
moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z, res);
numMovementsConsidered++;
double actionCost = res.cost;
if (actionCost >= ActionCosts.COST_INF) {
continue;
}
if (actionCost <= 0 || Double.isNaN(actionCost)) {
throw new IllegalStateException(moves + " calculated implausible cost " + actionCost);
}
// check destination after verifying it's not COST_INF -- some movements return a static IMPOSSIBLE object with COST_INF and destination being 0,0,0 to avoid allocating a new result for every failed calculation
if (moves.dynamicXZ && !worldBorder.entirelyContains(res.x, res.z)) { // see issue #218
continue;
}
if (!moves.dynamicXZ && (res.x != newX || res.z != newZ)) {
throw new IllegalStateException(moves + " " + res.x + " " + newX + " " + res.z + " " + newZ);
}
if (!moves.dynamicY && res.y != currentNode.y + moves.yOffset) {
throw new IllegalStateException(moves + " " + res.y + " " + (currentNode.y + moves.yOffset));
}
long hashCode = BetterBlockPos.longHash(res.x, res.y, res.z);
if (isFavoring) {
// see issue #18
actionCost *= favoring.calculate(hashCode);
}
PathNode neighbor = getNodeAtPosition(res.x, res.y, res.z, hashCode);
double tentativeCost = currentNode.cost + actionCost;
if (neighbor.cost - tentativeCost > minimumImprovement) {
neighbor.previous = currentNode;
neighbor.cost = tentativeCost;
neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal;
if (neighbor.isOpen()) {
openSet.update(neighbor);
} else {
openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there
mutableMoveResult.reset();
moves.apply(calcContext, currentNode.x, currentNode.y, currentNode.z, mutableMoveResult);
MutableMoveResult res = mutableMoveResult;
while (res != null) {
numMovementsConsidered++;
double actionCost = res.cost;
if (actionCost >= ActionCosts.COST_INF) {
res = res.getNext();
continue;
}
if (actionCost <= 0 || Double.isNaN(actionCost)) {
throw new IllegalStateException(moves + " calculated implausible cost " + actionCost);
}
// check destination after verifying it's not COST_INF -- some movements return a static IMPOSSIBLE object with COST_INF and destination being 0,0,0 to avoid allocating a new result for every failed calculation
if (moves.dynamicXZ && !worldBorder.entirelyContains(res.x, res.z)) { // see issue #218
res = res.getNext();
continue;
}
if (!moves.dynamicXZ && (res.x != newX || res.z != newZ)) {
throw new IllegalStateException(moves + " " + res.x + " " + newX + " " + res.z + " " + newZ);
}
for (int i = 0; i < COEFFICIENTS.length; i++) {
double heuristic = neighbor.estimatedCostToGoal + neighbor.cost / COEFFICIENTS[i];
if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) {
bestHeuristicSoFar[i] = heuristic;
bestSoFar[i] = neighbor;
if (failing && getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) {
failing = false;
if (!moves.dynamicY && res.y != currentNode.y + moves.yOffset) {
throw new IllegalStateException(moves + " " + res.y + " " + (currentNode.y + moves.yOffset));
}
long hashCode = BetterBlockPos.longHash(res.x, res.y, res.z);
if (isFavoring) {
// see issue #18
actionCost *= favoring.calculate(hashCode);
}
PathNode neighbor = getNodeAtPosition(res.x, res.y, res.z, hashCode);
double tentativeCost = currentNode.cost + actionCost;
if (neighbor.cost - tentativeCost > minimumImprovement) {
neighbor.previous = currentNode;
neighbor.cost = tentativeCost;
neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal;
if (neighbor.isOpen()) {
openSet.update(neighbor);
} else {
openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there
}
for (int i = 0; i < COEFFICIENTS.length; i++) {
double heuristic = neighbor.estimatedCostToGoal + neighbor.cost / COEFFICIENTS[i];
if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) {
bestHeuristicSoFar[i] = heuristic;
bestSoFar[i] = neighbor;
if (failing && getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) {
failing = false;
}
}
}
}
res = res.getNext();
}
}
}
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/baritone/pathing/calc/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,22 @@ private boolean assembleMovements() {

private Movement runBackwards(BetterBlockPos src, BetterBlockPos dest, double cost) {
for (Moves moves : Moves.values()) {
Movement move = moves.apply0(context, src);
if (move.getDest().equals(dest)) {
// have to calculate the cost at calculation time so we can accurately judge whether a cost increase happened between cached calculation and real execution
// however, taking into account possible favoring that could skew the node cost, we really want the stricter limit of the two
// so we take the minimum of the path node cost difference, and the calculated cost
move.override(Math.min(move.calculateCost(context), cost));
return move;
if (moves.canHaveMultipleDestinations()) {
for (Movement move : moves.getMultiDestination(context, src)) {
if (move.getDest().equals(dest)) {
move.override(Math.min(move.calculateCost(context), cost));
return move;
}
}
} else {
Movement move = moves.apply0(context, src);
if (move.getDest().equals(dest)) {
// have to calculate the cost at calculation time so we can accurately judge whether a cost increase happened between cached calculation and real execution
// however, taking into account possible favoring that could skew the node cost, we really want the stricter limit of the two
// so we take the minimum of the path node cost difference, and the calculated cost
move.override(Math.min(move.calculateCost(context), cost));
return move;
}
}
}
// this is no longer called from bestPathSoFar, now it's in postprocessing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class CalculationContext {
public final boolean allowBreak;
public final boolean allowParkour;
public final boolean allowParkourPlace;
public final boolean allowParkourAdv;
public final boolean allowParkourMomentumOrNeo;
public final boolean allowJumpAt256;
public final boolean allowParkourAscend;
public final boolean assumeWalkOnWater;
Expand Down Expand Up @@ -91,6 +93,8 @@ public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
this.allowBreak = Baritone.settings().allowBreak.value;
this.allowParkour = Baritone.settings().allowParkour.value;
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
this.allowParkourAdv = Baritone.settings().allowParkourAdv.value;
this.allowParkourMomentumOrNeo = Baritone.settings().allowParkourMomentumOrNeo.value;
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/baritone/pathing/movement/MovementHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.IBlockAccess;

import java.util.Optional;
Expand Down Expand Up @@ -446,6 +447,22 @@ static void moveTowards(IPlayerContext ctx, MovementState state, BlockPos pos) {
)).setInput(Input.MOVE_FORWARD, true);
}

/**
* Moves towards a double vector's coordinates.
*
* @param ctx Player context
* @param state Movement State
* @param pos Position to move to
*/
static void moveTowards(IPlayerContext ctx, MovementState state, Vec3d pos) {
state.setTarget(new MovementTarget(
new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
pos,
ctx.playerRotations()).getYaw(), ctx.player().rotationPitch),
false
)).setInput(Input.MOVE_FORWARD, true);
}

/**
* Returns whether or not the specified block is
* water, regardless of whether or not it is flowing.
Expand Down
Loading