Compare commits

...

79 Commits

Author SHA1 Message Date
Leijurv
cd4205c361 v1.2.7 2019-07-07 12:07:00 -07:00
Leijurv
b81bcf8c6d fix path start in diagonal and downward 2019-07-07 11:44:56 -07:00
Leijurv
4259764b70 thank you off by one errors very cool 2019-07-07 11:12:32 -07:00
Leijurv
8f761f7dff better skip ahead 2019-07-07 11:03:43 -07:00
Leijurv
cbbaf2aa2f unscuff 2019-07-06 20:38:59 -07:00
Leijurv
dd9b84646a disgraceful 2019-07-06 17:07:16 -07:00
Leijurv
94131fd705 too many newlines 2019-07-05 21:19:18 -07:00
Leijurv
6d8914e6c9 spell it out even more 2019-07-04 15:52:09 -07:00
Leijurv
63ee687cee shill EVEN harder 2019-07-03 23:47:47 -07:00
Leijurv
ab779dc850 increase shilling 2019-07-02 22:13:17 -07:00
Leijurv
c2f35ae46f dawn of the final month 2019-07-01 10:21:58 -07:00
Leijurv
199e0e5ed3 better comparison 2019-06-30 21:55:32 -07:00
Leijurv
a8155b4b0b privatize 2019-06-29 11:56:02 -07:00
Leijurv
fdd78cf110 codcacy wants these to be combined 2019-06-28 22:17:31 -07:00
Leijurv
afff6395d1 codcacy wants a default 2019-06-27 21:02:44 -07:00
Leijurv
4d3d48e962 crucial documentation oversight 2019-06-26 23:58:22 -07:00
Leijurv
36290e4e53 crucial encapsulation improvement 2019-06-25 22:54:24 -07:00
Leijurv
fd6923dd28 ok i forgot falling into water 2019-06-24 20:38:17 -07:00
Leijurv
9c64067d49 vastly improve resilience to lagbacks, fixes #446 2019-06-24 17:53:25 -07:00
Leijurv
f4d2ea7923 fix path canceling at edge of loaded chunks hopefully 2019-06-24 10:43:49 -07:00
Leijurv
ce3d3bb244 literally no reason to have this 2019-06-23 22:49:33 -07:00
Leijurv
fa71e7d84f reduce stupidity 2019-06-22 21:11:09 -07:00
Leijurv
b0115b8b4c Merge pull request #447 from babbaj/master
daily commit
2019-06-21 23:59:32 -07:00
Babbaj
3902b2db3b increase line count and improve readability 2019-06-21 23:01:37 -04:00
Leijurv
f998dce614 wow wow 2019-06-20 23:48:02 -07:00
Leijurv
2b9084d2f3 wow 2019-06-19 20:41:21 -07:00
Leijurv
b3605546ac golly another missing slash wow 2019-06-18 23:15:47 -07:00
Leijurv
96097ab726 this counts as a commit 2019-06-17 22:44:38 -07:00
Leijurv
be142d79bc link to the code 2019-06-16 23:06:57 -07:00
Leijurv
0fd241a9ba crucial performance optimization 2019-06-15 11:04:05 -07:00
Leijurv
7b192f17e8 privatize 2019-06-14 21:42:11 -07:00
Leijurv
cc015846d2 explain 2019-06-13 23:13:40 -07:00
Leijurv
e785bd13f5 sanity check 2019-06-12 16:41:05 -07:00
Leijurv
eb6c0a39ea codacy wants this 2019-06-11 23:46:04 -07:00
Leijurv
86525f98ec fix scuffed jumping, fixes #426 2019-06-10 23:12:37 -07:00
Leijurv
94bf703dde this counts as a commit 2019-06-09 23:56:54 -07:00
Leijurv
14bb0a0a80 alt text 2019-06-08 23:13:27 -07:00
Leijurv
1ee6e04f00 this counts as a commit 2019-06-07 21:29:31 -07:00
Brady
ee6796d5e2 crucial performance optimization (pt. 2) 2019-06-07 03:52:46 -05:00
Brady
81d7f3c319 crucial performance optimization 2019-06-07 03:19:23 -05:00
Leijurv
9822962d98 it is tbh 2019-06-06 23:55:12 -07:00
Brady
ce606f826b consistency 2019-06-06 19:05:13 -05:00
Brady
4c4bc8058b Some clean ups 2019-06-06 04:15:43 -05:00
Leijurv
f0210f7c5f add an additional underscore 2019-06-05 22:12:28 -07:00
Leijurv
aef84eceb8 fix a rare crash when the view is occluded by falling sand, fixes #443 2019-06-05 14:26:26 -07:00
Leijurv
a6ea9ed3a6 👶 2019-06-05 12:47:18 -07:00
Leijurv
0815e3c195 thank u intellij very cool suggestion 2019-06-05 12:08:19 -07:00
Leijurv
a1c03eb601 another tool selection fix 2019-06-05 12:04:09 -07:00
Leijurv
1e43563cc3 fix weird backfill behavior 2019-06-04 20:55:31 -07:00
Leijurv
63f3f9123a Merge pull request #409 from babbaj/master
use ImmutableSet
2019-06-03 22:17:14 -07:00
Leijurv
4860d3bd18 Merge pull request #439 from ImpcatDevelopment/delete-user-defined-waypoints
Added the command delete. Allows you to remove a user defined waypoint.
2019-06-03 22:09:08 -07:00
0x22
7fa6593bdc Added the command delete. Allows you to remove a user defined waypoint. Fixes #334 2019-06-04 01:04:13 -04:00
Leijurv
e1dd580df8 fix improper singleplayer check after quitting singleplayer 2019-06-03 15:27:24 -07:00
Leijurv
f19e63d6e9 mc version support is important 2019-06-03 13:43:32 -07:00
Leijurv
130873d91d 1.13.2 2019-06-02 21:33:10 -07:00
Leijurv
9611cb9057 1.13.2 is supported 2019-06-01 17:54:16 -07:00
Leijurv
023aa78d8b yay 2019-06-01 15:36:52 -07:00
Leijurv
39a231eae0 crucial performance optimization 2019-06-01 10:56:24 -07:00
Leijurv
aca6922be0 there is no actual integration 2019-05-31 23:01:16 -07:00
Leijurv
1a52537d0c badges 2019-05-30 20:49:04 -08:00
Leijurv
479b4e3349 releases download count 2019-05-29 10:45:59 -07:00
Leijurv
a1e2b018a2 very good suggestion 2019-05-28 14:17:54 -07:00
Leijurv
aa0f664cda just for debugging purposes 😉 2019-05-27 22:48:06 -07:00
Brady
2e2f4aee1b critical performance enhancement 2019-05-27 02:31:28 -05:00
Leijurv
18474d872c unused 2019-05-26 12:14:08 -07:00
Leijurv
44327c009a Merge pull request #427 from babbaj/master
yet another meaningless commit
2019-05-25 14:30:10 -07:00
Babbaj
de554655a5 yet another meaningless commit 2019-05-25 17:27:06 -04:00
Babbaj
bd0c7b9391 yet another meaningless commit 2019-05-25 17:25:23 -04:00
Babbaj
8d32db5206 Merge branch 'master' of https://github.com/cabaletta/baritone 2019-05-25 17:23:47 -04:00
Leijurv
a6954aa719 bye 2 2019-05-24 10:36:01 -07:00
Leijurv
b4d203ab99 bye 2019-05-23 20:47:22 -08:00
Leijurv
bb924ad83f thank you intellij very cool 2019-05-22 23:41:02 -07:00
Leijurv
79da32cc60 unused 2019-05-21 15:07:05 -07:00
Leijurv
c7fe9c3171 finalize 2019-05-20 22:37:51 -07:00
Leijurv
d70da4f37d finalize these 2019-05-19 21:53:09 -08:00
Leijurv
ccc1b04e81 crucial spacing 2019-05-18 17:11:16 -07:00
Leijurv
352e428890 explicitly set serialized name post obf 2019-05-17 22:21:40 -08:00
Leijurv
4679e12588 better usage 2019-05-16 15:20:52 -07:00
Babbaj
0f61aaafb8 use ImmutableSet 2019-04-28 21:27:11 -04:00
45 changed files with 351 additions and 275 deletions

