Merge branch 'master' into 1.13.2

This commit is contained in:
Leijurv 2021-01-29 19:31:16 -08:00
commit f41c873852
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
6 changed files with 106 additions and 7 deletions

View File

@ -83,6 +83,12 @@ Building Baritone:
$ gradlew build
```
For minecraft 1.15.2+, run the following instead to include the Forge jars:
```
$ gradlew build -Pbaritone.forge_build
```
Running Baritone:
```

View File

@ -40,7 +40,7 @@ Some common examples:
- `goal clear` to clear the goal
- `cancel` or `stop` to stop everything
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine 64 diamond_ore`.
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to select an area (`#help sel` to see what you can do with that selection).
- `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type.
- `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)

View File

@ -17,7 +17,29 @@
package baritone.api.process;
import net.minecraft.util.math.BlockPos;
public interface IFarmProcess extends IBaritoneProcess {
void farm();
/**
* Begin to search for crops to farm with in specified aria
* from specified location.
*
* @param range The distance from center to farm from
* @param pos The center position to base the range from
*/
void farm(int range, BlockPos pos);
/**
* Begin to search for nearby crops to farm.
*/
default void farm() {farm(0, null);}
/**
* Begin to search for crops to farm with in specified aria
* from the position the command was executed.
*
* @param range The distance to search for crops to farm
*/
default void farm(int range) {farm(range, null);}
}

View File

@ -18,14 +18,23 @@
package baritone.command.defaults;
import baritone.api.IBaritone;
import baritone.api.cache.IWaypoint;
import baritone.api.command.Command;
import baritone.api.command.datatypes.ForWaypoints;
import baritone.api.command.exception.CommandException;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.command.helpers.Paginator;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.BetterBlockPos;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
public class FarmCommand extends Command {
public FarmCommand(IBaritone baritone) {
@ -34,8 +43,30 @@ public class FarmCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
baritone.getFarmProcess().farm();
args.requireMax(2);
int range = 0;
BetterBlockPos origin = null;
//range
if (args.has(1)) {
range = args.getAs(Integer.class);
}
//waypoint
if (args.has(1)){
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE);
IWaypoint waypoint = null;
switch (waypoints.length) {
case 0:
throw new CommandInvalidStateException("No waypoints found");
case 1:
waypoint = waypoints[0];
break;
default:
throw new CommandInvalidStateException("Multiple waypoints were found");
}
origin = waypoint.getLocation();
}
baritone.getFarmProcess().farm(range, origin);
logDirect("Farming");
}
@ -55,7 +86,9 @@ public class FarmCommand extends Command {
"The farm command starts farming nearby plants. It harvests mature crops and plants new ones.",
"",
"Usage:",
"> farm"
"> farm - farms every crop it can find.",
"> farm <range> - farm crops within range from the starting position.",
"> farm <range> <waypoint> - farm crops within range from waypoint."
);
}
}

View File

@ -61,6 +61,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
import java.util.stream.Collectors;
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
@ -499,7 +500,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
Goal goal = assemble(bcc, approxPlaceable.subList(0, 9));
if (goal == null) {
goal = assemble(bcc, approxPlaceable); // we're far away, so assume that we have our whole inventory to recalculate placeable properly
goal = assemble(bcc, approxPlaceable, true); // we're far away, so assume that we have our whole inventory to recalculate placeable properly
if (goal == null) {
if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) {
logDirect("Skipping layer that I cannot construct! Layer #" + layer);
@ -603,14 +604,23 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlaceable) {
return assemble(bcc, approxPlaceable, false);
}
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlaceable, boolean logMissing) {
List<BetterBlockPos> placeable = new ArrayList<>();
List<BetterBlockPos> breakable = new ArrayList<>();
List<BetterBlockPos> sourceLiquids = new ArrayList<>();
List<BetterBlockPos> flowingLiquids = new ArrayList<>();
Map<IBlockState, Integer> missing = new HashMap<>();
incorrectPositions.forEach(pos -> {
IBlockState state = bcc.bsi.get0(pos);
if (state.getBlock() instanceof BlockAir) {
if (approxPlaceable.contains(bcc.getSchematic(pos.x, pos.y, pos.z, state))) {
placeable.add(pos);
} else {
IBlockState desired = bcc.getSchematic(pos.x, pos.y, pos.z, state);
missing.put(desired, 1 + missing.getOrDefault(desired, 0));
}
} else {
if (state.getBlock() instanceof BlockFlowingFluid) {
@ -619,6 +629,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (!MovementHelper.possiblyFlowing(state)) {
// if it's a source block then we want to replace it with a throwaway
sourceLiquids.add(pos);
} else {
flowingLiquids.add(pos);
}
} else {
breakable.add(pos);
@ -639,6 +651,18 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0])));
}
if (toBreak.isEmpty()) {
if (logMissing && !missing.isEmpty()) {
logDirect("Missing materials for at least:");
logDirect(missing.entrySet().stream()
.map(e -> String.format("%sx %s", e.getValue(), e.getKey()))
.collect(Collectors.joining("\n")));
}
if (logMissing && !flowingLiquids.isEmpty()) {
logDirect("Unreplaceable liquids at at least:");
logDirect(flowingLiquids.stream()
.map(p -> String.format("%s %s %s", p.x, p.y, p.z))
.collect(Collectors.joining("\n")));
}
return null;
}
return new GoalComposite(toBreak.toArray(new Goal[0]));

View File

@ -59,6 +59,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
private List<BlockPos> locations;
private int tickCount;
private int range;
private BlockPos center;
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
Items.BEETROOT_SEEDS,
Items.MELON_SEEDS,
@ -95,7 +98,13 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
}
@Override
public void farm() {
public void farm(int range, BlockPos pos) {
if (pos == null) {
center = baritone.getPlayerContext().playerFeet();
} else {
center = pos;
}
this.range = range;
active = true;
locations = null;
}
@ -189,6 +198,11 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
List<BlockPos> bonemealable = new ArrayList<>();
List<BlockPos> openSoulsand = new ArrayList<>();
for (BlockPos pos : locations) {
//check if the target block is out of range.
if (range != 0 && pos.getDistance(center.getX(), center.getY(), center.getZ()) > range) {
continue;
}
IBlockState state = ctx.world().getBlockState(pos);
boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir;
if (state.getBlock() == Blocks.FARMLAND) {