Skip to content

Commit b0575fb

Browse files
authored
Merge pull request cabaletta#4291 from rfresh2/block-break-delay
Block break delay setting
2 parents 866cf34 + faece77 commit b0575fb

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/api/java/baritone/api/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ public final class Settings {
385385
*/
386386
public final Setting<Float> blockReachDistance = new Setting<>(4.5f);
387387

388+
/**
389+
* How many ticks between breaking a block and starting to break the next block. Default in game is 6 ticks.
390+
* Values under 2 will be clamped.
391+
*/
392+
public final Setting<Integer> blockBreakSpeed = new Setting<>(6);
393+
388394
/**
389395
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
390396
*/

src/main/java/baritone/utils/BlockBreakHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package baritone.utils;
1919

20+
import baritone.api.BaritoneAPI;
2021
import baritone.api.utils.IPlayerContext;
2122
import net.minecraft.world.InteractionHand;
2223
import net.minecraft.world.phys.BlockHitResult;
@@ -27,9 +28,12 @@
2728
* @since 8/25/2018
2829
*/
2930
public final class BlockBreakHelper {
31+
// base ticks between block breaks caused by tick logic
32+
private static final int BASE_BREAK_DELAY = 2;
3033

3134
private final IPlayerContext ctx;
3235
private boolean didBreakLastTick;
36+
private int breakDelayTimer = 0;
3337

3438
BlockBreakHelper(IPlayerContext ctx) {
3539
this.ctx = ctx;
@@ -48,6 +52,10 @@ public void stopBreakingBlock() {
4852
}
4953

5054
public void tick(boolean isLeftClick) {
55+
if (breakDelayTimer > 0) {
56+
breakDelayTimer--;
57+
return;
58+
}
5159
HitResult trace = ctx.objectMouseOver();
5260
boolean isBlockTrace = trace != null && trace.getType() == HitResult.Type.BLOCK;
5361

@@ -68,6 +76,7 @@ public void tick(boolean isLeftClick) {
6876
didBreakLastTick = true;
6977
} else if (didBreakLastTick) {
7078
stopBreakingBlock();
79+
breakDelayTimer = BaritoneAPI.getSettings().blockBreakSpeed.value - BASE_BREAK_DELAY;
7180
didBreakLastTick = false;
7281
}
7382
}

0 commit comments

Comments
 (0)