View File

@@ -4,6 +4,9 @@
[![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)
[![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)
[![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://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)
[![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)
@@ -12,26 +15,26 @@
[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/)
![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg)
![](https://tokei.rs/b1/github/cabaletta/baritone?category=code)
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2)
![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code)
[![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/)
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.5%20/%20v1.3.0-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/)
[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/)
[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-red.svg)](https://github.com/zeroeightysix/KAMI/)
[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/)
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax)
[![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/built-with-swag.svg)](http://forthebadge.com/)
[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/)
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.
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. 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 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.
Have committed at least once a day for the last 8 months =D 🦀
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).
Have committed at least once a day for the last 11 months =D 🦀
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
@@ -47,11 +50,11 @@ Here are some links to help to get started:
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
- [Baritone chat control usage](USAGE.md)
- [Usage (chat control)](USAGE.md)
# 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
jar.
@@ -68,7 +71,7 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd
## Can I use Baritone as a library in my custom utility client?
That's what it's for, sure! (As long as usage is in compliance with the LGPL 3 License)
That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License)
## How is it so fast?

View File

@@ -1,5 +1,9 @@
# 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
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)

View File

@@ -2,30 +2,20 @@
# Prefix
Baritone commands can by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of goal it goes into public chat, which is bad.
Therefore you can use a prefix before your messages.
On Baritone v1.1.0 and newer: The prefix is `#` by default. Anything beginning with `#` isn't sent, and is only interpreted by Baritone.
For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting.
**Only** in Impact is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat. `#` works by default in 4.5 (not 4.4).
Other clients like Kami and Asuna have their own custom things (like `-path`), and can disable direct chat control entirely.
Baritone's chat control prefix is `#` by default. In Impact, you can also use `.b` as a prefix. (for example, `.b click` instead of `#click`)
Baritone commands can also by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of "goal" it goes into public chat, which is bad, so using `#` is suggested.
To disable direct chat control (with no prefix), turn off the `chatControl` setting. To disable chat control with the `#` prefix, turn off the `prefixControl` setting. In Impact, `.b` cannot be disabled. Be careful that you don't leave yourself with all control methods disabled (if you do, reset your settings by deleting the file `minecraft/baritone/settings.txt` and relaunching).
# Commands
**All** of these commands may need a prefix before them, as above ^.
`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java#L53).
`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java#L47).
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:
- `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
@@ -47,7 +37,7 @@ Some common examples:
- `damn` daniel
For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java).
For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java).
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>. If you find HTML easier to read than Javadoc, you can look <a href="https://baritone.leijurv.com/baritone/api/Settings.html#field.detail">here</a>.

View File

@@ -16,7 +16,7 @@
*/
group 'baritone'
version '1.2.6'
version '1.2.7'
buildscript {
repositories {

View File

@@ -33,9 +33,11 @@ import baritone.api.process.IGetToBlockProcess;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ReportedException;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk;
@@ -66,6 +68,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
"get - Same as list\n" +
"show - Same as list\n" +
"save - Saves a waypoint (works but don't try to make sense of it)\n" +
"delete - Deletes a waypoint\n" +
"goto - Paths towards specified block or waypoint\n" +
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
"sethome - Sets \"home\"\n" +
@@ -195,6 +198,17 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
logDirect("Goal: " + goal);
return true;
}
if (msg.equals("crash")) {
StringBuilder meme = new StringBuilder();
CrashReport rep = new CrashReport("Manually triggered debug crash", new Throwable());
mc.addGraphicsAndWorldToCrashReport(rep);
new ReportedException(rep).printStackTrace();
rep.getSectionsInStringBuilder(meme);
System.out.println(meme);
logDirect(meme.toString());
logDirect("ok");
return true;
}
if (msg.equals("path")) {
if (pathingBehavior.getGoal() == null) {
logDirect("No goal.");
@@ -332,7 +346,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
if (suffix.isEmpty()) {
// clear the area from the current goal to here
Goal goal = baritone.getPathingBehavior().getGoal();
if (goal == null || !(goal instanceof GoalBlock)) {
if (!(goal instanceof GoalBlock)) {
logDirect("Need to specify goal of opposite corner");
return true;
}
@@ -385,17 +399,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
logDirect("farming");
return true;
}
// this literally doesn't work, memory is disabled lol
/*if (msg.equals("echest")) {
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
if (contents.isPresent()) {
logDirect("echest contents:");
log(contents.get());
} else {
logDirect("echest contents unknown");
}
return true;
}*/
if (msg.equals("chests")) {
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
logDirect(entry.getKey() + "");
@@ -426,7 +429,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
return true;
}
Entity effectivelyFinal = toFollow.get();
baritone.getFollowProcess().follow(x -> effectivelyFinal.equals(x));
baritone.getFollowProcess().follow(effectivelyFinal::equals);
logDirect("Following " + toFollow.get());
return true;
}
@@ -581,6 +584,17 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
return true;
}
if (msg.startsWith("delete")) {
String name = msg.substring(6).trim();
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
if (waypoint == null) {
logDirect("No user defined position under the name '" + name + "' found.");
return true;
}
baritone.getWorldProvider().getCurrentWorld().getWaypoints().removeWaypoint(waypoint);
logDirect("Deleted user defined position under name '" + name + "'.");
return true;
}
if (msg.startsWith("goto")) {
String waypointType = msg.substring(4).trim();
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
@@ -649,24 +663,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
}
return true;
}
// this is completely impossible from api
/*if (msg.equals("costs")) {
List<Movement> moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new));
while (moves.contains(null)) {
moves.remove(null);
}
moves.sort(Comparator.comparingDouble(move -> move.getCost(new CalculationContext(baritone))));
for (Movement move : moves) {
String[] parts = move.getClass().toString().split("\\.");
double cost = move.getCost();
String strCost = cost + "";
if (cost >= ActionCosts.COST_INF) {
strCost = "IMPOSSIBLE";
}
logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
}
return true;
}*/
if (msg.equals("damn")) {
logDirect("daniel");
}

View File

@@ -17,11 +17,17 @@
package baritone.api.utils;
import com.google.gson.annotations.SerializedName;
/**
* Need a non obfed chunkpos that we can load using GSON
*/
public class MyChunkPos {
@SerializedName("x")
public int x;
@SerializedName("y")
public int z;
@Override

View File

@@ -158,11 +158,11 @@ public class SettingsUtil {
private final Settings.Setting<?> setting;
public ParserContext(Settings.Setting<?> setting) {
private ParserContext(Settings.Setting<?> setting) {
this.setting = setting;
}
final Settings.Setting<?> getSetting() {
private Settings.Setting<?> getSetting() {
return this.setting;
}
}

View File

@@ -41,7 +41,7 @@ public class MixinChunkRenderContainer {
)
)
private BlockPos getPosition(RenderChunk renderChunkIn) {
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);

View File

@@ -43,7 +43,7 @@ public abstract class MixinChunkRenderWorker {
)
)
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {

View File

@@ -47,7 +47,7 @@ public class MixinRenderChunk {
if (!chunkCache.isEmpty()) {
return false;
}
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
@@ -76,7 +76,7 @@ public class MixinRenderChunk {
)
)
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {

View File

@@ -38,7 +38,7 @@ public class MixinRenderList {
)
)
private void popMatrix() {
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
// reset the blend func to normal (not dependent on constant alpha)
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}

View File

@@ -38,7 +38,7 @@ public class MixinVboRenderList {
)
)
private void popMatrix() {
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
// reset the blend func to normal (not dependent on constant alpha)
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}

View File

@@ -32,6 +32,7 @@ import java.util.List;
public final class BaritoneProvider implements IBaritoneProvider {
private final Baritone primary = new Baritone();
private final List<IBaritone> all = Collections.singletonList(primary);
@Override
public IBaritone getPrimaryBaritone() {
@@ -40,8 +41,7 @@ public final class BaritoneProvider implements IBaritoneProvider {
@Override
public List<IBaritone> getAllBaritones() {
// TODO return a CopyOnWriteArrayList
return Collections.singletonList(primary);
return all;
}
@Override

View File

@@ -33,7 +33,7 @@ import java.util.OptionalInt;
import java.util.Random;
import java.util.function.Predicate;
public class InventoryBehavior extends Behavior {
public final class InventoryBehavior extends Behavior {
public InventoryBehavior(Baritone baritone) {
super(baritone);
}

View File

@@ -65,7 +65,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
private boolean lastAutoJump;
private BlockPos expectedSegmentStart;
private BetterBlockPos expectedSegmentStart;
private final LinkedBlockingQueue<PathEvent> toDispatch = new LinkedBlockingQueue<>();

View File

@@ -19,6 +19,7 @@ package baritone.cache;
import baritone.api.utils.BlockUtils;
import baritone.utils.pathing.PathingBlockType;
import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -33,64 +34,60 @@ import java.util.*;
*/
public final class CachedChunk {
public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF;
public static final ImmutableSet<Block> BLOCKS_TO_KEEP_TRACK_OF = ImmutableSet.of(
Blocks.DIAMOND_BLOCK,
//Blocks.COAL_ORE,
Blocks.COAL_BLOCK,
//Blocks.IRON_ORE,
Blocks.IRON_BLOCK,
//Blocks.GOLD_ORE,
Blocks.GOLD_BLOCK,
Blocks.EMERALD_ORE,
Blocks.EMERALD_BLOCK,
static {
HashSet<Block> temp = new HashSet<>();
//temp.add(Blocks.DIAMOND_ORE);
temp.add(Blocks.DIAMOND_BLOCK);
//temp.add(Blocks.COAL_ORE);
temp.add(Blocks.COAL_BLOCK);
//temp.add(Blocks.IRON_ORE);
temp.add(Blocks.IRON_BLOCK);
//temp.add(Blocks.GOLD_ORE);
temp.add(Blocks.GOLD_BLOCK);
temp.add(Blocks.EMERALD_ORE);
temp.add(Blocks.EMERALD_BLOCK);
Blocks.ENDER_CHEST,
Blocks.FURNACE,
Blocks.CHEST,
Blocks.TRAPPED_CHEST,
Blocks.END_PORTAL,
Blocks.END_PORTAL_FRAME,
Blocks.MOB_SPAWNER,
Blocks.BARRIER,
Blocks.OBSERVER,
Blocks.WHITE_SHULKER_BOX,
Blocks.ORANGE_SHULKER_BOX,
Blocks.MAGENTA_SHULKER_BOX,
Blocks.LIGHT_BLUE_SHULKER_BOX,
Blocks.YELLOW_SHULKER_BOX,
Blocks.LIME_SHULKER_BOX,
Blocks.PINK_SHULKER_BOX,
Blocks.GRAY_SHULKER_BOX,
Blocks.SILVER_SHULKER_BOX,
Blocks.CYAN_SHULKER_BOX,
Blocks.PURPLE_SHULKER_BOX,
Blocks.BLUE_SHULKER_BOX,
Blocks.BROWN_SHULKER_BOX,
Blocks.GREEN_SHULKER_BOX,
Blocks.RED_SHULKER_BOX,
Blocks.BLACK_SHULKER_BOX,
Blocks.PORTAL,
Blocks.HOPPER,
Blocks.BEACON,
Blocks.BREWING_STAND,
Blocks.SKULL,
Blocks.ENCHANTING_TABLE,
Blocks.ANVIL,
Blocks.LIT_FURNACE,
Blocks.BED,
Blocks.DRAGON_EGG,
Blocks.JUKEBOX,
Blocks.END_GATEWAY,
Blocks.WEB,
Blocks.NETHER_WART,
Blocks.LADDER,
Blocks.VINE
);
temp.add(Blocks.ENDER_CHEST);
temp.add(Blocks.FURNACE);
temp.add(Blocks.CHEST);
temp.add(Blocks.TRAPPED_CHEST);
temp.add(Blocks.END_PORTAL);
temp.add(Blocks.END_PORTAL_FRAME);
temp.add(Blocks.MOB_SPAWNER);
temp.add(Blocks.BARRIER);
temp.add(Blocks.OBSERVER);
temp.add(Blocks.WHITE_SHULKER_BOX);
temp.add(Blocks.ORANGE_SHULKER_BOX);
temp.add(Blocks.MAGENTA_SHULKER_BOX);
temp.add(Blocks.LIGHT_BLUE_SHULKER_BOX);
temp.add(Blocks.YELLOW_SHULKER_BOX);
temp.add(Blocks.LIME_SHULKER_BOX);
temp.add(Blocks.PINK_SHULKER_BOX);
temp.add(Blocks.GRAY_SHULKER_BOX);
temp.add(Blocks.SILVER_SHULKER_BOX);
temp.add(Blocks.CYAN_SHULKER_BOX);
temp.add(Blocks.PURPLE_SHULKER_BOX);
temp.add(Blocks.BLUE_SHULKER_BOX);
temp.add(Blocks.BROWN_SHULKER_BOX);
temp.add(Blocks.GREEN_SHULKER_BOX);
temp.add(Blocks.RED_SHULKER_BOX);
temp.add(Blocks.BLACK_SHULKER_BOX);
temp.add(Blocks.PORTAL);
temp.add(Blocks.HOPPER);
temp.add(Blocks.BEACON);
temp.add(Blocks.BREWING_STAND);
temp.add(Blocks.SKULL);
temp.add(Blocks.ENCHANTING_TABLE);
temp.add(Blocks.ANVIL);
temp.add(Blocks.LIT_FURNACE);
temp.add(Blocks.BED);
temp.add(Blocks.DRAGON_EGG);
temp.add(Blocks.JUKEBOX);
temp.add(Blocks.END_GATEWAY);
temp.add(Blocks.WEB);
temp.add(Blocks.NETHER_WART);
temp.add(Blocks.LADDER);
temp.add(Blocks.VINE);
BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
}
/**
* The size of the chunk data in bits. Equal to 16 KiB.

View File

@@ -303,6 +303,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
} catch (InterruptedException e) {
e.printStackTrace();
break;
} catch (Throwable th) {
// in the case of an exception, keep consuming from the queue so as not to leak memory
th.printStackTrace();
}
}
}

View File

@@ -62,7 +62,7 @@ public class WorldProvider implements IWorldProvider, Helper {
IntegratedServer integratedServer = mc.getIntegratedServer();
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
if (integratedServer != null) {
if (mc.isSingleplayer()) {
WorldServer localServerWorld = integratedServer.getWorld(dimension);
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();

View File

@@ -86,8 +86,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
if (slowPath) {
try {
Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value);
} catch (InterruptedException ex) {
}
} catch (InterruptedException ignored) {}
}
PathNode currentNode = openSet.removeLowest();
mostRecentConsidered = currentNode;

View File

@@ -96,7 +96,7 @@ class Path extends PathBase {
}
PathNode current = end;
LinkedList<BetterBlockPos> tempPath = new LinkedList<>();
LinkedList<PathNode> tempNodes = new LinkedList();
LinkedList<PathNode> tempNodes = new LinkedList<>();
// Repeatedly inserting to the beginning of an arraylist is O(n^2)
// Instead, do it into a linked list, then convert at the end
while (current != null) {

View File

@@ -23,6 +23,7 @@ import baritone.api.pathing.movement.IMovement;
import baritone.api.pathing.movement.MovementStatus;
import baritone.api.utils.*;
import baritone.api.utils.input.Input;
import baritone.behavior.PathingBehavior;
import baritone.utils.BlockStateInterface;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.item.EntityFallingBlock;
@@ -30,14 +31,11 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
public abstract class Movement implements IMovement, MovementHelper {
public static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
public static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
protected final IBaritone baritone;
protected final IPlayerContext ctx;
@@ -64,6 +62,8 @@ public abstract class Movement implements IMovement, MovementHelper {
public List<BlockPos> toPlaceCached = null;
public List<BlockPos> toWalkIntoCached = null;
private Set<BetterBlockPos> validPositionsCached = null;
private Boolean calculatedWhileLoaded;
protected Movement(IBaritone baritone, BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) {
@@ -101,6 +101,20 @@ public abstract class Movement implements IMovement, MovementHelper {
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
* State, and offers a Status to the calling class.
@@ -115,6 +129,7 @@ public abstract class Movement implements IMovement, MovementHelper {
currentState.setInput(Input.JUMP, true);
}
if (ctx.player().isEntityInsideOpaqueBlock()) {
ctx.getSelectedBlock().ifPresent(pos -> MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, pos)));
currentState.setInput(Input.CLICK_LEFT, true);
}
@@ -148,10 +163,10 @@ public abstract class Movement implements IMovement, MovementHelper {
}
if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
somethingInTheWay = true;
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
if (reachable.isPresent()) {
Rotation rotTowardsBlock = reachable.get();
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true));
if (ctx.isLookingAt(blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) {
state.setInput(Input.CLICK_LEFT, true);

View File

@@ -37,7 +37,7 @@ import net.minecraft.util.math.Vec3d;
import java.util.Optional;
import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP;
import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP;
/**
* Static helpers for cost calculation
@@ -499,7 +499,7 @@ public interface MovementHelper extends ActionCosts, Helper {
found = true;
}
for (int i = 0; i < 5; i++) {
BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]);
BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i]);
if (MovementHelper.canPlaceAgainst(ctx, against1)) {
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(false, placeAt.getX(), placeAt.getY(), placeAt.getZ())) { // get ready to place a throwaway block
Helper.HELPER.logDebug("bb pls get me some blocks. dirt, netherrack, cobble");

View File

@@ -27,11 +27,14 @@ import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import java.util.Set;
public class MovementAscend extends Movement {
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);
}
@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) {
IBlockState toPlace = context.get(destX, y, destZ);
double additionalPlacementCost = 0;
@@ -64,9 +78,9 @@ public class MovementAscend extends Movement {
}
boolean foundPlaceOption = false;
for (int i = 0; i < 5; i++) {
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
if (againstX == x && againstZ == z) { // we might be able to backplace now, but it doesn't matter because it will have been broken by the time we'd need to use it
continue;
}
@@ -143,6 +157,10 @@ public class MovementAscend extends Movement {
@Override
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);
// 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)
@@ -154,10 +172,6 @@ public class MovementAscend extends Movement {
return state.setStatus(MovementStatus.SUCCESS);
}
if (ctx.playerFeet().y < src.y) {
return state.setStatus(MovementStatus.UNREACHABLE);
}
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
ticksWithoutPlacement++;

View File

@@ -29,6 +29,7 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import baritone.utils.pathing.MutableMoveResult;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
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.Vec3d;
import java.util.Set;
public class MovementDescend extends Movement {
private int numTicks = 0;
@@ -61,6 +64,11 @@ public class MovementDescend extends Movement {
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) {
double totalCost = 0;
IBlockState destDown = context.get(destX, y - 1, destZ);

View File

@@ -28,6 +28,7 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import baritone.utils.pathing.MutableMoveResult;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
@@ -36,6 +37,7 @@ import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class MovementDiagonal extends Movement {
@@ -64,6 +66,16 @@ public class MovementDiagonal extends Movement {
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) {
IBlockState destInto = context.get(destX, y, destZ);
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
@@ -171,8 +183,9 @@ public class MovementDiagonal extends Movement {
}
if (ctx.playerFeet().equals(dest)) {
state.setStatus(MovementStatus.SUCCESS);
return state;
return state.setStatus(MovementStatus.SUCCESS);
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) {
return state.setStatus(MovementStatus.UNREACHABLE);
}
if (sprint()) {
state.setInput(Input.SPRINT, true);
@@ -181,7 +194,7 @@ public class MovementDiagonal extends Movement {
return state;
}
public boolean sprint() {
private boolean sprint() {
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) {
return false;
}

View File

@@ -24,10 +24,13 @@ import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import java.util.Set;
public class MovementDownward extends Movement {
private int numTicks = 0;
@@ -47,6 +50,11 @@ public class MovementDownward extends Movement {
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) {
if (!context.allowDownward) {
return COST_INF;
@@ -73,6 +81,8 @@ public class MovementDownward extends Movement {
if (ctx.playerFeet().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
} else if (!playerInValidPosition()) {
return state.setStatus(MovementStatus.UNREACHABLE);
}
double diffX = ctx.player().posX - (dest.getX() + 0.5);
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);

View File

@@ -42,7 +42,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
public class MovementFall extends Movement {
@@ -63,6 +65,16 @@ public class MovementFall extends Movement {
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() {
CalculationContext context = new CalculationContext(baritone);
MutableMoveResult result = new MutableMoveResult();

View File

@@ -34,6 +34,9 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import java.util.HashSet;
import java.util.Set;
public class MovementParkour extends Movement {
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
@@ -134,9 +137,9 @@ public class MovementParkour extends Movement {
return;
}
for (int i = 0; i < 5; i++) {
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
continue;
}
@@ -174,6 +177,17 @@ public class MovementParkour extends Movement {
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
public boolean safeToCancel(MovementState state) {
// once this movement is instantiated, the state is default to PREPPING

View File

@@ -30,6 +30,7 @@ import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
@@ -37,7 +38,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
public class MovementPillar extends Movement {
@@ -50,6 +51,11 @@ public class MovementPillar extends Movement {
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) {
Block from = context.get(x, y, z).getBlock();
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
@@ -240,10 +246,9 @@ public class MovementPillar extends Movement {
Block fr = frState.getBlock();
// TODO: Evaluate usage of getMaterial().isReplaceable()
if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) {
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance());
if (reachable.isPresent()) {
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
}
RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance())
.map(rot -> new MovementState.MovementTarget(rot, true))
.ifPresent(state::setTarget);
state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping
state.setInput(Input.CLICK_LEFT, true);
blockIsThere = false;

View File

@@ -30,12 +30,15 @@ import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import java.util.Set;
public class MovementTraverse extends Movement {
/**
@@ -58,6 +61,11 @@ public class MovementTraverse extends Movement {
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) {
IBlockState pb0 = context.get(destX, y + 1, destZ);
IBlockState pb1 = context.get(destX, y, destZ);
@@ -119,9 +127,9 @@ public class MovementTraverse extends Movement {
double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true); // only include falling on the upper block to break
double WC = throughWater ? context.waterWalkSpeed : WALK_ONE_BLOCK_COST;
for (int i = 0; i < 5; i++) {
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
if (againstX == x && againstZ == z) { // this would be a backplace
continue;
}
@@ -169,6 +177,10 @@ public class MovementTraverse extends Movement {
if (dist < 0.83) {
return state;
}
if (!state.getTarget().getRotation().isPresent()) {
// this can happen rarely when the server lags and doesn't send the falling sand entity until you've already walked through the block and are now mining the next one
return state;
}
// combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break
// it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw
@@ -179,8 +191,9 @@ public class MovementTraverse extends Movement {
pitchToBreak = 26;
}
state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true));
return state.setInput(Input.MOVE_FORWARD, true).setInput(Input.SPRINT, true);
return state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true))
.setInput(Input.MOVE_FORWARD, true)
.setInput(Input.SPRINT, true);
}
//sneak may have been set to true in the PREPPING state while mining an adjacent block
@@ -189,28 +202,18 @@ public class MovementTraverse extends Movement {
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor;
if (door) {
boolean isDoorActuallyBlockingUs = false;
if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) {
isDoorActuallyBlockingUs = true;
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) {
isDoorActuallyBlockingUs = true;
}
if (isDoorActuallyBlockingUs && !(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))
.setInput(Input.CLICK_RIGHT, true);
}
if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor)
&& (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)
|| pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src))
&& !(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))
.setInput(Input.CLICK_RIGHT, true);
}
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
BlockPos blocked = null;
if (!MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up())) {
blocked = positionsToBreak[0];
} else if (!MovementHelper.isGatePassable(ctx, positionsToBreak[1], src)) {
blocked = positionsToBreak[1];
}
BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0]
: !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1]
: null;
if (blocked != null) {
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true))
.setInput(Input.CLICK_RIGHT, true);
@@ -218,17 +221,16 @@ public class MovementTraverse extends Movement {
}
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
BlockPos whereAmI = ctx.playerFeet();
if (whereAmI.getY() != dest.getY() && !ladder) {
BlockPos feet = ctx.playerFeet();
if (feet.getY() != dest.getY() && !ladder) {
logDebug("Wrong Y coordinate");
if (whereAmI.getY() < dest.getY()) {
state.setInput(Input.JUMP, true);
if (feet.getY() < dest.getY()) {
return state.setInput(Input.JUMP, true);
}
return state;
}
if (isTheBridgeBlockThere) {
BetterBlockPos feet = ctx.playerFeet();
if (feet.equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
}
@@ -245,20 +247,20 @@ public class MovementTraverse extends Movement {
BlockPos into = dest.subtract(src).add(dest);
Block intoBelow = BlockStateInterface.get(ctx, into).getBlock();
Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock();
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
state.setInput(Input.SPRINT, true);
}
IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
BlockPos against = positionsToBreak[0];
if (whereAmI.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(BlockLadder.FACING).getOpposite());
}
MovementHelper.moveTowards(ctx, state, against);
return state;
} else {
wasTheBridgeBlockAlwaysThere = false;
Block standingOn = BlockStateInterface.get(ctx, ctx.playerFeet().down()).getBlock();
Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock();
if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118
double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ));
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
@@ -296,7 +298,7 @@ public class MovementTraverse extends Movement {
default:
break;
}
if (whereAmI.equals(dest)) {
if (feet.equals(dest)) {
// If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
// Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;

View File

@@ -33,7 +33,6 @@ import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.movements.*;
import baritone.utils.BlockStateInterface;
import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@@ -100,14 +99,13 @@ public class PathExecutor implements IPathExecutor, Helper {
if (pathPosition >= path.length()) {
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();
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
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
if (whereAmI.equals(path.positions().get(i))) {
logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i);
if (!movement.getValidPositions().contains(whereAmI)) {
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 (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) {
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++) {
path.movements().get(j).reset();
}
@@ -116,9 +114,9 @@ public class PathExecutor implements IPathExecutor, Helper {
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
if (whereAmI.equals(path.positions().get(i))) {
if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) {
if (i - pathPosition > 2) {
logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i);
}
@@ -147,38 +145,6 @@ public class PathExecutor implements IPathExecutor, Helper {
cancel();
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;
BlockStateInterface bsi = new BlockStateInterface(ctx);
for (int i = pathPosition - 10; i < pathPosition + 10; i++) {
@@ -205,10 +171,10 @@ public class PathExecutor implements IPathExecutor, Helper {
HashSet<BlockPos> newPlace = new HashSet<>();
HashSet<BlockPos> newWalkInto = new HashSet<>();
for (int i = pathPosition; i < path.movements().size(); i++) {
Movement movement = (Movement) path.movements().get(i);
newBreak.addAll(movement.toBreak(bsi));
newPlace.addAll(movement.toPlace(bsi));
newWalkInto.addAll(movement.toWalkInto(bsi));
Movement m = (Movement) path.movements().get(i);
newBreak.addAll(m.toBreak(bsi));
newPlace.addAll(m.toPlace(bsi));
newWalkInto.addAll(m.toWalkInto(bsi));
}
toBreak = newBreak;
toPlace = newPlace;
@@ -219,7 +185,14 @@ public class PathExecutor implements IPathExecutor, Helper {
if (end - start > 0) {
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();
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
costEstimateIndex = pathPosition;
@@ -233,7 +206,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) {
logDebug("Something has changed in the world and this movement has become impossible. Cancelling.");
cancel();
@@ -285,11 +258,13 @@ public class PathExecutor implements IPathExecutor, Helper {
private Tuple<Double, BlockPos> closestPathPos(IPath path) {
double best = -1;
BlockPos bestPos = null;
for (BlockPos pos : path.positions()) {
double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos);
if (dist < best || best == -1) {
best = dist;
bestPos = pos;
for (IMovement movement : path.movements()) {
for (BlockPos pos : ((Movement) movement).getValidPositions()) {
double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos);
if (dist < best || best == -1) {
best = dist;
bestPos = pos;
}
}
}
return new Tuple<>(best, bestPos);

View File

@@ -35,7 +35,7 @@ import net.minecraft.world.chunk.EmptyChunk;
import java.util.*;
import java.util.stream.Collectors;
public class BackfillProcess extends BaritoneProcessHelper {
public final class BackfillProcess extends BaritoneProcessHelper {
public HashMap<BlockPos, IBlockState> blocksToReplace = new HashMap<>();
@@ -85,6 +85,8 @@ public class BackfillProcess extends BaritoneProcessHelper {
// patience
baritone.getLookBehavior().updateTarget(fake.getTarget().getRotation().get(), true);
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
default:
throw new IllegalStateException();
}
}
return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process

View File

@@ -55,7 +55,7 @@ import java.util.*;
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
public class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess {
public final class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess {
private HashSet<BetterBlockPos> incorrectPositions;
private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now
@@ -154,7 +154,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
continue; // irrelevant
}
IBlockState curr = bcc.bsi.get0(x, y, z);
if (curr.getBlock() != Blocks.AIR && !valid(curr, desired)) {
if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !valid(curr, desired)) {
BetterBlockPos pos = new BetterBlockPos(x, y, z);
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
if (rot.isPresent()) {
@@ -359,7 +359,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
logDirect("Repeating build in vector " + repeat + ", new origin is " + origin);
return onTick(calcFailed, isSafeToCancel);
}
trim(bcc);
trim();
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
@@ -447,7 +447,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
return !incorrectPositions.isEmpty();
}
private void trim(BuilderCalculationContext bcc) {
private void trim() {
HashSet<BetterBlockPos> copy = new HashSet<>(incorrectPositions);
copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200);
if (!copy.isEmpty()) {
@@ -602,7 +602,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
return new GoalPlace(pos);
}
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP) {
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
return new GoalAdjacent(pos, allowSameLevel);
}

View File

@@ -29,7 +29,7 @@ import baritone.utils.BaritoneProcessHelper;
*
* @author leijurv
*/
public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess {
public final class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess {
/**
* The current goal

View File

@@ -41,7 +41,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
public final class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
private BlockPos explorationOrigin;
@@ -122,6 +122,7 @@ public class ExploreProcess extends BaritoneProcessHelper implements IExplorePro
break; // note: this breaks the switch not the for
case EXPLORED:
continue; // note: this continues the for
default:
}
int centerX = ((chunkX + dx) << 4) + 8;
int centerZ = ((chunkZ + dz) << 4) + 8;

View File

@@ -50,7 +50,7 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
public final class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
private boolean active;

View File

@@ -82,7 +82,12 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
}
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

View File

@@ -34,7 +34,7 @@ import net.minecraft.util.math.BlockPos;
import java.util.*;
public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
private Block gettingTo;
private List<BlockPos> knownLocations;

View File

@@ -114,7 +114,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 =(
.min(Comparator.comparingDouble(ctx.player()::getDistanceSq));
baritone.getInputOverrideHandler().clearAllKeys();
if (shaft.isPresent()) {
if (shaft.isPresent() && ctx.player().onGround) {
BlockPos pos = shaft.get();
IBlockState state = baritone.bsi.get0(pos);
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
@@ -281,7 +281,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
if (!Baritone.settings().mineScanDroppedItems.value) {
return new ArrayList<>();
return Collections.emptyList();
}
Set<Item> searchingFor = new HashSet<>();
for (Block block : mining) {

View File

@@ -69,7 +69,6 @@ public class GuiClick extends GuiScreen {
currentMouseOver = result.getBlockPos();
}
}
}
@Override
@@ -103,7 +102,7 @@ public class GuiClick extends GuiScreen {
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
GlStateManager.disableTexture2D();
@@ -121,7 +120,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 = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
if (result) {
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));

View File

@@ -92,7 +92,7 @@ public class PathingControlManager implements IPathingControlManager {
p.secretInternalSetGoal(null);
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
p.cancelSegmentIfSafe();
// get rid of the in progress stuff from the last process

View File

@@ -23,7 +23,7 @@ import net.minecraft.util.MovementInput;
public class PlayerMovementInput extends MovementInput {
private final InputOverrideHandler handler;
public PlayerMovementInput(InputOverrideHandler handler) {
PlayerMovementInput(InputOverrideHandler handler) {
this.handler = handler;
}
@@ -31,7 +31,7 @@ public class PlayerMovementInput extends MovementInput {
this.moveStrafe = 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)) {
this.moveForward++;

View File

@@ -64,10 +64,13 @@ public class Avoidance {
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
if (mobSpawnerCoeff != 1.0D) {
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2)
.forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
}
if (mobCoeff != 1.0D) {
ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
ctx.world().loadedEntityList.stream()
.filter(entity -> entity instanceof EntityMob)
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
}
return res;
}

View File

@@ -51,7 +51,7 @@ public class SegmentedCalculator {
private Optional<IPath> doCalc() {
Optional<IPath> soFar = Optional.empty();
while (true) {
PathCalculationResult result = segment(soFar);
PathCalculationResult result = segment(soFar.orElse(null));
switch (result.getType()) {
case SUCCESS_SEGMENT:
case SUCCESS_TO_GOAL:
@@ -62,8 +62,8 @@ public class SegmentedCalculator {
default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled
throw new IllegalStateException();
}
IPath segment = result.getPath().get(); // path calculation result type is SUCCESS_SEGMENT, so the path must be present
IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).get()).orElse(segment);
IPath segment = result.getPath().orElseThrow(IllegalStateException::new); // path calculation result type is SUCCESS_SEGMENT, so the path must be present
IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment);
loadAdjacent(combined.getDest().getX(), combined.getDest().getZ());
soFar = Optional.of(combined);
if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) {
@@ -85,9 +85,9 @@ public class SegmentedCalculator {
}
}
private PathCalculationResult segment(Optional<IPath> previous) {
BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c
AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null), context), context); // this is on another thread, so cannot include mob avoidances.
private PathCalculationResult segment(IPath previous) {
BetterBlockPos segmentStart = previous != null ? previous.getDest() : start;
AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous, context), context); // this is on another thread, so cannot include mob avoidances.
return search.calculate(Baritone.settings().primaryTimeoutMS.value, Baritone.settings().failureTimeoutMS.value); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer
}

View File

@@ -50,14 +50,14 @@ public class OpenSetsTest {
return testSizes;
}
private static void removeAndTest(int amount, IOpenSet[] test, Optional<Collection<PathNode>> mustContain) {
private static void removeAndTest(int amount, IOpenSet[] test, Collection<PathNode> mustContain) {
double[][] results = new double[test.length][amount];
for (int i = 0; i < test.length; i++) {
long before = System.nanoTime() / 1000000L;
for (int j = 0; j < amount; j++) {
PathNode pn = test[i].removeLowest();
if (mustContain.isPresent() && !mustContain.get().contains(pn)) {
throw new IllegalStateException(mustContain.get() + " " + pn);
if (mustContain != null && !mustContain.contains(pn)) {
throw new IllegalStateException(mustContain + " " + pn);
}
results[i][j] = pn.combinedCost;
}
@@ -131,7 +131,7 @@ public class OpenSetsTest {
System.out.println("Removal round 1");
// remove a quarter of the nodes and verify that they are indeed the size/4 lowest ones
removeAndTest(size / 4, test, Optional.of(lowestQuarter));
removeAndTest(size / 4, test, lowestQuarter);
// none of them should be empty (sanity check)
for (IOpenSet set : test) {
@@ -160,7 +160,7 @@ public class OpenSetsTest {
System.out.println("Removal round 2");
// remove the remaining 3/4
removeAndTest(size - size / 4, test, Optional.empty());
removeAndTest(size - size / 4, test, null);
// every set should now be empty
for (IOpenSet set : test) {