Skip to content

Commit 35c804d

Browse files
committed
Use a list of placements instead of one. Which means we place blocks faster.
1 parent f6045b7 commit 35c804d

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,11 @@ public final class Settings {
15031503
*/
15041504
public final Setting<Boolean> elytraChatSpam = new Setting<>(false);
15051505

1506+
/**
1507+
* The max amount of blocks baritone can place at once in a burst speed, not a constant speed.
1508+
*/
1509+
public final Setting<Integer> placementLimit = new Setting<>(3);
1510+
15061511
/**
15071512
* A map of lowercase setting field names to their respective setting
15081513
*/

src/main/java/baritone/process/BuilderProcess.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ public Placement(int hotbarSelection, BlockPos placeAgainst, Direction side, Rot
325325
}
326326
}
327327

328-
private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
328+
private Optional<List<Placement>> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
329+
ArrayList<Placement> list = new ArrayList<>();
330+
329331
BetterBlockPos center = ctx.playerFeet();
330332
for (int dx = -5; dx <= 5; dx++) {
331333
for (int dy = -5; dy <= 1; dy++) {
@@ -344,13 +346,13 @@ private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, Li
344346
}
345347
desirableOnHotbar.add(desired);
346348
Optional<Placement> opt = possibleToPlace(desired, x, y, z, bcc.bsi);
347-
if (opt.isPresent()) {
348-
return opt;
349-
}
349+
opt.ifPresent(list::add);
350350
}
351+
351352
}
352353
}
353354
}
355+
if (!list.isEmpty()) return Optional.of(list);
354356
return Optional.empty();
355357
}
356358

@@ -561,14 +563,24 @@ public int lengthZ() {
561563
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
562564
}
563565
List<BlockState> desirableOnHotbar = new ArrayList<>();
564-
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
566+
Optional<List<Placement>> toPlace = searchForPlacables(bcc, desirableOnHotbar);
565567
if (toPlace.isPresent() && isSafeToCancel && ctx.player().isOnGround() && ticks <= 0) {
566-
Rotation rot = toPlace.get().rot;
567-
baritone.getLookBehavior().updateTarget(rot, true);
568-
ctx.player().getInventory().selected = toPlace.get().hotbarSelection;
569-
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
570-
if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) {
571-
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
568+
logDebug("We have " + toPlace.get().size() + " placement options right now");
569+
int i = 0;
570+
for (Placement placement : toPlace.get()) {
571+
if (i > Baritone.settings().placementLimit.value) break;
572+
i++;
573+
574+
Rotation rot = placement.rot;
575+
baritone.getLookBehavior().updateTarget(rot, true);
576+
ctx.player().getInventory().selected = placement.hotbarSelection;
577+
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
578+
if ((ctx.isLookingAt(placement.placeAgainst) &&
579+
((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(placement.side))
580+
|| ctx.playerRotations().isReallyCloseTo(rot)
581+
) {
582+
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
583+
}
572584
}
573585
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
574586
}

0 commit comments

Comments
 (0)