Merge pull request #3356 from wagyourtail/forceAllowBreak

add `allowBreakAnyway` setting
This commit is contained in:
Leijurv 2022-03-31 14:08:13 -07:00 committed by GitHub
commit dc6b32a154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -49,6 +49,11 @@ public final class Settings {
*/
public final Setting<Boolean> allowBreak = new Setting<>(true);
/**
* Blocks that baritone will be allowed to break even with allowBreak set to false
*/
public final Setting<List<Block>> allowBreakAnyway = new Setting<>(new ArrayList<>());
/**
* Allow Baritone to sprint
*/

View File

@ -34,6 +34,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
/**
@ -55,6 +58,7 @@ public class CalculationContext {
public final boolean canSprint;
protected final double placeBlockCost; // protected because you should call the function instead
public final boolean allowBreak;
public final List<Block> allowBreakAnyway;
public final boolean allowParkour;
public final boolean allowParkourPlace;
public final boolean allowJumpAt256;
@ -89,6 +93,7 @@ public class CalculationContext {
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6;
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
this.allowBreak = Baritone.settings().allowBreak.value;
this.allowBreakAnyway = new ArrayList<>(Baritone.settings().allowBreakAnyway.value);
this.allowParkour = Baritone.settings().allowParkour.value;
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
@ -149,7 +154,7 @@ public class CalculationContext {
}
public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) {
if (!allowBreak) {
if (!allowBreak && !allowBreakAnyway.contains(current.getBlock())) {
return COST_INF;
}
if (isPossiblyProtected(x, y, z)) {

View File

@ -947,7 +947,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
@Override
public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) {
if (!allowBreak || isPossiblyProtected(x, y, z)) {
if ((!allowBreak && !allowBreakAnyway.contains(current.getBlock())) || isPossiblyProtected(x, y, z)) {
return COST_INF;
}
IBlockState sch = getSchematic(x, y, z, current);