align setting value with actual tick delay between breaks

This commit is contained in:
rfresh2 2024-03-10 16:43:58 -07:00
parent 413c11a23e
commit faece77e8c
No known key found for this signature in database
GPG Key ID: FD6E7EA7A754A98A
2 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -28,10 +28,12 @@ import net.minecraft.world.phys.HitResult;
* @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;
@ -50,11 +52,10 @@ public final class BlockBreakHelper {
}
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;
@ -75,7 +76,7 @@ public final class BlockBreakHelper {
didBreakLastTick = true;
} else if (didBreakLastTick) {
stopBreakingBlock();
breakDelay = BaritoneAPI.getSettings().blockBreakDelay.value;
breakDelayTimer = BaritoneAPI.getSettings().blockBreakSpeed.value - BASE_BREAK_DELAY;
didBreakLastTick = false;
}
}