Skip to content

Commit

Permalink
align setting value with actual tick delay between breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Mar 10, 2024
1 parent 413c11a commit faece77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,11 @@ 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.
* How many ticks between breaking a block and starting to break the next block. Default in game is 6 ticks.
* Values under 2 will be clamped.
*/
public final Setting<Integer> blockBreakDelay = new Setting<>(4);
public final Setting<Integer> blockBreakSpeed = new Setting<>(6);

/**
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/baritone/utils/BlockBreakHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
* @since 8/25/2018
*/
public final class BlockBreakHelper {
// base ticks between block breaks caused by tick logic
private static final int BASE_BREAK_DELAY = 2;

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

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

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

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

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

0 comments on commit faece77

Please sign in to comment.