Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a4635df16 | |||
| 1390af20b6 | |||
| 1427cf57a8 | |||
| d70243b4c0 | |||
| 8f63dd4ba6 | |||
| 01658286af | |||
| aa90c8b7cd | |||
| eba1011fd6 | |||
| 96a424c25a | |||
| f4dd100345 | |||
| c7e1c917c3 | |||
| cd4205c361 | |||
| b81bcf8c6d | |||
| 4259764b70 | |||
| 8f761f7dff | |||
| cbbaf2aa2f | |||
| dd9b84646a | |||
| 94131fd705 | |||
| 6d8914e6c9 | |||
| 63ee687cee | |||
| ab779dc850 | |||
| c2f35ae46f | |||
| 199e0e5ed3 | |||
| a8155b4b0b | |||
| fdd78cf110 | |||
| afff6395d1 | |||
| 4d3d48e962 | |||
| 36290e4e53 | |||
| fd6923dd28 | |||
| 9c64067d49 | |||
| f4d2ea7923 | |||
| ce3d3bb244 | |||
| fa71e7d84f | |||
| b0115b8b4c | |||
| 3902b2db3b | |||
| 4ff61f96df | |||
| f998dce614 | |||
| 2b9084d2f3 | |||
| b3605546ac | |||
| 96097ab726 | |||
| be142d79bc | |||
| 0fd241a9ba | |||
| 7b192f17e8 | |||
| cc015846d2 | |||
| e785bd13f5 | |||
| eb6c0a39ea | |||
| 86525f98ec | |||
| 125facfbb6 | |||
| 94bf703dde | |||
| 14bb0a0a80 | |||
| 1ee6e04f00 | |||
| ee6796d5e2 | |||
| 81d7f3c319 | |||
| 9822962d98 | |||
| ce606f826b | |||
| 4c4bc8058b | |||
| f0210f7c5f | |||
| aef84eceb8 | |||
| a6ea9ed3a6 | |||
| 0815e3c195 | |||
| a1c03eb601 | |||
| 1e43563cc3 | |||
| 63f3f9123a | |||
| 4860d3bd18 | |||
| 7fa6593bdc | |||
| e1dd580df8 | |||
| f19e63d6e9 | |||
| 130873d91d | |||
| 9611cb9057 | |||
| 023aa78d8b | |||
| 39a231eae0 | |||
| aca6922be0 | |||
| 1a52537d0c | |||
| 479b4e3349 | |||
| a1e2b018a2 | |||
| aa0f664cda | |||
| 2e2f4aee1b | |||
| 18474d872c | |||
| 44327c009a | |||
| de554655a5 | |||
| bd0c7b9391 | |||
| 8d32db5206 | |||
| a6954aa719 | |||
| b4d203ab99 | |||
| bb924ad83f | |||
| 79da32cc60 | |||
| c7fe9c3171 | |||
| d70da4f37d | |||
| ccc1b04e81 | |||
| 352e428890 | |||
| 4679e12588 | |||
| 0f61aaafb8 |
@@ -1,37 +1,40 @@
|
|||||||
# Baritone
|
# Baritone
|
||||||
[](https://travis-ci.com/cabaletta/baritone)
|
[](https://travis-ci.com/cabaletta/baritone/)
|
||||||
[](https://github.com/cabaletta/baritone/releases)
|
[](https://github.com/cabaletta/baritone/releases/)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||||
[](http://hits.dwyl.com/cabaletta/baritone)
|
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||||
|
[](https://github.com/cabaletta/baritone/releases/)
|
||||||
|
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||||
|
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||||
[](https://github.com/cabaletta/baritone/issues)
|
[](https://github.com/cabaletta/baritone/issues/)
|
||||||
[](https://github.com/cabaletta/baritone/issues/)
|
[](https://github.com/cabaletta/baritone/issues/)
|
||||||
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||||
[](https://github.com/cabaletta/baritone/pulls/)
|
[](https://github.com/cabaletta/baritone/pulls/)
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
[](https://minecraft.gamepedia.com/1.13.2)
|
|
||||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||||
[](https://github.com/cabaletta/baritone/commit/)
|
[](https://github.com/cabaletta/baritone/commit/)
|
||||||
[](https://impactdevelopment.github.io/)
|
[](https://impactdevelopment.github.io/)
|
||||||
|
[](https://github.com/fr1kin/ForgeHax/)
|
||||||
[](https://wweclient.com/)
|
[](https://wweclient.com/)
|
||||||
[](https://github.com/zeroeightysix/KAMI/)
|
|
||||||
[](https://futureclient.net/)
|
[](https://futureclient.net/)
|
||||||
[](https://github.com/fr1kin/ForgeHax)
|
[](http://forthebadge.com/)
|
||||||
[](http://forthebadge.com)
|
[](http://forthebadge.com/)
|
||||||
[](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.
|
||||||
|
|
||||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
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.
|
||||||
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).
|
|
||||||
|
|
||||||
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
|
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||||
|
|
||||||
@@ -43,15 +46,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.
|
||||||
|
|
||||||
@@ -68,11 +71,11 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd
|
|||||||
|
|
||||||
## Can I use Baritone as a library in my custom utility client?
|
## 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?
|
## 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?
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -2,30 +2,20 @@
|
|||||||
|
|
||||||
# Prefix
|
# 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.
|
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`)
|
||||||
|
|
||||||
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 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
|
# Commands
|
||||||
|
|
||||||
**All** of these commands may need a prefix before them, as above ^.
|
**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`.
|
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
|
||||||
@@ -47,7 +37,7 @@ Some common examples:
|
|||||||
- `damn` daniel
|
- `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>.
|
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>.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.3.2'
|
version '1.3.3'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -231,6 +231,11 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Integer> rightClickSpeed = new Setting<>(4);
|
public final Setting<Integer> rightClickSpeed = new Setting<>(4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many degrees to randomize the yaw every tick. Set to 0 to disable
|
||||||
|
*/
|
||||||
|
public final Setting<Double> randomLooking = new Setting<>(2d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the big A* setting.
|
* This is the big A* setting.
|
||||||
* As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path.
|
* As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import baritone.api.process.IGetToBlockProcess;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||||
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -66,6 +67,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
"get - Same as list\n" +
|
"get - Same as list\n" +
|
||||||
"show - Same as list\n" +
|
"show - Same as list\n" +
|
||||||
"save - Saves a waypoint (works but don't try to make sense of it)\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" +
|
"goto - Paths towards specified block or waypoint\n" +
|
||||||
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
|
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
|
||||||
"sethome - Sets \"home\"\n" +
|
"sethome - Sets \"home\"\n" +
|
||||||
@@ -195,6 +197,16 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
logDirect("Goal: " + goal);
|
logDirect("Goal: " + goal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.equals("crash")) {
|
||||||
|
StringBuilder meme = new StringBuilder();
|
||||||
|
CrashReport rep = new CrashReport("Manually triggered debug crash", new Throwable());
|
||||||
|
mc.addGraphicsAndWorldToCrashReport(rep);
|
||||||
|
rep.getSectionsInStringBuilder(meme);
|
||||||
|
System.out.println(meme);
|
||||||
|
logDirect(meme.toString());
|
||||||
|
logDirect("ok");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.equals("path")) {
|
if (msg.equals("path")) {
|
||||||
if (pathingBehavior.getGoal() == null) {
|
if (pathingBehavior.getGoal() == null) {
|
||||||
logDirect("No goal.");
|
logDirect("No goal.");
|
||||||
@@ -332,7 +344,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
if (suffix.isEmpty()) {
|
if (suffix.isEmpty()) {
|
||||||
// clear the area from the current goal to here
|
// clear the area from the current goal to here
|
||||||
Goal goal = baritone.getPathingBehavior().getGoal();
|
Goal goal = baritone.getPathingBehavior().getGoal();
|
||||||
if (goal == null || !(goal instanceof GoalBlock)) {
|
if (!(goal instanceof GoalBlock)) {
|
||||||
logDirect("Need to specify goal of opposite corner");
|
logDirect("Need to specify goal of opposite corner");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -385,17 +397,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
logDirect("farming");
|
logDirect("farming");
|
||||||
return true;
|
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")) {
|
if (msg.equals("chests")) {
|
||||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
||||||
logDirect(entry.getKey() + "");
|
logDirect(entry.getKey() + "");
|
||||||
@@ -426,7 +427,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Entity effectivelyFinal = toFollow.get();
|
Entity effectivelyFinal = toFollow.get();
|
||||||
baritone.getFollowProcess().follow(x -> effectivelyFinal.equals(x));
|
baritone.getFollowProcess().follow(effectivelyFinal::equals);
|
||||||
logDirect("Following " + toFollow.get());
|
logDirect("Following " + toFollow.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -581,6 +582,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.");
|
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
||||||
return true;
|
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")) {
|
if (msg.startsWith("goto")) {
|
||||||
String waypointType = msg.substring(4).trim();
|
String waypointType = msg.substring(4).trim();
|
||||||
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
|
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
|
||||||
@@ -649,24 +661,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
}
|
}
|
||||||
return true;
|
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")) {
|
if (msg.equals("damn")) {
|
||||||
logDirect("daniel");
|
logDirect("daniel");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,17 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need a non obfed chunkpos that we can load using GSON
|
* Need a non obfed chunkpos that we can load using GSON
|
||||||
*/
|
*/
|
||||||
public class MyChunkPos {
|
public class MyChunkPos {
|
||||||
|
|
||||||
|
@SerializedName("x")
|
||||||
public int x;
|
public int x;
|
||||||
|
|
||||||
|
@SerializedName("y")
|
||||||
public int z;
|
public int z;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class MixinChunkRenderContainer {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer() && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||||
GlStateManager.enableAlphaTest();
|
GlStateManager.enableAlphaTest();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public abstract class MixinChunkRenderWorker {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class MixinRenderChunk {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class MixinRenderList {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void popMatrix() {
|
private void popMatrix() {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class MixinVboRenderList {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void popMatrix() {
|
private void popMatrix() {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.OptionalInt;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class InventoryBehavior extends Behavior {
|
public final class InventoryBehavior extends Behavior {
|
||||||
public InventoryBehavior(Baritone baritone) {
|
public InventoryBehavior(Baritone baritone) {
|
||||||
super(baritone);
|
super(baritone);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
|||||||
@Override
|
@Override
|
||||||
public void updateTarget(Rotation target, boolean force) {
|
public void updateTarget(Rotation target, boolean force) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
if (!force) {
|
||||||
|
double rand = Math.random() - 0.5;
|
||||||
|
if (Math.abs(rand) < 0.1) {
|
||||||
|
rand *= 4;
|
||||||
|
}
|
||||||
|
this.target = new Rotation(this.target.getYaw() + (float) (rand * Baritone.settings().randomLooking.value), this.target.getPitch());
|
||||||
|
}
|
||||||
this.force = force || !Baritone.settings().freeLook.value;
|
this.force = force || !Baritone.settings().freeLook.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
|
|
||||||
private boolean lastAutoJump;
|
private boolean lastAutoJump;
|
||||||
|
|
||||||
private BlockPos expectedSegmentStart;
|
private BetterBlockPos expectedSegmentStart;
|
||||||
|
|
||||||
private final LinkedBlockingQueue<PathEvent> toDispatch = new LinkedBlockingQueue<>();
|
private final LinkedBlockingQueue<PathEvent> toDispatch = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
|
|||||||
+75
-93
@@ -19,13 +19,17 @@ package baritone.cache;
|
|||||||
|
|
||||||
import baritone.api.utils.BlockUtils;
|
import baritone.api.utils.BlockUtils;
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
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 net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -33,99 +37,77 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class CachedChunk {
|
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.ENDER_CHEST,
|
||||||
|
Blocks.FURNACE,
|
||||||
|
Blocks.CHEST,
|
||||||
|
Blocks.TRAPPED_CHEST,
|
||||||
|
Blocks.END_PORTAL,
|
||||||
|
Blocks.END_PORTAL_FRAME,
|
||||||
|
Blocks.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.LIGHT_GRAY_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.NETHER_PORTAL,
|
||||||
|
Blocks.HOPPER,
|
||||||
|
Blocks.BEACON,
|
||||||
|
Blocks.BREWING_STAND,
|
||||||
|
|
||||||
static {
|
// TODO: Maybe add a predicate for blocks to keep track of?
|
||||||
HashSet<Block> temp = new HashSet<>();
|
// This should really not need to happen
|
||||||
//temp.add(Blocks.DIAMOND_ORE);
|
Blocks.CREEPER_HEAD,
|
||||||
temp.add(Blocks.DIAMOND_BLOCK);
|
Blocks.CREEPER_WALL_HEAD,
|
||||||
//temp.add(Blocks.COAL_ORE);
|
Blocks.DRAGON_HEAD,
|
||||||
temp.add(Blocks.COAL_BLOCK);
|
Blocks.DRAGON_WALL_HEAD,
|
||||||
//temp.add(Blocks.IRON_ORE);
|
Blocks.PLAYER_HEAD,
|
||||||
temp.add(Blocks.IRON_BLOCK);
|
Blocks.PLAYER_WALL_HEAD,
|
||||||
//temp.add(Blocks.GOLD_ORE);
|
Blocks.ZOMBIE_HEAD,
|
||||||
temp.add(Blocks.GOLD_BLOCK);
|
Blocks.ZOMBIE_WALL_HEAD,
|
||||||
temp.add(Blocks.EMERALD_ORE);
|
Blocks.SKELETON_SKULL,
|
||||||
temp.add(Blocks.EMERALD_BLOCK);
|
Blocks.SKELETON_WALL_SKULL,
|
||||||
|
Blocks.WITHER_SKELETON_SKULL,
|
||||||
temp.add(Blocks.ENDER_CHEST);
|
Blocks.WITHER_SKELETON_WALL_SKULL,
|
||||||
temp.add(Blocks.FURNACE);
|
Blocks.ENCHANTING_TABLE,
|
||||||
temp.add(Blocks.CHEST);
|
Blocks.ANVIL,
|
||||||
temp.add(Blocks.TRAPPED_CHEST);
|
Blocks.WHITE_BED,
|
||||||
temp.add(Blocks.END_PORTAL);
|
Blocks.ORANGE_BED,
|
||||||
temp.add(Blocks.END_PORTAL_FRAME);
|
Blocks.MAGENTA_BED,
|
||||||
temp.add(Blocks.SPAWNER);
|
Blocks.LIGHT_BLUE_BED,
|
||||||
temp.add(Blocks.BARRIER);
|
Blocks.YELLOW_BED,
|
||||||
temp.add(Blocks.OBSERVER);
|
Blocks.LIME_BED,
|
||||||
|
Blocks.PINK_BED,
|
||||||
temp.add(Blocks.WHITE_SHULKER_BOX);
|
Blocks.GRAY_BED,
|
||||||
temp.add(Blocks.ORANGE_SHULKER_BOX);
|
Blocks.LIGHT_GRAY_BED,
|
||||||
temp.add(Blocks.MAGENTA_SHULKER_BOX);
|
Blocks.CYAN_BED,
|
||||||
temp.add(Blocks.LIGHT_BLUE_SHULKER_BOX);
|
Blocks.PURPLE_BED,
|
||||||
temp.add(Blocks.YELLOW_SHULKER_BOX);
|
Blocks.BLUE_BED,
|
||||||
temp.add(Blocks.LIME_SHULKER_BOX);
|
Blocks.BROWN_BED,
|
||||||
temp.add(Blocks.PINK_SHULKER_BOX);
|
Blocks.GREEN_BED,
|
||||||
temp.add(Blocks.GRAY_SHULKER_BOX);
|
Blocks.RED_BED,
|
||||||
temp.add(Blocks.LIGHT_GRAY_SHULKER_BOX);
|
Blocks.BLACK_BED,
|
||||||
temp.add(Blocks.CYAN_SHULKER_BOX);
|
Blocks.DRAGON_EGG,
|
||||||
temp.add(Blocks.PURPLE_SHULKER_BOX);
|
Blocks.JUKEBOX,
|
||||||
temp.add(Blocks.BLUE_SHULKER_BOX);
|
Blocks.END_GATEWAY,
|
||||||
temp.add(Blocks.BROWN_SHULKER_BOX);
|
Blocks.COBWEB,
|
||||||
temp.add(Blocks.GREEN_SHULKER_BOX);
|
Blocks.NETHER_WART,
|
||||||
temp.add(Blocks.RED_SHULKER_BOX);
|
Blocks.LADDER,
|
||||||
temp.add(Blocks.BLACK_SHULKER_BOX);
|
Blocks.VINE
|
||||||
|
);
|
||||||
temp.add(Blocks.NETHER_PORTAL);
|
|
||||||
temp.add(Blocks.HOPPER);
|
|
||||||
temp.add(Blocks.BEACON);
|
|
||||||
temp.add(Blocks.BREWING_STAND);
|
|
||||||
|
|
||||||
// TODO: Maybe add a predicate for blocks to keep track of?
|
|
||||||
// This should really not need to happen
|
|
||||||
temp.add(Blocks.CREEPER_HEAD);
|
|
||||||
temp.add(Blocks.CREEPER_WALL_HEAD);
|
|
||||||
temp.add(Blocks.DRAGON_HEAD);
|
|
||||||
temp.add(Blocks.DRAGON_WALL_HEAD);
|
|
||||||
temp.add(Blocks.PLAYER_HEAD);
|
|
||||||
temp.add(Blocks.PLAYER_WALL_HEAD);
|
|
||||||
temp.add(Blocks.ZOMBIE_HEAD);
|
|
||||||
temp.add(Blocks.ZOMBIE_WALL_HEAD);
|
|
||||||
temp.add(Blocks.SKELETON_SKULL);
|
|
||||||
temp.add(Blocks.SKELETON_WALL_SKULL);
|
|
||||||
temp.add(Blocks.WITHER_SKELETON_SKULL);
|
|
||||||
temp.add(Blocks.WITHER_SKELETON_WALL_SKULL);
|
|
||||||
|
|
||||||
temp.add(Blocks.ENCHANTING_TABLE);
|
|
||||||
temp.add(Blocks.ANVIL);
|
|
||||||
|
|
||||||
temp.add(Blocks.WHITE_BED);
|
|
||||||
temp.add(Blocks.ORANGE_BED);
|
|
||||||
temp.add(Blocks.MAGENTA_BED);
|
|
||||||
temp.add(Blocks.LIGHT_BLUE_BED);
|
|
||||||
temp.add(Blocks.YELLOW_BED);
|
|
||||||
temp.add(Blocks.LIME_BED);
|
|
||||||
temp.add(Blocks.PINK_BED);
|
|
||||||
temp.add(Blocks.GRAY_BED);
|
|
||||||
temp.add(Blocks.LIGHT_GRAY_BED);
|
|
||||||
temp.add(Blocks.CYAN_BED);
|
|
||||||
temp.add(Blocks.PURPLE_BED);
|
|
||||||
temp.add(Blocks.BLUE_BED);
|
|
||||||
temp.add(Blocks.BROWN_BED);
|
|
||||||
temp.add(Blocks.GREEN_BED);
|
|
||||||
temp.add(Blocks.RED_BED);
|
|
||||||
temp.add(Blocks.BLACK_BED);
|
|
||||||
|
|
||||||
temp.add(Blocks.DRAGON_EGG);
|
|
||||||
temp.add(Blocks.JUKEBOX);
|
|
||||||
temp.add(Blocks.END_GATEWAY);
|
|
||||||
temp.add(Blocks.COBWEB);
|
|
||||||
temp.add(Blocks.NETHER_WART);
|
|
||||||
temp.add(Blocks.LADDER);
|
|
||||||
temp.add(Blocks.VINE);
|
|
||||||
BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
|
|
||||||
|
|
||||||
// TODO: Lit Furnaces
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the chunk data in bits. Equal to 16 KiB.
|
* The size of the chunk data in bits. Equal to 16 KiB.
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
IntegratedServer integratedServer = mc.getIntegratedServer();
|
IntegratedServer integratedServer = mc.getIntegratedServer();
|
||||||
|
|
||||||
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
// 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);
|
WorldServer localServerWorld = integratedServer.getWorld(dimension);
|
||||||
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
|
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
|
||||||
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();
|
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
|||||||
if (slowPath) {
|
if (slowPath) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value);
|
Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PathNode currentNode = openSet.removeLowest();
|
PathNode currentNode = openSet.removeLowest();
|
||||||
mostRecentConsidered = currentNode;
|
mostRecentConsidered = currentNode;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Path extends PathBase {
|
|||||||
}
|
}
|
||||||
PathNode current = end;
|
PathNode current = end;
|
||||||
LinkedList<BetterBlockPos> tempPath = new LinkedList<>();
|
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)
|
// Repeatedly inserting to the beginning of an arraylist is O(n^2)
|
||||||
// Instead, do it into a linked list, then convert at the end
|
// Instead, do it into a linked list, then convert at the end
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
|
|||||||
@@ -23,19 +23,18 @@ 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 {
|
||||||
|
|
||||||
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 IBaritone baritone;
|
||||||
protected final IPlayerContext ctx;
|
protected final IPlayerContext ctx;
|
||||||
@@ -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.
|
||||||
@@ -113,6 +128,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
currentState.setInput(Input.JUMP, true);
|
currentState.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
if (ctx.player().isEntityInsideOpaqueBlock()) {
|
if (ctx.player().isEntityInsideOpaqueBlock()) {
|
||||||
|
ctx.getSelectedBlock().ifPresent(pos -> MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, pos)));
|
||||||
currentState.setInput(Input.CLICK_LEFT, true);
|
currentState.setInput(Input.CLICK_LEFT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,10 +162,10 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try
|
if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try
|
||||||
somethingInTheWay = true;
|
somethingInTheWay = true;
|
||||||
|
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
|
||||||
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
||||||
if (reachable.isPresent()) {
|
if (reachable.isPresent()) {
|
||||||
Rotation rotTowardsBlock = reachable.get();
|
Rotation rotTowardsBlock = reachable.get();
|
||||||
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
|
|
||||||
state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true));
|
state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true));
|
||||||
if (ctx.isLookingAt(blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) {
|
if (ctx.isLookingAt(blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) {
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
|
|
||||||
import java.util.Optional;
|
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
|
* Static helpers for cost calculation
|
||||||
@@ -94,7 +94,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block instanceof BlockAir) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) {
|
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockAbstractSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||||
@@ -512,7 +512,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
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 (MovementHelper.canPlaceAgainst(ctx, against1)) {
|
||||||
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(false, placeAt.getX(), placeAt.getY(), placeAt.getZ())) { // get ready to place a throwaway block
|
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");
|
Helper.HELPER.logDebug("bb pls get me some blocks. dirt, netherrack, cobble");
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -64,9 +78,9 @@ public class MovementAscend extends Movement {
|
|||||||
}
|
}
|
||||||
boolean foundPlaceOption = false;
|
boolean foundPlaceOption = false;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
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 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 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
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -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[]{};
|
||||||
@@ -135,9 +138,9 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
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 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 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
|
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -213,7 +227,7 @@ public class MovementParkour extends Movement {
|
|||||||
state.setStatus(MovementStatus.SUCCESS);
|
state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
} else if (!ctx.playerFeet().equals(src)) {
|
} else if (!ctx.playerFeet().equals(src)) {
|
||||||
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) {
|
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) {
|
||||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
|
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
|
||||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
|
|||||||
@@ -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,7 +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.Optional;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementPillar extends Movement {
|
public class MovementPillar extends Movement {
|
||||||
|
|
||||||
@@ -50,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();
|
||||||
@@ -241,10 +247,9 @@ public class MovementPillar extends Movement {
|
|||||||
Block fr = frState.getBlock();
|
Block fr = frState.getBlock();
|
||||||
// TODO: Evaluate usage of getMaterial().isReplaceable()
|
// TODO: Evaluate usage of getMaterial().isReplaceable()
|
||||||
if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) {
|
if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) {
|
||||||
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance());
|
RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance())
|
||||||
if (reachable.isPresent()) {
|
.map(rot -> new MovementState.MovementTarget(rot, true))
|
||||||
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
|
.ifPresent(state::setTarget);
|
||||||
}
|
|
||||||
state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping
|
state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
blockIsThere = false;
|
blockIsThere = false;
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -122,9 +130,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 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;
|
double WC = throughWater ? context.waterWalkSpeed : WALK_ONE_BLOCK_COST;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
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 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 againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
|
||||||
if (againstX == x && againstZ == z) { // this would be a backplace
|
if (againstX == x && againstZ == z) { // this would be a backplace
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -172,6 +180,10 @@ public class MovementTraverse extends Movement {
|
|||||||
if (dist < 0.83) {
|
if (dist < 0.83) {
|
||||||
return state;
|
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
|
// 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
|
// 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
|
||||||
@@ -182,8 +194,9 @@ public class MovementTraverse extends Movement {
|
|||||||
pitchToBreak = 26;
|
pitchToBreak = 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true));
|
return state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true))
|
||||||
return state.setInput(Input.MOVE_FORWARD, true).setInput(Input.SPRINT, 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
|
//sneak may have been set to true in the PREPPING state while mining an adjacent block
|
||||||
@@ -192,28 +205,18 @@ 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;
|
||||||
|
|
||||||
boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor;
|
if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor)
|
||||||
if (door) {
|
&& (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)
|
||||||
boolean isDoorActuallyBlockingUs = false;
|
|| pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src))
|
||||||
if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) {
|
&& !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
||||||
isDoorActuallyBlockingUs = true;
|
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
|
||||||
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) {
|
.setInput(Input.CLICK_RIGHT, true);
|
||||||
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 BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
||||||
BlockPos blocked = null;
|
BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0]
|
||||||
if (!MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up())) {
|
: !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1]
|
||||||
blocked = positionsToBreak[0];
|
: null;
|
||||||
} else if (!MovementHelper.isGatePassable(ctx, positionsToBreak[1], src)) {
|
|
||||||
blocked = positionsToBreak[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blocked != null) {
|
if (blocked != null) {
|
||||||
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true))
|
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true))
|
||||||
.setInput(Input.CLICK_RIGHT, true);
|
.setInput(Input.CLICK_RIGHT, true);
|
||||||
@@ -221,17 +224,16 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
||||||
BlockPos whereAmI = ctx.playerFeet();
|
BlockPos feet = ctx.playerFeet();
|
||||||
if (whereAmI.getY() != dest.getY() && !ladder) {
|
if (feet.getY() != dest.getY() && !ladder) {
|
||||||
logDebug("Wrong Y coordinate");
|
logDebug("Wrong Y coordinate");
|
||||||
if (whereAmI.getY() < dest.getY()) {
|
if (feet.getY() < dest.getY()) {
|
||||||
state.setInput(Input.JUMP, true);
|
return state.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTheBridgeBlockThere) {
|
if (isTheBridgeBlockThere) {
|
||||||
BetterBlockPos feet = ctx.playerFeet();
|
|
||||||
if (feet.equals(dest)) {
|
if (feet.equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -248,20 +250,20 @@ public class MovementTraverse extends Movement {
|
|||||||
BlockPos into = dest.subtract(src).add(dest);
|
BlockPos into = dest.subtract(src).add(dest);
|
||||||
IBlockState intoBelow = BlockStateInterface.get(ctx, into);
|
IBlockState intoBelow = BlockStateInterface.get(ctx, into);
|
||||||
IBlockState intoAbove = BlockStateInterface.get(ctx, into.up());
|
IBlockState intoAbove = BlockStateInterface.get(ctx, into.up());
|
||||||
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);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
|
IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
|
||||||
BlockPos against = positionsToBreak[0];
|
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.get(BlockLadder.FACING).getOpposite());
|
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.get(BlockLadder.FACING).getOpposite());
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(ctx, state, against);
|
MovementHelper.moveTowards(ctx, state, against);
|
||||||
return state;
|
return state;
|
||||||
} else {
|
} else {
|
||||||
wasTheBridgeBlockAlwaysThere = false;
|
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
|
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));
|
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
|
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
|
||||||
@@ -299,7 +301,7 @@ public class MovementTraverse extends Movement {
|
|||||||
default:
|
default:
|
||||||
break;
|
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
|
// 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);
|
// Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
|
||||||
double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;
|
double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import net.minecraft.world.chunk.EmptyChunk;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BackfillProcess extends BaritoneProcessHelper {
|
public final class BackfillProcess extends BaritoneProcessHelper {
|
||||||
|
|
||||||
public HashMap<BlockPos, IBlockState> blocksToReplace = new HashMap<>();
|
public HashMap<BlockPos, IBlockState> blocksToReplace = new HashMap<>();
|
||||||
|
|
||||||
@@ -84,12 +84,14 @@ public 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
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 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
|
private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now
|
||||||
@@ -157,7 +157,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
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()) {
|
||||||
@@ -376,7 +376,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
logDirect("Repeating build in vector " + repeat + ", new origin is " + origin);
|
logDirect("Repeating build in vector " + repeat + ", new origin is " + origin);
|
||||||
return onTick(calcFailed, isSafeToCancel);
|
return onTick(calcFailed, isSafeToCancel);
|
||||||
}
|
}
|
||||||
trim(bcc);
|
trim();
|
||||||
|
|
||||||
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
|
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
|
||||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
|
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
|
||||||
@@ -464,7 +464,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return !incorrectPositions.isEmpty();
|
return !incorrectPositions.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trim(BuilderCalculationContext bcc) {
|
private void trim() {
|
||||||
HashSet<BetterBlockPos> copy = new HashSet<>(incorrectPositions);
|
HashSet<BetterBlockPos> copy = new HashSet<>(incorrectPositions);
|
||||||
copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200);
|
copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200);
|
||||||
if (!copy.isEmpty()) {
|
if (!copy.isEmpty()) {
|
||||||
@@ -619,7 +619,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return new GoalPlace(pos);
|
return new GoalPlace(pos);
|
||||||
}
|
}
|
||||||
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
|
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
|
||||||
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)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
|
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
|
||||||
return new GoalAdjacent(pos, allowSameLevel);
|
return new GoalAdjacent(pos, allowSameLevel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import baritone.utils.BaritoneProcessHelper;
|
|||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess {
|
public final class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current goal
|
* The current goal
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
|
public final class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
|
||||||
|
|
||||||
private BlockPos explorationOrigin;
|
private BlockPos explorationOrigin;
|
||||||
|
|
||||||
@@ -122,6 +122,7 @@ public class ExploreProcess extends BaritoneProcessHelper implements IExplorePro
|
|||||||
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;
|
||||||
|
|||||||
@@ -48,10 +48,13 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
public final class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
||||||
|
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
|
||||||
|
private List<BlockPos> locations;
|
||||||
|
private int tickCount;
|
||||||
|
|
||||||
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
|
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
|
||||||
Items.BEETROOT_SEEDS,
|
Items.BEETROOT_SEEDS,
|
||||||
Items.MELON_SEEDS,
|
Items.MELON_SEEDS,
|
||||||
@@ -91,6 +94,7 @@ public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
|||||||
@Override
|
@Override
|
||||||
public void farm() {
|
public void farm() {
|
||||||
active = true;
|
active = true;
|
||||||
|
locations = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Harvest {
|
private enum Harvest {
|
||||||
@@ -162,9 +166,12 @@ public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
|||||||
if (Baritone.settings().replantNetherWart.value) {
|
if (Baritone.settings().replantNetherWart.value) {
|
||||||
scan.add(Blocks.SOUL_SAND);
|
scan.add(Blocks.SOUL_SAND);
|
||||||
}
|
}
|
||||||
|
if (Baritone.settings().mineGoalUpdateInterval.value != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.value == 0) {
|
||||||
List<BlockPos> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4);
|
Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10));
|
||||||
|
}
|
||||||
|
if (locations == null) {
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
List<BlockPos> toBreak = new ArrayList<>();
|
List<BlockPos> toBreak = new ArrayList<>();
|
||||||
List<BlockPos> openFarmland = new ArrayList<>();
|
List<BlockPos> openFarmland = new ArrayList<>();
|
||||||
List<BlockPos> bonemealable = new ArrayList<>();
|
List<BlockPos> bonemealable = new ArrayList<>();
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
||||||
|
|
||||||
private Block gettingTo;
|
private Block gettingTo;
|
||||||
private List<BlockPos> knownLocations;
|
private List<BlockPos> knownLocations;
|
||||||
|
|||||||
@@ -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)) {
|
||||||
@@ -281,7 +286,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
||||||
if (!Baritone.settings().mineScanDroppedItems.value) {
|
if (!Baritone.settings().mineScanDroppedItems.value) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
Set<Item> searchingFor = new HashSet<>();
|
Set<Item> searchingFor = new HashSet<>();
|
||||||
for (Block block : mining) {
|
for (Block block : mining) {
|
||||||
@@ -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++;
|
||||||
|
|||||||
@@ -64,10 +64,13 @@ public class Avoidance {
|
|||||||
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
|
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
|
||||||
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
|
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
|
||||||
if (mobSpawnerCoeff != 1.0D) {
|
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) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class SegmentedCalculator {
|
|||||||
private Optional<IPath> doCalc() {
|
private Optional<IPath> doCalc() {
|
||||||
Optional<IPath> soFar = Optional.empty();
|
Optional<IPath> soFar = Optional.empty();
|
||||||
while (true) {
|
while (true) {
|
||||||
PathCalculationResult result = segment(soFar);
|
PathCalculationResult result = segment(soFar.orElse(null));
|
||||||
switch (result.getType()) {
|
switch (result.getType()) {
|
||||||
case SUCCESS_SEGMENT:
|
case SUCCESS_SEGMENT:
|
||||||
case SUCCESS_TO_GOAL:
|
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
|
default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
IPath segment = result.getPath().get(); // path calculation result type is SUCCESS_SEGMENT, so the path must be present
|
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).get()).orElse(segment);
|
IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment);
|
||||||
loadAdjacent(combined.getDest().getX(), combined.getDest().getZ());
|
loadAdjacent(combined.getDest().getX(), combined.getDest().getZ());
|
||||||
soFar = Optional.of(combined);
|
soFar = Optional.of(combined);
|
||||||
if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) {
|
if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) {
|
||||||
@@ -85,9 +85,9 @@ public class SegmentedCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PathCalculationResult segment(Optional<IPath> previous) {
|
private PathCalculationResult segment(IPath previous) {
|
||||||
BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c
|
BetterBlockPos segmentStart = previous != null ? previous.getDest() : start;
|
||||||
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.
|
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
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ public class OpenSetsTest {
|
|||||||
return testSizes;
|
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];
|
double[][] results = new double[test.length][amount];
|
||||||
for (int i = 0; i < test.length; i++) {
|
for (int i = 0; i < test.length; i++) {
|
||||||
long before = System.nanoTime() / 1000000L;
|
long before = System.nanoTime() / 1000000L;
|
||||||
for (int j = 0; j < amount; j++) {
|
for (int j = 0; j < amount; j++) {
|
||||||
PathNode pn = test[i].removeLowest();
|
PathNode pn = test[i].removeLowest();
|
||||||
if (mustContain.isPresent() && !mustContain.get().contains(pn)) {
|
if (mustContain != null && !mustContain.contains(pn)) {
|
||||||
throw new IllegalStateException(mustContain.get() + " " + pn);
|
throw new IllegalStateException(mustContain + " " + pn);
|
||||||
}
|
}
|
||||||
results[i][j] = pn.combinedCost;
|
results[i][j] = pn.combinedCost;
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ public class OpenSetsTest {
|
|||||||
|
|
||||||
System.out.println("Removal round 1");
|
System.out.println("Removal round 1");
|
||||||
// remove a quarter of the nodes and verify that they are indeed the size/4 lowest ones
|
// 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)
|
// none of them should be empty (sanity check)
|
||||||
for (IOpenSet set : test) {
|
for (IOpenSet set : test) {
|
||||||
@@ -160,7 +160,7 @@ public class OpenSetsTest {
|
|||||||
|
|
||||||
System.out.println("Removal round 2");
|
System.out.println("Removal round 2");
|
||||||
// remove the remaining 3/4
|
// remove the remaining 3/4
|
||||||
removeAndTest(size - size / 4, test, Optional.empty());
|
removeAndTest(size - size / 4, test, null);
|
||||||
|
|
||||||
// every set should now be empty
|
// every set should now be empty
|
||||||
for (IOpenSet set : test) {
|
for (IOpenSet set : test) {
|
||||||
|
|||||||
Reference in New Issue
Block a user