block break delay setting

This commit is contained in:
rfresh2 2024-03-09 13:22:15 -08:00
parent 4144344acd
commit 413c11a23e
No known key found for this signature in database
GPG Key ID: FD6E7EA7A754A98A
2 changed files with 15 additions and 0 deletions

View File

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

View File

@ -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;
@ -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;
@ -48,6 +50,11 @@ public final class BlockBreakHelper {
}
public void tick(boolean isLeftClick) {
if (breakDelay > 0) {
breakDelay--;
return;
}
HitResult trace = ctx.objectMouseOver();
boolean isBlockTrace = trace != null && trace.getType() == HitResult.Type.BLOCK;
@ -68,6 +75,7 @@ public final class BlockBreakHelper {
didBreakLastTick = true;
} else if (didBreakLastTick) {
stopBreakingBlock();
breakDelay = BaritoneAPI.getSettings().blockBreakDelay.value;
didBreakLastTick = false;
}
}