forked from RepoMirrors/baritone
Merge branch 'master' into 1.13.2
This commit is contained in:
commit
50783e65a9
|
@ -14,12 +14,19 @@ Baritone version:
|
|||
Forge mods (if used):
|
||||
|
||||
## Exception, error or logs
|
||||
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
|
||||
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue
|
||||
|
||||
Linux: `~/.minecraft/logs/`
|
||||
|
||||
Windows: `%appdata%/.minecraft/logs/`
|
||||
|
||||
Mac: `/Library/Application\ Support/minecraft/logs/`
|
||||
|
||||
## How to reproduce
|
||||
Add your steps to reproduce the issue/bug experienced here.
|
||||
|
||||
## Final checklist
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
|
||||
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
|
|
@ -10,4 +10,5 @@ assignees: ''
|
|||
With as much detail as possible, describe your question and what you may need help with.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
|
|
@ -16,4 +16,5 @@ If applicable, what settings/customizability should be offered to tweak the func
|
|||
Describe how your suggestion would improve Baritone, or the reason behind it being added.
|
||||
|
||||
## Final checklist
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
- [x] I know how to properly use check boxes
|
||||
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||
|
|
12
README.md
12
README.md
|
@ -8,6 +8,7 @@
|
|||
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/)
|
||||
[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/)
|
||||
|
@ -22,6 +23,7 @@
|
|||
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.10%20/%20v1.3.5%20/%20v1.4.3-brightgreen.svg)](https://impactclient.net/)
|
||||
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/)
|
||||
[![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api)
|
||||
[![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.11-green.svg)](https://rootnet.dev/)
|
||||
[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/)
|
||||
[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/)
|
||||
[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/)
|
||||
|
@ -29,14 +31,14 @@
|
|||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
|
||||
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description.
|
||||
|
||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
|
||||
|
||||
|
@ -56,6 +58,10 @@ Here are some links to help to get started:
|
|||
|
||||
- [Usage (chat control)](USAGE.md)
|
||||
|
||||
## Stars over time
|
||||
|
||||
[![Stargazers over time](https://starchart.cc/cabaletta/baritone.svg)](https://starchart.cc/cabaletta/baritone)
|
||||
|
||||
# API
|
||||
|
||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
||||
|
|
18
SETUP.md
18
SETUP.md
|
@ -47,6 +47,8 @@ You can verify whether or not it worked by running `.b version` in chat (only va
|
|||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
|
||||
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8.
|
||||
|
||||
Setting up the Environment:
|
||||
|
||||
```
|
||||
|
@ -54,6 +56,12 @@ $ gradlew setupDecompWorkspace
|
|||
$ gradlew --refresh-dependencies
|
||||
```
|
||||
|
||||
Building Baritone:
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
|
@ -87,16 +95,6 @@ For information on how to build baritone, see [Building Baritone](#building-bari
|
|||
|
||||
![Image](https://i.imgur.com/hrLhG9u.png)
|
||||
|
||||
# Building
|
||||
|
||||
Make sure that you have properly [setup](#setup) the environment before trying to build it.
|
||||
|
||||
## Command Line
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
## IntelliJ
|
||||
|
||||
- Navigate to the gradle tasks on the right tab as follows
|
||||
|
|
2
USAGE.md
2
USAGE.md
|
@ -20,6 +20,8 @@ Try `#help` I promise it won't just send you back here =)
|
|||
|
||||
just look at `#help` lmao
|
||||
|
||||
Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
|
||||
|
||||
# Commands
|
||||
|
||||
**All** of these commands may need a prefix before them, as above ^.
|
||||
|
|
|
@ -134,19 +134,19 @@
|
|||
-assumenosideeffects public class java.lang.* extends java.lang.Number {
|
||||
public static java.lang.String toString(byte);
|
||||
public static java.lang.Byte valueOf(byte);
|
||||
public static byte parseByte(java.lang.String);
|
||||
public static byte parseByte(java.lang.String,int);
|
||||
public static java.lang.Byte valueOf(java.lang.String,int);
|
||||
public static java.lang.Byte valueOf(java.lang.String);
|
||||
public static java.lang.Byte decode(java.lang.String);
|
||||
# public static byte parseByte(java.lang.String);
|
||||
# public static byte parseByte(java.lang.String,int);
|
||||
# public static java.lang.Byte valueOf(java.lang.String,int);
|
||||
# public static java.lang.Byte valueOf(java.lang.String);
|
||||
# public static java.lang.Byte decode(java.lang.String);
|
||||
public int compareTo(java.lang.Byte);
|
||||
public static java.lang.String toString(short);
|
||||
public static short parseShort(java.lang.String);
|
||||
public static short parseShort(java.lang.String,int);
|
||||
public static java.lang.Short valueOf(java.lang.String,int);
|
||||
public static java.lang.Short valueOf(java.lang.String);
|
||||
# public static short parseShort(java.lang.String);
|
||||
# public static short parseShort(java.lang.String,int);
|
||||
# public static java.lang.Short valueOf(java.lang.String,int);
|
||||
# public static java.lang.Short valueOf(java.lang.String);
|
||||
public static java.lang.Short valueOf(short);
|
||||
public static java.lang.Short decode(java.lang.String);
|
||||
# public static java.lang.Short decode(java.lang.String);
|
||||
public static short reverseBytes(short);
|
||||
public int compareTo(java.lang.Short);
|
||||
public static java.lang.String toString(int,int);
|
||||
|
@ -154,10 +154,10 @@
|
|||
public static java.lang.String toOctalString(int);
|
||||
public static java.lang.String toBinaryString(int);
|
||||
public static java.lang.String toString(int);
|
||||
public static int parseInt(java.lang.String,int);
|
||||
public static int parseInt(java.lang.String);
|
||||
public static java.lang.Integer valueOf(java.lang.String,int);
|
||||
public static java.lang.Integer valueOf(java.lang.String);
|
||||
# public static int parseInt(java.lang.String,int);
|
||||
# public static int parseInt(java.lang.String);
|
||||
# public static java.lang.Integer valueOf(java.lang.String,int);
|
||||
# public static java.lang.Integer valueOf(java.lang.String);
|
||||
public static java.lang.Integer valueOf(int);
|
||||
public static java.lang.Integer getInteger(java.lang.String);
|
||||
public static java.lang.Integer getInteger(java.lang.String,int);
|
||||
|
@ -179,12 +179,12 @@
|
|||
public static java.lang.String toOctalString(long);
|
||||
public static java.lang.String toBinaryString(long);
|
||||
public static java.lang.String toString(long);
|
||||
public static long parseLong(java.lang.String,int);
|
||||
public static long parseLong(java.lang.String);
|
||||
public static java.lang.Long valueOf(java.lang.String,int);
|
||||
public static java.lang.Long valueOf(java.lang.String);
|
||||
# public static long parseLong(java.lang.String,int);
|
||||
# public static long parseLong(java.lang.String);
|
||||
# public static java.lang.Long valueOf(java.lang.String,int);
|
||||
# public static java.lang.Long valueOf(java.lang.String);
|
||||
public static java.lang.Long valueOf(long);
|
||||
public static java.lang.Long decode(java.lang.String);
|
||||
# public static java.lang.Long decode(java.lang.String);
|
||||
public static java.lang.Long getLong(java.lang.String);
|
||||
public static java.lang.Long getLong(java.lang.String,long);
|
||||
public static java.lang.Long getLong(java.lang.String,java.lang.Long);
|
||||
|
@ -201,9 +201,9 @@
|
|||
public int compareTo(java.lang.Long);
|
||||
public static java.lang.String toString(float);
|
||||
public static java.lang.String toHexString(float);
|
||||
public static java.lang.Float valueOf(java.lang.String);
|
||||
# public static java.lang.Float valueOf(java.lang.String);
|
||||
public static java.lang.Float valueOf(float);
|
||||
public static float parseFloat(java.lang.String);
|
||||
# public static float parseFloat(java.lang.String);
|
||||
public static boolean isNaN(float);
|
||||
public static boolean isInfinite(float);
|
||||
public static int floatToIntBits(float);
|
||||
|
@ -215,9 +215,9 @@
|
|||
public int compareTo(java.lang.Float);
|
||||
public static java.lang.String toString(double);
|
||||
public static java.lang.String toHexString(double);
|
||||
public static java.lang.Double valueOf(java.lang.String);
|
||||
public static java.lang.Double valueOf(double);
|
||||
public static double parseDouble(java.lang.String);
|
||||
# public static java.lang.Double valueOf(java.lang.String);
|
||||
# public static java.lang.Double valueOf(double);
|
||||
# public static double parseDouble(java.lang.String);
|
||||
public static boolean isNaN(double);
|
||||
public static boolean isInfinite(double);
|
||||
public static long doubleToLongBits(double);
|
||||
|
|
|
@ -1050,6 +1050,10 @@ public final class Settings {
|
|||
*/
|
||||
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop Notifications
|
||||
*/
|
||||
public final Setting<Boolean> desktopNotifications = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.util.text.TextComponentString;
|
|||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -47,7 +48,9 @@ public interface Helper {
|
|||
|
||||
static ITextComponent getPrefix() {
|
||||
// Inner text component
|
||||
ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
final Calendar now = Calendar.getInstance();
|
||||
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
|
||||
ITextComponent baritone = new TextComponentString(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
|
||||
baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE);
|
||||
|
||||
// Outer brackets
|
||||
|
|
|
@ -77,6 +77,10 @@ public interface IPlayerContext {
|
|||
return new Rotation(player().rotationYaw, player().rotationPitch);
|
||||
}
|
||||
|
||||
static double eyeHeight(boolean ifSneaking) {
|
||||
return ifSneaking ? 1.54 : 1.62;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block that the crosshair is currently placed over. Updated once per tick.
|
||||
*
|
||||
|
|
|
@ -41,7 +41,16 @@ public final class RayTraceUtils {
|
|||
* @return The calculated raytrace result
|
||||
*/
|
||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
|
||||
Vec3d start = entity.getEyePosition(1.0F);
|
||||
return rayTraceTowards(entity, rotation, blockReachDistance, false);
|
||||
}
|
||||
|
||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) {
|
||||
Vec3d start;
|
||||
if (wouldSneak) {
|
||||
start = inferSneakingEyePosition(entity);
|
||||
} else {
|
||||
start = entity.getEyePosition(1.0F); // do whatever is correct
|
||||
}
|
||||
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
||||
Vec3d end = start.add(
|
||||
direction.x * blockReachDistance,
|
||||
|
@ -50,4 +59,8 @@ public final class RayTraceUtils {
|
|||
);
|
||||
return entity.world.rayTraceBlocks(start, end, RayTraceFluidMode.NEVER, false, true);
|
||||
}
|
||||
|
||||
public static Vec3d inferSneakingEyePosition(Entity entity) {
|
||||
return new Vec3d(entity.posX, entity.posY + IPlayerContext.eyeHeight(true), entity.posZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,10 @@ public final class RotationUtils {
|
|||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||
}
|
||||
|
||||
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, boolean wouldSneak) {
|
||||
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance(), wouldSneak);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified entity is able to reach the center of any of the sides
|
||||
* of the specified block. It first checks if the block center is reachable, and if so,
|
||||
|
@ -159,6 +163,10 @@ public final class RotationUtils {
|
|||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) {
|
||||
return reachable(entity, pos, blockReachDistance, false);
|
||||
}
|
||||
|
||||
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
|
||||
if (baritone.getPlayerContext().isLookingAt(pos)) {
|
||||
/*
|
||||
|
@ -171,9 +179,18 @@ public final class RotationUtils {
|
|||
*
|
||||
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
|
||||
*/
|
||||
return Optional.of(new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F));
|
||||
Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F);
|
||||
if (wouldSneak) {
|
||||
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
|
||||
if (result != null && result.type == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(pos)) {
|
||||
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
|
||||
}
|
||||
} else {
|
||||
return Optional.of(hypothetical);
|
||||
}
|
||||
}
|
||||
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance);
|
||||
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance, wouldSneak);
|
||||
//System.out.println("center: " + possibleRotation);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
|
@ -188,7 +205,7 @@ public final class RotationUtils {
|
|||
double xDiff = shape.getStart(EnumFacing.Axis.X) * sideOffset.x + shape.getEnd(EnumFacing.Axis.X) * (1 - sideOffset.x);
|
||||
double yDiff = shape.getStart(EnumFacing.Axis.Y) * sideOffset.y + shape.getEnd(EnumFacing.Axis.Y) * (1 - sideOffset.y);
|
||||
double zDiff = shape.getStart(EnumFacing.Axis.Z) * sideOffset.z + shape.getEnd(EnumFacing.Axis.Z) * (1 - sideOffset.z);
|
||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
|
||||
if (possibleRotation.isPresent()) {
|
||||
return possibleRotation;
|
||||
}
|
||||
|
@ -207,9 +224,10 @@ public final class RotationUtils {
|
|||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
|
||||
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance, boolean wouldSneak) {
|
||||
Vec3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
|
||||
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
|
||||
//System.out.println(result);
|
||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
||||
if (result.getBlockPos().equals(pos)) {
|
||||
|
@ -231,7 +249,7 @@ public final class RotationUtils {
|
|||
* @param blockReachDistance The block reach distance of the entity
|
||||
* @return The optional rotation
|
||||
*/
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance);
|
||||
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
|
||||
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
|||
int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ();
|
||||
double dist = Math.sqrt(distX * distX + distZ * distZ);
|
||||
if (dist > 1024) {
|
||||
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
|
||||
if (!Baritone.settings().censorCoordinates.value) {
|
||||
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
|
||||
}
|
||||
cachedRegions.remove(getRegionID(region.getX(), region.getZ()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import baritone.api.utils.Helper;
|
|||
import baritone.api.utils.PathCalculationResult;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import baritone.utils.NotificationHelper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -216,6 +217,9 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper {
|
|||
if (logInfo) {
|
||||
logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks");
|
||||
logDebug("No path found =(");
|
||||
if (Baritone.settings().desktopNotifications.value) {
|
||||
NotificationHelper.notify("No path found =(", true);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||
//i'm doing it anyway
|
||||
//i dont care if theres snow in the way!!!!!!!
|
||||
//you dont own me!!!!
|
||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
|
||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
|
||||
VecUtils.getBlockPosCenter(blockPos), ctx.playerRotations()), true)
|
||||
);
|
||||
// don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block
|
||||
|
|
|
@ -518,9 +518,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||
}
|
||||
|
||||
|
||||
static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) {
|
||||
static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown, boolean wouldSneak) {
|
||||
IPlayerContext ctx = baritone.getPlayerContext();
|
||||
Optional<Rotation> direct = RotationUtils.reachable(ctx, placeAt); // we assume that if there is a block there, it must be replacable
|
||||
Optional<Rotation> direct = RotationUtils.reachable(ctx, placeAt, wouldSneak); // we assume that if there is a block there, it must be replacable
|
||||
boolean found = false;
|
||||
if (direct.isPresent()) {
|
||||
state.setTarget(new MovementState.MovementTarget(direct.get(), true));
|
||||
|
@ -538,7 +538,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||
double faceY = (placeAt.getY() + against1.getY() + 0.5D) * 0.5D;
|
||||
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
||||
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
|
||||
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance(), wouldSneak);
|
||||
if (res != null && res.type == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) {
|
||||
state.setTarget(new MovementState.MovementTarget(place, true));
|
||||
found = true;
|
||||
|
@ -556,11 +556,17 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||
EnumFacing side = ctx.objectMouseOver().sideHit;
|
||||
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
|
||||
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
|
||||
if (wouldSneak) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
||||
return PlaceResult.READY_TO_PLACE;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (wouldSneak) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
||||
return PlaceResult.ATTEMPTING;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class MovementAscend extends Movement {
|
|||
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
||||
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
||||
ticksWithoutPlacement++;
|
||||
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
|
||||
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true) == PlaceResult.READY_TO_PLACE) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
if (ctx.player().isSneaking()) {
|
||||
state.setInput(Input.CLICK_RIGHT, true);
|
||||
|
|
|
@ -224,7 +224,7 @@ public class MovementDescend extends Movement {
|
|||
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
|
||||
EntityPlayerSP player = ctx.player();
|
||||
state.setTarget(new MovementState.MovementTarget(
|
||||
new Rotation(RotationUtils.calcRotationFromVec3d(player.getEyePosition(1.0F),
|
||||
new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
|
||||
new Vec3d(destX, dest.getY(), destZ),
|
||||
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
|
||||
false
|
||||
|
|
|
@ -251,7 +251,7 @@ public class MovementParkour extends Movement {
|
|||
}
|
||||
} else if (!ctx.playerFeet().equals(src)) {
|
||||
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) {
|
||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||
state.setInput(Input.CLICK_RIGHT, true);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class MovementPillar extends Movement {
|
|||
}
|
||||
boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE;
|
||||
boolean vine = fromDown.getBlock() == Blocks.VINE;
|
||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
|
||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
|
||||
VecUtils.getBlockPosCenter(positionToPlace),
|
||||
new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch));
|
||||
if (!ladder) {
|
||||
|
|
|
@ -283,7 +283,7 @@ public class MovementTraverse extends Movement {
|
|||
}
|
||||
}
|
||||
double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
|
||||
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false);
|
||||
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true);
|
||||
if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
|||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
for (BlockPos toPlace : toFillIn()) {
|
||||
MovementState fake = new MovementState();
|
||||
switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false)) {
|
||||
switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false, false)) {
|
||||
case NO_OPTION:
|
||||
continue;
|
||||
case READY_TO_PLACE:
|
||||
|
|
|
@ -230,7 +230,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
|||
both.addAll(openSoulsand);
|
||||
for (BlockPos pos : both) {
|
||||
boolean soulsand = openSoulsand.contains(pos);
|
||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
|
||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false);
|
||||
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
|
||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
|
||||
if (result.type == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) {
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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.utils;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This class is not called from the main game thread.
|
||||
* Do not refer to any Minecraft classes, it wouldn't be thread safe.
|
||||
*
|
||||
* @author aUniqueUser
|
||||
*/
|
||||
public class NotificationHelper {
|
||||
|
||||
private static TrayIcon trayIcon;
|
||||
|
||||
public static void notify(String text, boolean error) {
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
windows(text, error);
|
||||
} else if (SystemUtils.IS_OS_MAC_OSX) {
|
||||
mac(text);
|
||||
} else if (SystemUtils.IS_OS_LINUX) {
|
||||
linux(text);
|
||||
}
|
||||
}
|
||||
|
||||
private static void windows(String text, boolean error) {
|
||||
if (SystemTray.isSupported()) {
|
||||
try {
|
||||
if (trayIcon == null) {
|
||||
SystemTray tray = SystemTray.getSystemTray();
|
||||
Image image = Toolkit.getDefaultToolkit().createImage("");
|
||||
|
||||
trayIcon = new TrayIcon(image, "Baritone");
|
||||
trayIcon.setImageAutoSize(true);
|
||||
trayIcon.setToolTip("Baritone");
|
||||
tray.add(trayIcon);
|
||||
}
|
||||
|
||||
trayIcon.displayMessage("Baritone", text, error ? TrayIcon.MessageType.ERROR : TrayIcon.MessageType.INFO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("SystemTray is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private static void mac(String text) {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command("osascript", "-e", "display notification \"" + text + "\" with title \"Baritone\"");
|
||||
try {
|
||||
processBuilder.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// The only way to display notifications on linux is to use the java-gnome library,
|
||||
// or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome
|
||||
// library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome)
|
||||
private static void linux(String text) {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command("notify-send", "-a", "Baritone", text);
|
||||
try {
|
||||
processBuilder.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue