diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1812fe486..e48e03a8b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1503,6 +1503,11 @@ public final class Settings { */ public final Setting 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 placementLimit = new Setting<>(3); + /** * A map of lowercase setting field names to their respective setting */ diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 4b49398a0..eb5ab1f78 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -325,7 +325,9 @@ public Placement(int hotbarSelection, BlockPos placeAgainst, Direction side, Rot } } - private Optional searchForPlacables(BuilderCalculationContext bcc, List desirableOnHotbar) { + private Optional> searchForPlacables(BuilderCalculationContext bcc, List desirableOnHotbar) { + ArrayList list = new ArrayList<>(); + BetterBlockPos center = ctx.playerFeet(); for (int dx = -5; dx <= 5; dx++) { for (int dy = -5; dy <= 1; dy++) { @@ -344,13 +346,13 @@ private Optional searchForPlacables(BuilderCalculationContext bcc, Li } desirableOnHotbar.add(desired); Optional opt = possibleToPlace(desired, x, y, z, bcc.bsi); - if (opt.isPresent()) { - return opt; - } + opt.ifPresent(list::add); } + } } } + if (!list.isEmpty()) return Optional.of(list); return Optional.empty(); } @@ -561,14 +563,24 @@ public int lengthZ() { return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL); } List desirableOnHotbar = new ArrayList<>(); - Optional toPlace = searchForPlacables(bcc, desirableOnHotbar); + Optional> 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"); + int i = 0; + for (Placement placement : toPlace.get()) { + if (i > Baritone.settings().placementLimit.value) break; + i++; + + 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); }