add forceAllowBreak setting

This commit is contained in:
Wagyourtail 2022-03-24 17:33:33 -07:00
parent 8c2aae2ddc
commit 4e6b6d97ce
No known key found for this signature in database
GPG Key ID: B3A2A4A58244B050
3 changed files with 19 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>> forceAllowBreak = 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> forceAllowBreak;
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.forceAllowBreak = new ArrayList<>(Baritone.settings().forceAllowBreak.value);
this.allowParkour = Baritone.settings().allowParkour.value;
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
@ -150,7 +155,9 @@ public class CalculationContext {
public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) {
if (!allowBreak) {
return COST_INF;
if (!forceAllowBreak.contains(current.getBlock())) {
return COST_INF;
}
}
if (isPossiblyProtected(x, y, z)) {
return COST_INF;

View File

@ -947,7 +947,12 @@ 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) {
if (!forceAllowBreak.contains(current.getBlock())) {
return COST_INF;
}
}
if (isPossiblyProtected(x, y, z)) {
return COST_INF;
}
IBlockState sch = getSchematic(x, y, z, current);