mirror of https://github.com/cabaletta/baritone
Merge branch 'master' into 1.13.2
This commit is contained in:
commit
8f63dd4ba6
32
README.md
32
README.md
|
@ -1,15 +1,15 @@
|
||||||
# Baritone
|
# Baritone
|
||||||
[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone)
|
[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/)
|
||||||
[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases)
|
[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/)
|
||||||
[![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE)
|
[![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE)
|
||||||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||||
[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone)
|
[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/)
|
||||||
[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases)
|
[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/)
|
||||||
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2)
|
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://github.com/cabaletta/baritone/tree/master/)
|
||||||
[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.2)
|
[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.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)
|
[![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)
|
[![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)
|
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/)
|
||||||
[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/)
|
[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/)
|
||||||
[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||||
[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/)
|
[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/)
|
||||||
|
@ -24,20 +24,22 @@
|
||||||
[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/)
|
[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||||
[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/)
|
[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/)
|
||||||
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/)
|
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/)
|
||||||
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax)
|
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/)
|
||||||
[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/)
|
[![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/)
|
[![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)
|
[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/)
|
||||||
[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com)
|
[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/)
|
||||||
|
|
||||||
A Minecraft pathfinder bot.
|
A Minecraft pathfinder bot.
|
||||||
|
|
||||||
Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) 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://impactdevelopment.github.io/) 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.
|
||||||
|
|
||||||
|
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge 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.
|
||||||
|
|
||||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
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 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).
|
||||||
|
|
||||||
Have committed at least once a day for the last 10 months =D 🦀
|
Have committed at least once a day for the last 11 months =D 🦀
|
||||||
|
|
||||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||||
|
|
||||||
|
@ -49,15 +51,15 @@ Here are some links to help to get started:
|
||||||
|
|
||||||
- [Installation & setup](SETUP.md)
|
- [Installation & setup](SETUP.md)
|
||||||
|
|
||||||
- [API Javadocs](https://baritone.leijurv.com)
|
- [API Javadocs](https://baritone.leijurv.com/)
|
||||||
|
|
||||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
||||||
|
|
||||||
- [Baritone chat control usage](USAGE.md)
|
- [Usage (chat control)](USAGE.md)
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0
|
||||||
|
|
||||||
## How is it so fast?
|
## How is it so fast?
|
||||||
|
|
||||||
Magic. (Hours of [leijurv](https://github.com/leijurv) enduring excruciating pain)
|
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||||
|
|
||||||
## Why is it called Baritone?
|
## Why is it called Baritone?
|
||||||
|
|
||||||
|
|
4
SETUP.md
4
SETUP.md
|
@ -1,5 +1,9 @@
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
|
||||||
|
|
||||||
|
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||||
|
|
||||||
## Prebuilt official releases
|
## Prebuilt official releases
|
||||||
These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself)
|
These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself)
|
||||||
|
|
||||||
|
|
3
USAGE.md
3
USAGE.md
|
@ -16,9 +16,6 @@ To disable direct chat control (with no prefix), turn off the `chatControl` sett
|
||||||
|
|
||||||
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
|
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some common examples:
|
Some common examples:
|
||||||
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
||||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate
|
- `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate
|
||||||
|
|
|
@ -160,11 +160,11 @@ public class SettingsUtil {
|
||||||
|
|
||||||
private final Settings.Setting<?> setting;
|
private final Settings.Setting<?> setting;
|
||||||
|
|
||||||
public ParserContext(Settings.Setting<?> setting) {
|
private ParserContext(Settings.Setting<?> setting) {
|
||||||
this.setting = setting;
|
this.setting = setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Settings.Setting<?> getSetting() {
|
private Settings.Setting<?> getSetting() {
|
||||||
return this.setting;
|
return this.setting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.List;
|
||||||
public final class BaritoneProvider implements IBaritoneProvider {
|
public final class BaritoneProvider implements IBaritoneProvider {
|
||||||
|
|
||||||
private final Baritone primary = new Baritone();
|
private final Baritone primary = new Baritone();
|
||||||
|
private final List<IBaritone> all = Collections.singletonList(primary);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBaritone getPrimaryBaritone() {
|
public IBaritone getPrimaryBaritone() {
|
||||||
|
@ -40,8 +41,7 @@ public final class BaritoneProvider implements IBaritoneProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IBaritone> getAllBaritones() {
|
public List<IBaritone> getAllBaritones() {
|
||||||
// TODO return a CopyOnWriteArrayList
|
return all;
|
||||||
return Collections.singletonList(primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -303,6 +303,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
break;
|
break;
|
||||||
|
} catch (Throwable th) {
|
||||||
|
// in the case of an exception, keep consuming from the queue so as not to leak memory
|
||||||
|
th.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,14 @@ import baritone.api.pathing.movement.IMovement;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.*;
|
import baritone.api.utils.*;
|
||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.entity.item.EntityFallingBlock;
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public abstract class Movement implements IMovement, MovementHelper {
|
public abstract class Movement implements IMovement, MovementHelper {
|
||||||
|
|
||||||
|
@ -62,6 +61,8 @@ public abstract class Movement implements IMovement, MovementHelper {
|
||||||
public List<BlockPos> toPlaceCached = null;
|
public List<BlockPos> toPlaceCached = null;
|
||||||
public List<BlockPos> toWalkIntoCached = null;
|
public List<BlockPos> toWalkIntoCached = null;
|
||||||
|
|
||||||
|
private Set<BetterBlockPos> validPositionsCached = null;
|
||||||
|
|
||||||
private Boolean calculatedWhileLoaded;
|
private Boolean calculatedWhileLoaded;
|
||||||
|
|
||||||
protected Movement(IBaritone baritone, BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) {
|
protected Movement(IBaritone baritone, BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) {
|
||||||
|
@ -99,6 +100,20 @@ public abstract class Movement implements IMovement, MovementHelper {
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract Set<BetterBlockPos> calculateValidPositions();
|
||||||
|
|
||||||
|
public Set<BetterBlockPos> getValidPositions() {
|
||||||
|
if (validPositionsCached == null) {
|
||||||
|
validPositionsCached = calculateValidPositions();
|
||||||
|
Objects.requireNonNull(validPositionsCached);
|
||||||
|
}
|
||||||
|
return validPositionsCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean playerInValidPosition() {
|
||||||
|
return getValidPositions().contains(ctx.playerFeet()) || getValidPositions().contains(((PathingBehavior) baritone.getPathingBehavior()).pathStart());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the execution of the latest Movement
|
* Handles the execution of the latest Movement
|
||||||
* State, and offers a Status to the calling class.
|
* State, and offers a Status to the calling class.
|
||||||
|
|
|
@ -27,11 +27,14 @@ import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementAscend extends Movement {
|
public class MovementAscend extends Movement {
|
||||||
|
|
||||||
private int ticksWithoutPlacement = 0;
|
private int ticksWithoutPlacement = 0;
|
||||||
|
@ -51,6 +54,17 @@ public class MovementAscend extends Movement {
|
||||||
return cost(context, src.x, src.y, src.z, dest.x, dest.z);
|
return cost(context, src.x, src.y, src.z, dest.x, dest.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
BetterBlockPos prior = new BetterBlockPos(src.subtract(getDirection()).up()); // sometimes we back up to place the block, also sprint ascends, also skip descend to straight ascend
|
||||||
|
return ImmutableSet.of(src,
|
||||||
|
src.up(),
|
||||||
|
dest,
|
||||||
|
prior,
|
||||||
|
prior.up()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState toPlace = context.get(destX, y, destZ);
|
IBlockState toPlace = context.get(destX, y, destZ);
|
||||||
double additionalPlacementCost = 0;
|
double additionalPlacementCost = 0;
|
||||||
|
@ -143,6 +157,10 @@ public class MovementAscend extends Movement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovementState updateState(MovementState state) {
|
public MovementState updateState(MovementState state) {
|
||||||
|
if (ctx.playerFeet().y < src.y) {
|
||||||
|
// this check should run even when in preparing state (breaking blocks)
|
||||||
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
|
}
|
||||||
super.updateState(state);
|
super.updateState(state);
|
||||||
// TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump
|
// TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump
|
||||||
// for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly)
|
// for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly)
|
||||||
|
@ -154,10 +172,6 @@ public class MovementAscend extends Movement {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.playerFeet().y < src.y) {
|
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
||||||
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
||||||
ticksWithoutPlacement++;
|
ticksWithoutPlacement++;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockFalling;
|
import net.minecraft.block.BlockFalling;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -37,6 +38,8 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementDescend extends Movement {
|
public class MovementDescend extends Movement {
|
||||||
|
|
||||||
private int numTicks = 0;
|
private int numTicks = 0;
|
||||||
|
@ -61,6 +64,11 @@ public class MovementDescend extends Movement {
|
||||||
return result.cost;
|
return result.cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
return ImmutableSet.of(src, dest.up(), dest);
|
||||||
|
}
|
||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||||
double totalCost = 0;
|
double totalCost = 0;
|
||||||
IBlockState destDown = context.get(destX, y - 1, destZ);
|
IBlockState destDown = context.get(destX, y - 1, destZ);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -36,6 +37,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementDiagonal extends Movement {
|
public class MovementDiagonal extends Movement {
|
||||||
|
|
||||||
|
@ -64,6 +66,16 @@ public class MovementDiagonal extends Movement {
|
||||||
return result.cost;
|
return result.cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
BetterBlockPos diagA = new BetterBlockPos(src.x, src.y, dest.z);
|
||||||
|
BetterBlockPos diagB = new BetterBlockPos(dest.x, src.y, src.z);
|
||||||
|
if (dest.y != src.y) { // only if allowDiagonalDescend
|
||||||
|
return ImmutableSet.of(src, dest.up(), diagA, diagB, dest, diagA.down(), diagB.down());
|
||||||
|
}
|
||||||
|
return ImmutableSet.of(src, dest, diagA, diagB);
|
||||||
|
}
|
||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||||
IBlockState destInto = context.get(destX, y, destZ);
|
IBlockState destInto = context.get(destX, y, destZ);
|
||||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
||||||
|
@ -172,8 +184,9 @@ public class MovementDiagonal extends Movement {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest)) {
|
||||||
state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
return state;
|
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) {
|
||||||
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
if (sprint()) {
|
if (sprint()) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
|
@ -182,7 +195,7 @@ public class MovementDiagonal extends Movement {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sprint() {
|
private boolean sprint() {
|
||||||
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) {
|
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,13 @@ import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementDownward extends Movement {
|
public class MovementDownward extends Movement {
|
||||||
|
|
||||||
private int numTicks = 0;
|
private int numTicks = 0;
|
||||||
|
@ -47,6 +50,11 @@ public class MovementDownward extends Movement {
|
||||||
return cost(context, src.x, src.y, src.z);
|
return cost(context, src.x, src.y, src.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
return ImmutableSet.of(src, dest);
|
||||||
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
if (!context.allowDownward) {
|
if (!context.allowDownward) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
|
@ -73,6 +81,8 @@ public class MovementDownward extends Movement {
|
||||||
|
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
|
} else if (!playerInValidPosition()) {
|
||||||
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
double diffX = ctx.player().posX - (dest.getX() + 0.5);
|
double diffX = ctx.player().posX - (dest.getX() + 0.5);
|
||||||
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
|
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
|
||||||
|
|
|
@ -43,7 +43,9 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementFall extends Movement {
|
public class MovementFall extends Movement {
|
||||||
|
|
||||||
|
@ -64,6 +66,16 @@ public class MovementFall extends Movement {
|
||||||
return result.cost;
|
return result.cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
Set<BetterBlockPos> set = new HashSet<>();
|
||||||
|
set.add(src);
|
||||||
|
for (int y = src.y - dest.y; y >= 0; y--) {
|
||||||
|
set.add(dest.up(y));
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean willPlaceBucket() {
|
private boolean willPlaceBucket() {
|
||||||
CalculationContext context = new CalculationContext(baritone);
|
CalculationContext context = new CalculationContext(baritone);
|
||||||
MutableMoveResult result = new MutableMoveResult();
|
MutableMoveResult result = new MutableMoveResult();
|
||||||
|
|
|
@ -35,6 +35,9 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Fluids;
|
import net.minecraft.init.Fluids;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementParkour extends Movement {
|
public class MovementParkour extends Movement {
|
||||||
|
|
||||||
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
||||||
|
@ -175,6 +178,17 @@ public class MovementParkour extends Movement {
|
||||||
return res.cost;
|
return res.cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
Set<BetterBlockPos> set = new HashSet<>();
|
||||||
|
for (int i = 0; i <= dist; i++) {
|
||||||
|
for (int y = 0; y < 2; y++) {
|
||||||
|
set.add(src.offset(direction, i).up(y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean safeToCancel(MovementState state) {
|
public boolean safeToCancel(MovementState state) {
|
||||||
// once this movement is instantiated, the state is default to PREPPING
|
// once this movement is instantiated, the state is default to PREPPING
|
||||||
|
|
|
@ -30,6 +30,7 @@ import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -37,6 +38,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementPillar extends Movement {
|
public class MovementPillar extends Movement {
|
||||||
|
|
||||||
|
@ -49,6 +51,11 @@ public class MovementPillar extends Movement {
|
||||||
return cost(context, src.x, src.y, src.z);
|
return cost(context, src.x, src.y, src.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
return ImmutableSet.of(src, dest);
|
||||||
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
IBlockState fromState = context.get(x, y, z);
|
IBlockState fromState = context.get(x, y, z);
|
||||||
Block from = fromState.getBlock();
|
Block from = fromState.getBlock();
|
||||||
|
|
|
@ -30,6 +30,7 @@ import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
import net.minecraft.fluid.WaterFluid;
|
||||||
|
@ -38,6 +39,8 @@ import net.minecraft.state.properties.SlabType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementTraverse extends Movement {
|
public class MovementTraverse extends Movement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +63,11 @@ public class MovementTraverse extends Movement {
|
||||||
return cost(context, src.x, src.y, src.z, dest.x, dest.z);
|
return cost(context, src.x, src.y, src.z, dest.x, dest.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<BetterBlockPos> calculateValidPositions() {
|
||||||
|
return ImmutableSet.of(src, dest);
|
||||||
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
||||||
IBlockState pb1 = context.get(destX, y, destZ);
|
IBlockState pb1 = context.get(destX, y, destZ);
|
||||||
|
@ -197,13 +205,12 @@ public class MovementTraverse extends Movement {
|
||||||
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
|
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
|
||||||
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
|
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
|
||||||
|
|
||||||
if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) {
|
if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor)
|
||||||
if ((pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)
|
&& (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)
|
||||||
|| pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src))
|
|| pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src))
|
||||||
&& !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
&& !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
||||||
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
|
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
|
||||||
.setInput(Input.CLICK_RIGHT, true);
|
.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.movements.*;
|
import baritone.pathing.movement.movements.*;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -99,14 +98,13 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
if (pathPosition >= path.length()) {
|
if (pathPosition >= path.length()) {
|
||||||
return true; // stop bugging me, I'm done
|
return true; // stop bugging me, I'm done
|
||||||
}
|
}
|
||||||
BetterBlockPos whereShouldIBe = path.positions().get(pathPosition);
|
Movement movement = (Movement) path.movements().get(pathPosition);
|
||||||
BetterBlockPos whereAmI = ctx.playerFeet();
|
BetterBlockPos whereAmI = ctx.playerFeet();
|
||||||
if (!whereShouldIBe.equals(whereAmI) && !Blocks.AIR.equals(BlockStateInterface.getBlock(ctx, whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
if (!movement.getValidPositions().contains(whereAmI)) {
|
||||||
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
for (int i = 0; i < pathPosition && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
||||||
if (whereAmI.equals(path.positions().get(i))) {
|
if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) {
|
||||||
logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i);
|
|
||||||
int previousPos = pathPosition;
|
int previousPos = pathPosition;
|
||||||
pathPosition = Math.max(i - 1, 0); // previous step might not actually be done
|
pathPosition = i;
|
||||||
for (int j = pathPosition; j <= previousPos; j++) {
|
for (int j = pathPosition; j <= previousPos; j++) {
|
||||||
path.movements().get(j).reset();
|
path.movements().get(j).reset();
|
||||||
}
|
}
|
||||||
|
@ -115,9 +113,9 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = pathPosition + 3; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing)
|
for (int i = pathPosition + 3; i < path.length() - 1; i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing)
|
||||||
// also don't check pathPosition+2 because reasons
|
// also don't check pathPosition+2 because reasons
|
||||||
if (whereAmI.equals(path.positions().get(i))) {
|
if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) {
|
||||||
if (i - pathPosition > 2) {
|
if (i - pathPosition > 2) {
|
||||||
logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i);
|
logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i);
|
||||||
}
|
}
|
||||||
|
@ -146,38 +144,6 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
cancel();
|
cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//this commented block is literally cursed.
|
|
||||||
/*Out.log(actions.get(pathPosition));
|
|
||||||
if (pathPosition < actions.size() - 1) {//if there are two ActionBridges in a row and they are at right angles, walk diagonally. This makes it so you walk at 45 degrees along a zigzag path instead of doing inefficient zigging and zagging
|
|
||||||
if ((actions.get(pathPosition) instanceof ActionBridge) && (actions.get(pathPosition + 1) instanceof ActionBridge)) {
|
|
||||||
ActionBridge curr = (ActionBridge) actions.get(pathPosition);
|
|
||||||
ActionBridge next = (ActionBridge) actions.get(pathPosition + 1);
|
|
||||||
if (curr.dx() != next.dx() || curr.dz() != next.dz()) {//two movement are not parallel, so this is a right angle
|
|
||||||
if (curr.amIGood() && next.amIGood()) {//nothing in the way
|
|
||||||
BlockPos cornerToCut1 = new BlockPos(next.to.getX() - next.from.getX() + curr.from.getX(), next.to.getY(), next.to.getZ() - next.from.getZ() + curr.from.getZ());
|
|
||||||
BlockPos cornerToCut2 = cornerToCut1.up();
|
|
||||||
//Block corner1 = Baritone.get(cornerToCut1).getBlock();
|
|
||||||
//Block corner2 = Baritone.get(cornerToCut2).getBlock();
|
|
||||||
//Out.gui("Cutting conner " + cornerToCut1 + " " + corner1, Out.Mode.Debug);
|
|
||||||
if (!Action.avoidWalkingInto(cornerToCut1) && !Action.avoidWalkingInto(cornerToCut2)) {
|
|
||||||
double x = (next.from.getX() + next.to.getX() + 1.0D) * 0.5D;
|
|
||||||
double z = (next.from.getZ() + next.to.getZ() + 1.0D) * 0.5D;
|
|
||||||
MovementManager.clearMovement();
|
|
||||||
if (!MovementManager.forward && curr.oneInTen != null && curr.oneInTen) {
|
|
||||||
MovementManager.clearMovement();
|
|
||||||
MovementManager.forward = LookManager.lookAtCoords(x, 0, z, false);
|
|
||||||
} else {
|
|
||||||
MovementManager.moveTowardsCoords(x, 0, z);
|
|
||||||
}
|
|
||||||
if (MovementManager.forward && !MovementManager.backward) {
|
|
||||||
thePlayer.setSprinting(true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
//long start = System.nanoTime() / 1000000L;
|
//long start = System.nanoTime() / 1000000L;
|
||||||
BlockStateInterface bsi = new BlockStateInterface(ctx);
|
BlockStateInterface bsi = new BlockStateInterface(ctx);
|
||||||
for (int i = pathPosition - 10; i < pathPosition + 10; i++) {
|
for (int i = pathPosition - 10; i < pathPosition + 10; i++) {
|
||||||
|
@ -204,10 +170,10 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
HashSet<BlockPos> newPlace = new HashSet<>();
|
HashSet<BlockPos> newPlace = new HashSet<>();
|
||||||
HashSet<BlockPos> newWalkInto = new HashSet<>();
|
HashSet<BlockPos> newWalkInto = new HashSet<>();
|
||||||
for (int i = pathPosition; i < path.movements().size(); i++) {
|
for (int i = pathPosition; i < path.movements().size(); i++) {
|
||||||
Movement movement = (Movement) path.movements().get(i);
|
Movement m = (Movement) path.movements().get(i);
|
||||||
newBreak.addAll(movement.toBreak(bsi));
|
newBreak.addAll(m.toBreak(bsi));
|
||||||
newPlace.addAll(movement.toPlace(bsi));
|
newPlace.addAll(m.toPlace(bsi));
|
||||||
newWalkInto.addAll(movement.toWalkInto(bsi));
|
newWalkInto.addAll(m.toWalkInto(bsi));
|
||||||
}
|
}
|
||||||
toBreak = newBreak;
|
toBreak = newBreak;
|
||||||
toPlace = newPlace;
|
toPlace = newPlace;
|
||||||
|
@ -218,7 +184,14 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
if (end - start > 0) {
|
if (end - start > 0) {
|
||||||
System.out.println("Recalculating break and place took " + (end - start) + "ms");
|
System.out.println("Recalculating break and place took " + (end - start) + "ms");
|
||||||
}*/
|
}*/
|
||||||
IMovement movement = path.movements().get(pathPosition);
|
if (pathPosition < path.movements().size() - 1) {
|
||||||
|
IMovement next = path.movements().get(pathPosition + 1);
|
||||||
|
if (!behavior.baritone.bsi.worldContainsLoadedChunk(next.getDest().x, next.getDest().z)) {
|
||||||
|
logDebug("Pausing since destination is at edge of loaded chunks");
|
||||||
|
clearKeys();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean canCancel = movement.safeToCancel();
|
boolean canCancel = movement.safeToCancel();
|
||||||
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
|
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
|
||||||
costEstimateIndex = pathPosition;
|
costEstimateIndex = pathPosition;
|
||||||
|
@ -232,7 +205,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double currentCost = ((Movement) movement).recalculateCost(behavior.secretInternalGetCalculationContext());
|
double currentCost = movement.recalculateCost(behavior.secretInternalGetCalculationContext());
|
||||||
if (currentCost >= ActionCosts.COST_INF && canCancel) {
|
if (currentCost >= ActionCosts.COST_INF && canCancel) {
|
||||||
logDebug("Something has changed in the world and this movement has become impossible. Cancelling.");
|
logDebug("Something has changed in the world and this movement has become impossible. Cancelling.");
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -284,11 +257,13 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
private Tuple<Double, BlockPos> closestPathPos(IPath path) {
|
private Tuple<Double, BlockPos> closestPathPos(IPath path) {
|
||||||
double best = -1;
|
double best = -1;
|
||||||
BlockPos bestPos = null;
|
BlockPos bestPos = null;
|
||||||
for (BlockPos pos : path.positions()) {
|
for (IMovement movement : path.movements()) {
|
||||||
double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos);
|
for (BlockPos pos : ((Movement) movement).getValidPositions()) {
|
||||||
if (dist < best || best == -1) {
|
double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos);
|
||||||
best = dist;
|
if (dist < best || best == -1) {
|
||||||
bestPos = pos;
|
best = dist;
|
||||||
|
bestPos = pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Tuple<>(best, bestPos);
|
return new Tuple<>(best, bestPos);
|
||||||
|
@ -451,7 +426,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||||
if (current instanceof MovementFall) {
|
if (current instanceof MovementFall) {
|
||||||
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
BlockPos fallDest = data.getB();
|
BetterBlockPos fallDest = new BetterBlockPos(data.getB());
|
||||||
if (!path.positions().contains(fallDest)) {
|
if (!path.positions().contains(fallDest)) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,12 +84,14 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||||
// patience
|
// patience
|
||||||
baritone.getLookBehavior().updateTarget(fake.getTarget().getRotation().get(), true);
|
baritone.getLookBehavior().updateTarget(fake.getTarget().getRotation().get(), true);
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process
|
return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process
|
||||||
}
|
}
|
||||||
|
|
||||||
public void amIBreakingABlockHMMMMMMM() {
|
private void amIBreakingABlockHMMMMMMM() {
|
||||||
if (!ctx.getSelectedBlock().isPresent()) {
|
if (!ctx.getSelectedBlock().isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||||
continue; // irrelevant
|
continue; // irrelevant
|
||||||
}
|
}
|
||||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
IBlockState curr = bcc.bsi.get0(x, y, z);
|
||||||
if (!(curr.getBlock() instanceof BlockAir) && !valid(curr, desired)) {
|
if (!(curr.getBlock() instanceof BlockAir) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired)) {
|
||||||
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
||||||
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||||
if (rot.isPresent()) {
|
if (rot.isPresent()) {
|
||||||
|
|
|
@ -122,6 +122,7 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl
|
||||||
break; // note: this breaks the switch not the for
|
break; // note: this breaks the switch not the for
|
||||||
case EXPLORED:
|
case EXPLORED:
|
||||||
continue; // note: this continues the for
|
continue; // note: this continues the for
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
int centerX = ((chunkX + dx) << 4) + 8;
|
int centerX = ((chunkX + dx) << 4) + 8;
|
||||||
int centerZ = ((chunkZ + dz) << 4) + 8;
|
int centerZ = ((chunkZ + dz) << 4) + 8;
|
||||||
|
|
|
@ -82,7 +82,12 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanWorld() {
|
private void scanWorld() {
|
||||||
cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities).flatMap(List::stream).filter(this::followable).filter(this.filter).distinct().collect(Collectors.toCollection(ArrayList::new));
|
cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.filter(this::followable)
|
||||||
|
.filter(this.filter)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -99,6 +99,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Baritone.settings().allowBreak.value) {
|
||||||
|
logDirect("Unable to mine when allowBreak is false!");
|
||||||
|
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);
|
||||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||||
|
@ -114,7 +119,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||||
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
||||||
.min(Comparator.comparingDouble(ctx.player()::getDistanceSq));
|
.min(Comparator.comparingDouble(ctx.player()::getDistanceSq));
|
||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
if (shaft.isPresent()) {
|
if (shaft.isPresent() && ctx.player().onGround) {
|
||||||
BlockPos pos = shaft.get();
|
BlockPos pos = shaft.get();
|
||||||
IBlockState state = baritone.bsi.get0(pos);
|
IBlockState state = baritone.bsi.get0(pos);
|
||||||
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||||
|
@ -395,6 +400,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||||
@Override
|
@Override
|
||||||
public void mine(int quantity, Block... blocks) {
|
public void mine(int quantity, Block... blocks) {
|
||||||
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks);
|
||||||
|
if (mining != null && !Baritone.settings().allowBreak.value) {
|
||||||
|
logDirect("Unable to mine when allowBreak is false!");
|
||||||
|
mining = null;
|
||||||
|
}
|
||||||
this.desiredQuantity = quantity;
|
this.desiredQuantity = quantity;
|
||||||
this.knownOreLocations = new ArrayList<>();
|
this.knownOreLocations = new ArrayList<>();
|
||||||
this.blacklist = new ArrayList<>();
|
this.blacklist = new ArrayList<>();
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class GuiClick extends GuiScreen {
|
||||||
currentMouseOver = result.getBlockPos();
|
currentMouseOver = result.getBlockPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,7 +121,7 @@ public class GuiClick extends GuiScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toWorld(double x, double y, double z) {
|
private Vec3d toWorld(double x, double y, double z) {
|
||||||
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
||||||
if (result) {
|
if (result) {
|
||||||
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
||||||
|
|
|
@ -100,8 +100,6 @@ public final class PathRenderer implements Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
||||||
//long start = System.nanoTime();
|
|
||||||
|
|
||||||
|
|
||||||
// Render the current path, if there is one
|
// Render the current path, if there is one
|
||||||
if (current != null && current.getPath() != null) {
|
if (current != null && current.getPath() != null) {
|
||||||
|
@ -112,8 +110,6 @@ public final class PathRenderer implements Helper {
|
||||||
drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20);
|
drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
//long split = System.nanoTime();
|
|
||||||
|
|
||||||
// If there is a path calculation currently running, render the path calculation process
|
// If there is a path calculation currently running, render the path calculation process
|
||||||
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
||||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||||
|
@ -125,11 +121,6 @@ public final class PathRenderer implements Helper {
|
||||||
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value);
|
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//long end = System.nanoTime();
|
|
||||||
//System.out.println((end - split) + " " + (split - start));
|
|
||||||
// if (end - start > 0) {
|
|
||||||
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class PathingControlManager implements IPathingControlManager {
|
||||||
p.secretInternalSetGoal(null);
|
p.secretInternalSetGoal(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inControlThisTick != inControlLastTick && command.commandType != PathingCommandType.REQUEST_PAUSE && inControlLastTick != null && !inControlLastTick.isTemporary()) {
|
if (!Objects.equals(inControlThisTick, inControlLastTick) && command.commandType != PathingCommandType.REQUEST_PAUSE && inControlLastTick != null && !inControlLastTick.isTemporary()) {
|
||||||
// if control has changed from a real process to another real process, and the new process wants to do something
|
// if control has changed from a real process to another real process, and the new process wants to do something
|
||||||
p.cancelSegmentIfSafe();
|
p.cancelSegmentIfSafe();
|
||||||
// get rid of the in progress stuff from the last process
|
// get rid of the in progress stuff from the last process
|
||||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.util.MovementInput;
|
||||||
public class PlayerMovementInput extends MovementInput {
|
public class PlayerMovementInput extends MovementInput {
|
||||||
private final InputOverrideHandler handler;
|
private final InputOverrideHandler handler;
|
||||||
|
|
||||||
public PlayerMovementInput(InputOverrideHandler handler) {
|
PlayerMovementInput(InputOverrideHandler handler) {
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class PlayerMovementInput extends MovementInput {
|
||||||
this.moveStrafe = 0.0F;
|
this.moveStrafe = 0.0F;
|
||||||
this.moveForward = 0.0F;
|
this.moveForward = 0.0F;
|
||||||
|
|
||||||
jump = handler.isInputForcedDown(Input.JUMP); // oppa gangnam
|
jump = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
|
||||||
|
|
||||||
if (this.forwardKeyDown = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
|
if (this.forwardKeyDown = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
|
||||||
this.moveForward++;
|
this.moveForward++;
|
||||||
|
|
Loading…
Reference in New Issue