Skip to content

Add custom block place limit. #4746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 1.19.4
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,13 @@ public final class Settings {
*/
public final Setting<Boolean> elytraChatSpam = new Setting<>(false);

/**
* A custom height limit to contain block placements under
* <p>
* Prevents Baritone from placing blocks if some servers have different build limits
*/
public final Setting<Integer> blockPlaceHeightLimit = new Setting<>(Integer.MAX_VALUE);

/**
* A map of lowercase setting field names to their respective setting
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class CalculationContext {
public double backtrackCostFavoringCoefficient;
public double jumpPenalty;
public final double walkOnWaterOnePenalty;
public final int blockPlaceHeightLimit;
public final BetterWorldBorder worldBorder;

public final PrecomputedData precomputedData;
Expand Down Expand Up @@ -125,6 +126,7 @@ public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
this.backtrackCostFavoringCoefficient = Baritone.settings().backtrackCostFavoringCoefficient.value;
this.jumpPenalty = Baritone.settings().jumpPenalty.value;
this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.value;
this.blockPlaceHeightLimit = Baritone.settings().blockPlaceHeightLimit.value;
// why cache these things here, why not let the movements just get directly from settings?
// because if some movements are calculated one way and others are calculated another way,
// then you get a wildly inconsistent path that isn't optimal for either scenario.
Expand Down Expand Up @@ -167,6 +169,9 @@ public double costOfPlacingAt(int x, int y, int z, BlockState current) {
if (!Baritone.settings().allowPlaceInFluidsFlow.value && !current.getFluidState().isEmpty() && !current.getFluidState().isSource()) {
return COST_INF;
}
if (y > blockPlaceHeightLimit) {
return COST_INF;
}
return placeBlockCost;
}

Expand Down