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
6 changes: 6 additions & 0 deletions src/api/java/baritone/api/IBaritone.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public interface IBaritone {
*/
IElytraProcess getElytraProcess();

/**
* @return The {@link IBranchMineProcess} instance
* @see IBranchMineProcess
*/
IBranchMineProcess getBranchMineProcess();

/**
* @return The {@link IWorldProvider} instance
* @see IWorldProvider
Expand Down
35 changes: 35 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,41 @@ public final class Settings {
*/
public final Setting<Boolean> allowWalkOnMagmaBlocks = new Setting<>(false);

/**
* Distance between branch tunnels in branch mine mode
*/
public final Setting<Integer> branchMineInterval = new Setting<>(3);

/**
* Height of branch mine tunnels (1 = 1x1, 2 = 1x2)
*/
public final Setting<Integer> branchMineTunnelHeight = new Setting<>(2);

/**
* Collect visible ores while branch mining
*/
public final Setting<Boolean> branchMineOreCollection = new Setting<>(true);

/**
* Ticks between ore scans during branch mining
*/
public final Setting<Integer> branchMineScanInterval = new Setting<>(20);

/**
* Build a staircase between layers in branch mine mode
*/
public final Setting<Boolean> branchMineStaircase = new Setting<>(true);

/**
* Vertical distance between branch mine layers
*/
public final Setting<Integer> branchMineLayerHeight = new Setting<>(3);

/**
* Branch offset per layer for maximum coverage (staggering)
*/
public final Setting<Integer> branchMineStaggerOffset = new Setting<>(1);

/**
* A map of lowercase setting field names to their respective setting
*/
Expand Down
56 changes: 56 additions & 0 deletions src/api/java/baritone/api/process/IBranchMineProcess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.api.process;

import baritone.api.selection.ISelection;
import net.minecraft.core.BlockPos;

/**
* Process for branch mining within a defined area.
*
* <p>The bot will excavate a staircase branch-mine pattern through the selected
* volume, optionally collecting visible ores along the way. Branches are staggered
* between layers so that lower layers cover the gaps left by upper layers.</p>
*
* @author leijurv (adapted)
* @since 1.0.0
*/
public interface IBranchMineProcess extends IBaritoneProcess {

/**
* Begin branch mining the volume defined by the two corner positions.
*
* @param pos1 First corner
* @param pos2 Second corner
*/
void branchMine(BlockPos pos1, BlockPos pos2);

/**
* Begin branch mining the volume defined by the given selection.
*
* @param selection The selection to mine within
*/
void branchMine(ISelection selection);

/**
* Cancel the current branch mining task.
*/
default void cancel() {
onLostControl();
}
}
8 changes: 8 additions & 0 deletions src/main/java/baritone/Baritone.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import baritone.api.behavior.IBehavior;
import baritone.api.event.listener.IEventBus;
import baritone.api.process.IBaritoneProcess;
import baritone.api.process.IBranchMineProcess;
import baritone.api.process.IElytraProcess;
import baritone.api.utils.IPlayerContext;
import baritone.behavior.*;
Expand Down Expand Up @@ -80,6 +81,7 @@ public class Baritone implements IBaritone {
private final FarmProcess farmProcess;
private final InventoryPauserProcess inventoryPauserProcess;
private final IElytraProcess elytraProcess;
private final BranchMineProcess branchMineProcess;

private final PathingControlManager pathingControlManager;
private final SelectionManager selectionManager;
Expand Down Expand Up @@ -123,6 +125,7 @@ public class Baritone implements IBaritone {
this.farmProcess = this.registerProcess(FarmProcess::new);
this.inventoryPauserProcess = this.registerProcess(InventoryPauserProcess::new);
this.elytraProcess = this.registerProcess(ElytraProcess::create);
this.branchMineProcess = this.registerProcess(BranchMineProcess::new);
this.registerProcess(BackfillProcess::new);
}

Expand Down Expand Up @@ -240,6 +243,11 @@ public IElytraProcess getElytraProcess() {
return this.elytraProcess;
}

@Override
public IBranchMineProcess getBranchMineProcess() {
return this.branchMineProcess;
}

@Override
public void openClick() {
new Thread(() -> {
Expand Down
90 changes: 90 additions & 0 deletions src/main/java/baritone/command/defaults/BranchMineCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.command.defaults;

import baritone.api.IBaritone;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.datatypes.RelativeBlockPos;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.selection.ISelection;
import baritone.api.utils.BetterBlockPos;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class BranchMineCommand extends Command {

public BranchMineCommand(IBaritone baritone) {
super(baritone, "branchmine", "bm");
}

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
BetterBlockPos pos1;
BetterBlockPos pos2;
if (args.hasExactly(6)) {
BetterBlockPos origin = ctx.playerFeet();
pos1 = args.getDatatypePost(RelativeBlockPos.INSTANCE, origin);
pos2 = args.getDatatypePost(RelativeBlockPos.INSTANCE, origin);
} else if (args.hasExactly(0)) {
ISelection[] selections = baritone.getSelectionManager().getSelections();
if (selections.length == 0) {
throw new CommandInvalidStateException("No selection. Use #sel to create one, or provide coordinates.");
}
if (selections.length > 1) {
throw new CommandInvalidStateException("Multiple selections found. Use #sel to keep only one, or provide coordinates.");
}
ISelection selection = selections[0];
pos1 = selection.pos1();
pos2 = selection.pos2();
} else {
throw new CommandInvalidStateException("Usage: #branchmine <x1> <y1> <z1> <x2> <y2> <z2> or #branchmine with a selection");
}
baritone.getBranchMineProcess().branchMine(pos1, pos2);
logDirect("Starting branch mine from " + pos1 + " to " + pos2);
}

@Override
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
if (args.hasAtMost(3)) {
return args.tabCompleteDatatype(RelativeBlockPos.INSTANCE);
} else if (args.hasAtMost(6)) {
return args.tabCompleteDatatype(RelativeBlockPos.INSTANCE);
}
return Stream.empty();
}

@Override
public String getShortDesc() {
return "Branch mine an area";
}

@Override
public List<String> getLongDesc() {
return Arrays.asList(
"Mines an area using an optimized branch-mine pattern.",
"",
"Usage:",
"> branchmine <x1> <y1> <z1> <x2> <y2> <z2> - Mine the specified area.",
"> branchmine - Mine the current selection."
);
}
}
3 changes: 2 additions & 1 deletion src/main/java/baritone/command/defaults/DefaultCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static List<ICommand> createAll(IBaritone baritone) {
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
new CommandAlias(baritone, "home", "Path to your home waypoint", "waypoints goto home"),
new SelCommand(baritone),
new ElytraCommand(baritone)
new ElytraCommand(baritone),
new BranchMineCommand(baritone)
));
ExecutionControlCommands prc = new ExecutionControlCommands(baritone);
commands.add(prc.pauseCommand);
Expand Down
Loading