Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
0037742
Add ladder clutches.
Murat65536 Jun 10, 2025
f75772e
Add vine clutches.
Murat65536 Jun 10, 2025
99f1495
Add powdered snow clutches. (still need to look at picking snow back up)
Murat65536 Jun 10, 2025
6cded51
Powdered snow clutches are picked back up.
Murat65536 Jun 10, 2025
2e6be02
Reduced 2 definitions to 1.
Murat65536 Jun 10, 2025
4090342
Change clutches to enum.
Murat65536 Jun 10, 2025
d58f703
A bunch of changes. Change from enum to multiple classes extending ab…
Murat65536 Jun 13, 2025
334e30a
Fix bug where it was checking under the block it was placing on. Also…
Murat65536 Jun 14, 2025
2607df7
Add ladder clutches and clean up a little.
Murat65536 Jun 14, 2025
7592503
Combine ladder and vine clutches since they are basically the same. T…
Murat65536 Jun 14, 2025
fee7795
Clean up a little and take those ugly variables out of MovementDescend.
Murat65536 Jun 16, 2025
2a0fd42
Small change to move null check to dynamicFallCost.
Murat65536 Jun 16, 2025
8aa0892
Add twisting vine clutches.
Murat65536 Jun 16, 2025
725a7fa
Changes to allow for expandability and 1/3 codacy fixes I hope.
Murat65536 Jun 17, 2025
b0e353b
Codacy fix maybe?
Murat65536 Jun 17, 2025
acf321c
Fix vines.
Murat65536 Jun 17, 2025
1b0daf5
Fix ladders.
Murat65536 Jun 18, 2025
2243d48
Change `attemptToPlaceABlock` to allow for custom blocks and ability …
Murat65536 Jun 18, 2025
9b89354
Add a `properties` variable for each clutch to reduce the amount of v…
Murat65536 Jun 19, 2025
19bf5fc
Add ability to use inventory.
Murat65536 Jun 20, 2025
f1456c5
Change swapped slot from 7 to selected.
Murat65536 Jun 23, 2025
206ae51
Add slime block clutches.
Murat65536 Jun 26, 2025
7e13e17
Add scaffolding clutch.
Murat65536 Jun 26, 2025
6829eb5
Add sweet berry clutch.
Murat65536 Jun 27, 2025
da00a02
Add hay bale clutch and fix unprotected fall.
Murat65536 Jun 27, 2025
d66fa4e
Add lava clutch.
Murat65536 Jun 29, 2025
3f95180
Fix clutchable to respect `fallDamageModifier`.
Murat65536 Jun 30, 2025
6634008
Add cobweb clutch.
Murat65536 Jun 30, 2025
8a1e38d
Add falls to fall damage cancelling blocks.
Murat65536 Jul 2, 2025
2551d86
Add placement checks.
Murat65536 Jul 5, 2025
6084cc2
Rough draft of clutch costs. Still a little messy.
Murat65536 Jul 14, 2025
b4ee291
Small readability changes.
Murat65536 Jul 14, 2025
69cdf21
Cost calculation changes.
Murat65536 Jul 15, 2025
6a9ab16
Work on comparing different clutch methods.
Murat65536 Jul 15, 2025
b638665
Calculation fixes to block placement.
Murat65536 Jul 16, 2025
22da96c
Fix `clutched`.
Murat65536 Jul 16, 2025
d292d45
Account for existing velocity.
Murat65536 Jul 18, 2025
580bb96
Still not accurate cost calculation, but it's more accurate than befo…
Murat65536 Jul 18, 2025
fd3a758
Formatting fix.
Murat65536 Jul 18, 2025
54d0c2b
Somewhat better?
Murat65536 Jul 19, 2025
44960cb
Fix velocity issue. This code is getting very messy.
Murat65536 Jul 19, 2025
6de8d5f
Discard unneeded changes.
Murat65536 Jul 19, 2025
7f1cae7
Remove unneeded velocity calc.
Murat65536 Jul 19, 2025
b71f8e0
Allow aboveCost.
Murat65536 Jul 19, 2025
3650220
Add leather boots check to `PowderedSnowClutch`.
Murat65536 Jul 19, 2025
dd2870c
Finish powdered snow cost calculation.
Murat65536 Jul 19, 2025
68933e3
Add ladder cost estimation. (not based on value in code since I could…
Murat65536 Jul 20, 2025
d468ebe
Add estimations for most clutch costs.
Murat65536 Jul 20, 2025
38d8839
Change for liquids.
Murat65536 Jul 20, 2025
0c5162b
Make safer.
Murat65536 Jul 20, 2025
20e9627
Add different water buckets.
Murat65536 Jul 20, 2025
4764be5
Formatting changes.
Murat65536 Jul 22, 2025
1dfd55f
FIX COST CALCULATION! NOW 100% ACCURATE!
Murat65536 Jul 23, 2025
99371c9
Formatting changes.
Murat65536 Jul 23, 2025
8122abf
Merge branch '1.19.4' of https://github.com/cabaletta/baritone into c…
Murat65536 Jul 23, 2025
07c7bde
Small change.
Murat65536 Jul 23, 2025
bf3e08a
Merge branch '1.19.4' of https://github.com/cabaletta/baritone into c…
Murat65536 Jul 24, 2025
8af6bc2
Add @Override annotation to implementations of abstract methods.
Murat65536 Jul 25, 2025
fdb0bc1
More minute formatting changes.
Murat65536 Jul 25, 2025
51be6f3
Fix hay bale.
Murat65536 Jul 29, 2025
5e1caf7
Small change to maybe allow for water costs.
Murat65536 Jul 29, 2025
a437155
Add more flexibility to the waterlogged blocks allowed.
Murat65536 Aug 12, 2025
9482c49
Small change.
Murat65536 Aug 12, 2025
df59f0d
Add slow-falling calculations and optimization.
Murat65536 Aug 12, 2025
3ac8950
Levitation check and slight optimization change.
Murat65536 Aug 12, 2025
2c5e0f0
Remove redundant conditional.
Murat65536 Aug 12, 2025
aec0f24
Expand condition for double blocks.
Murat65536 Aug 12, 2025
47b7dbe
Simplify velocity calculation.
Murat65536 Aug 12, 2025
569a70d
Simplify velocity calculation more.
Murat65536 Aug 12, 2025
02e13f8
Make solid block placement destinations accurate and minor formatting…
Murat65536 Aug 14, 2025
6e50000
Small naming tweaks.
Murat65536 Aug 14, 2025
2bee497
Remove unneeded overrides.
Murat65536 Aug 14, 2025
4ce8e6a
Fix cost calculation, remove excessive method, and add general block …
Murat65536 Aug 16, 2025
b76d794
Rename `ClutchHelper` to `ClutchUtils`.
Murat65536 Aug 17, 2025
44ae52f
Merge branch 'cabaletta:1.19.4' into clutches
Murat65536 Aug 24, 2025
fae7315
Remove unused code and clean a little.
Murat65536 Aug 25, 2025
fbba05a
Expand case for falling without damage.
Murat65536 Sep 11, 2025
740a718
Replace optionals for performance reasons.
Murat65536 Sep 11, 2025
201233f
Fix `hasClutched`.
Murat65536 Sep 11, 2025
ced9756
Fix `isFinished`.
Murat65536 Sep 11, 2025
867b97f
Fix ladder and vine clutches.
Murat65536 Sep 11, 2025
fd9546b
Clean up.
Murat65536 Sep 11, 2025
1140e3b
Fix scaffolding.
Murat65536 Sep 11, 2025
d788e09
Merge branch '1.19.4' into clutches
Murat65536 Sep 11, 2025
5dc501d
Fix parkour.
Murat65536 Sep 11, 2025
f829ec9
Fix `hasClutched`.
Murat65536 Sep 11, 2025
5e455d7
Remove `hasClutched`.
Murat65536 Sep 12, 2025
43123a7
Add `activeEffects`.
Murat65536 Sep 12, 2025
6db179c
Fix `LavaClutch`.
Murat65536 Sep 12, 2025
5ee0602
Remove debug output in `SlimeClutch`.
Murat65536 Sep 13, 2025
3777667
Fix `activeEffects`.
Murat65536 Sep 13, 2025
0115ba1
Merge remote-tracking branch 'origin/clutches' into clutches
Murat65536 Sep 13, 2025
a9d3b59
Fix `hasClutched` and removed messy and problematic code.
Murat65536 Oct 5, 2025
408a78f
Small fix.
Murat65536 Oct 5, 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
14 changes: 4 additions & 10 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,6 @@ public final class Settings {
*/
public final Setting<Boolean> strictLiquidCheck = new Setting<>(false);

/**
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
* Reliability: questionable.
*/
public final Setting<Boolean> allowWaterBucketFall = new Setting<>(true);

/**
* Allow Baritone to assume it can walk on still water just like any other block.
* This functionality is assumed to be provided by a separate library that might have imported Baritone.
Expand Down Expand Up @@ -550,17 +544,17 @@ public final class Settings {
public final Setting<Float> pathingMapLoadFactor = new Setting<>(0.75f);

/**
* How far are you allowed to fall onto solid ground (without a water bucket)?
* How far are you allowed to fall onto solid ground (without clutching)?
* 3 won't deal any damage. But if you just want to get down the mountain quickly and you have
* Feather Falling IV, you might set it a bit higher, like 4 or 5.
*/
public final Setting<Integer> maxFallHeightNoWater = new Setting<>(3);
public final Setting<Integer> maxFallHeightNoClutch = new Setting<>(3);

/**
* How far are you allowed to fall onto solid ground (with a water bucket)?
* How far are you allowed to fall onto solid ground (while clutching)?
* It's not that reliable, so I've set it below what would kill an unarmored player (23)
*/
public final Setting<Integer> maxFallHeightBucket = new Setting<>(20);
public final Setting<Integer> maxFallHeightClutch = new Setting<>(20);

/**
* Is it okay to sprint through a descend followed by a diagonal?
Expand Down
54 changes: 52 additions & 2 deletions src/api/java/baritone/api/pathing/movement/ActionCosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package baritone.api.pathing.movement;

import baritone.api.utils.Pair;

public interface ActionCosts {

/**
Expand Down Expand Up @@ -76,10 +78,15 @@ static double velocity(int ticks) {
return (Math.pow(0.98, ticks) - 1) * -3.92;
}

static double oldFormula(double ticks) {
return -3.92 * (99 - 49.5 * (Math.pow(0.98, ticks) + 1) - ticks);
static double velocity(int ticks, double distanceMultiplier, double startingVelocity) {
double velocity = startingVelocity;
for (int i = 0; i < ticks; i++) {
velocity = 0.98 * (velocity + distanceMultiplier);
}
return velocity;
}


static double distanceToTicks(double distance) {
if (distance == 0) {
return 0; // Avoid 0/0 NaN
Expand All @@ -95,4 +102,47 @@ static double distanceToTicks(double distance) {
tickCount++;
}
}

static double distanceToTicks(double distance, double distanceMultiplier, double startingVelocity) {
if (distance == 0) {
return 0d; // Avoid 0/0 NaN
}
double tmpDistance = distance;
int tickCount = 0;
while (true) {
double velocity = velocity(tickCount, distanceMultiplier, startingVelocity);
if (tmpDistance <= velocity) {
return tickCount + tmpDistance / velocity;
}
tmpDistance -= velocity;
tickCount++;
}
}

static Pair<Double, Double> distanceToTicks(double distance, double endBlockHeight, double endBlockSpeedMultiplier, double startingVelocity) {
if (distance == 0) {
return new Pair<>(0d, startingVelocity);
}
double tmpDistance = distance;
int tickCount = 0;
boolean firstTick = true;
while (true) {
double velocity;
if (tmpDistance < endBlockHeight) {
if (firstTick) {
firstTick = false;
velocity = velocity(tickCount, 0.08d, startingVelocity) * endBlockSpeedMultiplier;
} else {
velocity = 0.0784d * endBlockSpeedMultiplier;
}
} else {
velocity = velocity(tickCount, 0.08d, startingVelocity);
}
if (tmpDistance <= velocity) {
return new Pair<>(tickCount + tmpDistance / velocity, velocity);
}
tmpDistance -= velocity;
tickCount++;
}
}
}
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/utils/RayTraceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static HitResult rayTraceTowards(Entity entity, Rotation rotation, double
if (wouldSneak) {
start = inferSneakingEyePosition(entity);
} else {
start = entity.getEyePosition(1.0F); // do whatever is correct
start = entity.getEyePosition();
}

Vec3 direction = RotationUtils.calcLookDirectionFromRotation(rotation);
Expand Down
1 change: 1 addition & 0 deletions src/api/java/baritone/api/utils/RotationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, dou
*
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
*/
// TODO This is a very hacky solution.
Rotation hypothetical = ctx.playerRotations().add(new Rotation(0, 0.0001F));
if (wouldSneak) {
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/baritone/behavior/InventoryBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,21 @@ public boolean hasGenericThrowaway() {
return false;
}

public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z, Item customItem) {
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z));
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}))))) {
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)))))) {
return true; // gotem
}
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
return true;
}
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
return true;
if (customItem != null) {
return throwaway(select, stack -> stack.is(customItem));
} else {
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -225,8 +229,7 @@ public boolean throwaway(boolean select, Predicate<? super ItemStack> desired, b
for (int i = 9; i < 36; i++) {
if (desired.test(inv.get(i))) {
if (select) {
requestSwapWithHotBar(i, 7);
p.getInventory().selected = 7;
requestSwapWithHotBar(i, p.getInventory().selected);
}
return true;
}
Expand Down
109 changes: 109 additions & 0 deletions src/main/java/baritone/pathing/clutch/Clutch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.pathing.clutch;

import baritone.Baritone;
import baritone.api.IBaritone;
import baritone.api.pathing.movement.ActionCosts;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.IPlayerContext;
import baritone.api.utils.Pair;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.pathing.MutableClutchResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

public abstract class Clutch {
private final double costMultiplier;

protected Clutch(double costMultiplier) {
this.costMultiplier = costMultiplier;
}

protected Clutch() {
this(1d);
}

public final ItemStack getClutchingItem(CalculationContext context) { // We could return the slot instead of the item
for (int slot = 0; slot < (Baritone.settings().allowInventory.value ? 36 : 9); slot++) {
ItemStack item = context.getBaritone().getPlayerContext().player().getInventory().items.get(slot);
if (isAcceptedItem(item.getItem())) {
return item;
}
}
return null;
}

public abstract boolean isAcceptedItem(Item item);

public abstract boolean compare(BlockState state);

public boolean isSolid(CalculationContext context) {
return false;
}

public boolean isPlaceable(CalculationContext context, int x, int y, int z, BlockState block) {
return MovementHelper.canPlaceAgainst(context.bsi, x, y, z, block);
}

public boolean clutch(IBaritone baritone, MovementState state, BlockPos dest, MutableClutchResult result) {
return ClutchUtils.blockClutch(baritone, state, dest, result, true);
}

public boolean hasClutched(IPlayerContext ctx, BetterBlockPos dest, BlockState destState) {
VoxelShape shape = destState.getCollisionShape(ctx.world(), dest);
if (shape.isEmpty()) {
return ctx.player().getBoundingBox().intersects(dest.x, dest.y, dest.z, dest.x + 1, dest.y + 1, dest.z + 1);
} else {
return ctx.player().getBoundingBox().intersects(
dest.x + shape.bounds().minX, dest.x + shape.bounds().minY, dest.x + shape.bounds().minZ,
dest.x + shape.bounds().maxX, dest.x + shape.bounds().maxY, dest.x + shape.bounds().maxZ);
}
}

public boolean isFinished(IPlayerContext ctx, MovementState state, MutableClutchResult result) {
return true;
}

public float getFallDamage(int fallDamage) {
return 0f;
}

public Pair<Double, Double> getCost(double distance, double endBlockHeight, double velocity) {
return ActionCosts.distanceToTicks(distance, endBlockHeight, costMultiplier, velocity);
}

public double getAdditionalCost() {
return 0d;
}

public boolean slowsOnTopBlock() {
return true;
}

public boolean topBlockPriority() {
return true;
}
}
66 changes: 66 additions & 0 deletions src/main/java/baritone/pathing/clutch/ClutchUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.pathing.clutch;

import baritone.api.IBaritone;
import baritone.api.utils.input.Input;
import baritone.pathing.clutch.clutches.*;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.pathing.MutableClutchResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;

public interface ClutchUtils {
// This list holds the order to try the clutches in. More convenient clutches should go further up.
Clutch[] CLUTCHES = new Clutch[]{
WaterClutch.INSTANCE,
LavaClutch.INSTANCE,
PowderedSnowClutch.INSTANCE,
TwistingVineClutch.INSTANCE,
SweetBerryClutch.INSTANCE,
VineClutch.INSTANCE,
LadderClutch.INSTANCE,
ScaffoldingClutch.INSTANCE,
SlimeClutch.INSTANCE,
HayBaleClutch.INSTANCE,
CobwebClutch.INSTANCE,
BlockClutch.INSTANCE,
};
ItemStack STACK_EMPTY_BUCKET = new ItemStack(Items.BUCKET);

static boolean blockClutch(IBaritone baritone, MovementState state, BlockPos dest, MutableClutchResult result, boolean allowDown) {
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest, allowDown, true, true, result.item.getItem()) == MovementHelper.PlaceResult.READY_TO_PLACE) {
state.setInput(Input.CLICK_RIGHT, true);
return true;
} else {
return false;
}
}

static boolean bucketPickup(MovementState state, Inventory inventory) {
int slot = inventory.findSlotMatchingItem(STACK_EMPTY_BUCKET);
if (Inventory.isHotbarSlot(slot)) {
inventory.selected = slot;
state.setInput(Input.CLICK_RIGHT, true);
}
return slot == -1;
}
}
51 changes: 51 additions & 0 deletions src/main/java/baritone/pathing/clutch/clutches/BlockClutch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.pathing.clutch.clutches;

import baritone.pathing.clutch.Clutch;
import baritone.pathing.movement.CalculationContext;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.state.BlockState;

public class BlockClutch extends Clutch {
public static final BlockClutch INSTANCE = new BlockClutch();

private BlockClutch() {}

@Override
public boolean isAcceptedItem(Item item) {
return item instanceof BlockItem blockItem &&
!blockItem.getBlock().defaultBlockState().getCollisionShape(null, null).isEmpty();
}

@Override
public boolean compare(BlockState state) {
return !state.getCollisionShape(null, null).isEmpty();
}

@Override
public boolean isSolid(CalculationContext context) {
return true;
}

@Override
public float getFallDamage(int fallDamage) {
return fallDamage;
}
}
Loading