Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,11 @@ public final class Settings {
*/
public final Setting<Boolean> elytraChatSpam = new Setting<>(false);

/**
* The max amount of blocks baritone can place at once in a burst speed, not a constant speed.
*/
public final Setting<Integer> placementLimit = new Setting<>(3);

/**
* A map of lowercase setting field names to their respective setting
*/
Expand Down
31 changes: 20 additions & 11 deletions src/main/java/baritone/process/BuilderProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ public Placement(int hotbarSelection, BlockPos placeAgainst, Direction side, Rot
}
}

private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
private Optional<List<Placement>> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
ArrayList<Placement> list = new ArrayList<>();

BetterBlockPos center = ctx.playerFeet();
for (int dx = -5; dx <= 5; dx++) {
for (int dy = -5; dy <= 1; dy++) {
Expand All @@ -344,13 +346,14 @@ private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, Li
}
desirableOnHotbar.add(desired);
Optional<Placement> opt = possibleToPlace(desired, x, y, z, bcc.bsi);
if (opt.isPresent()) {
return opt;
}
opt.ifPresent(list::add);
}

if (list.size() == Baritone.settings().placementLimit.value) return Optional.of(list);
}
}
}
if (!list.isEmpty()) return Optional.of(list);
return Optional.empty();
}

Expand Down Expand Up @@ -561,14 +564,20 @@ public int lengthZ() {
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
}
List<BlockState> desirableOnHotbar = new ArrayList<>();
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
Optional<List<Placement>> toPlace = searchForPlacables(bcc, desirableOnHotbar);
if (toPlace.isPresent() && isSafeToCancel && ctx.player().isOnGround() && ticks <= 0) {
Rotation rot = toPlace.get().rot;
baritone.getLookBehavior().updateTarget(rot, true);
ctx.player().getInventory().selected = toPlace.get().hotbarSelection;
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) {
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
logDebug("We have " + toPlace.get().size() + " placement options right now");
for (Placement placement : toPlace.get()) {
Rotation rot = placement.rot;
baritone.getLookBehavior().updateTarget(rot, true);
ctx.player().getInventory().selected = placement.hotbarSelection;
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
if ((ctx.isLookingAt(placement.placeAgainst) &&
((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(placement.side))
|| ctx.playerRotations().isReallyCloseTo(rot)
) {
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
}
}
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
}
Expand Down