Skip to content

Commit

Permalink
block break delay setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Mar 9, 2024
1 parent 4144344 commit 413c11a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ public final class Settings {
*/
public final Setting<Float> blockReachDistance = new Setting<>(4.5f);


/**
* Delay between breaking a block and starting to break the next block. The vanilla delay is 6 ticks.
* Baritone waits an additional 2 ticks on top of this setting value.
*/
public final Setting<Integer> blockBreakDelay = new Setting<>(4);

/**
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
*/
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/baritone/utils/BlockBreakHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package baritone.utils;

import baritone.api.BaritoneAPI;
import baritone.api.utils.IPlayerContext;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.BlockHitResult;
Expand All @@ -30,6 +31,7 @@ public final class BlockBreakHelper {

private final IPlayerContext ctx;
private boolean didBreakLastTick;
private int breakDelay = 0;

BlockBreakHelper(IPlayerContext ctx) {
this.ctx = ctx;
Expand All @@ -48,6 +50,11 @@ public void stopBreakingBlock() {
}

public void tick(boolean isLeftClick) {
if (breakDelay > 0) {
breakDelay--;
return;
}

HitResult trace = ctx.objectMouseOver();
boolean isBlockTrace = trace != null && trace.getType() == HitResult.Type.BLOCK;

Expand All @@ -68,6 +75,7 @@ public void tick(boolean isLeftClick) {
didBreakLastTick = true;
} else if (didBreakLastTick) {
stopBreakingBlock();
breakDelay = BaritoneAPI.getSettings().blockBreakDelay.value;
didBreakLastTick = false;
}
}
Expand Down

0 comments on commit 413c11a

Please sign in to comment.