Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0378096
Make Baritone not look forward while bridging.
Murat65536 May 11, 2025
1078270
Clean up.
Murat65536 May 14, 2025
cbfb329
Add direction-independent movement.
Murat65536 May 23, 2025
72fb0a0
Add default to switch case.
Murat65536 May 24, 2025
83afa11
Fix.
Murat65536 Jul 2, 2025
a30e3ce
Merge branch 'cabaletta:1.19.4' into bridging-improvements
Murat65536 Jul 6, 2025
1911553
Keep original player movement.
Murat65536 Jul 7, 2025
5d8136b
Simplify.
Murat65536 Jul 13, 2025
8ee7a1e
Small change.
Murat65536 Jul 23, 2025
1a3d302
Clean up.
Murat65536 Jul 23, 2025
9c84fa5
Merge branch 'cabaletta:1.19.4' into bridging-improvements
Murat65536 Jul 23, 2025
1c4c3f3
Merge branch 'cabaletta:1.19.4' into bridging-improvements
Murat65536 Jul 24, 2025
9d33858
Small change.
Murat65536 Jul 25, 2025
2ba448c
Merge remote-tracking branch 'origin/bridging-improvements' into brid…
Murat65536 Jul 25, 2025
1029604
Fix bug.
Murat65536 Jul 31, 2025
7b5ba80
Change to Vec2.
Murat65536 Aug 6, 2025
f1e5c44
Replace messy Vec2 with a cleaner record class. Also, remove a messy …
Murat65536 Aug 17, 2025
9714fa4
Condense logic into huge lambda.
Murat65536 Aug 18, 2025
0eb0e67
Condense more.
Murat65536 Aug 18, 2025
a2a6769
Round yaw to 45 degrees when bridging.
Murat65536 Aug 24, 2025
61c0a09
Add 45 degree intervals to yaw change.
Murat65536 Aug 28, 2025
f9ae702
Formatting change.
Murat65536 Aug 28, 2025
ce81d36
Convert to ternary operators.
Murat65536 Aug 29, 2025
0379128
Adjust order.
Murat65536 Aug 30, 2025
714e7af
More minor formatting changes.
Murat65536 Aug 30, 2025
a56f3cf
Clarify yaw distance comment
Murat65536 Sep 11, 2025
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
72 changes: 72 additions & 0 deletions src/main/java/baritone/pathing/movement/MovementHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import baritone.utils.ToolSet;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.piston.MovingPistonBlock;
Expand Down Expand Up @@ -658,6 +659,77 @@ static void moveTowards(IPlayerContext ctx, MovementState state, BlockPos pos) {
)).setInput(Input.MOVE_FORWARD, true);
}

static void moveTowardsWithRotation(IPlayerContext ctx, MovementState state, BlockPos dest, Rotation rotation) {
state.setTarget(new MovementTarget(rotation, false));
/*
Options:
W: ax, az
S: -ax,-az
A: -az,ax
D: az,-ax
W+A:ax-az,az+ax,
W+D:ax+az,az-ax,
S+A:-ax-az,-az+ax,
S+D:-ax+az,-az-ax
*/
boolean canSprint = Baritone.settings().allowSprint.value;
float ax = Mth.sin((float)Math.toRadians(ctx.playerRotations().getYaw()));
float az = Mth.cos((float)Math.toRadians(ctx.playerRotations().getYaw()));
Rotation blockRotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(dest),
ctx.playerRotations());
float targetAx = Mth.sin((float)Math.toRadians(blockRotation.getYaw()));
float targetAz = Mth.cos((float)Math.toRadians(blockRotation.getYaw()));
float[][] options = {
{canSprint ? ax * 1.3f : ax, canSprint ? az * 1.3f : az},
{-ax, -az},
{-az, az},
{az, -ax},
{(canSprint ? ax * 1.3f : ax) - az, (canSprint ? az * 1.3f : az) + ax},
{(canSprint ? ax * 1.3f : ax) + az, (canSprint ? az * 1.3f : az) - ax},
{-ax - az, -az + ax},
{-ax + az, -az - ax}
};
int selection = -1;
float closestX = 100000;
Comment thread
Murat65536 marked this conversation as resolved.
Outdated
float closestZ = 100000;
for (int i = 0; i < options.length; i++) {
if (Math.abs(targetAx - options[i][0]) + Math.abs(targetAz - options[i][1]) < closestX + closestZ) {
closestX = Math.abs(targetAx - options[i][0]);
closestZ = Math.abs(targetAz - options[i][1]);
selection = i;
}
}
switch (selection) {
case 0:
state.setInput(Input.MOVE_FORWARD, true);
break;
case 1:
state.setInput(Input.MOVE_BACK, true);
break;
case 2:
state.setInput(Input.MOVE_LEFT, true);
break;
case 3:
state.setInput(Input.MOVE_RIGHT, true);
break;
case 4:
state.setInput(Input.MOVE_FORWARD, true).setInput(Input.MOVE_LEFT, true);
break;
case 5:
state.setInput(Input.MOVE_FORWARD, true).setInput(Input.MOVE_RIGHT, true);
break;
case 6:
state.setInput(Input.MOVE_BACK, true).setInput(Input.MOVE_LEFT, true);
break;
case 7:
state.setInput(Input.MOVE_BACK, true).setInput(Input.MOVE_RIGHT, true);
break;
default:
break;
}
}

/**
* Returns whether or not the specified block is
* water, regardless of whether or not it is flowing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ public MovementState updateState(MovementState state) {
}
return state;
}
MovementHelper.moveTowards(ctx, state, positionsToBreak[0]);
MovementHelper.moveTowardsWithRotation(ctx, state, dest,
RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(dest),
ctx.playerRotations()).add(new Rotation(225, 0).withPitch(ctx.playerRotations().getPitch())));
Comment thread
Murat65536 marked this conversation as resolved.
Outdated
return state;
// TODO MovementManager.moveTowardsBlock(to); // move towards not look at because if we are bridging for a couple blocks in a row, it is faster if we dont spin around and walk forwards then spin around and place backwards for every block
}
Expand Down