Expose current layer in IBuilderProcess

This commit is contained in:
Ic3Tank
2025-02-04 22:04:21 +01:00
parent 1dc5be3985
commit ba1ccce962
2 changed files with 30 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.BlockState;
import java.io.File;
import java.util.List;
import java.util.Optional;
/**
* @author Brady
@@ -74,4 +75,17 @@ public interface IBuilderProcess extends IBaritoneProcess {
* cause it to give up. This is updated every tick, but only while the builder process is active.
*/
List<BlockState> getApproxPlaceable();
/**
* Returns the lower bound of the current mining layer if mineInLayers is true.
* If mineInLayers is false, this will return an empty optional.
* @return The lower bound of the current mining layer
*/
Optional<Integer> getMinLayer();
/**
* Returns the upper bound of the current mining layer if mineInLayers is true.
* If mineInLayers is false, this will return an empty optional.
* @return The upper bound of the current mining layer
*/
Optional<Integer> getMaxLayer();
}

View File

@@ -998,6 +998,22 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return paused ? "Builder Paused" : "Building " + name;
}
@Override
public Optional<Integer> getMinLayer() {
if (Baritone.settings().buildInLayers.value) {
return Optional.of(this.layer);
}
return Optional.empty();
}
@Override
public Optional<Integer> getMaxLayer() {
if (Baritone.settings().buildInLayers.value) {
return Optional.of(this.stopAtHeight);
}
return Optional.empty();
}
private List<BlockState> approxPlaceable(int size) {
List<BlockState> result = new ArrayList<>();
for (int i = 0; i < size; i++) {