Skip to content

Commit ba1ccce

Browse files
committed
Expose current layer in IBuilderProcess
1 parent 1dc5be3 commit ba1ccce

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/api/java/baritone/api/process/IBuilderProcess.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.world.level.block.state.BlockState;
2525
import java.io.File;
2626
import java.util.List;
27+
import java.util.Optional;
2728

2829
/**
2930
* @author Brady
@@ -74,4 +75,17 @@ default boolean build(String schematicFile, BlockPos origin) {
7475
* cause it to give up. This is updated every tick, but only while the builder process is active.
7576
*/
7677
List<BlockState> getApproxPlaceable();
78+
/**
79+
* Returns the lower bound of the current mining layer if mineInLayers is true.
80+
* If mineInLayers is false, this will return an empty optional.
81+
* @return The lower bound of the current mining layer
82+
*/
83+
Optional<Integer> getMinLayer();
84+
85+
/**
86+
* Returns the upper bound of the current mining layer if mineInLayers is true.
87+
* If mineInLayers is false, this will return an empty optional.
88+
* @return The upper bound of the current mining layer
89+
*/
90+
Optional<Integer> getMaxLayer();
7791
}

src/main/java/baritone/process/BuilderProcess.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,22 @@ public String displayName0() {
998998
return paused ? "Builder Paused" : "Building " + name;
999999
}
10001000

1001+
@Override
1002+
public Optional<Integer> getMinLayer() {
1003+
if (Baritone.settings().buildInLayers.value) {
1004+
return Optional.of(this.layer);
1005+
}
1006+
return Optional.empty();
1007+
}
1008+
1009+
@Override
1010+
public Optional<Integer> getMaxLayer() {
1011+
if (Baritone.settings().buildInLayers.value) {
1012+
return Optional.of(this.stopAtHeight);
1013+
}
1014+
return Optional.empty();
1015+
}
1016+
10011017
private List<BlockState> approxPlaceable(int size) {
10021018
List<BlockState> result = new ArrayList<>();
10031019
for (int i = 0; i < size; i++) {

0 commit comments

Comments
 (0)