Merge branch 'master' into 1.13.2
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
[](http://hits.dwyl.com/cabaletta/baritone)
|
[](http://hits.dwyl.com/cabaletta/baritone)
|
||||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||||
[](https://github.com/cabaletta/baritone/issues)
|
[](https://github.com/cabaletta/baritone/issues)
|
||||||
[](https://github.com/cabaletta/baritone/issues/)
|
[](https://github.com/cabaletta/baritone/issues/)
|
||||||
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||||
[](https://github.com/cabaletta/baritone/pulls/)
|
[](https://github.com/cabaletta/baritone/pulls/)
|
||||||
@@ -51,7 +51,7 @@ Here are some links to help to get started:
|
|||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
||||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com).
|
||||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
||||||
jar.
|
jar.
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -214,6 +214,13 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> sprintAscends = new Setting<>(true);
|
public final Setting<Boolean> sprintAscends = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we overshoot a traverse and end up one block beyond the destination, mark it as successful anyway.
|
||||||
|
* <p>
|
||||||
|
* This helps with speed at >=20m/s
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> overshootTraverse = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When breaking blocks for a movement, wait until all falling blocks have settled before continuing
|
* When breaking blocks for a movement, wait until all falling blocks have settled before continuing
|
||||||
*/
|
*/
|
||||||
@@ -537,6 +544,8 @@ public final class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclusively use cached chunks for pathing
|
* Exclusively use cached chunks for pathing
|
||||||
|
* <p>
|
||||||
|
* Never turn this on
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
||||||
|
|
||||||
@@ -567,7 +576,7 @@ public final class Settings {
|
|||||||
public final Setting<Boolean> renderCachedChunks = new Setting<>(false);
|
public final Setting<Boolean> renderCachedChunks = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0.0f = not visible, fully transparent
|
* 0.0f = not visible, fully transparent (instead of setting this to 0, turn off renderCachedChunks)
|
||||||
* 1.0f = fully opaque
|
* 1.0f = fully opaque
|
||||||
*/
|
*/
|
||||||
public final Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
|
public final Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
|
||||||
@@ -638,7 +647,7 @@ public final class Settings {
|
|||||||
public final Setting<Integer> exploreMaintainY = new Setting<>(64);
|
public final Setting<Integer> exploreMaintainY = new Setting<>(64);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replant nether wart
|
* Replant nether wart while farming
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
|
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
|
||||||
|
|
||||||
@@ -655,14 +664,16 @@ public final class Settings {
|
|||||||
public final Setting<Boolean> buildInLayers = new Setting<>(false);
|
public final Setting<Boolean> buildInLayers = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable
|
* false = build from bottom to top
|
||||||
|
* <p>
|
||||||
|
* true = build from top to bottom
|
||||||
*/
|
*/
|
||||||
public final Setting<Integer> buildRepeatDistance = new Setting<>(0);
|
public final Setting<Boolean> layerOrder = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What direction to repeat the build in
|
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
|
||||||
*/
|
*/
|
||||||
public final Setting<EnumFacing> buildRepeatDirection = new Setting<>(EnumFacing.NORTH);
|
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow standing above a block while mining it, in BuilderProcess
|
* Allow standing above a block while mining it, in BuilderProcess
|
||||||
@@ -798,6 +809,11 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||||
|
*/
|
||||||
|
public final Setting<Double> yLevelBoxSize = new Setting<>(15D);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of the current path
|
* The color of the current path
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class GoalYLevel implements Goal, ActionCosts {
|
|||||||
/**
|
/**
|
||||||
* The target Y level
|
* The target Y level
|
||||||
*/
|
*/
|
||||||
private final int level;
|
public final int level;
|
||||||
|
|
||||||
public GoalYLevel(int level) {
|
public GoalYLevel(int level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long longHash(int x, int y, int z) {
|
public static long longHash(int x, int y, int z) {
|
||||||
|
// TODO use the same thing as BlockPos.fromLong();
|
||||||
|
// invertibility would be incredibly useful
|
||||||
/*
|
/*
|
||||||
* This is the hashcode implementation of Vec3i (the superclass of the class which I shall not name)
|
* This is the hashcode implementation of Vec3i (the superclass of the class which I shall not name)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -688,18 +688,20 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
private Goal parseGoal(String[] params) {
|
private Goal parseGoal(String[] params) {
|
||||||
Goal goal;
|
Goal goal;
|
||||||
try {
|
try {
|
||||||
|
BetterBlockPos playerFeet = ctx.playerFeet();
|
||||||
switch (params.length) {
|
switch (params.length) {
|
||||||
case 0:
|
case 0:
|
||||||
goal = new GoalBlock(ctx.playerFeet());
|
goal = new GoalBlock(playerFeet);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
goal = new GoalYLevel(Integer.parseInt(params[0]));
|
|
||||||
|
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
goal = new GoalXZ(Integer.parseInt(params[0]), Integer.parseInt(params[1]));
|
goal = new GoalXZ(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.z));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2])));
|
goal = new GoalBlock(new BlockPos(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.y), parseOrDefault(params[2], playerFeet.z)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logDirect("unable to understand lol");
|
logDirect("unable to understand lol");
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.IRegistry;
|
import net.minecraft.util.registry.IRegistry;
|
||||||
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -181,6 +182,11 @@ public class SettingsUtil {
|
|||||||
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||||
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||||
),
|
),
|
||||||
|
VEC3I(
|
||||||
|
Vec3i.class,
|
||||||
|
str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||||
|
vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ()
|
||||||
|
),
|
||||||
BLOCK(
|
BLOCK(
|
||||||
Block.class,
|
Block.class,
|
||||||
str -> BlockUtils.stringToBlockRequired(str.trim()),
|
str -> BlockUtils.stringToBlockRequired(str.trim()),
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -45,6 +46,8 @@ public class ContainerMemory implements IContainerMemory {
|
|||||||
this.saveTo = saveTo;
|
this.saveTo = saveTo;
|
||||||
try {
|
try {
|
||||||
read(Files.readAllBytes(saveTo));
|
read(Files.readAllBytes(saveTo));
|
||||||
|
} catch (NoSuchFileException ignored) {
|
||||||
|
inventories.clear();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
inventories.clear();
|
inventories.clear();
|
||||||
|
|||||||
@@ -231,7 +231,11 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isTheBridgeBlockThere) {
|
if (isTheBridgeBlockThere) {
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
BetterBlockPos feet = ctx.playerFeet();
|
||||||
|
if (feet.equals(dest)) {
|
||||||
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
|
}
|
||||||
|
if (Baritone.settings().overshootTraverse.value && (feet.equals(dest.add(getDirection())) || feet.equals(dest.add(getDirection()).add(getDirection())))) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
||||||
|
|||||||
@@ -318,12 +318,29 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
if (realSchematic == null) {
|
if (realSchematic == null) {
|
||||||
realSchematic = schematic;
|
realSchematic = schematic;
|
||||||
}
|
}
|
||||||
|
ISchematic realSchematic = this.realSchematic; // wrap this properly, dont just have the inner class refer to the builderprocess.this
|
||||||
|
int minYInclusive;
|
||||||
|
int maxYInclusive;
|
||||||
|
// layer = 0 should be nothing
|
||||||
|
// layer = realSchematic.heightY() should be everything
|
||||||
|
if (Baritone.settings().layerOrder.value) { // top to bottom
|
||||||
|
maxYInclusive = realSchematic.heightY() - 1;
|
||||||
|
minYInclusive = realSchematic.heightY() - layer;
|
||||||
|
} else {
|
||||||
|
maxYInclusive = layer - 1;
|
||||||
|
minYInclusive = 0;
|
||||||
|
}
|
||||||
schematic = new ISchematic() {
|
schematic = new ISchematic() {
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z) {
|
public IBlockState desiredState(int x, int y, int z) {
|
||||||
return realSchematic.desiredState(x, y, z);
|
return realSchematic.desiredState(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inSchematic(int x, int y, int z) {
|
||||||
|
return ISchematic.super.inSchematic(x, y, z) && y >= minYInclusive && y <= maxYInclusive;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int widthX() {
|
public int widthX() {
|
||||||
return realSchematic.widthX();
|
return realSchematic.widthX();
|
||||||
@@ -331,7 +348,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int heightY() {
|
public int heightY() {
|
||||||
return layer;
|
return realSchematic.heightY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -347,20 +364,16 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
layer++;
|
layer++;
|
||||||
return onTick(calcFailed, isSafeToCancel);
|
return onTick(calcFailed, isSafeToCancel);
|
||||||
}
|
}
|
||||||
int distance = Baritone.settings().buildRepeatDistance.value;
|
Vec3i repeat = Baritone.settings().buildRepeat.value;
|
||||||
EnumFacing direction = Baritone.settings().buildRepeatDirection.value;
|
if (repeat.equals(new Vec3i(0, 0, 0))) {
|
||||||
if (distance == 0) {
|
|
||||||
logDirect("Done building");
|
logDirect("Done building");
|
||||||
onLostControl();
|
onLostControl();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// build repeat time
|
// build repeat time
|
||||||
if (distance == -1) {
|
|
||||||
distance = schematic.size(direction.getAxis());
|
|
||||||
}
|
|
||||||
layer = 0;
|
layer = 0;
|
||||||
origin = new BlockPos(origin).offset(direction, distance);
|
origin = new BlockPos(origin).add(repeat);
|
||||||
logDirect("Repeating build " + distance + " blocks to the " + direction + ", new origin is " + origin);
|
logDirect("Repeating build in vector " + repeat + ", new origin is " + origin);
|
||||||
return onTick(calcFailed, isSafeToCancel);
|
return onTick(calcFailed, isSafeToCancel);
|
||||||
}
|
}
|
||||||
trim(bcc);
|
trim(bcc);
|
||||||
|
|||||||
@@ -88,17 +88,16 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean shouldCancel = calcFailed;
|
if (calcFailed) {
|
||||||
if (calcFailed && !knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) {
|
if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) {
|
||||||
logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance...");
|
logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance...");
|
||||||
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add);
|
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add);
|
||||||
knownOreLocations.removeIf(blacklist::contains);
|
knownOreLocations.removeIf(blacklist::contains);
|
||||||
shouldCancel = false; // 😎
|
} else {
|
||||||
}
|
logDirect("Unable to find any path to " + mining + ", canceling Mine");
|
||||||
if (shouldCancel) {
|
cancel();
|
||||||
logDirect("Unable to find any path to " + mining + ", canceling Mine");
|
return null;
|
||||||
cancel();
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||||
|
|||||||
@@ -276,13 +276,13 @@ public final class PathRenderer implements Helper {
|
|||||||
double maxY;
|
double maxY;
|
||||||
double y1;
|
double y1;
|
||||||
double y2;
|
double y2;
|
||||||
|
double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
|
||||||
if (goal instanceof IGoalRenderPos) {
|
if (goal instanceof IGoalRenderPos) {
|
||||||
BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos();
|
BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos();
|
||||||
minX = goalPos.getX() + 0.002 - renderPosX;
|
minX = goalPos.getX() + 0.002 - renderPosX;
|
||||||
maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
|
maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
|
||||||
minZ = goalPos.getZ() + 0.002 - renderPosZ;
|
minZ = goalPos.getZ() + 0.002 - renderPosZ;
|
||||||
maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
|
maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
|
||||||
double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
|
|
||||||
if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
|
if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
|
||||||
y /= 2;
|
y /= 2;
|
||||||
}
|
}
|
||||||
@@ -345,6 +345,16 @@ public final class PathRenderer implements Helper {
|
|||||||
drawDankLitGoalBox(player, g, partialTicks, color);
|
drawDankLitGoalBox(player, g, partialTicks, color);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (goal instanceof GoalYLevel) {
|
||||||
|
GoalYLevel goalpos = (GoalYLevel) goal;
|
||||||
|
minX = player.posX - Baritone.settings().yLevelBoxSize.value - renderPosX;
|
||||||
|
minZ = player.posZ - Baritone.settings().yLevelBoxSize.value - renderPosZ;
|
||||||
|
maxX = player.posX + Baritone.settings().yLevelBoxSize.value - renderPosX;
|
||||||
|
maxZ = player.posZ + Baritone.settings().yLevelBoxSize.value - renderPosZ;
|
||||||
|
minY = ((GoalYLevel) goal).level - renderPosY;
|
||||||
|
maxY = minY + 2;
|
||||||
|
y1 = 1 + y + goalpos.level - renderPosY;
|
||||||
|
y2 = 1 - y + goalpos.level - renderPosY;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user