Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc849daccb | |||
| f5b4de023f | |||
| 6dc7a7788e | |||
| 0e51a73149 | |||
| 44a092cd94 | |||
| 7000b6cda2 | |||
| 7a17f7d253 | |||
| 821e73c1d3 | |||
| 784bc52d6d | |||
| 4338e34734 | |||
| 61147536e5 | |||
| 6b9737eb3f | |||
| fe54372a53 | |||
| 21e9c0b7c1 | |||
| 8bf977060e | |||
| 074ec333cf | |||
| d505ec4f9f | |||
| 4d127acb9a | |||
| df900c9e64 | |||
| 93a090c56e | |||
| 8b43d93259 | |||
| 053662d0af | |||
| af943a8253 | |||
| 8151444671 | |||
| f32147d9d5 | |||
| 515e0364f7 | |||
| 09239f8180 | |||
| 0d9f233e33 | |||
| e034437c63 | |||
| 72be046f34 | |||
| 3ba8824eb0 | |||
| b51a261bd1 | |||
| 38602dd141 | |||
| cdbec60da0 | |||
| 2b41012c5b | |||
| 6bb87d0a64 | |||
| b16f9edd2c | |||
| ce4b1e09ed | |||
| 01658286af | |||
| aa90c8b7cd | |||
| eba1011fd6 | |||
| 96a424c25a | |||
| f4dd100345 | |||
| 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 | |||
| 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 +0,0 @@
|
|||||||
<!-- No UwU's or OwO's allowed -->
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Please file a separate report for each issue
|
||||||
|
title: Please add a brief but descriptive title
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## Some information
|
||||||
|
Operating system:
|
||||||
|
Java version:
|
||||||
|
Minecraft version:
|
||||||
|
Baritone version:
|
||||||
|
Forge mods (if used):
|
||||||
|
|
||||||
|
## Exception, error or logs
|
||||||
|
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
|
||||||
|
|
||||||
|
## How to reproduce
|
||||||
|
Add your steps to reproduce the issue/bug experienced here.
|
||||||
|
|
||||||
|
## Final checklist
|
||||||
|
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
|
||||||
|
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
|
||||||
|
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: Question
|
||||||
|
about: Please file a separate report for each question
|
||||||
|
title: Please add a brief but descriptive title
|
||||||
|
labels: question
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## What do you need help with?
|
||||||
|
With as much detail as possible, describe your question and what you may need help with.
|
||||||
|
|
||||||
|
## Final checklist
|
||||||
|
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Suggestion
|
||||||
|
about: Please file a separate report for each suggestion
|
||||||
|
title: Please add a brief but descriptive title
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## Describe your suggestion
|
||||||
|
With as much detail as possible, describe what your suggestion would do for Baritone.
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
Describe how your suggestion would improve Baritone, or the reason behind it being added.
|
||||||
|
|
||||||
|
## Final checklist
|
||||||
|
- [ ] I have not used any OwO's or UwU's in this issue.
|
||||||
@@ -1,37 +1,43 @@
|
|||||||
# 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/tree/1.14.4/)
|
||||||
[](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.12.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 🦀
|
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||||
|
|
||||||
|
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 +49,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 +74,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,11 @@
|
|||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
|
||||||
|
|
||||||
|
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
|
||||||
|
|
||||||
|
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,42 +2,34 @@
|
|||||||
|
|
||||||
# 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 set a goal to a certain coordinate then path to it
|
||||||
|
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
|
||||||
- `goal` to set the goal to your player's feet
|
- `goal` to set the goal to your player's feet
|
||||||
- `goal clear` to clear the goal
|
- `goal clear` to clear the goal
|
||||||
- `cancel` or `stop` to stop everything
|
- `cancel` or `stop` to stop everything
|
||||||
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
|
||||||
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.)
|
- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.)
|
||||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||||
- `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time).
|
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
|
||||||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||||
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||||
|
- `schematica` to build the schematic that is currently open in schematica
|
||||||
- `tunnel` to dig just straight ahead and make a tunnel
|
- `tunnel` to dig just straight ahead and make a tunnel
|
||||||
- `farm` to automatically harvest, replant, or bone meal crops
|
- `farm` to automatically harvest, replant, or bone meal crops
|
||||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||||
@@ -47,7 +39,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>.
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.2.6'
|
version '1.2.8'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -55,6 +55,14 @@ sourceSets {
|
|||||||
launch {
|
launch {
|
||||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
schematica_api {
|
||||||
|
compileClasspath += main.compileClasspath
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
compileClasspath += schematica_api.output
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
|||||||
Vendored
+5
@@ -31,6 +31,11 @@
|
|||||||
# need to keep mixin names
|
# need to keep mixin names
|
||||||
-keep class baritone.launch.** { *; }
|
-keep class baritone.launch.** { *; }
|
||||||
|
|
||||||
|
#try to keep usage of schematica in separate classes
|
||||||
|
-keep class baritone.utils.schematic.schematica.**
|
||||||
|
#proguard doesnt like it when it cant find our fake schematica classes
|
||||||
|
-dontwarn baritone.utils.schematic.schematica.**
|
||||||
|
|
||||||
# copy all necessary libraries into tempLibraries to build
|
# copy all necessary libraries into tempLibraries to build
|
||||||
|
|
||||||
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
||||||
|
|||||||
@@ -128,5 +128,8 @@ public interface IBaritone {
|
|||||||
*/
|
*/
|
||||||
IEventBus getGameEventHandler();
|
IEventBus getGameEventHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open click
|
||||||
|
*/
|
||||||
void openClick();
|
void openClick();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
|||||||
return build(schematicFile, file, origin);
|
return build(schematicFile, file, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void buildOpenSchematic();
|
||||||
|
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
void resume();
|
void resume();
|
||||||
|
|||||||
@@ -33,47 +33,23 @@ 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.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.event.ClickEvent;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
|
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
|
||||||
|
|
||||||
private static final String HELP_MSG =
|
|
||||||
"baritone - Output settings into chat\n" +
|
|
||||||
"settings - Same as baritone\n" +
|
|
||||||
"goal - Create a goal (one number is '<Y>', two is '<X> <Z>', three is '<X> <Y> <Z>, 'clear' to clear)\n" +
|
|
||||||
"path - Go towards goal\n" +
|
|
||||||
"repack - (debug) Repacks chunk cache\n" +
|
|
||||||
"rescan - (debug) Same as repack\n" +
|
|
||||||
"axis - Paths towards the closest axis or diagonal axis, at y=120\n" +
|
|
||||||
"cancel - Cancels current path\n" +
|
|
||||||
"forcecancel - sudo cancel (only use if very glitched, try toggling 'pause' first)\n" +
|
|
||||||
"gc - Calls System.gc();\n" +
|
|
||||||
"invert - Runs away from the goal instead of towards it\n" +
|
|
||||||
"follow - Follows a player 'follow username'\n" +
|
|
||||||
"reloadall - (debug) Reloads chunk cache\n" +
|
|
||||||
"saveall - (debug) Saves chunk cache\n" +
|
|
||||||
"find - (debug) outputs how many blocks of a certain type are within the cache\n" +
|
|
||||||
"mine - Paths to and mines specified blocks 'mine x_ore y_ore ...'\n" +
|
|
||||||
"thisway - Creates a goal X blocks where you're facing\n" +
|
|
||||||
"list - Lists waypoints under a category\n" +
|
|
||||||
"get - Same as list\n" +
|
|
||||||
"show - Same as list\n" +
|
|
||||||
"save - Saves a waypoint (works but don't try to make sense of it)\n" +
|
|
||||||
"goto - Paths towards specified block or waypoint\n" +
|
|
||||||
"spawn - Paths towards world spawn or your most recent bed right-click\n" +
|
|
||||||
"sethome - Sets \"home\"\n" +
|
|
||||||
"home - Paths towards \"home\" \n" +
|
|
||||||
"costs - (debug) all movement costs from current location\n" +
|
|
||||||
"damn - Daniel\n" +
|
|
||||||
"Go to https://github.com/cabaletta/baritone/blob/master/USAGE.md for more information";
|
|
||||||
|
|
||||||
private static final String COMMAND_PREFIX = "#";
|
private static final String COMMAND_PREFIX = "#";
|
||||||
|
|
||||||
public final IBaritone baritone;
|
public final IBaritone baritone;
|
||||||
@@ -144,9 +120,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("") || msg.equals("help") || msg.equals("?")) {
|
if (msg.equals("") || msg.equals("help") || msg.equals("?")) {
|
||||||
for (String line : HELP_MSG.split("\n")) {
|
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||||
logDirect(line);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
}
|
TextComponentString helpLink = new TextComponentString(" Click here for instructions on how to use Baritone (https://github.com/cabaletta/baritone/blob/master/USAGE.md)");
|
||||||
|
helpLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/cabaletta/baritone/blob/master/USAGE.md"));
|
||||||
|
component.appendSibling(helpLink);
|
||||||
|
BaritoneAPI.getSettings().logger.value.accept(component);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.contains(" ")) {
|
if (msg.contains(" ")) {
|
||||||
@@ -195,6 +174,17 @@ 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);
|
||||||
|
new ReportedException(rep).printStackTrace();
|
||||||
|
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.");
|
||||||
@@ -280,6 +270,10 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
logDirect(success ? "Loaded" : "Unable to load");
|
logDirect(success ? "Loaded" : "Unable to load");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.startsWith("schematica")) {
|
||||||
|
baritone.getBuilderProcess().buildOpenSchematic();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.equals("come")) {
|
if (msg.equals("come")) {
|
||||||
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
|
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
|
||||||
logDirect("Coming");
|
logDirect("Coming");
|
||||||
@@ -332,7 +326,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 +379,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() + "");
|
||||||
@@ -403,11 +386,34 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.startsWith("followentities")) {
|
||||||
|
baritone.getFollowProcess().follow(Entity.class::isInstance);
|
||||||
|
logDirect("Following any entities");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.startsWith("followplayers")) {
|
if (msg.startsWith("followplayers")) {
|
||||||
baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A
|
baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A
|
||||||
logDirect("Following any players");
|
logDirect("Following any players");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.startsWith("followentity")) {
|
||||||
|
String name = msg.substring(12).trim();
|
||||||
|
Optional<Entity> toFollow = Optional.empty();
|
||||||
|
for (Entity entity : ctx.world().loadedEntityList) {
|
||||||
|
String entityName = entity.getName().trim().toLowerCase();
|
||||||
|
if ((entityName.contains(name) || name.contains(entityName)) && !(entity instanceof EntityItem || entity instanceof EntityPlayer)) { // We dont want it following players while `#follow` exists.
|
||||||
|
toFollow = Optional.of(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!toFollow.isPresent()) {
|
||||||
|
logDirect("Entity not found");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Entity effectivelyFinal = toFollow.get();
|
||||||
|
baritone.getFollowProcess().follow(effectivelyFinal::equals);
|
||||||
|
logDirect("Following entity " + toFollow.get());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.startsWith("follow")) {
|
if (msg.startsWith("follow")) {
|
||||||
String name = msg.substring(6).trim();
|
String name = msg.substring(6).trim();
|
||||||
Optional<Entity> toFollow = Optional.empty();
|
Optional<Entity> toFollow = Optional.empty();
|
||||||
@@ -426,7 +432,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 +587,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 +666,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");
|
||||||
}
|
}
|
||||||
@@ -694,7 +693,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
|
|||||||
goal = new GoalBlock(playerFeet);
|
goal = new GoalBlock(playerFeet);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y));
|
goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -158,11 +158,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class MixinChunkRenderContainer {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||||
GlStateManager.enableAlpha();
|
GlStateManager.enableAlpha();
|
||||||
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.getMinecraft().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().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) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class MixinRenderChunk {
|
|||||||
if (!chunkCache.isEmpty()) {
|
if (!chunkCache.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
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) {
|
||||||
@@ -76,7 +76,7 @@ public class MixinRenderChunk {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
|
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
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.getMinecraft().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(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.getMinecraft().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<>();
|
||||||
|
|
||||||
|
|||||||
+53
-56
@@ -19,6 +19,7 @@ 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;
|
||||||
@@ -33,64 +34,60 @@ 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.DIAMOND_BLOCK,
|
||||||
|
//Blocks.COAL_ORE,
|
||||||
|
Blocks.COAL_BLOCK,
|
||||||
|
//Blocks.IRON_ORE,
|
||||||
|
Blocks.IRON_BLOCK,
|
||||||
|
//Blocks.GOLD_ORE,
|
||||||
|
Blocks.GOLD_BLOCK,
|
||||||
|
Blocks.EMERALD_ORE,
|
||||||
|
Blocks.EMERALD_BLOCK,
|
||||||
|
|
||||||
static {
|
Blocks.ENDER_CHEST,
|
||||||
HashSet<Block> temp = new HashSet<>();
|
Blocks.FURNACE,
|
||||||
//temp.add(Blocks.DIAMOND_ORE);
|
Blocks.CHEST,
|
||||||
temp.add(Blocks.DIAMOND_BLOCK);
|
Blocks.TRAPPED_CHEST,
|
||||||
//temp.add(Blocks.COAL_ORE);
|
Blocks.END_PORTAL,
|
||||||
temp.add(Blocks.COAL_BLOCK);
|
Blocks.END_PORTAL_FRAME,
|
||||||
//temp.add(Blocks.IRON_ORE);
|
Blocks.MOB_SPAWNER,
|
||||||
temp.add(Blocks.IRON_BLOCK);
|
Blocks.BARRIER,
|
||||||
//temp.add(Blocks.GOLD_ORE);
|
Blocks.OBSERVER,
|
||||||
temp.add(Blocks.GOLD_BLOCK);
|
Blocks.WHITE_SHULKER_BOX,
|
||||||
temp.add(Blocks.EMERALD_ORE);
|
Blocks.ORANGE_SHULKER_BOX,
|
||||||
temp.add(Blocks.EMERALD_BLOCK);
|
Blocks.MAGENTA_SHULKER_BOX,
|
||||||
|
Blocks.LIGHT_BLUE_SHULKER_BOX,
|
||||||
|
Blocks.YELLOW_SHULKER_BOX,
|
||||||
|
Blocks.LIME_SHULKER_BOX,
|
||||||
|
Blocks.PINK_SHULKER_BOX,
|
||||||
|
Blocks.GRAY_SHULKER_BOX,
|
||||||
|
Blocks.SILVER_SHULKER_BOX,
|
||||||
|
Blocks.CYAN_SHULKER_BOX,
|
||||||
|
Blocks.PURPLE_SHULKER_BOX,
|
||||||
|
Blocks.BLUE_SHULKER_BOX,
|
||||||
|
Blocks.BROWN_SHULKER_BOX,
|
||||||
|
Blocks.GREEN_SHULKER_BOX,
|
||||||
|
Blocks.RED_SHULKER_BOX,
|
||||||
|
Blocks.BLACK_SHULKER_BOX,
|
||||||
|
Blocks.PORTAL,
|
||||||
|
Blocks.HOPPER,
|
||||||
|
Blocks.BEACON,
|
||||||
|
Blocks.BREWING_STAND,
|
||||||
|
Blocks.SKULL,
|
||||||
|
Blocks.ENCHANTING_TABLE,
|
||||||
|
Blocks.ANVIL,
|
||||||
|
Blocks.LIT_FURNACE,
|
||||||
|
Blocks.BED,
|
||||||
|
Blocks.DRAGON_EGG,
|
||||||
|
Blocks.JUKEBOX,
|
||||||
|
Blocks.END_GATEWAY,
|
||||||
|
Blocks.WEB,
|
||||||
|
Blocks.NETHER_WART,
|
||||||
|
Blocks.LADDER,
|
||||||
|
Blocks.VINE
|
||||||
|
);
|
||||||
|
|
||||||
temp.add(Blocks.ENDER_CHEST);
|
|
||||||
temp.add(Blocks.FURNACE);
|
|
||||||
temp.add(Blocks.CHEST);
|
|
||||||
temp.add(Blocks.TRAPPED_CHEST);
|
|
||||||
temp.add(Blocks.END_PORTAL);
|
|
||||||
temp.add(Blocks.END_PORTAL_FRAME);
|
|
||||||
temp.add(Blocks.MOB_SPAWNER);
|
|
||||||
temp.add(Blocks.BARRIER);
|
|
||||||
temp.add(Blocks.OBSERVER);
|
|
||||||
temp.add(Blocks.WHITE_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.ORANGE_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.MAGENTA_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.LIGHT_BLUE_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.YELLOW_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.LIME_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.PINK_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.GRAY_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.SILVER_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.CYAN_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.PURPLE_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.BLUE_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.BROWN_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.GREEN_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.RED_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.BLACK_SHULKER_BOX);
|
|
||||||
temp.add(Blocks.PORTAL);
|
|
||||||
temp.add(Blocks.HOPPER);
|
|
||||||
temp.add(Blocks.BEACON);
|
|
||||||
temp.add(Blocks.BREWING_STAND);
|
|
||||||
temp.add(Blocks.SKULL);
|
|
||||||
temp.add(Blocks.ENCHANTING_TABLE);
|
|
||||||
temp.add(Blocks.ANVIL);
|
|
||||||
temp.add(Blocks.LIT_FURNACE);
|
|
||||||
temp.add(Blocks.BED);
|
|
||||||
temp.add(Blocks.DRAGON_EGG);
|
|
||||||
temp.add(Blocks.JUKEBOX);
|
|
||||||
temp.add(Blocks.END_GATEWAY);
|
|
||||||
temp.add(Blocks.WEB);
|
|
||||||
temp.add(Blocks.NETHER_WART);
|
|
||||||
temp.add(Blocks.LADDER);
|
|
||||||
temp.add(Blocks.VINE);
|
|
||||||
BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the chunk data in bits. Equal to 16 KiB.
|
* 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
@@ -62,7 +62,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,6 +23,7 @@ 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.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.entity.item.EntityFallingBlock;
|
import net.minecraft.entity.item.EntityFallingBlock;
|
||||||
@@ -30,14 +31,11 @@ import net.minecraft.util.EnumFacing;
|
|||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.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.Objects;
|
|
||||||
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;
|
||||||
@@ -64,6 +62,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) {
|
||||||
@@ -101,6 +101,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.
|
||||||
@@ -115,6 +129,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,10 +163,10 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
|
if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, 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);
|
||||||
|
|||||||
@@ -37,7 +37,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
|
||||||
@@ -134,7 +134,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
||||||
// has already been accounted for above
|
// has already been accounted for above
|
||||||
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
||||||
return block.isPassable(null, null);
|
return block.isPassable(null, BlockPos.ORIGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,7 +254,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|
|
||||||
static boolean avoidWalkingInto(Block block) {
|
static boolean avoidWalkingInto(Block block) {
|
||||||
return block instanceof BlockLiquid
|
return block instanceof BlockLiquid
|
||||||
|| block instanceof BlockDynamicLiquid
|
|
||||||
|| block == Blocks.MAGMA
|
|| block == Blocks.MAGMA
|
||||||
|| block == Blocks.CACTUS
|
|| block == Blocks.CACTUS
|
||||||
|| block == Blocks.FIRE
|
|| block == Blocks.FIRE
|
||||||
@@ -499,7 +498,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)
|
||||||
@@ -150,14 +168,10 @@ public class MovementAscend extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.add(getDirection().down()))) {
|
||||||
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)) {
|
||||||
@@ -171,8 +183,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);
|
||||||
@@ -181,7 +194,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);
|
||||||
|
|||||||
@@ -42,7 +42,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 {
|
||||||
|
|
||||||
@@ -63,6 +65,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();
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ 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.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[]{};
|
||||||
@@ -134,9 +137,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;
|
||||||
}
|
}
|
||||||
@@ -174,6 +177,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
|
||||||
@@ -212,7 +226,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) {
|
||||||
Block from = context.get(x, y, z).getBlock();
|
Block from = context.get(x, y, z).getBlock();
|
||||||
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
||||||
@@ -240,10 +246,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,12 +30,16 @@ 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;
|
||||||
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.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MovementTraverse extends Movement {
|
public class MovementTraverse extends Movement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +62,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);
|
||||||
@@ -119,9 +128,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;
|
||||||
}
|
}
|
||||||
@@ -169,6 +178,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
|
||||||
@@ -179,8 +192,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
|
||||||
@@ -189,46 +203,40 @@ 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) {
|
|
||||||
boolean isDoorActuallyBlockingUs = false;
|
boolean notPassable = pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src);
|
||||||
if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) {
|
boolean canOpen = !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()));
|
||||||
isDoorActuallyBlockingUs = true;
|
|
||||||
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) {
|
if (notPassable && canOpen) {
|
||||||
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))
|
return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true))
|
||||||
.setInput(Input.CLICK_RIGHT, true);
|
.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
||||||
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))
|
Optional<Rotation> rotation = RotationUtils.reachable(ctx, blocked);
|
||||||
.setInput(Input.CLICK_RIGHT, true);
|
if (rotation.isPresent()) {
|
||||||
|
return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -245,20 +253,20 @@ public class MovementTraverse extends Movement {
|
|||||||
BlockPos into = dest.subtract(src).add(dest);
|
BlockPos into = dest.subtract(src).add(dest);
|
||||||
Block intoBelow = BlockStateInterface.get(ctx, into).getBlock();
|
Block intoBelow = BlockStateInterface.get(ctx, into).getBlock();
|
||||||
Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock();
|
Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock();
|
||||||
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
||||||
state.setInput(Input.SPRINT, true);
|
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.getValue(BlockLadder.FACING).getOpposite());
|
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(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
|
||||||
@@ -296,7 +304,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;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ 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.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
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;
|
||||||
@@ -100,14 +99,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();
|
||||||
}
|
}
|
||||||
@@ -116,9 +114,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);
|
||||||
}
|
}
|
||||||
@@ -147,38 +145,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++) {
|
||||||
@@ -205,10 +171,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;
|
||||||
@@ -219,7 +185,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;
|
||||||
@@ -233,7 +206,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double currentCost = ((Movement) movement).recalculateCost(behavior.secretInternalGetCalculationContext());
|
double currentCost = movement.recalculateCost(behavior.secretInternalGetCalculationContext());
|
||||||
if (currentCost >= ActionCosts.COST_INF && canCancel) {
|
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();
|
||||||
@@ -285,11 +258,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);
|
||||||
@@ -452,7 +427,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.getSecond();
|
BetterBlockPos fallDest = new BetterBlockPos(data.getSecond());
|
||||||
if (!path.positions().contains(fallDest)) {
|
if (!path.positions().contains(fallDest)) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,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<>();
|
||||||
|
|
||||||
@@ -85,12 +85,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import baritone.utils.PathingCommandContext;
|
import baritone.utils.PathingCommandContext;
|
||||||
import baritone.utils.schematic.AirSchematic;
|
import baritone.utils.schematic.AirSchematic;
|
||||||
import baritone.utils.schematic.Schematic;
|
import baritone.utils.schematic.Schematic;
|
||||||
|
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
@@ -55,7 +56,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
|
||||||
@@ -106,6 +107,20 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildOpenSchematic() {
|
||||||
|
if (SchematicaHelper.isSchematicaPresent()) {
|
||||||
|
Optional<Tuple<ISchematic, BlockPos>> schematic = SchematicaHelper.getOpenSchematic();
|
||||||
|
if (schematic.isPresent()) {
|
||||||
|
this.build(schematic.get().getFirst().toString(), schematic.get().getFirst(), schematic.get().getSecond());
|
||||||
|
} else {
|
||||||
|
logDirect("No schematic currently open");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logDirect("Schematica is not present");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clearArea(BlockPos corner1, BlockPos corner2) {
|
public void clearArea(BlockPos corner1, BlockPos corner2) {
|
||||||
BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ()));
|
BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ()));
|
||||||
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
|
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
|
||||||
@@ -154,7 +169,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() != Blocks.AIR && !valid(curr, desired)) {
|
if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !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()) {
|
||||||
@@ -359,7 +374,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) {
|
||||||
@@ -447,7 +462,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()) {
|
||||||
@@ -602,7 +617,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return new GoalPlace(pos);
|
return new GoalPlace(pos);
|
||||||
}
|
}
|
||||||
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
|
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
|
||||||
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
||||||
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
|
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
|
||||||
return new GoalAdjacent(pos, allowSameLevel);
|
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;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalComposite;
|
|||||||
import baritone.api.process.IFarmProcess;
|
import baritone.api.process.IFarmProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.RayTraceUtils;
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.api.utils.RotationUtils;
|
import baritone.api.utils.RotationUtils;
|
||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
@@ -40,7 +41,9 @@ import net.minecraft.item.EnumDyeColor;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemDye;
|
import net.minecraft.item.ItemDye;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -50,10 +53,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,
|
||||||
@@ -65,17 +71,16 @@ public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
|||||||
|
|
||||||
private static final List<Item> PICKUP_DROPPED = Arrays.asList(
|
private static final List<Item> PICKUP_DROPPED = Arrays.asList(
|
||||||
Items.BEETROOT_SEEDS,
|
Items.BEETROOT_SEEDS,
|
||||||
Items.WHEAT,
|
Items.BEETROOT,
|
||||||
Items.MELON_SEEDS,
|
Items.MELON_SEEDS,
|
||||||
Items.MELON,
|
Items.MELON,
|
||||||
|
Item.getItemFromBlock(Blocks.MELON_BLOCK),
|
||||||
Items.WHEAT_SEEDS,
|
Items.WHEAT_SEEDS,
|
||||||
Items.WHEAT,
|
Items.WHEAT,
|
||||||
Items.PUMPKIN_SEEDS,
|
Items.PUMPKIN_SEEDS,
|
||||||
|
Item.getItemFromBlock(Blocks.PUMPKIN),
|
||||||
Items.POTATO,
|
Items.POTATO,
|
||||||
Items.CARROT,
|
Items.CARROT,
|
||||||
Items.BEETROOT,
|
|
||||||
Item.getItemFromBlock(Blocks.PUMPKIN),
|
|
||||||
Item.getItemFromBlock(Blocks.MELON_BLOCK),
|
|
||||||
Items.NETHER_WART,
|
Items.NETHER_WART,
|
||||||
Items.REEDS,
|
Items.REEDS,
|
||||||
Item.getItemFromBlock(Blocks.CACTUS)
|
Item.getItemFromBlock(Blocks.CACTUS)
|
||||||
@@ -93,6 +98,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 {
|
||||||
@@ -164,9 +170,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<>();
|
||||||
@@ -216,11 +225,14 @@ public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
|||||||
boolean soulsand = openSoulsand.contains(pos);
|
boolean soulsand = openSoulsand.contains(pos);
|
||||||
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
|
||||||
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
|
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
|
||||||
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
|
||||||
if (ctx.isLookingAt(pos)) {
|
if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) {
|
||||||
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
||||||
|
if (ctx.isLookingAt(pos)) {
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
}
|
}
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (BlockPos pos : bonemealable) {
|
for (BlockPos pos : bonemealable) {
|
||||||
|
|||||||
@@ -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<>();
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public final class BlockBreakHelper implements Helper {
|
|||||||
this.playerContext = playerContext;
|
this.playerContext = playerContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryBreakBlock(BlockPos pos, EnumFacing side) {
|
private void tryBreakBlock(BlockPos pos, EnumFacing side) {
|
||||||
if (playerContext.playerController().onPlayerDamageBlock(pos, side)) {
|
if (playerContext.playerController().onPlayerDamageBlock(pos, side)) {
|
||||||
playerContext.player().swingArm(EnumHand.MAIN_HAND);
|
playerContext.player().swingArm(EnumHand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ public class GuiClick extends GuiScreen {
|
|||||||
currentMouseOver = result.getBlockPos();
|
currentMouseOver = result.getBlockPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,7 +102,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
||||||
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
@@ -121,7 +120,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toWorld(double x, double y, double z) {
|
private Vec3d toWorld(double x, double y, double z) {
|
||||||
boolean result = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
boolean result = GLU.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));
|
||||||
|
|||||||
@@ -97,8 +97,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) {
|
||||||
@@ -109,8 +107,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 -> {
|
||||||
@@ -122,11 +118,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
|
||||||
@@ -126,7 +126,7 @@ public class PathingControlManager implements IPathingControlManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postTick() {
|
private void postTick() {
|
||||||
// if we did this in pretick, it would suck
|
// if we did this in pretick, it would suck
|
||||||
// we use the time between ticks as calculation time
|
// we use the time between ticks as calculation time
|
||||||
// therefore, we only cancel and recalculate after the tick for the current path has executed
|
// therefore, we only cancel and recalculate after the tick for the current path has executed
|
||||||
|
|||||||
@@ -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++;
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ import baritone.Baritone;
|
|||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||||
|
import net.minecraft.entity.monster.EntityEnderman;
|
||||||
import net.minecraft.entity.monster.EntityMob;
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
|
import net.minecraft.entity.monster.EntityPigZombie;
|
||||||
|
import net.minecraft.entity.monster.EntitySpider;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -64,10 +67,16 @@ 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)
|
||||||
|
.filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5)
|
||||||
|
.filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry())
|
||||||
|
.filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming())
|
||||||
|
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Baritone.
|
|
||||||
*
|
|
||||||
* Baritone is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Baritone is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.utils.pathing;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.pathing.calc.IPath;
|
|
||||||
import baritone.api.pathing.goals.Goal;
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.PathCalculationResult;
|
|
||||||
import baritone.cache.CachedWorld;
|
|
||||||
import baritone.pathing.calc.AStarPathFinder;
|
|
||||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
|
||||||
import baritone.pathing.movement.CalculationContext;
|
|
||||||
import baritone.pathing.path.SplicedPath;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate and splice many path segments to reach a goal
|
|
||||||
*
|
|
||||||
* @author leijurv
|
|
||||||
*/
|
|
||||||
public class SegmentedCalculator {
|
|
||||||
private final BetterBlockPos start;
|
|
||||||
private final Goal goal;
|
|
||||||
private final CalculationContext context;
|
|
||||||
|
|
||||||
private SegmentedCalculator(BetterBlockPos start, Goal goal, CalculationContext context) {
|
|
||||||
this.start = start;
|
|
||||||
this.goal = goal;
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<IPath> doCalc() {
|
|
||||||
Optional<IPath> soFar = Optional.empty();
|
|
||||||
while (true) {
|
|
||||||
PathCalculationResult result = segment(soFar);
|
|
||||||
switch (result.getType()) {
|
|
||||||
case SUCCESS_SEGMENT:
|
|
||||||
case SUCCESS_TO_GOAL:
|
|
||||||
break;
|
|
||||||
case FAILURE: // if path calculation failed, we're done
|
|
||||||
case EXCEPTION: // if path calculation threw an exception, we're done
|
|
||||||
return soFar;
|
|
||||||
default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
IPath segment = result.getPath().get(); // path calculation result type is SUCCESS_SEGMENT, so the path must be present
|
|
||||||
IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).get()).orElse(segment);
|
|
||||||
loadAdjacent(combined.getDest().getX(), combined.getDest().getZ());
|
|
||||||
soFar = Optional.of(combined);
|
|
||||||
if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) {
|
|
||||||
return soFar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAdjacent(int blockX, int blockZ) {
|
|
||||||
BetterBlockPos bp = new BetterBlockPos(blockX, 64, blockZ);
|
|
||||||
CachedWorld cached = (CachedWorld) context.getBaritone().getPlayerContext().worldData().getCachedWorld();
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
// pathing thread is not allowed to load new cached regions from disk
|
|
||||||
// it checks if every chunk is loaded before getting blocks from it
|
|
||||||
// so you see path segments ending at multiples of 512 (plus or minus one) on either x or z axis
|
|
||||||
// this loads every adjacent chunk to the segment end, so it can continue into the next cached region
|
|
||||||
BetterBlockPos toLoad = bp.offset(EnumFacing.byHorizontalIndex(i), 16);
|
|
||||||
cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private PathCalculationResult segment(Optional<IPath> previous) {
|
|
||||||
BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c
|
|
||||||
AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null), context), context); // this is on another thread, so cannot include mob avoidances.
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer<IPath> onCompletion, Runnable onFailure) {
|
|
||||||
Baritone.getExecutor().execute(() -> {
|
|
||||||
Optional<IPath> result;
|
|
||||||
try {
|
|
||||||
result = new SegmentedCalculator(start, goal, context).doCalc();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
result = Optional.empty();
|
|
||||||
}
|
|
||||||
if (result.isPresent()) {
|
|
||||||
onCompletion.accept(result.get());
|
|
||||||
} else {
|
|
||||||
onFailure.run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.utils.schematic.schematica;
|
||||||
|
|
||||||
|
import baritone.api.utils.ISchematic;
|
||||||
|
|
||||||
|
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public final class SchematicAdapter implements ISchematic {
|
||||||
|
private final SchematicWorld schematic;
|
||||||
|
|
||||||
|
public SchematicAdapter(SchematicWorld schematicWorld) {
|
||||||
|
this.schematic = schematicWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState desiredState(int x, int y, int z) {
|
||||||
|
return schematic.getSchematic().getBlockState(new BlockPos(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int widthX() {
|
||||||
|
return schematic.getSchematic().getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int heightY() {
|
||||||
|
return schematic.getSchematic().getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int lengthZ() {
|
||||||
|
return schematic.getSchematic().getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.utils.schematic.schematica;
|
||||||
|
|
||||||
|
import baritone.api.utils.ISchematic;
|
||||||
|
import com.github.lunatrius.schematica.Schematica;
|
||||||
|
import com.github.lunatrius.schematica.proxy.ClientProxy;
|
||||||
|
import net.minecraft.util.Tuple;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public enum SchematicaHelper {
|
||||||
|
;
|
||||||
|
|
||||||
|
public static boolean isSchematicaPresent() {
|
||||||
|
try {
|
||||||
|
Class.forName(Schematica.class.getName());
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() {
|
||||||
|
return Optional.ofNullable(ClientProxy.schematic)
|
||||||
|
.map(world -> new Tuple<>(new SchematicAdapter(world), world.position));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.core.util.math;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class MBlockPos extends BlockPos {
|
||||||
|
MBlockPos() {
|
||||||
|
super(6, 6, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getX() {
|
||||||
|
throw new LinkageError("LOL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getY() {
|
||||||
|
throw new LinkageError("LOL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getZ() {
|
||||||
|
throw new LinkageError("LOL");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.schematica;
|
||||||
|
|
||||||
|
import com.github.lunatrius.schematica.proxy.CommonProxy;
|
||||||
|
|
||||||
|
public class Schematica {
|
||||||
|
public static CommonProxy proxy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.schematica.api;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public interface ISchematic {
|
||||||
|
IBlockState getBlockState(BlockPos var1);
|
||||||
|
|
||||||
|
int getWidth();
|
||||||
|
|
||||||
|
int getHeight();
|
||||||
|
|
||||||
|
int getLength();
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.schematica.client.world;
|
||||||
|
|
||||||
|
import com.github.lunatrius.core.util.math.MBlockPos;
|
||||||
|
import com.github.lunatrius.schematica.api.ISchematic;
|
||||||
|
|
||||||
|
public class SchematicWorld {
|
||||||
|
public final MBlockPos position = (MBlockPos)(Object)"cringe";
|
||||||
|
|
||||||
|
public ISchematic getSchematic() {
|
||||||
|
throw new LinkageError("LOL");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.schematica.proxy;
|
||||||
|
|
||||||
|
import com.github.lunatrius.schematica.client.world.SchematicWorld;
|
||||||
|
|
||||||
|
public class ClientProxy extends CommonProxy {
|
||||||
|
public static SchematicWorld schematic;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.github.lunatrius.schematica.proxy;
|
||||||
|
|
||||||
|
public abstract class CommonProxy {}
|
||||||
@@ -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