Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a0771e5f4 | ||
|
|
9c6c977314 | ||
|
|
38c5388e00 | ||
|
|
519a76a171 | ||
|
|
b6cc15e9ab | ||
|
|
ebb9dd1aaf | ||
|
|
e077995332 | ||
|
|
c9ebc0191d | ||
|
|
db0ebeebee | ||
|
|
70dc2a3009 | ||
|
|
696ec6756d | ||
|
|
697c92ae77 | ||
|
|
c4da682e84 | ||
|
|
33ee39dcce | ||
|
|
587c2cc8e2 | ||
|
|
1c8899ceae | ||
|
|
088009fe4a | ||
|
|
90ac6f331e | ||
|
|
e80e4afa48 | ||
|
|
b73295d180 | ||
|
|
186a3cb6df | ||
|
|
b6fba56291 | ||
|
|
f52fee8254 | ||
|
|
f1061cfd31 | ||
|
|
9a9358bc78 |
16
.github/workflows/gradle_build.yml
vendored
16
.github/workflows/gradle_build.yml
vendored
@@ -13,12 +13,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '16'
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
@@ -31,15 +31,15 @@ jobs:
|
||||
|
||||
- name: Build (forge) with Gradle
|
||||
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Artifacts
|
||||
path: dist/
|
||||
|
||||
- name: Archive mapping.txt
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Mappings
|
||||
path: build/tmp/proguard/mapping.txt
|
||||
|
||||
10
.github/workflows/run_tests.yml
vendored
10
.github/workflows/run_tests.yml
vendored
@@ -11,12 +11,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '16'
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt update -y
|
||||
|
||||
RUN apt install \
|
||||
openjdk-16-jdk \
|
||||
openjdk-17-jdk \
|
||||
--assume-yes
|
||||
|
||||
COPY . /code
|
||||
|
||||
129
README.md
129
README.md
@@ -1,2 +1,127 @@
|
||||
This branch of Baritone is deprecated. It will no longer recieve updates. Updates to older versions of Minecraft will not be merged into this branch,
|
||||
even if a newer branch is not deprecated (this branch will be skipped). Bug reports that only affect deprecated branches will not be addressed.
|
||||
# Baritone
|
||||
<p align="center">
|
||||
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/downloads/cabaletta/baritone/total.svg" alt="GitHub All Releases"/></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.13.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.14.4-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.15.2-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/>
|
||||
<img src="https://img.shields.io/badge/MC-1.18.1-brightgreen.svg" alt="Minecraft"/>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
|
||||
<a href="https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400" alt="Codacy Badge"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat" alt="Code of Conduct"/></a>
|
||||
<a href="https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle"><img src="https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle" alt="Known Vulnerabilities"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="Contributions welcome"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/github/issues/cabaletta/baritone.svg" alt="Issues"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed/cabaletta/baritone.svg" alt="GitHub issues-closed"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/pulls/"><img src="https://img.shields.io/github/issues-pr/cabaletta/baritone.svg" alt="Pull Requests"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/graphs/contributors/"><img src="https://img.shields.io/github/contributors/cabaletta/baritone.svg" alt="GitHub contributors"/></a>
|
||||
<a href="https://github.com/cabaletta/baritone/commit/"><img src="https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg" alt="GitHub commits"/></a>
|
||||
<img src="https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg" alt="Code size"/>
|
||||
<img src="https://img.shields.io/github/repo-size/cabaletta/baritone.svg" alt="GitHub repo size"/>
|
||||
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code" alt="Lines of Code"/>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://impactclient.net/"><img src="https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3%20/%20v1.6.3-brightgreen.svg" alt="Impact integration"/></a>
|
||||
<a href="https://github.com/kami-blue/client"><img src="https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green" alt="KAMI Blue integration"/></a>
|
||||
<a href="https://github.com/fr1kin/ForgeHax/"><img src="https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg" alt="ForgeHax integration"/></a>
|
||||
<a href="https://aristois.net/"><img src="https://img.shields.io/badge/Aristois%20add--on%20integration-v1.6.3-green.svg" alt="Aristois add-on integration"/></a>
|
||||
<a href="https://rootnet.dev/"><img src="https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg" alt="rootNET integration"/></a>
|
||||
<a href="https://futureclient.net/"><img src="https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red" alt="Future integration"/></a>
|
||||
<a href="https://rusherhack.org/"><img src="https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green" alt="RusherHack integration"/></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
|
||||
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
|
||||
</p>
|
||||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar.
|
||||
|
||||
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
|
||||
|
||||
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**.
|
||||
|
||||
If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**.
|
||||
|
||||
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 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
|
||||
|
||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
||||
|
||||
# Getting Started
|
||||
|
||||
Here are some links to help to get started:
|
||||
|
||||
- [Features](FEATURES.md)
|
||||
|
||||
- [Installation & setup](SETUP.md)
|
||||
|
||||
- [API Javadocs](https://baritone.leijurv.com/)
|
||||
|
||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
||||
|
||||
- [Usage (chat control)](USAGE.md)
|
||||
|
||||
## Stars over time
|
||||
|
||||
[](https://starchart.cc/cabaletta/baritone)
|
||||
|
||||
# API
|
||||
|
||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
||||
jar.
|
||||
|
||||
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
|
||||
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
||||
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
|
||||
```
|
||||
|
||||
# FAQ
|
||||
|
||||
## Can I use Baritone as a library in my custom utility client?
|
||||
|
||||
That's what it's for, sure! (As long as usage complies with the LGPL 3.0 License)
|
||||
|
||||
## How is it so fast?
|
||||
|
||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
||||
|
||||
### Additional Special Thanks To:
|
||||
|
||||

|
||||
|
||||
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications.
|
||||
|
||||
YourKit is the creator of the [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/), and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||
|
||||
We thank them for granting Baritone an OSS license so that we can make our software the best it can be.
|
||||
|
||||
## Why is it called Baritone?
|
||||
|
||||
It's named for FitMC's deep sultry voice.
|
||||
|
||||
21
SETUP.md
21
SETUP.md
@@ -11,7 +11,7 @@ These releases are not always completely up to date with latest features, and ar
|
||||
|
||||
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
|
||||
|
||||
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.5, v1.7.* is for 1.17.1, v1.8.* is for 1.18.1
|
||||
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL)
|
||||
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.
|
||||
|
||||
@@ -22,16 +22,15 @@ The build is fully deterministic and reproducible, and you can verify Travis did
|
||||
|
||||
Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
|
||||
|
||||
**The Forge and Fabric releases can simply be added as a Forge/Fabric mods.**
|
||||
**The Forge release can simply be added as a Forge mod.**
|
||||
|
||||
If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar`
|
||||
|
||||
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
||||
- **Forge/Fabric API**: Same as API, but packaged for Forge/Fabric. This should be used where another mod has a Baritone integration.
|
||||
- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration.
|
||||
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
|
||||
- **Forge/Fabric Standalone**: Same as Standalone, but packaged for Forge/Fabric. This should be used when Baritone is your only Forge/Fabric mod, or none of your other Forge/Fabric mods integrate with Baritone.
|
||||
- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone.
|
||||
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
||||
- **Forge/Fabric Unoptimized**: Same as Unoptimized, but packaged for Forge/Fabric.
|
||||
|
||||
## Build it yourself
|
||||
- Clone or download Baritone
|
||||
@@ -43,13 +42,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone
|
||||
## Command Line
|
||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
||||
|
||||
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16 for 1.17.1, and JDK 17 for 1.18.1.
|
||||
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8.
|
||||
|
||||
To check which java you are using do
|
||||
`java -version` in a command prompt or terminal.
|
||||
If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
|
||||
If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
|
||||
|
||||
Open JDK download: https://openjdk.java.net/install/
|
||||
Open JDK 8 download: https://openjdk.java.net/install/
|
||||
#### macOS guide
|
||||
In order to get JDK 8, Try running the following command:
|
||||
`% /usr/libexec/java_home -V`
|
||||
@@ -85,12 +84,6 @@ For minecraft 1.15.2+, run the following instead to include the Forge jars:
|
||||
$ gradlew build -Pbaritone.forge_build
|
||||
```
|
||||
|
||||
Do this instead for Fabric jars:
|
||||
|
||||
```
|
||||
$ gradlew build -Pbaritone.fabric_build
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
|
||||
16
USAGE.md
16
USAGE.md
@@ -32,13 +32,13 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
|
||||
|
||||
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`.
|
||||
|
||||
Commands in Baritone:
|
||||
Some common examples:
|
||||
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
|
||||
- `goal x y z` or `goal x z` or `goal y`, then `path` to 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 clear` to clear the goal
|
||||
- `cancel` or `stop` to stop everything, `forcecancel` is also an option
|
||||
- `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)
|
||||
- `mine diamond_ore iron_ore` to mine diamond ore or iron 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.) An amount of blocks can also be specified, for example, `mine 64 diamond_ore`.
|
||||
- `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 select an area (`#help sel` to see what you can do with that selection).
|
||||
@@ -51,19 +51,11 @@ Commands in Baritone:
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
|
||||
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.
|
||||
- `come` tells Baritone to head towards your camera, useful when freecam doesn't move your player position.
|
||||
- `blacklist` will stop baritone from going to the closest block so it won't attempt to get to it.
|
||||
- `eta` to get information about the estimated time until the next segment and the goal, be aware that the ETA to your goal is really unprecise.
|
||||
- `proc` to view miscellaneous information about the process currently controlling Baritone.
|
||||
- `repack` to re-cache the chunks around you.
|
||||
- `gc` to call `System.gc()` which may free up some memory.
|
||||
- `render` to fix glitched chunk rendering without having to reload all of them.
|
||||
- `reloadall` to reload Baritone's world cache or `saveall` to save Baritone's world cache.
|
||||
- `find` to search through Baritone's cache and attempt to find the location of the block.
|
||||
- `surface` or `top` to tell Baritone to head towards the closest surface-like area, this can be the surface or highest available air space.
|
||||
- `version` to get the version of Baritone you're running
|
||||
- `damn` daniel
|
||||
|
||||
For the rest of the commands, you can take a look at the code [here](https://baritone.leijurv.com/baritone/api/Settings.html).
|
||||
|
||||
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>.
|
||||
|
||||
There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links.
|
||||
|
||||
10
build.gradle
10
build.gradle
@@ -31,7 +31,7 @@ import baritone.gradle.task.ProguardTask
|
||||
|
||||
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
|
||||
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||
@@ -95,7 +95,7 @@ dependencies {
|
||||
mappings loom.layered() {
|
||||
officialMojangMappings()
|
||||
//technically optional, but really helpful in dev:
|
||||
parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
|
||||
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
|
||||
}
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
if (!compileType.equals("FORGE")) {
|
||||
@@ -179,12 +179,12 @@ if (compileType.equals("OFFICIAL")) {
|
||||
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://downloads.sourceforge.net/project/proguard/v7.1.0-beta5/proguard-7.1.0-beta5.zip'
|
||||
extract 'proguard-7.1.0-beta5/lib/proguard.jar'
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
|
||||
extract 'proguard-7.2.0-beta2/lib/proguard.jar'
|
||||
compType compileType
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
build.finalizedBy(createDist)
|
||||
@@ -83,7 +83,7 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
|
||||
protected void verifyArtifacts() throws IllegalStateException {
|
||||
if (!Files.exists(this.artifactPath)) {
|
||||
throw new IllegalStateException("Artifact not found! Run build first! Missing file: " + this.artifactPath);
|
||||
throw new IllegalStateException("Artifact not found! Run build first!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,8 +237,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
|
||||
// Setup the template that will be used to derive the API and Standalone configs
|
||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||
template.add(0, "-injars '" + this.artifactPath.toString() + "'");
|
||||
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
|
||||
template.add(0, "-injars " + this.artifactPath.toString());
|
||||
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
|
||||
|
||||
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
|
||||
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
|
||||
@@ -312,15 +312,9 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Files.delete(this.proguardOut);
|
||||
}
|
||||
|
||||
// Make paths relative to work directory; fixes spaces in path to config, @"" doesn't work
|
||||
Path workingDirectory = getTemporaryFile("");
|
||||
Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR));
|
||||
config = workingDirectory.relativize(config);
|
||||
|
||||
// Honestly, if you still have spaces in your path at this point, you're SOL.
|
||||
|
||||
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
|
||||
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
|
||||
.directory(workingDirectory.toFile()) // Set the working directory to the temporary folder]
|
||||
.directory(getTemporaryFile("").toFile()) // Set the working directory to the temporary folder]
|
||||
.start();
|
||||
|
||||
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
|
||||
mod_version=1.7.3
|
||||
mod_version=1.8.3
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
minecraft_version=1.17.1
|
||||
forge_version=1.17.1-37.0.69
|
||||
fabric_version=0.11.6
|
||||
minecraft_version=1.18.2
|
||||
forge_version=1.18.2-40.0.0
|
||||
fabric_version=0.13.1
|
||||
|
||||
# # un comment for forge debugging default (as opposed to fabric)
|
||||
# baritone.forge_build=true
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
53
gradlew
vendored
53
gradlew
vendored
@@ -1,5 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -66,6 +82,7 @@ esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
@@ -109,10 +126,11 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
@@ -138,19 +156,19 @@ if $cygwin ; then
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -159,14 +177,9 @@ save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
43
gradlew.bat
vendored
43
gradlew.bat
vendored
@@ -1,3 +1,19 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -35,7 +54,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
5
scripts/proguard.pro
vendored
5
scripts/proguard.pro
vendored
@@ -1,6 +1,5 @@
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes InnerClasses
|
||||
|
||||
-optimizationpasses 5
|
||||
-verbose
|
||||
@@ -28,7 +27,6 @@
|
||||
-keep class baritone.api.IBaritoneProvider
|
||||
|
||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||
-keepname class baritone.api.utils.BlockOptionalMeta # this name is exposed to the user, so we need to keep it in all builds
|
||||
|
||||
# Keep any class or member annotated with @KeepName so we dont have to put everything in the script
|
||||
-keep,allowobfuscation @interface baritone.KeepName
|
||||
@@ -47,10 +45,9 @@
|
||||
|
||||
#try to keep usage of schematica in separate classes
|
||||
-keep class baritone.utils.schematic.schematica.**
|
||||
-keep class baritone.utils.schematic.litematica.**
|
||||
#proguard doesnt like it when it cant find our fake schematica classes
|
||||
-dontwarn baritone.utils.schematic.schematica.**
|
||||
-dontwarn baritone.utils.schematic.litematica.**
|
||||
|
||||
|
||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||
# methods.
|
||||
|
||||
@@ -37,6 +37,4 @@ pluginManagement {
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'baritone'
|
||||
}
|
||||
@@ -35,8 +35,8 @@ import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Baritone's settings. Settings apply to all Baritone instances.
|
||||
@@ -50,11 +50,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> allowBreak = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Blocks that baritone will be allowed to break even with allowBreak set to false
|
||||
*/
|
||||
public final Setting<List<Block>> allowBreakAnyway = new Setting<>(new ArrayList<>());
|
||||
|
||||
/**
|
||||
* Allow Baritone to sprint
|
||||
*/
|
||||
@@ -108,13 +103,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(3D);
|
||||
|
||||
/**
|
||||
* Don't allow breaking blocks next to liquids.
|
||||
* <p>
|
||||
* Enable if you have mods adding custom fluid physics.
|
||||
*/
|
||||
public final Setting<Boolean> strictLiquidCheck = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
|
||||
* Reliability: questionable.
|
||||
@@ -124,8 +112,6 @@ public final class Settings {
|
||||
/**
|
||||
* Allow Baritone to assume it can walk on still water just like any other block.
|
||||
* This functionality is assumed to be provided by a separate library that might have imported Baritone.
|
||||
* <p>
|
||||
* Note: This will prevent some usage of the frostwalker enchantment, like pillaring up from water.
|
||||
*/
|
||||
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||
|
||||
@@ -206,7 +192,7 @@ public final class Settings {
|
||||
* Blocks that Baritone is not allowed to break
|
||||
*/
|
||||
public final Setting<List<Block>> blocksToDisallowBreaking = new Setting<>(new ArrayList<>(
|
||||
// Leave Empty by Default
|
||||
// Leave Empty by Default
|
||||
));
|
||||
|
||||
/**
|
||||
@@ -246,8 +232,6 @@ public final class Settings {
|
||||
* A mapping of blocks to blocks treated as correct in their position
|
||||
* <p>
|
||||
* If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well
|
||||
* <p>
|
||||
* Syntax same as <a href="https://baritone.leijurv.com/baritone/api/Settings.html#buildSubstitutes">buildSubstitutes</a>
|
||||
*/
|
||||
public final Setting<Map<Block, List<Block>>> buildValidSubstitutes = new Setting<>(new HashMap<>());
|
||||
|
||||
@@ -255,15 +239,6 @@ public final class Settings {
|
||||
* A mapping of blocks to blocks to be built instead
|
||||
* <p>
|
||||
* If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list
|
||||
* <p>
|
||||
* Usage Syntax:
|
||||
* <pre>
|
||||
* sourceblockA->blockToSubstituteA1,blockToSubstituteA2,...blockToSubstituteAN,sourceBlockB->blockToSubstituteB1,blockToSubstituteB2,...blockToSubstituteBN,...sourceBlockX->blockToSubstituteX1,blockToSubstituteX2...blockToSubstituteXN
|
||||
* </pre>
|
||||
* Example:
|
||||
* <pre>
|
||||
* stone->cobblestone,andesite,oak_planks->birch_planks,acacia_planks,glass
|
||||
* </pre>
|
||||
*/
|
||||
public final Setting<Map<Block, List<Block>>> buildSubstitutes = new Setting<>(new HashMap<>());
|
||||
|
||||
@@ -286,12 +261,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* A list of names of block properties the builder will ignore.
|
||||
*/
|
||||
public final Setting<List<String>> buildIgnoreProperties = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
)));
|
||||
|
||||
/**
|
||||
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
||||
* <p>
|
||||
@@ -419,9 +388,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
|
||||
|
||||
/**
|
||||
* Distance to avoid mob spawners.
|
||||
*/
|
||||
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
|
||||
|
||||
/**
|
||||
@@ -431,9 +397,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
|
||||
|
||||
/**
|
||||
* Distance to avoid mobs.
|
||||
*/
|
||||
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
||||
|
||||
/**
|
||||
@@ -584,17 +547,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
||||
|
||||
|
||||
/**
|
||||
* allows baritone to save bed waypoints when interacting with beds
|
||||
*/
|
||||
public final Setting<Boolean> doBedWaypoints = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* allows baritone to save death waypoints
|
||||
*/
|
||||
public final Setting<Boolean> doDeathWaypoints = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||
*/
|
||||
@@ -931,7 +883,7 @@ public final class Settings {
|
||||
/**
|
||||
* Only build the selected part of schematics
|
||||
*/
|
||||
public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
|
||||
public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
|
||||
@@ -1143,7 +1095,7 @@ public final class Settings {
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>(Minecraft.getInstance().gui.getChat()::addMessage);
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will send a desktop notification. This function can be added to
|
||||
|
||||
@@ -26,8 +26,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
INSTANCE;
|
||||
private static String ScalesAliasRegex = "[kKmM]";
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + ScalesAliasRegex + "?)|)$");
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
|
||||
|
||||
@Override
|
||||
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
|
||||
@@ -42,15 +41,11 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
|
||||
boolean isRelative = !matcher.group(1).isEmpty();
|
||||
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, ""));
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
|
||||
|
||||
if (matcher.group(2).toLowerCase().contains("k")) {
|
||||
if (matcher.group(2).contains("k")) {
|
||||
offset *= 1000;
|
||||
}
|
||||
if (matcher.group(2).toLowerCase().contains("m")) {
|
||||
offset *= 1000000;
|
||||
}
|
||||
|
||||
|
||||
if (isRelative) {
|
||||
return origin + offset;
|
||||
|
||||
@@ -83,10 +83,10 @@ public enum RelativeFile implements IDatatypePost<File, File> {
|
||||
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
||||
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
||||
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
|
||||
useParent
|
||||
? currentFile.getParentFile()
|
||||
: currentFile
|
||||
).listFiles()))
|
||||
useParent
|
||||
? currentFile.getParentFile()
|
||||
: currentFile
|
||||
).listFiles()))
|
||||
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
|
||||
(f.isDirectory() ? File.separator : ""))
|
||||
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Registry<V> {
|
||||
* @param entry The entry to unregister.
|
||||
*/
|
||||
public void unregister(V entry) {
|
||||
if (!registered(entry)) {
|
||||
if (registered(entry)) {
|
||||
return;
|
||||
}
|
||||
_entries.remove(entry);
|
||||
|
||||
@@ -19,8 +19,8 @@ package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
import java.util.Arrays;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
/**
|
||||
* Useful for automated combat (retreating specifically)
|
||||
|
||||
@@ -65,8 +65,8 @@ public interface ActionCosts {
|
||||
|
||||
|
||||
static double[] generateFallNBlocksCost() {
|
||||
double[] costs = new double[4097];
|
||||
for (int i = 0; i < 4097; i++) {
|
||||
double[] costs = new double[257];
|
||||
for (int i = 0; i < 257; i++) {
|
||||
costs[i] = distanceToTicks(i);
|
||||
}
|
||||
return costs;
|
||||
|
||||
@@ -57,8 +57,6 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void buildOpenLitematic(int i);
|
||||
|
||||
void pause();
|
||||
|
||||
boolean isPaused();
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
package baritone.api.schematic;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FillSchematic extends AbstractSchematic {
|
||||
|
||||
private final BlockOptionalMeta bom;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
private final Map<Block, List<Block>> substitutions;
|
||||
private final Map<BlockState, Map<Block, BlockState>> blockStateCache = new HashMap<>();
|
||||
|
||||
public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
|
||||
public SubstituteSchematic(ISchematic schematic, Map<Block,List<Block>> substitutions) {
|
||||
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
|
||||
this.schematic = schematic;
|
||||
this.substitutions = substitutions;
|
||||
@@ -81,10 +81,9 @@ public class SubstituteSchematic extends AbstractSchematic {
|
||||
} catch (IllegalArgumentException e) { //property does not exist for target block
|
||||
}
|
||||
}
|
||||
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, BlockState>()).put(block, newState);
|
||||
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block,BlockState>()).put(block, newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
|
||||
return toState.setValue(prop, fromState.getValue(prop));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -147,11 +146,11 @@ public final class BlockOptionalMeta {
|
||||
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
|
||||
rpl.reload();
|
||||
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
|
||||
ReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(PackType.SERVER_DATA);
|
||||
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
|
||||
manager = new LootTables(predicate);
|
||||
resourceManager.registerReloadListener(manager);
|
||||
try {
|
||||
resourceManager.reload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
||||
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class SettingsUtil {
|
||||
/**
|
||||
* This should always be the same as whether the setting can be parsed from or serialized to a string
|
||||
*
|
||||
* @param setting The Setting
|
||||
* @param the setting
|
||||
* @return true if the setting can not be set or read by the user
|
||||
*/
|
||||
public static boolean javaOnlySetting(Settings.Setting setting) {
|
||||
@@ -300,7 +300,7 @@ public class SettingsUtil {
|
||||
Parser keyParser = Parser.getParser(keyType);
|
||||
Parser valueParser = Parser.getParser(valueType);
|
||||
|
||||
return ((Map<?, ?>) value).entrySet().stream()
|
||||
return ((Map<?,?>) value).entrySet().stream()
|
||||
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ public class MixinClientPlayNetHandler {
|
||||
}*/
|
||||
|
||||
@Inject(
|
||||
method = "handleLevelChunk",
|
||||
method = "handleLevelChunkWithLight",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postHandleChunkData(ClientboundLevelChunkPacket packetIn, CallbackInfo ci) {
|
||||
private void postHandleChunkData(ClientboundLevelChunkWithLightPacket packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
LocalPlayer player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
|
||||
@@ -175,7 +175,7 @@ public class MixinClientPlayNetHandler {
|
||||
method = "handlePlayerCombatKill",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/player/LocalPlayer;shouldShowDeathScreen()Z"
|
||||
target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"
|
||||
)
|
||||
)
|
||||
private void onPlayerDeath(ClientboundPlayerCombatKillPacket packetIn, CallbackInfo ci) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MixinMinecraft {
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;",
|
||||
ordinal = 5,
|
||||
ordinal = 4,
|
||||
shift = At.Shift.BY,
|
||||
by = -3
|
||||
)
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.0",
|
||||
"minecraft": "1.17.x"
|
||||
"minecraft": "1.18.x"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"package": "baritone.launch.mixins",
|
||||
"refmap": "mixins.baritone.refmap.json",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"verbose": false,
|
||||
"injectors": {
|
||||
"maxShiftBy": 2
|
||||
|
||||
@@ -69,7 +69,6 @@ public class Baritone implements IBaritone {
|
||||
private PathingBehavior pathingBehavior;
|
||||
private LookBehavior lookBehavior;
|
||||
private InventoryBehavior inventoryBehavior;
|
||||
private WaypointBehavior waypointBehavior;
|
||||
private InputOverrideHandler inputOverrideHandler;
|
||||
|
||||
private FollowProcess followProcess;
|
||||
@@ -102,7 +101,6 @@ public class Baritone implements IBaritone {
|
||||
lookBehavior = new LookBehavior(this);
|
||||
inventoryBehavior = new InventoryBehavior(this);
|
||||
inputOverrideHandler = new InputOverrideHandler(this);
|
||||
waypointBehavior = new WaypointBehavior(this);
|
||||
}
|
||||
|
||||
this.pathingControlManager = new PathingControlManager(this);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
||||
@@ -98,7 +98,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
baritone.getPathingControlManager().cancelEverything();
|
||||
return;
|
||||
}
|
||||
|
||||
expectedSegmentStart = pathStart();
|
||||
baritone.getPathingControlManager().preTick();
|
||||
tickPath();
|
||||
|
||||
@@ -1,93 +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.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.event.events.BlockInteractEvent;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.level.block.BedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BedPart;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class WaypointBehavior extends Behavior {
|
||||
|
||||
|
||||
public WaypointBehavior(Baritone baritone) {
|
||||
super(baritone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockInteract(BlockInteractEvent event) {
|
||||
if (!Baritone.settings().doBedWaypoints.value)
|
||||
return;
|
||||
if (event.getType() == BlockInteractEvent.Type.USE) {
|
||||
BetterBlockPos pos = BetterBlockPos.from(event.getPos());
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
if (state.getBlock() instanceof BedBlock) {
|
||||
if (state.getValue(BedBlock.PART) == BedPart.FOOT) {
|
||||
pos = pos.relative(state.getValue(BedBlock.FACING));
|
||||
}
|
||||
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED);
|
||||
boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent();
|
||||
if (!exists) {
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDeath() {
|
||||
if (!Baritone.settings().doDeathWaypoints.value)
|
||||
return;
|
||||
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
|
||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
|
||||
BaseComponent component = new TextComponent("Death position saved.");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Click to goto death")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goto %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
"wp",
|
||||
deathWaypoint.getTag().getName(),
|
||||
deathWaypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
Helper.HELPER.logDirect(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
||||
private BlockPos guessPosition() {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
IWorldData data = ibaritone.getWorldProvider().getCurrentWorld();
|
||||
if (data != null && data.getCachedWorld() == this && ibaritone.getPlayerContext().player() != null) {
|
||||
if (data != null && data.getCachedWorld() == this) {
|
||||
return ibaritone.getPlayerContext().playerFeet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class ChunkPacker {
|
||||
return PathingBlockType.AVOID;
|
||||
}
|
||||
if (x == 0 || x == 15 || z == 0 || z == 15) {
|
||||
Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + (chunk.getPos().x << 4), y, z + (chunk.getPos().z << 4)));
|
||||
Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + chunk.getPos().x << 4, y, z + chunk.getPos().z << 4));
|
||||
if (flow.x != 0.0 || flow.z != 0.0) {
|
||||
return PathingBlockType.WATER;
|
||||
}
|
||||
|
||||
6
src/main/java/baritone/cache/WorldData.java
vendored
6
src/main/java/baritone/cache/WorldData.java
vendored
@@ -21,9 +21,11 @@ import baritone.Baritone;
|
||||
import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
|
||||
/**
|
||||
* Data about a world, from baritone's point of view. Includes cached chunks, waypoints, and map data.
|
||||
|
||||
59
src/main/java/baritone/cache/WorldProvider.java
vendored
59
src/main/java/baritone/cache/WorldProvider.java
vendored
@@ -45,11 +45,9 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
private static final Map<Path, WorldData> worldCache = new HashMap<>(); // this is how the bots have the same cached world
|
||||
|
||||
private WorldData currentWorld;
|
||||
private Level mcWorld; // this let's us detect a broken load/unload hook
|
||||
|
||||
@Override
|
||||
public final WorldData getCurrentWorld() {
|
||||
detectAndHandleBrokenLoading();
|
||||
return this.currentWorld;
|
||||
}
|
||||
|
||||
@@ -59,43 +57,45 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
* @param world The world's Registry Data
|
||||
*/
|
||||
public final void initWorld(ResourceKey<Level> worldKey, DimensionType world) {
|
||||
File directory;
|
||||
File readme;
|
||||
Path directory;
|
||||
Path readme;
|
||||
|
||||
IntegratedServer integratedServer = mc.getSingleplayerServer();
|
||||
|
||||
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
|
||||
if (mc.hasSingleplayerServer()) {
|
||||
directory = DimensionType.getStorageFolder(worldKey, integratedServer.getWorldPath(LevelResource.ROOT).toFile());
|
||||
directory = DimensionType.getStorageFolder(worldKey, integratedServer.getWorldPath(LevelResource.ROOT));
|
||||
|
||||
// Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world
|
||||
if (directory.toPath().relativize(mc.gameDirectory.toPath()).getNameCount() != 2) {
|
||||
if (directory.relativize(mc.gameDirectory.toPath()).getNameCount() != 2) {
|
||||
// subdirectory of the main save directory for this world
|
||||
directory = directory.getParentFile();
|
||||
directory = directory.getParent();
|
||||
}
|
||||
|
||||
directory = new File(directory, "baritone");
|
||||
directory = directory.resolve("baritone");
|
||||
readme = directory;
|
||||
} else { // Otherwise, the server must be remote...
|
||||
String folderName;
|
||||
if (mc.getCurrentServer() != null) {
|
||||
folderName = mc.isConnectedToRealms() ? "realms" : mc.getCurrentServer().ip;
|
||||
if (mc.isConnectedToRealms()) {
|
||||
folderName = "realms";
|
||||
} else {
|
||||
//replaymod causes null currentServer and false singleplayer.
|
||||
System.out.println("World seems to be a replay. Not loading Baritone cache.");
|
||||
currentWorld = null;
|
||||
mcWorld = mc.level;
|
||||
return;
|
||||
if (mc.getCurrentServer() != null) {
|
||||
folderName = mc.getCurrentServer().ip;
|
||||
} else {
|
||||
//replaymod causes null currentServerData and false singleplayer.
|
||||
currentWorld = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
folderName = folderName.replace(":", "_");
|
||||
}
|
||||
directory = new File(Baritone.getDir(), folderName);
|
||||
readme = Baritone.getDir();
|
||||
directory = Baritone.getDir().toPath().resolve(folderName);
|
||||
readme = Baritone.getDir().toPath();
|
||||
}
|
||||
|
||||
// lol wtf is this baritone folder in my minecraft save?
|
||||
try (FileOutputStream out = new FileOutputStream(new File(readme, "readme.txt"))) {
|
||||
try (FileOutputStream out = new FileOutputStream(readme.resolve("readme.txt").toFile())) {
|
||||
// good thing we have a readme
|
||||
out.write("https://github.com/cabaletta/baritone\n".getBytes());
|
||||
} catch (IOException ignored) {}
|
||||
@@ -112,17 +112,15 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
synchronized (worldCache) {
|
||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, world));
|
||||
}
|
||||
this.mcWorld = mc.level;
|
||||
}
|
||||
|
||||
public final Path getDimDir(ResourceKey<Level> level, int height, File directory) {
|
||||
return directory.toPath().resolve(level.location().getNamespace()).resolve(level.location().getPath() + "_" + height);
|
||||
public final Path getDimDir(ResourceKey<Level> level, int height, Path directory) {
|
||||
return directory.resolve(level.location().getNamespace()).resolve(level.location().getPath() + "_" + height);
|
||||
}
|
||||
|
||||
public final void closeWorld() {
|
||||
WorldData world = this.currentWorld;
|
||||
this.currentWorld = null;
|
||||
this.mcWorld = null;
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
@@ -130,25 +128,8 @@ public class WorldProvider implements IWorldProvider, Helper {
|
||||
}
|
||||
|
||||
public final void ifWorldLoaded(Consumer<WorldData> currentWorldConsumer) {
|
||||
detectAndHandleBrokenLoading();
|
||||
if (this.currentWorld != null) {
|
||||
currentWorldConsumer.accept(this.currentWorld);
|
||||
}
|
||||
}
|
||||
|
||||
private final void detectAndHandleBrokenLoading() {
|
||||
if (this.mcWorld != mc.level) {
|
||||
if (this.currentWorld != null) {
|
||||
System.out.println("mc.world unloaded unnoticed! Unloading Baritone cache now.");
|
||||
closeWorld();
|
||||
}
|
||||
if (mc.level != null) {
|
||||
System.out.println("mc.world loaded unnoticed! Loading Baritone cache now.");
|
||||
initWorld(mc.level.dimension(), mc.level.dimensionType());
|
||||
}
|
||||
} else if (currentWorld == null && mc.level != null && (mc.hasSingleplayerServer() || mc.getCurrentServer() != null)) {
|
||||
System.out.println("Retrying to load Baritone cache");
|
||||
initWorld(mc.level.dimension(), mc.level.dimensionType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public enum WorldScanner implements IWorldScanner {
|
||||
boolean foundWithinY = false;
|
||||
for (int y0 : coordinateIterationOrder) {
|
||||
LevelChunkSection section = chunkInternalStorageArray[y0];
|
||||
if (section == null || LevelChunkSection.isEmpty(section)) {
|
||||
if (section == null || section.hasOnlyAir()) {
|
||||
continue;
|
||||
}
|
||||
int yReal = y0 << 4;
|
||||
|
||||
@@ -42,8 +42,7 @@ public final class DefaultCommands {
|
||||
new VersionCommand(baritone),
|
||||
new RepackCommand(baritone),
|
||||
new BuildCommand(baritone),
|
||||
//new SchematicaCommand(baritone),
|
||||
new LitematicaCommand(baritone),
|
||||
new SchematicaCommand(baritone),
|
||||
new ComeCommand(baritone),
|
||||
new AxisCommand(baritone),
|
||||
new ForceCancelCommand(baritone),
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -45,17 +45,11 @@ public class ETACommand extends Command {
|
||||
throw new CommandInvalidStateException("No process in control");
|
||||
}
|
||||
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||
|
||||
double ticksRemainingInSegment = pathingBehavior.ticksRemainingInSegment().orElse(Double.NaN);
|
||||
double ticksRemainingInGoal = pathingBehavior.estimatedTicksToGoal().orElse(Double.NaN);
|
||||
|
||||
logDirect(String.format(
|
||||
"Next segment: %.1fs (%.0f ticks)\n" +
|
||||
"Goal: %.1fs (%.0f ticks)",
|
||||
ticksRemainingInSegment / 20, // we just assume tps is 20, it isn't worth the effort that is needed to calculate it exactly
|
||||
ticksRemainingInSegment,
|
||||
ticksRemainingInGoal / 20,
|
||||
ticksRemainingInGoal
|
||||
"Next segment: %.2f\n" +
|
||||
"Goal: %.2f",
|
||||
pathingBehavior.ticksRemainingInSegment().orElse(-1.0),
|
||||
pathingBehavior.estimatedTicksToGoal().orElse(-1.0)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ public class ExecutionControlCommands {
|
||||
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
|
||||
@@ -80,7 +79,7 @@ public class ExecutionControlCommands {
|
||||
}
|
||||
}
|
||||
);
|
||||
pauseCommand = new Command(baritone, "pause", "p", "paws") {
|
||||
pauseCommand = new Command(baritone, "pause", "p") {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
@@ -113,7 +112,7 @@ public class ExecutionControlCommands {
|
||||
);
|
||||
}
|
||||
};
|
||||
resumeCommand = new Command(baritone, "resume", "r", "unpause", "unpaws") {
|
||||
resumeCommand = new Command(baritone, "resume", "r", "unpause") {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
|
||||
@@ -22,22 +22,13 @@ import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.BlockById;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class FindCommand extends Command {
|
||||
|
||||
@@ -47,13 +38,12 @@ public class FindCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMin(1);
|
||||
List<Block> toFind = new ArrayList<>();
|
||||
while (args.hasAny()) {
|
||||
toFind.add(args.getDatatypeFor(BlockById.INSTANCE));
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
BaseComponent[] components = toFind.stream()
|
||||
toFind.stream()
|
||||
.flatMap(block ->
|
||||
ctx.worldData().getCachedWorld().getLocationsOf(
|
||||
Registry.BLOCK.getKey(block).getPath(),
|
||||
@@ -64,39 +54,13 @@ public class FindCommand extends Command {
|
||||
).stream()
|
||||
)
|
||||
.map(BetterBlockPos::new)
|
||||
.map(this::positionToComponent)
|
||||
.toArray(BaseComponent[]::new);
|
||||
if (components.length > 0) {
|
||||
Arrays.asList(components).forEach(this::logDirect);
|
||||
} else {
|
||||
logDirect("No positions known, are you sure the blocks are cached?");
|
||||
}
|
||||
}
|
||||
|
||||
private BaseComponent positionToComponent(BetterBlockPos pos) {
|
||||
String positionText = String.format("%s %s %s", pos.x, pos.y, pos.z);
|
||||
String command = String.format("%sgoal %s", FORCE_COMMAND_PREFIX, positionText);
|
||||
BaseComponent baseComponent = new TextComponent(pos.toString());
|
||||
BaseComponent hoverComponent = new TextComponent("Click to set goal to this position");
|
||||
baseComponent.setStyle(baseComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withInsertion(positionText)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)));
|
||||
return baseComponent;
|
||||
.map(BetterBlockPos::toString)
|
||||
.forEach(this::logDirect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
|
||||
.map(Registry.BLOCK::getKey)
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(args.getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
||||
return args.tabCompleteDatatype(BlockById.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,11 +71,10 @@ public class FindCommand extends Command {
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"The find command searches through Baritone's cache and attempts to find the location of the block.",
|
||||
"Tab completion will suggest only cached blocks and uncached blocks can not be found.",
|
||||
"",
|
||||
"",
|
||||
"Usage:",
|
||||
"> find <block> [...] - Try finding the listed blocks"
|
||||
"> "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +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.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class LitematicaCommand extends Command {
|
||||
|
||||
public LitematicaCommand(IBaritone baritone) {
|
||||
super(baritone, "litematica");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
int schematic = 0;
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(1);
|
||||
if (args.is(Integer.class)) {
|
||||
schematic = args.getAs(Integer.class) - 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
baritone.getBuilderProcess().buildOpenLitematic(schematic);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logDirect("Pleas provide a valid index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Builds the loaded schematic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"Build a schematic currently open in Litematica.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> litematica",
|
||||
"> litematica <#>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -65,12 +65,14 @@ public class MineCommand extends Command {
|
||||
return Arrays.asList(
|
||||
"The mine command allows you to tell Baritone to search for and mine individual blocks.",
|
||||
"",
|
||||
"The specified blocks can be ores, or any other block.",
|
||||
"The specified blocks can be ores (which are commonly cached), or any other block.",
|
||||
"",
|
||||
"Also see the legitMine settings (see #set l legitMine).",
|
||||
"",
|
||||
"Usage:",
|
||||
"> mine diamond_ore - Mines all diamonds it can find."
|
||||
"> mine diamond_ore - Mines all diamonds it can find.",
|
||||
"> mine redstone_ore lit_redstone_ore - Mines redstone ore.",
|
||||
"> mine log:0 - Mines only oak logs."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,15 @@ import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -46,12 +52,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SelCommand extends Command {
|
||||
|
||||
private ISelectionManager manager = baritone.getSelectionManager();
|
||||
@@ -193,7 +193,7 @@ public class SelCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
ISchematic schematic = new StaticSchematic() {{
|
||||
ISchematic schematic = new StaticSchematic(){{
|
||||
states = blockstates;
|
||||
x = size.getX();
|
||||
y = size.getY();
|
||||
|
||||
@@ -81,9 +81,9 @@ public class SetCommand extends Command {
|
||||
" (%s)",
|
||||
settingTypeToString(setting)
|
||||
));
|
||||
typeComponent.setStyle(typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
|
||||
typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY);
|
||||
TextComponent hoverComponent = new TextComponent("");
|
||||
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
|
||||
hoverComponent.getStyle().withColor(ChatFormatting.GRAY);
|
||||
hoverComponent.append(setting.getName());
|
||||
hoverComponent.append(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
hoverComponent.append(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
@@ -146,8 +146,7 @@ public class SetCommand extends Command {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a toggleable setting", "some other setting");
|
||||
}
|
||||
//noinspection unchecked
|
||||
Settings.Setting<Boolean> asBoolSetting = (Settings.Setting<Boolean>) setting;
|
||||
asBoolSetting.value ^= true;
|
||||
((Settings.Setting<Boolean>) setting).value ^= true;
|
||||
logDirect(String.format(
|
||||
"Toggled setting %s to %s",
|
||||
setting.getName(),
|
||||
|
||||
@@ -20,8 +20,8 @@ package baritone.command.defaults;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.cache.IWorldData;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.ForWaypoints;
|
||||
@@ -50,7 +50,7 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class WaypointsCommand extends Command {
|
||||
|
||||
private Map<IWorldData, List<IWaypoint>> deletedWaypoints = new HashMap<>();
|
||||
private Map<IWorldData,List<IWaypoint>> deletedWaypoints = new HashMap<>();
|
||||
|
||||
public WaypointsCommand(IBaritone baritone) {
|
||||
super(baritone, "waypoints", "waypoint", "wp");
|
||||
@@ -155,8 +155,8 @@ public class WaypointsCommand extends Command {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
}
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
|
||||
BaseComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
TextComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
@@ -164,7 +164,7 @@ public class WaypointsCommand extends Command {
|
||||
label,
|
||||
Stream.of(waypoints).map(wp -> Long.toString(wp.getCreationTimestamp())).collect(Collectors.joining(" "))
|
||||
)
|
||||
)));
|
||||
));
|
||||
logDirect(textComponent);
|
||||
} else if (action == Action.RESTORE) {
|
||||
List<IWaypoint> waypoints = new ArrayList<>();
|
||||
@@ -259,7 +259,7 @@ public class WaypointsCommand extends Command {
|
||||
)
|
||||
)));
|
||||
BaseComponent recreateComponent = new TextComponent("Click to show a command to recreate this waypoint");
|
||||
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
String.format(
|
||||
"%s%s save %s %s %s %s %s",
|
||||
@@ -271,16 +271,16 @@ public class WaypointsCommand extends Command {
|
||||
waypoint.getLocation().y,
|
||||
waypoint.getLocation().z
|
||||
)
|
||||
)));
|
||||
));
|
||||
BaseComponent backComponent = new TextComponent("Click to return to the waypoints list");
|
||||
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s list",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label
|
||||
)
|
||||
)));
|
||||
));
|
||||
logDirect(deleteComponent);
|
||||
logDirect(goalComponent);
|
||||
logDirect(recreateComponent);
|
||||
@@ -289,7 +289,7 @@ public class WaypointsCommand extends Command {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
|
||||
TextComponent textComponent = new TextComponent("That waypoint has successfully been deleted, click to restore it");
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
@@ -297,7 +297,7 @@ public class WaypointsCommand extends Command {
|
||||
label,
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
)));
|
||||
));
|
||||
logDirect(textComponent);
|
||||
} else if (action == Action.GOAL) {
|
||||
Goal goal = new GoalBlock(waypoint.getLocation());
|
||||
|
||||
@@ -21,24 +21,19 @@ import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.cache.WorldData;
|
||||
import baritone.pathing.precompute.PrecomputedData;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
|
||||
/**
|
||||
@@ -60,13 +55,11 @@ public class CalculationContext {
|
||||
public final boolean canSprint;
|
||||
protected final double placeBlockCost; // protected because you should call the function instead
|
||||
public final boolean allowBreak;
|
||||
public final List<Block> allowBreakAnyway;
|
||||
public final boolean allowParkour;
|
||||
public final boolean allowParkourPlace;
|
||||
public final boolean allowJumpAt256;
|
||||
public final boolean allowParkourAscend;
|
||||
public final boolean assumeWalkOnWater;
|
||||
public final int frostWalker;
|
||||
public final boolean allowDiagonalDescend;
|
||||
public final boolean allowDiagonalAscend;
|
||||
public final boolean allowDownward;
|
||||
@@ -79,14 +72,11 @@ public class CalculationContext {
|
||||
public final double walkOnWaterOnePenalty;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
public final PrecomputedData precomputedData;
|
||||
|
||||
public CalculationContext(IBaritone baritone) {
|
||||
this(baritone, false);
|
||||
}
|
||||
|
||||
public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) {
|
||||
this.precomputedData = new PrecomputedData();
|
||||
this.safeForThreadedUse = forUseOnAnotherThread;
|
||||
this.baritone = baritone;
|
||||
LocalPlayer player = baritone.getPlayerContext().player();
|
||||
@@ -99,13 +89,11 @@ public class CalculationContext {
|
||||
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodData().getFoodLevel() > 6;
|
||||
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
|
||||
this.allowBreak = Baritone.settings().allowBreak.value;
|
||||
this.allowBreakAnyway = new ArrayList<>(Baritone.settings().allowBreakAnyway.value);
|
||||
this.allowParkour = Baritone.settings().allowParkour.value;
|
||||
this.allowParkourPlace = Baritone.settings().allowParkourPlace.value;
|
||||
this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value;
|
||||
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
||||
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
||||
this.frostWalker = EnchantmentHelper.getEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
|
||||
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
||||
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
||||
this.allowDownward = Baritone.settings().allowDownward.value;
|
||||
@@ -155,13 +143,14 @@ public class CalculationContext {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!worldBorder.canPlaceAt(x, z)) {
|
||||
// TODO perhaps MovementHelper.canPlaceAgainst could also use this?
|
||||
return COST_INF;
|
||||
}
|
||||
return placeBlockCost;
|
||||
}
|
||||
|
||||
public double breakCostMultiplierAt(int x, int y, int z, BlockState current) {
|
||||
if (!allowBreak && !allowBreakAnyway.contains(current.getBlock())) {
|
||||
if (!allowBreak) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (isPossiblyProtected(x, y, z)) {
|
||||
|
||||
@@ -26,35 +26,29 @@ import baritone.api.utils.*;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||
import baritone.pathing.precompute.Ternary;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.piston.MovingPistonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP;
|
||||
import static baritone.pathing.precompute.Ternary.*;
|
||||
|
||||
/**
|
||||
* Static helpers for cost calculation
|
||||
@@ -64,9 +58,6 @@ import static baritone.pathing.precompute.Ternary.*;
|
||||
public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, z)) {
|
||||
return true;
|
||||
}
|
||||
Block b = state.getBlock();
|
||||
return Baritone.settings().blocksToDisallowBreaking.value.contains(b)
|
||||
|| b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||
@@ -92,19 +83,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
&& FallingBlock.isFree(bsi.get0(x, y - 1, z))) { // and if it would fall (i.e. it's unsupported)
|
||||
return true; // dont break a block that is adjacent to unsupported gravel because it can cause really weird stuff
|
||||
}
|
||||
// only pure liquids for now
|
||||
// waterlogged blocks can have closed bottom sides and such
|
||||
if (block instanceof LiquidBlock) {
|
||||
if (directlyAbove || Baritone.settings().strictLiquidCheck.value) {
|
||||
return true;
|
||||
}
|
||||
int level = state.getValue(LiquidBlock.LEVEL);
|
||||
if (level == 0) {
|
||||
return true; // source blocks like to flow horizontally
|
||||
}
|
||||
// everything else will prefer flowing down
|
||||
return !(bsi.get0(x, y - 1, z).getBlock() instanceof LiquidBlock); // assume everything is in a static state
|
||||
}
|
||||
return !state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@@ -116,88 +94,32 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkThrough(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.canWalkThrough(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z) {
|
||||
return context.precomputedData.canWalkThrough(context.bsi, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Ternary canWalkThrough = canWalkThroughBlockState(state);
|
||||
if (canWalkThrough == YES) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) { // early return for most common case
|
||||
return true;
|
||||
}
|
||||
if (canWalkThrough == NO) {
|
||||
if (block instanceof BaseFireBlock || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK || block == Blocks.END_ROD || block == Blocks.POINTED_DRIPSTONE || block == Blocks.AMETHYST_CLUSTER || block instanceof AzaleaBlock) {
|
||||
return false;
|
||||
}
|
||||
return canWalkThroughPosition(bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static Ternary canWalkThroughBlockState(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof BaseFireBlock || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK || block == Blocks.END_ROD || block == Blocks.SWEET_BERRY_BUSH || block == Blocks.POINTED_DRIPSTONE || block instanceof AmethystClusterBlock || block instanceof AzaleaBlock) {
|
||||
return NO;
|
||||
}
|
||||
if (block == Blocks.BIG_DRIPLEAF) {
|
||||
return NO;
|
||||
}
|
||||
if (block == Blocks.POWDER_SNOW) {
|
||||
return NO;
|
||||
return false;
|
||||
}
|
||||
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||
return NO;
|
||||
return false;
|
||||
}
|
||||
if (block instanceof DoorBlock || block instanceof FenceGateBlock) {
|
||||
// TODO this assumes that all doors in all mods are openable
|
||||
if (block == Blocks.IRON_DOOR) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
// Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume
|
||||
// that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't
|
||||
// be opened by just interacting.
|
||||
return block != Blocks.IRON_DOOR;
|
||||
}
|
||||
if (block instanceof CarpetBlock) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (block instanceof SnowLayerBlock) {
|
||||
// snow layers cached as the top layer of a packed chunk have no metadata, we can't make a decision based on their depth here
|
||||
// it would otherwise make long distance pathing through snowy biomes impossible
|
||||
return MAYBE;
|
||||
}
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (!fluidState.isEmpty()) {
|
||||
if (fluidState.getType().getAmount(fluidState) != 8) {
|
||||
return NO;
|
||||
} else {
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
if (block instanceof CauldronBlock) {
|
||||
return NO;
|
||||
}
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean canWalkThroughPosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block instanceof CarpetBlock) {
|
||||
if (block instanceof WoolCarpetBlock) {
|
||||
return canWalkOn(bsi, x, y - 1, z);
|
||||
}
|
||||
|
||||
if (block instanceof SnowLayerBlock) {
|
||||
// we've already checked doors and fence gates
|
||||
// so the only remaining dynamic isPassables are snow and trapdoor
|
||||
// if they're cached as a top block, we don't know their metadata
|
||||
// default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
||||
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
||||
@@ -212,33 +134,52 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkOn(bsi, x, y - 1, z);
|
||||
}
|
||||
|
||||
if (isFlowing(x, y, z, state, bsi)) {
|
||||
return false; // Don't walk through flowing liquids
|
||||
}
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (!fluidState.isEmpty()) {
|
||||
if (isFlowing(x, y, z, state, bsi)) {
|
||||
return false;
|
||||
}
|
||||
// Everything after this point has to be a special case as it relies on the water not being flowing, which means a special case is needed.
|
||||
if (fluidState.getType() instanceof WaterFluid) {
|
||||
if (Baritone.settings().assumeWalkOnWater.value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState up = bsi.get0(x, y + 1, z);
|
||||
if (!up.getFluidState().isEmpty() || up.getBlock() instanceof WaterlilyBlock) {
|
||||
return false;
|
||||
}
|
||||
return fluidState.getType() instanceof WaterFluid;
|
||||
return true;
|
||||
}
|
||||
|
||||
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
||||
// 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
|
||||
return state.isPathfindable(bsi.access, BlockPos.ZERO, PathComputationType.LAND); // workaround for future compatibility =P
|
||||
}
|
||||
|
||||
static Ternary fullyPassableBlockState(BlockState state) {
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*
|
||||
* @param context Calculation context to provide block state lookup
|
||||
* @param x The block's x position
|
||||
* @param y The block's y position
|
||||
* @param z The block's z position
|
||||
* @return Whether or not the block at the specified position
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(
|
||||
context.bsi.access,
|
||||
context.bsi.isPassableBlockPos.set(x, y, z),
|
||||
context.bsi.get0(x, y, z)
|
||||
);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
return fullyPassable(ctx.world(), pos, ctx.world().getBlockState(pos));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(BlockGetter access, BlockPos pos, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock) { // early return for most common case
|
||||
return YES;
|
||||
return true;
|
||||
}
|
||||
// exceptions - blocks that are isPassable true, but we can't actually jump through
|
||||
if (block instanceof BaseFireBlock
|
||||
@@ -256,49 +197,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|| block instanceof EndPortalBlock
|
||||
|| block instanceof SkullBlock
|
||||
|| block instanceof ShulkerBoxBlock) {
|
||||
return NO;
|
||||
}
|
||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||
// at least in 1.12.2 vanilla, that is.....
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
// see PR #1087 for why
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* canWalkThrough but also won't impede movement at all. so not including doors or fence gates (we'd have to right click),
|
||||
* not including water, and not including ladders or vines or cobwebs (they slow us down)
|
||||
*/
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||
return fullyPassable(context, x, y, z, context.get(x, y, z));
|
||||
}
|
||||
|
||||
static boolean fullyPassable(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.fullyPassable(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean fullyPassable(IPlayerContext ctx, BlockPos pos) {
|
||||
BlockState state = ctx.world().getBlockState(pos);
|
||||
Ternary fullyPassable = fullyPassableBlockState(state);
|
||||
if (fullyPassable == YES) {
|
||||
return true;
|
||||
}
|
||||
if (fullyPassable == NO) {
|
||||
return false;
|
||||
}
|
||||
return fullyPassablePosition(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), state); // meh
|
||||
}
|
||||
|
||||
static boolean fullyPassablePosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
return state.isPathfindable(bsi.access, bsi.isPassableBlockPos.set(x, y, z), PathComputationType.LAND);
|
||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||
return state.isPathfindable(access, pos, PathComputationType.LAND);
|
||||
}
|
||||
|
||||
static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||
@@ -386,7 +288,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return !state.getFluidState().isEmpty()
|
||||
|| block == Blocks.MAGMA_BLOCK
|
||||
|| block == Blocks.CACTUS
|
||||
|| block == Blocks.SWEET_BERRY_BUSH
|
||||
|| block instanceof BaseFireBlock
|
||||
|| block == Blocks.END_PORTAL
|
||||
|| block == Blocks.COBWEB
|
||||
@@ -397,8 +298,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
* Can I walk on this block without anything weird happening like me falling
|
||||
* through? Includes water because we know that we automatically jump on
|
||||
* water
|
||||
* <p>
|
||||
* If changing something in this function remember to also change it in precomputed data
|
||||
*
|
||||
* @param bsi Block state provider
|
||||
* @param x The block's x position
|
||||
@@ -408,68 +307,36 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
* @return Whether or not the specified block can be walked on
|
||||
*/
|
||||
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Ternary canWalkOn = canWalkOnBlockState(state);
|
||||
if (canWalkOn == YES) {
|
||||
return true;
|
||||
}
|
||||
if (canWalkOn == NO) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN || block == Blocks.HONEY_BLOCK) {
|
||||
// early return for most common case (air)
|
||||
// plus magma, which is a normal cube but it hurts you
|
||||
return false;
|
||||
}
|
||||
return canWalkOnPosition(bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static Ternary canWalkOnBlockState(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (isBlockNormalCube(state) && block != Blocks.MAGMA_BLOCK && block != Blocks.BUBBLE_COLUMN && block != Blocks.HONEY_BLOCK) {
|
||||
return YES;
|
||||
if (isBlockNormalCube(state)) {
|
||||
return true;
|
||||
}
|
||||
if (block instanceof AzaleaBlock) {
|
||||
return YES;
|
||||
return true;
|
||||
}
|
||||
if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this
|
||||
return YES;
|
||||
return true;
|
||||
}
|
||||
if (block == Blocks.FARMLAND || block == Blocks.DIRT_PATH) {
|
||||
return YES;
|
||||
return true;
|
||||
}
|
||||
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
|
||||
return YES;
|
||||
return true;
|
||||
}
|
||||
if (block == Blocks.GLASS || block instanceof StainedGlassBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (block instanceof StairBlock) {
|
||||
return YES;
|
||||
}
|
||||
if (isWater(state)) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (MovementHelper.isLava(state) && Baritone.settings().assumeWalkOnLava.value) {
|
||||
return MAYBE;
|
||||
}
|
||||
if (block instanceof SlabBlock) {
|
||||
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
static boolean canWalkOnPosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (isWater(state)) {
|
||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||
BlockState upState = bsi.get0(x, y + 1, z);
|
||||
Block up = upState.getBlock();
|
||||
if (up == Blocks.LILY_PAD || up instanceof CarpetBlock) {
|
||||
if (up == Blocks.LILY_PAD || up instanceof WoolCarpetBlock) {
|
||||
return true;
|
||||
}
|
||||
if (MovementHelper.isFlowing(x, y, z, state, bsi) || upState.getFluidState().getType() == Fluids.FLOWING_WATER) {
|
||||
if (isFlowing(x, y, z, state, bsi) || upState.getFluidState().getType() == Fluids.FLOWING_WATER) {
|
||||
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
||||
return isWater(upState) && !Baritone.settings().assumeWalkOnWater.value;
|
||||
}
|
||||
@@ -477,20 +344,19 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
||||
return isWater(upState) ^ Baritone.settings().assumeWalkOnWater.value;
|
||||
}
|
||||
|
||||
if (MovementHelper.isLava(state) && !MovementHelper.isFlowing(x, y, z, state, bsi) && Baritone.settings().assumeWalkOnLava.value) { // if we get here it means that assumeWalkOnLava must be true, so put it last
|
||||
if (Baritone.settings().assumeWalkOnLava.value && isLava(state) && !isFlowing(x, y, z, state, bsi)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // If we don't recognise it then we want to just return false to be safe.
|
||||
}
|
||||
|
||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
return context.precomputedData.canWalkOn(context.bsi, x, y, z, state);
|
||||
}
|
||||
|
||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z) {
|
||||
return canWalkOn(context, x, y, z, context.get(x, y, z));
|
||||
if (block == Blocks.GLASS || block instanceof StainedGlassBlock) {
|
||||
return true;
|
||||
}
|
||||
if (block instanceof SlabBlock) {
|
||||
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
||||
return state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return block instanceof StairBlock;
|
||||
}
|
||||
|
||||
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, BlockState state) {
|
||||
@@ -509,60 +375,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return canWalkOn(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
|
||||
return context.frostWalker != 0
|
||||
&& state.getMaterial() == Material.WATER
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
return EnchantmentHelper.hasFrostWalker(ctx.player())
|
||||
&& state.getMaterial() == Material.WATER
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If movements make us stand/walk on this block, will it have a top to walk on?
|
||||
*/
|
||||
static boolean mustBeSolidToWalkOn(CalculationContext context, int x, int y, int z, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
||||
return false;
|
||||
}
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
// used for frostwalker so only includes blocks where we are still on ground when leaving them to any side
|
||||
// TODO 1.19+ : add leaves, add dripleaf?
|
||||
if (block instanceof SlabBlock) {
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.BOTTOM) {
|
||||
return true;
|
||||
}
|
||||
} else if (block instanceof StairBlock) {
|
||||
if (state.getValue(StairBlock.HALF) == Half.TOP) {
|
||||
return true;
|
||||
}
|
||||
StairsShape shape = state.getValue(StairBlock.SHAPE);
|
||||
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT) {
|
||||
return true;
|
||||
}
|
||||
} else if (block instanceof TrapDoorBlock) {
|
||||
if (!state.getValue(TrapDoorBlock.OPEN) && state.getValue(TrapDoorBlock.HALF) == Half.TOP) {
|
||||
return true;
|
||||
}
|
||||
} else if (block == Blocks.SCAFFOLDING) {
|
||||
return true;
|
||||
}
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false;
|
||||
}
|
||||
Block blockAbove = context.getBlock(x, y + 1, z);
|
||||
if (blockAbove instanceof LiquidBlock) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
||||
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
@@ -576,9 +388,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, z)) {
|
||||
return false;
|
||||
}
|
||||
// can we look at the center of a side face of this block and likely be able to place?
|
||||
// (thats how this check is used)
|
||||
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
||||
@@ -591,7 +400,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, BlockState state, boolean includeFalling) {
|
||||
Block block = state.getBlock();
|
||||
if (!canWalkThrough(context, x, y, z, state)) {
|
||||
if (!canWalkThrough(context.bsi, x, y, z, state)) {
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
return COST_INF;
|
||||
}
|
||||
@@ -800,7 +609,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean isTransparent(Block b) {
|
||||
|
||||
return b instanceof AirBlock ||
|
||||
return b == Blocks.AIR ||
|
||||
b == Blocks.LAVA ||
|
||||
b == Blocks.WATER;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MovementAscend extends Movement {
|
||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||
BlockState toPlace = context.get(destX, y, destZ);
|
||||
double additionalPlacementCost = 0;
|
||||
if (!MovementHelper.canWalkOn(context, destX, y, destZ, toPlace)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
||||
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ, toPlace);
|
||||
if (additionalPlacementCost >= COST_INF) {
|
||||
return COST_INF;
|
||||
@@ -93,7 +93,7 @@ public class MovementAscend extends Movement {
|
||||
}
|
||||
}
|
||||
BlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway
|
||||
if (context.get(x, y + 3, z).getBlock() instanceof FallingBlock && (MovementHelper.canWalkThrough(context, x, y + 1, z) || !(srcUp2.getBlock() instanceof FallingBlock))) {//it would fall on us and possibly suffocate us
|
||||
if (context.get(x, y + 3, z).getBlock() instanceof FallingBlock && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof FallingBlock))) {//it would fall on us and possibly suffocate us
|
||||
// HOWEVER, we assume that we're standing in the start position
|
||||
// that means that src and src.up(1) are both air
|
||||
// maybe they aren't now, but they will be by the time this starts
|
||||
|
||||
@@ -42,7 +42,6 @@ import net.minecraft.world.phys.Vec3;
|
||||
public class MovementDescend extends Movement {
|
||||
|
||||
private int numTicks = 0;
|
||||
public boolean forceSafeMode = false;
|
||||
|
||||
public MovementDescend(IBaritone baritone, BetterBlockPos start, BetterBlockPos end) {
|
||||
super(baritone, start, end, new BetterBlockPos[]{end.above(2), end.above(), end}, end.below());
|
||||
@@ -52,14 +51,6 @@ public class MovementDescend extends Movement {
|
||||
public void reset() {
|
||||
super.reset();
|
||||
numTicks = 0;
|
||||
forceSafeMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by PathExecutor if needing safeMode can only be detected with knowledge about the next movement
|
||||
*/
|
||||
public void forceSafeMode() {
|
||||
forceSafeMode = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +100,7 @@ public class MovementDescend extends Movement {
|
||||
//C, D, etc determine the length of the fall
|
||||
|
||||
BlockState below = context.get(destX, y - 2, destZ);
|
||||
if (!MovementHelper.canWalkOn(context, destX, y - 2, destZ, below)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ, below)) {
|
||||
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
||||
return;
|
||||
}
|
||||
@@ -117,9 +108,6 @@ public class MovementDescend extends Movement {
|
||||
if (destDown.getBlock() == Blocks.LADDER || destDown.getBlock() == Blocks.VINE) {
|
||||
return;
|
||||
}
|
||||
if (MovementHelper.canUseFrostWalker(context, destDown)) { // no need to check assumeWalkOnWater
|
||||
return; // the water will freeze when we try to walk into it
|
||||
}
|
||||
|
||||
// we walk half the block plus 0.3 to get to the edge, then we walk the other 0.2 while simultaneously falling (math.max because of how it's in parallel)
|
||||
double walk = WALK_OFF_BLOCK_COST;
|
||||
@@ -141,7 +129,7 @@ public class MovementDescend extends Movement {
|
||||
// and potentially replace the water we're going to fall into
|
||||
return false;
|
||||
}
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y - 2, destZ, below)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y - 2, destZ, below)) {
|
||||
return false;
|
||||
}
|
||||
double costSoFar = 0;
|
||||
@@ -157,7 +145,7 @@ public class MovementDescend extends Movement {
|
||||
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
||||
if (MovementHelper.isWater(ontoBlock)) {
|
||||
if (!MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
return false;
|
||||
}
|
||||
if (context.assumeWalkOnWater) {
|
||||
@@ -166,7 +154,7 @@ public class MovementDescend extends Movement {
|
||||
if (MovementHelper.isFlowing(destX, newY, destZ, ontoBlock, context.bsi)) {
|
||||
return false; // TODO flowing check required here?
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context, destX, newY - 1, destZ)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY - 1, destZ)) {
|
||||
// we could punch right through the water into something else
|
||||
return false;
|
||||
}
|
||||
@@ -185,10 +173,10 @@ public class MovementDescend extends Movement {
|
||||
effectiveStartHeight = newY;
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
||||
if (MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context, destX, newY, destZ, ontoBlock)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
return false;
|
||||
}
|
||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||
@@ -259,9 +247,6 @@ public class MovementDescend extends Movement {
|
||||
}
|
||||
|
||||
public boolean safeMode() {
|
||||
if (forceSafeMode) {
|
||||
return true;
|
||||
}
|
||||
// (dest - src) + dest is offset 1 more in the same direction
|
||||
// so it's the block we'd need to worry about running into if we decide to sprint straight through this descend
|
||||
BlockPos into = dest.subtract(src.below()).offset(dest);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MovementDiagonal extends Movement {
|
||||
@Override
|
||||
protected boolean safeToCancel(MovementState state) {
|
||||
//too simple. backfill does not work after cornering with this
|
||||
//return context.precomputedData.canWalkOn(ctx, ctx.playerFeet().down());
|
||||
//return MovementHelper.canWalkOn(ctx, ctx.playerFeet().down());
|
||||
LocalPlayer player = ctx.player();
|
||||
double offset = 0.25;
|
||||
double x = player.position().x;
|
||||
@@ -109,49 +109,40 @@ public class MovementDiagonal extends Movement {
|
||||
}
|
||||
|
||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y + 1, destZ)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
||||
return;
|
||||
}
|
||||
BlockState destInto = context.get(destX, y, destZ);
|
||||
BlockState fromDown;
|
||||
boolean ascend = false;
|
||||
BlockState destWalkOn;
|
||||
boolean descend = false;
|
||||
boolean frostWalker = false;
|
||||
if (!MovementHelper.canWalkThrough(context, destX, y, destZ, destInto)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto)) {
|
||||
ascend = true;
|
||||
if (!context.allowDiagonalAscend || !MovementHelper.canWalkThrough(context, x, y + 2, z) || !MovementHelper.canWalkOn(context, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context, destX, y + 2, destZ)) {
|
||||
if (!context.allowDiagonalAscend || !MovementHelper.canWalkThrough(context.bsi, x, y + 2, z) || !MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 2, destZ)) {
|
||||
return;
|
||||
}
|
||||
destWalkOn = destInto;
|
||||
fromDown = context.get(x, y - 1, z);
|
||||
} else {
|
||||
destWalkOn = context.get(destX, y - 1, destZ);
|
||||
fromDown = context.get(x, y - 1, z);
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, fromDown);
|
||||
frostWalker = standingOnABlock && MovementHelper.canUseFrostWalker(context, destWalkOn);
|
||||
if (!frostWalker && !MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
descend = true;
|
||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context, destX, y - 1, destZ, destWalkOn)) {
|
||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
frostWalker &= !context.assumeWalkOnWater; // do this after checking for descends because jesus can't prevent the water from freezing, it just prevents us from relying on the water freezing
|
||||
}
|
||||
double multiplier = WALK_ONE_BLOCK_COST;
|
||||
// For either possible soul sand, that affects half of our walking
|
||||
if (destWalkOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (frostWalker) {
|
||||
// frostwalker lets us walk on water without the penalty
|
||||
} else if (destWalkOn.getBlock() == Blocks.WATER) {
|
||||
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
|
||||
}
|
||||
Block fromDownBlock = fromDown.getBlock();
|
||||
if (fromDownBlock == Blocks.LADDER || fromDownBlock == Blocks.VINE) {
|
||||
Block fromDown = context.get(x, y - 1, z).getBlock();
|
||||
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
||||
return;
|
||||
}
|
||||
if (fromDownBlock == Blocks.SOUL_SAND) {
|
||||
if (fromDown == Blocks.SOUL_SAND) {
|
||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
}
|
||||
BlockState cuttingOver1 = context.get(x, y - 1, destZ);
|
||||
@@ -178,17 +169,17 @@ public class MovementDiagonal extends Movement {
|
||||
BlockState pb0 = context.get(x, y, destZ);
|
||||
BlockState pb2 = context.get(destX, y, z);
|
||||
if (ascend) {
|
||||
boolean ATop = MovementHelper.canWalkThrough(context, x, y + 2, destZ);
|
||||
boolean AMid = MovementHelper.canWalkThrough(context, x, y + 1, destZ);
|
||||
boolean ALow = MovementHelper.canWalkThrough(context, x, y, destZ, pb0);
|
||||
boolean BTop = MovementHelper.canWalkThrough(context, destX, y + 2, z);
|
||||
boolean BMid = MovementHelper.canWalkThrough(context, destX, y + 1, z);
|
||||
boolean BLow = MovementHelper.canWalkThrough(context, destX, y, z, pb2);
|
||||
boolean ATop = MovementHelper.canWalkThrough(context.bsi, x, y + 2, destZ);
|
||||
boolean AMid = MovementHelper.canWalkThrough(context.bsi, x, y + 1, destZ);
|
||||
boolean ALow = MovementHelper.canWalkThrough(context.bsi, x, y, destZ, pb0);
|
||||
boolean BTop = MovementHelper.canWalkThrough(context.bsi, destX, y + 2, z);
|
||||
boolean BMid = MovementHelper.canWalkThrough(context.bsi, destX, y + 1, z);
|
||||
boolean BLow = MovementHelper.canWalkThrough(context.bsi, destX, y, z, pb2);
|
||||
if ((!(ATop && AMid && ALow) && !(BTop && BMid && BLow)) // no option
|
||||
|| MovementHelper.avoidWalkingInto(pb0) // bad
|
||||
|| MovementHelper.avoidWalkingInto(pb2) // bad
|
||||
|| (ATop && AMid && MovementHelper.canWalkOn(context, x, y, destZ, pb0)) // we could just ascend
|
||||
|| (BTop && BMid && MovementHelper.canWalkOn(context, destX, y, z, pb2)) // we could just ascend
|
||||
|| (ATop && AMid && MovementHelper.canWalkOn(context.bsi, x, y, destZ, pb0)) // we could just ascend
|
||||
|| (BTop && BMid && MovementHelper.canWalkOn(context.bsi, destX, y, z, pb2)) // we could just ascend
|
||||
|| (!ATop && AMid && ALow) // head bonk A
|
||||
|| (!BTop && BMid && BLow)) { // head bonk B
|
||||
return;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MovementDownward extends Movement {
|
||||
if (!context.allowDownward) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context, x, y - 2, z)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, x, y - 2, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
BlockState down = context.get(x, y - 1, z);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.pathing.movement.movements;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.movement.MovementStatus;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
@@ -28,16 +27,16 @@ import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.movement.MovementState;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.pathing.MutableMoveResult;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementParkour extends Movement {
|
||||
|
||||
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
||||
@@ -75,7 +74,7 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
BlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
||||
if (MovementHelper.canWalkOn(context, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||
if (MovementHelper.canWalkOn(context.bsi, x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||
// second most common case -- we could just traverse not parkour
|
||||
return;
|
||||
}
|
||||
@@ -92,16 +91,9 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
BlockState standingOn = context.get(x, y - 1, z);
|
||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof StairBlock || MovementHelper.isBottomSlab(standingOn)) {
|
||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof StairBlock || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getType() != Fluids.EMPTY) {
|
||||
return;
|
||||
}
|
||||
// we can't jump from (frozen) water with assumeWalkOnWater because we can't be sure it will be frozen
|
||||
if (context.assumeWalkOnWater && !standingOn.getFluidState().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!context.get(x, y, z).getFluidState().isEmpty()) {
|
||||
return; // can't jump out of water
|
||||
}
|
||||
int maxJump;
|
||||
if (standingOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
maxJump = 2; // 1 block gap
|
||||
@@ -112,13 +104,13 @@ public class MovementParkour extends Movement {
|
||||
maxJump = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check parkour jumps from smallest to largest for obstacles/walls and landing positions
|
||||
int verifiedMaxJump = 1; // i - 1 (when i = 2)
|
||||
for (int i = 2; i <= maxJump; i++) {
|
||||
int destX = x + xDiff * i;
|
||||
int destZ = z + zDiff * i;
|
||||
|
||||
|
||||
// check head/feet
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) {
|
||||
break;
|
||||
@@ -126,11 +118,11 @@ public class MovementParkour extends Movement {
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for ascend landing position
|
||||
BlockState destInto = context.bsi.get0(destX, y, destZ);
|
||||
if (!MovementHelper.fullyPassable(context, destX, y, destZ, destInto)) {
|
||||
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
|
||||
if (!MovementHelper.fullyPassable(context.bsi.access, context.bsi.isPassableBlockPos.set(destX, y, destZ), destInto)) {
|
||||
if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) {
|
||||
res.x = destX;
|
||||
res.y = y + 1;
|
||||
res.z = destZ;
|
||||
@@ -139,14 +131,11 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// check for flat landing position
|
||||
BlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
|
||||
// farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
|
||||
// frostwalker works here because we can't jump from possibly unfrozen water
|
||||
if ((landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context, destX, y - 1, destZ, landingOn))
|
||||
|| (Math.min(16, context.frostWalker + 2) >= i && MovementHelper.canUseFrostWalker(context, landingOn))
|
||||
) {
|
||||
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) {
|
||||
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
|
||||
res.x = destX;
|
||||
res.y = y;
|
||||
@@ -156,14 +145,14 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
verifiedMaxJump = i;
|
||||
}
|
||||
|
||||
|
||||
// parkour place starts here
|
||||
if (!context.allowParkourPlace) {
|
||||
return;
|
||||
@@ -276,12 +265,7 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
} else if (!ctx.playerFeet().equals(src)) {
|
||||
if (ctx.playerFeet().equals(src.relative(direction)) || ctx.player().position().y - src.y > 0.0001) {
|
||||
if (Baritone.settings().allowPlace.value // see PR #3775
|
||||
&& ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway()
|
||||
&& !MovementHelper.canWalkOn(ctx, dest.below())
|
||||
&& !ctx.player().isOnGround()
|
||||
&& MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), true, false) == PlaceResult.READY_TO_PLACE
|
||||
) {
|
||||
if (!MovementHelper.canWalkOn(ctx, dest.below()) && !ctx.player().isOnGround() && MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), true, false) == PlaceResult.READY_TO_PLACE) {
|
||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||
state.setInput(Input.CLICK_RIGHT, true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CarpetBlock;
|
||||
import net.minecraft.world.level.block.FallingBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.LadderBlock;
|
||||
@@ -43,7 +42,6 @@ import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementPillar extends Movement {
|
||||
@@ -107,10 +105,6 @@ public class MovementPillar extends Movement {
|
||||
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
|
||||
return COST_INF;
|
||||
}
|
||||
if ((from == Blocks.LILY_PAD || from instanceof CarpetBlock) && !fromDown.getFluidState().isEmpty()) {
|
||||
// to ascend here we'd have to break the block we are standing on
|
||||
return COST_INF;
|
||||
}
|
||||
double hardness = MovementHelper.getMiningDurationTicks(context, x, y + 2, z, toBreak, true);
|
||||
if (hardness >= COST_INF) {
|
||||
return COST_INF;
|
||||
@@ -130,7 +124,7 @@ public class MovementPillar extends Movement {
|
||||
}
|
||||
}
|
||||
// this is commented because it may have had a purpose, but it's very unclear what it was. it's from the minebot era.
|
||||
//if (!MovementHelper.canWalkOn(context, chkPos, check) || MovementHelper.canWalkThrough(context, chkPos, check)) {//if the block above where we want to break is not a full block, don't do it
|
||||
//if (!MovementHelper.canWalkOn(chkPos, check) || MovementHelper.canWalkThrough(chkPos, check)) {//if the block above where we want to break is not a full block, don't do it
|
||||
// TODO why does canWalkThrough mean this action is COST_INF?
|
||||
// FallingBlock makes sense, and !canWalkOn deals with weird cases like if it were lava
|
||||
// but I don't understand why canWalkThrough makes it impossible
|
||||
|
||||
@@ -35,15 +35,14 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CarpetBlock;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.LadderBlock;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -78,11 +77,9 @@ public class MovementTraverse extends Movement {
|
||||
BlockState pb0 = context.get(destX, y + 1, destZ);
|
||||
BlockState pb1 = context.get(destX, y, destZ);
|
||||
BlockState destOn = context.get(destX, y - 1, destZ);
|
||||
BlockState srcDown = context.get(x, y - 1, z);
|
||||
Block srcDownBlock = srcDown.getBlock();
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, srcDown);
|
||||
boolean frostWalker = standingOnABlock && !context.assumeWalkOnWater && MovementHelper.canUseFrostWalker(context, destOn);
|
||||
if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge
|
||||
BlockState down = context.get(x, y - 1, z);
|
||||
Block srcDown = down.getBlock();
|
||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||
double WC = WALK_ONE_BLOCK_COST;
|
||||
boolean water = false;
|
||||
if (MovementHelper.isWater(pb0) || MovementHelper.isWater(pb1)) {
|
||||
@@ -91,12 +88,10 @@ public class MovementTraverse extends Movement {
|
||||
} else {
|
||||
if (destOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (frostWalker) {
|
||||
// with frostwalker we can walk on water without the penalty, if we are sure we won't be using jesus
|
||||
} else if (destOn.getBlock() == Blocks.WATER) {
|
||||
WC += context.walkOnWaterOnePenalty;
|
||||
}
|
||||
if (srcDownBlock == Blocks.SOUL_SAND) {
|
||||
if (srcDown == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
}
|
||||
}
|
||||
@@ -114,13 +109,13 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
return WC;
|
||||
}
|
||||
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
|
||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||
hardness1 *= 5;
|
||||
hardness2 *= 5;
|
||||
}
|
||||
return WC + hardness1 + hardness2;
|
||||
} else {//this is a bridge, so we need to place a block
|
||||
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
|
||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (MovementHelper.isReplaceable(destX, y - 1, destZ, destOn, context.bsi)) {
|
||||
@@ -151,16 +146,12 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
}
|
||||
// now that we've checked all possible directions to side place, we actually need to backplace
|
||||
if (srcDownBlock == Blocks.SOUL_SAND || (srcDownBlock instanceof SlabBlock && srcDown.getValue(SlabBlock.TYPE) != SlabType.DOUBLE)) {
|
||||
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof SlabBlock && down.getValue(SlabBlock.TYPE) != SlabType.DOUBLE)) {
|
||||
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
|
||||
}
|
||||
if (!standingOnABlock) { // standing on water / swimming
|
||||
if (down.getFluidState().getType() instanceof WaterFluid) {
|
||||
return COST_INF; // this is obviously impossible
|
||||
}
|
||||
Block blockSrc = context.getBlock(x, y, z);
|
||||
if ((blockSrc == Blocks.LILY_PAD || blockSrc instanceof CarpetBlock) && !srcDown.getFluidState().isEmpty()) {
|
||||
return COST_INF; // we can stand on these but can't place against them
|
||||
}
|
||||
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol
|
||||
return WC + placeCost + hardness1 + hardness2;
|
||||
}
|
||||
@@ -241,7 +232,7 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder || MovementHelper.canUseFrostWalker(ctx, positionToPlace);
|
||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
||||
BlockPos feet = ctx.playerFeet();
|
||||
if (feet.getY() != dest.getY() && !ladder) {
|
||||
logDebug("Wrong Y coordinate");
|
||||
|
||||
@@ -71,8 +71,8 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
private HashSet<BlockPos> toPlace = new HashSet<>();
|
||||
private HashSet<BlockPos> toWalkInto = new HashSet<>();
|
||||
|
||||
private final PathingBehavior behavior;
|
||||
private final IPlayerContext ctx;
|
||||
private PathingBehavior behavior;
|
||||
private IPlayerContext ctx;
|
||||
|
||||
private boolean sprintNextTick;
|
||||
|
||||
@@ -348,7 +348,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||
|
||||
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint
|
||||
if (!new CalculationContext(behavior.baritone, false).canSprint) {
|
||||
if (!new CalculationContext(behavior.baritone).canSprint) {
|
||||
return false;
|
||||
}
|
||||
IMovement current = path.movements().get(pathPosition);
|
||||
@@ -378,26 +378,6 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
// however, descend and ascend don't request sprinting, because they don't know the context of what movement comes after it
|
||||
if (current instanceof MovementDescend) {
|
||||
|
||||
if (pathPosition < path.length() - 2) {
|
||||
// keep this out of onTick, even if that means a tick of delay before it has an effect
|
||||
IMovement next = path.movements().get(pathPosition + 1);
|
||||
if (MovementHelper.canUseFrostWalker(ctx, next.getDest().below())) {
|
||||
// frostwalker only works if you cross the edge of the block on ground so in some cases we may not overshoot
|
||||
// Since MovementDescend can't know the next movement we have to tell it
|
||||
if (next instanceof MovementTraverse || next instanceof MovementParkour) {
|
||||
boolean couldPlaceInstead = Baritone.settings().allowPlace.value && behavior.baritone.getInventoryBehavior().hasGenericThrowaway() && next instanceof MovementParkour; // traverse doesn't react fast enough
|
||||
// this is true if the next movement does not ascend or descends and goes into the same cardinal direction (N-NE-E-SE-S-SW-W-NW) as the descend
|
||||
// in that case current.getDirection() is e.g. (0, -1, 1) and next.getDirection() is e.g. (0, 0, 3) so the cross product of (0, 0, 1) and (0, 0, 3) is taken, which is (0, 0, 0) because the vectors are colinear (don't form a plane)
|
||||
// since movements in exactly the opposite direction (e.g. descend (0, -1, 1) and traverse (0, 0, -1)) would also pass this check we also have to rule out that case
|
||||
// we can do that by adding the directions because traverse is always 1 long like descend and parkour can't jump through current.getSrc().down()
|
||||
boolean sameFlatDirection = !current.getDirection().above().offset(next.getDirection()).equals(BlockPos.ZERO)
|
||||
&& current.getDirection().above().cross(next.getDirection()).equals(BlockPos.ZERO); // here's why you learn maths in school
|
||||
if (sameFlatDirection && !couldPlaceInstead) {
|
||||
((MovementDescend) current).forceSafeMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((MovementDescend) current).safeMode() && !((MovementDescend) current).skipToAscend()) {
|
||||
logDebug("Sprinting would be unsafe");
|
||||
return false;
|
||||
@@ -415,20 +395,11 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
return true;
|
||||
}
|
||||
if (canSprintFromDescendInto(ctx, current, next)) {
|
||||
|
||||
if (next instanceof MovementDescend && pathPosition < path.length() - 3) {
|
||||
IMovement next_next = path.movements().get(pathPosition + 2);
|
||||
if (next_next instanceof MovementDescend && !canSprintFromDescendInto(ctx, next, next_next)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if (ctx.playerFeet().equals(current.getDest())) {
|
||||
pathPosition++;
|
||||
onChangeInPathPosition();
|
||||
onTick();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
||||
|
||||
@@ -1,117 +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.pathing.precompute;
|
||||
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import static baritone.pathing.precompute.Ternary.MAYBE;
|
||||
import static baritone.pathing.precompute.Ternary.YES;
|
||||
|
||||
public class PrecomputedData {
|
||||
|
||||
private final int[] data = new int[Block.BLOCK_STATE_REGISTRY.size()];
|
||||
|
||||
private static final int COMPLETED_MASK = 1 << 0;
|
||||
private static final int CAN_WALK_ON_MASK = 1 << 1;
|
||||
private static final int CAN_WALK_ON_SPECIAL_MASK = 1 << 2;
|
||||
private static final int CAN_WALK_THROUGH_MASK = 1 << 3;
|
||||
private static final int CAN_WALK_THROUGH_SPECIAL_MASK = 1 << 4;
|
||||
private static final int FULLY_PASSABLE_MASK = 1 << 5;
|
||||
private static final int FULLY_PASSABLE_SPECIAL_MASK = 1 << 6;
|
||||
|
||||
private int fillData(int id, BlockState state) {
|
||||
int blockData = 0;
|
||||
|
||||
Ternary canWalkOnState = MovementHelper.canWalkOnBlockState(state);
|
||||
if (canWalkOnState == YES) {
|
||||
blockData |= CAN_WALK_ON_MASK;
|
||||
}
|
||||
if (canWalkOnState == MAYBE) {
|
||||
blockData |= CAN_WALK_ON_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary canWalkThroughState = MovementHelper.canWalkThroughBlockState(state);
|
||||
if (canWalkThroughState == YES) {
|
||||
blockData |= CAN_WALK_THROUGH_MASK;
|
||||
}
|
||||
if (canWalkThroughState == MAYBE) {
|
||||
blockData |= CAN_WALK_THROUGH_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary fullyPassableState = MovementHelper.fullyPassableBlockState(state);
|
||||
if (fullyPassableState == YES) {
|
||||
blockData |= FULLY_PASSABLE_MASK;
|
||||
}
|
||||
if (fullyPassableState == MAYBE) {
|
||||
blockData |= FULLY_PASSABLE_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
blockData |= COMPLETED_MASK;
|
||||
|
||||
data[id] = blockData; // in theory, this is thread "safe" because every thread should compute the exact same int to write?
|
||||
return blockData;
|
||||
}
|
||||
|
||||
public boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & CAN_WALK_ON_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkOnPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & CAN_WALK_ON_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & CAN_WALK_THROUGH_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkThroughPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & CAN_WALK_THROUGH_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean fullyPassable(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
int id = Block.BLOCK_STATE_REGISTRY.getId(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & FULLY_PASSABLE_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.fullyPassablePosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & FULLY_PASSABLE_MASK) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +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.pathing.precompute;
|
||||
|
||||
public enum Ternary {
|
||||
YES, MAYBE, NO
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||
Baritone.settings().backfill.value = false;
|
||||
return false;
|
||||
}
|
||||
amIBreakingABlockHMMMMMMM();
|
||||
for (BlockPos pos : new ArrayList<>(blocksToReplace.keySet())) {
|
||||
if (ctx.world().getChunk(pos) instanceof EmptyLevelChunk || ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||
if (ctx.world().getChunk(pos) instanceof EmptyLevelChunk) {
|
||||
blocksToReplace.remove(pos);
|
||||
}
|
||||
}
|
||||
amIBreakingABlockHMMMMMMM();
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
|
||||
return !toFillIn().isEmpty();
|
||||
@@ -91,7 +91,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
|
||||
}
|
||||
|
||||
private void amIBreakingABlockHMMMMMMM() {
|
||||
if (!ctx.getSelectedBlock().isPresent() || !baritone.getPathingBehavior().isPathing()) {
|
||||
if (!ctx.getSelectedBlock().isPresent()) {
|
||||
return;
|
||||
}
|
||||
blocksToReplace.put(ctx.getSelectedBlock().get(), ctx.world().getBlockState(ctx.getSelectedBlock().get()));
|
||||
|
||||
@@ -26,9 +26,9 @@ import baritone.api.process.IBuilderProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.schematic.FillSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.RayTraceUtils;
|
||||
@@ -44,8 +44,6 @@ import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.schematic.MapArtSchematic;
|
||||
import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import baritone.utils.schematic.litematica.LitematicaHelper;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -53,7 +51,6 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
@@ -68,13 +65,10 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
|
||||
@@ -91,7 +85,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
private int layer;
|
||||
private int numRepeats;
|
||||
private List<BlockState> approxPlaceable;
|
||||
public int stopAtHeight = 0;
|
||||
|
||||
public BuilderProcess(Baritone baritone) {
|
||||
super(baritone);
|
||||
@@ -102,7 +95,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.name = name;
|
||||
this.schematic = schematic;
|
||||
this.realSchematic = null;
|
||||
boolean buildingSelectionSchematic = schematic instanceof SelectionSchematic;
|
||||
if (!Baritone.settings().buildSubstitutes.value.isEmpty()) {
|
||||
this.schematic = new SubstituteSchematic(this.schematic, Baritone.settings().buildSubstitutes.value);
|
||||
}
|
||||
@@ -121,28 +113,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.origin = new Vec3i(x, y, z);
|
||||
this.paused = false;
|
||||
this.layer = Baritone.settings().startAtLayer.value;
|
||||
this.stopAtHeight = schematic.heightY();
|
||||
if (Baritone.settings().buildOnlySelection.value && buildingSelectionSchematic) { // currently redundant but safer maybe
|
||||
if (baritone.getSelectionManager().getSelections().length == 0) {
|
||||
logDirect("Poor little kitten forgot to set a selection while BuildOnlySelection is true");
|
||||
this.stopAtHeight = 0;
|
||||
} else if (Baritone.settings().buildInLayers.value) {
|
||||
OptionalInt minim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.min().y).min();
|
||||
OptionalInt maxim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.max().y).max();
|
||||
if (minim.isPresent() && maxim.isPresent()) {
|
||||
int startAtHeight = Baritone.settings().layerOrder.value ? y + schematic.heightY() - maxim.getAsInt() : minim.getAsInt() - y;
|
||||
this.stopAtHeight = (Baritone.settings().layerOrder.value ? y + schematic.heightY() - minim.getAsInt() : maxim.getAsInt() - y) + 1;
|
||||
this.layer = Math.max(this.layer, startAtHeight / Baritone.settings().layerHeight.value); // startAtLayer or startAtHeight, whichever is highest
|
||||
logDebug(String.format("Schematic starts at y=%s with height %s", y, schematic.heightY()));
|
||||
logDebug(String.format("Selection starts at y=%s and ends at y=%s", minim.getAsInt(), maxim.getAsInt()));
|
||||
logDebug(String.format("Considering relevant height %s - %s", startAtHeight, this.stopAtHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.numRepeats = 0;
|
||||
this.observedCompleted = new LongOpenHashSet();
|
||||
this.incorrectPositions = null;
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
@@ -210,28 +182,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpenLitematic(int i) {
|
||||
if (LitematicaHelper.isLitematicaPresent()) {
|
||||
//if java.lang.NoSuchMethodError is thrown see comment in SchematicPlacementManager
|
||||
if (LitematicaHelper.hasLoadedSchematic()) {
|
||||
String name = LitematicaHelper.getName(i);
|
||||
try {
|
||||
LitematicaSchematic schematic1 = new LitematicaSchematic(NbtIo.readCompressed(Files.newInputStream(LitematicaHelper.getSchematicFile(i).toPath())), false);
|
||||
Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic1, i);
|
||||
LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i);
|
||||
build(name, schematic2, correctedOrigin);
|
||||
} catch (Exception e) {
|
||||
logDirect("Schematic File could not be loaded.");
|
||||
}
|
||||
} else {
|
||||
logDirect("No schematic currently loaded");
|
||||
}
|
||||
} else {
|
||||
logDirect("Litematica is not present");
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1;
|
||||
@@ -495,7 +445,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
BuilderCalculationContext bcc = new BuilderCalculationContext();
|
||||
if (!recalc(bcc)) {
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < stopAtHeight) {
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) {
|
||||
logDirect("Starting layer " + layer);
|
||||
layer++;
|
||||
return onTick(calcFailed, isSafeToCancel, recursions + 1);
|
||||
@@ -674,7 +624,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
// this is not in render distance
|
||||
if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))
|
||||
&& !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) {
|
||||
&& !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) {
|
||||
// and we've never seen this position be correct
|
||||
// therefore mark as incorrect
|
||||
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
||||
@@ -897,18 +847,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue;
|
||||
}
|
||||
// <toxic cloud>
|
||||
BlockState itemState = ((BlockItem) stack.getItem())
|
||||
.getBlock()
|
||||
.getStateForPlacement(
|
||||
new BlockPlaceContext(
|
||||
new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}
|
||||
)
|
||||
);
|
||||
if (itemState != null) {
|
||||
result.add(itemState);
|
||||
} else {
|
||||
result.add(Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {})));
|
||||
// </toxic cloud>
|
||||
}
|
||||
return result;
|
||||
@@ -922,21 +861,14 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
TrapDoorBlock.OPEN, TrapDoorBlock.HALF
|
||||
);
|
||||
|
||||
private boolean sameBlockstate(BlockState first, BlockState second) {
|
||||
private boolean sameWithoutOrientation(BlockState first, BlockState second) {
|
||||
if (first.getBlock() != second.getBlock()) {
|
||||
return false;
|
||||
}
|
||||
boolean ignoreDirection = Baritone.settings().buildIgnoreDirection.value;
|
||||
List<String> ignoredProps = Baritone.settings().buildIgnoreProperties.value;
|
||||
if (!ignoreDirection && ignoredProps.isEmpty()) {
|
||||
return first.equals(second); // early return if no properties are being ignored
|
||||
}
|
||||
ImmutableMap<Property<?>, Comparable<?>> map1 = first.getValues();
|
||||
ImmutableMap<Property<?>, Comparable<?>> map2 = second.getValues();
|
||||
for (Property<?> prop : map1.keySet()) {
|
||||
if (map1.get(prop) != map2.get(prop)
|
||||
&& !(ignoreDirection && orientationProps.contains(prop))
|
||||
&& !ignoredProps.contains(prop.getName())) {
|
||||
if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -968,7 +900,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (current.equals(desired)) {
|
||||
return true;
|
||||
}
|
||||
return sameBlockstate(current, desired);
|
||||
return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired);
|
||||
}
|
||||
|
||||
public class BuilderCalculationContext extends CalculationContext {
|
||||
@@ -1035,12 +967,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
|
||||
@Override
|
||||
public double breakCostMultiplierAt(int x, int y, int z, BlockState current) {
|
||||
if ((!allowBreak && !allowBreakAnyway.contains(current.getBlock())) || isPossiblyProtected(x, y, z)) {
|
||||
if (!allowBreak || isPossiblyProtected(x, y, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
BlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
|
||||
if (sch.getBlock() instanceof AirBlock) {
|
||||
if (sch.getBlock() == Blocks.AIR) {
|
||||
// it should be air
|
||||
// regardless of current contents, we can break it
|
||||
return 1;
|
||||
|
||||
@@ -30,14 +30,13 @@ import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
import java.util.*;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
||||
|
||||
private BlockOptionalMeta gettingTo;
|
||||
|
||||
@@ -40,7 +40,6 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.FallingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -103,7 +102,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
updateLoucaSystem();
|
||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||
@@ -112,10 +115,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
||||
}
|
||||
if (Baritone.settings().legitMine.value) {
|
||||
if (!addNearby()) {
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
addNearby();
|
||||
}
|
||||
Optional<BlockPos> shaft = curr.stream()
|
||||
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
|
||||
@@ -177,11 +177,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
|
||||
private PathingCommand updateGoal() {
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean legit = Baritone.settings().legitMine.value;
|
||||
List<BlockPos> locs = knownOreLocations;
|
||||
if (!locs.isEmpty()) {
|
||||
@@ -216,7 +211,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
@@ -227,7 +221,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
|
||||
private void rescan(List<BlockPos> already, CalculationContext context) {
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return;
|
||||
}
|
||||
@@ -377,18 +370,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return prune(ctx, locs, filter, max, blacklist, dropped);
|
||||
}
|
||||
|
||||
private boolean addNearby() {
|
||||
private void addNearby() {
|
||||
List<BlockPos> dropped = droppedItemsScan();
|
||||
knownOreLocations.addAll(dropped);
|
||||
BlockPos playerFeet = ctx.playerFeet();
|
||||
BlockStateInterface bsi = new BlockStateInterface(ctx);
|
||||
|
||||
|
||||
BlockOptionalMetaLookup filter = filterFilter();
|
||||
if (filter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int searchDist = 10;
|
||||
double fakedBlockReachDistance = 20; // at least 10 * sqrt(3) with some extra space to account for positioning within the block
|
||||
for (int x = playerFeet.getX() - searchDist; x <= playerFeet.getX() + searchDist; x++) {
|
||||
@@ -406,7 +392,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, ORE_LOCATIONS_COUNT, blacklist, dropped);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped) {
|
||||
@@ -482,8 +467,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
@Override
|
||||
public void mine(int quantity, BlockOptionalMetaLookup filter) {
|
||||
this.filter = filter;
|
||||
if (this.filterFilter() == null) {
|
||||
this.filter = null;
|
||||
if (filter != null && !Baritone.settings().allowBreak.value) {
|
||||
logDirect("Unable to mine when allowBreak is false!");
|
||||
this.mine(quantity, (BlockOptionalMetaLookup) null);
|
||||
return;
|
||||
}
|
||||
this.desiredQuantity = quantity;
|
||||
this.knownOreLocations = new ArrayList<>();
|
||||
@@ -495,22 +482,4 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
||||
}
|
||||
}
|
||||
|
||||
private BlockOptionalMetaLookup filterFilter() {
|
||||
if (this.filter == null) {
|
||||
return null;
|
||||
}
|
||||
if (!Baritone.settings().allowBreak.value) {
|
||||
BlockOptionalMetaLookup f = new BlockOptionalMetaLookup(this.filter.blocks()
|
||||
.stream()
|
||||
.filter(e -> Baritone.settings().allowBreakAnyway.value.contains(e.getBlock()))
|
||||
.toArray(BlockOptionalMeta[]::new));
|
||||
if (f.blocks().isEmpty()) {
|
||||
logDirect("Unable to mine when allowBreak is false and target block is not in allowBreakAnyway!");
|
||||
return null;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import baritone.api.utils.IPlayerContext;
|
||||
import baritone.cache.CachedRegion;
|
||||
import baritone.cache.WorldData;
|
||||
import baritone.utils.accessor.IClientChunkProvider;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -44,10 +43,9 @@ public class BlockStateInterface {
|
||||
|
||||
private final ClientChunkCache provider;
|
||||
private final WorldData worldData;
|
||||
protected final Level world;
|
||||
protected final BlockGetter world;
|
||||
public final BlockPos.MutableBlockPos isPassableBlockPos;
|
||||
public final BlockGetter access;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
private LevelChunk prev = null;
|
||||
private CachedRegion prevCached = null;
|
||||
@@ -66,7 +64,6 @@ public class BlockStateInterface {
|
||||
|
||||
public BlockStateInterface(Level world, WorldData worldData, boolean copyLoadedChunks) {
|
||||
this.world = world;
|
||||
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
||||
this.worldData = worldData;
|
||||
if (copyLoadedChunks) {
|
||||
this.provider = ((IClientChunkProvider) world.getChunkSource()).createThreadSafeCopy();
|
||||
@@ -100,9 +97,9 @@ public class BlockStateInterface {
|
||||
}
|
||||
|
||||
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
||||
y -= world.dimensionType().minY();
|
||||
y -= worldData.dimension.minY();
|
||||
// Invalid vertical position
|
||||
if (y < 0 || y >= world.dimensionType().height()) {
|
||||
if (y < 0 || y >= worldData.dimension.height()) {
|
||||
return AIR;
|
||||
}
|
||||
|
||||
@@ -172,7 +169,7 @@ public class BlockStateInterface {
|
||||
// get the block at x,y,z from this chunk WITHOUT creating a single blockpos object
|
||||
public static BlockState getFromChunk(LevelChunk chunk, int x, int y, int z) {
|
||||
LevelChunkSection section = chunk.getSections()[y >> 4];
|
||||
if (LevelChunkSection.isEmpty(section)) {
|
||||
if (section.hasOnlyAir()) {
|
||||
return AIR;
|
||||
}
|
||||
return section.getBlockState(x & 15, y & 15, z & 15);
|
||||
|
||||
@@ -91,12 +91,12 @@ public class GuiClick extends Screen implements Helper {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
|
||||
BaseComponent component = new TextComponent("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
component.setStyle(component.getStyle()
|
||||
component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + "help sel"
|
||||
)));
|
||||
));
|
||||
Helper.HELPER.logDirect(component);
|
||||
clickStart = null;
|
||||
} else {
|
||||
|
||||
@@ -229,7 +229,8 @@ public final class PathRenderer implements IRenderer, Helper {
|
||||
if (!settings.renderGoalAnimated.value) {
|
||||
// y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason
|
||||
y = 0.999F;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
y = Mth.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
|
||||
}
|
||||
if (goal instanceof IGoalRenderPos) {
|
||||
@@ -270,9 +271,9 @@ public final class PathRenderer implements IRenderer, Helper {
|
||||
stack,
|
||||
mc.renderBuffers().bufferSource(),
|
||||
TEXTURE_BEACON_BEAM,
|
||||
settings.renderGoalAnimated.value ? partialTicks : 0,
|
||||
partialTicks,
|
||||
1.0F,
|
||||
settings.renderGoalAnimated.value ? player.level.getGameTime() : 0,
|
||||
player.level.getGameTime(),
|
||||
0,
|
||||
256,
|
||||
color.getColorComponents(null),
|
||||
|
||||
@@ -18,20 +18,19 @@
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.item.DiggerItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.TieredItem;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A cached list of the best tools on the hotbar for any block
|
||||
*
|
||||
@@ -76,20 +75,13 @@ public class ToolSet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate the material cost of a possible tool. The priority matches the
|
||||
* harvest level order; there is a chance for multiple at the same with modded tools
|
||||
* but in that case we don't really care.
|
||||
* Evaluate the material cost of a possible tool. Will return 1 for tools, -1 for other
|
||||
*
|
||||
* @param itemStack a possibly empty ItemStack
|
||||
* @return values from 0 up
|
||||
* @return Either 1 or -1
|
||||
*/
|
||||
private int getMaterialCost(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof TieredItem) {
|
||||
TieredItem tool = (TieredItem) itemStack.getItem();
|
||||
return tool.getTier().getLevel();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return itemStack.getItem() instanceof DiggerItem ? 1 : -1;
|
||||
}
|
||||
|
||||
public boolean hasSilkTouch(ItemStack stack) {
|
||||
@@ -128,7 +120,7 @@ public class ToolSet {
|
||||
if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof SwordItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (Baritone.settings().itemSaver.value && (itemStack.getDamageValue() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ public class SelectionSchematic extends MaskSchematic {
|
||||
public SelectionSchematic(ISchematic schematic, Vec3i origin, ISelection[] selections) {
|
||||
super(schematic);
|
||||
this.selections = Stream.of(selections).map(
|
||||
sel -> sel
|
||||
.shift(Direction.WEST, origin.getX())
|
||||
.shift(Direction.DOWN, origin.getY())
|
||||
.shift(Direction.NORTH, origin.getZ()))
|
||||
sel -> sel
|
||||
.shift(Direction.WEST, origin.getX())
|
||||
.shift(Direction.DOWN, origin.getY())
|
||||
.shift(Direction.NORTH, origin.getZ()))
|
||||
.toArray(ISelection[]::new);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SelectionSchematic extends MaskSchematic {
|
||||
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||
for (ISelection selection : selections) {
|
||||
if (x >= selection.min().x && y >= selection.min().y && z >= selection.min().z
|
||||
&& x <= selection.max().x && y <= selection.max().y && z <= selection.max().z) {
|
||||
&& x <= selection.max().x && y <= selection.max().y && z <= selection.max().z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package baritone.utils.schematic.format;
|
||||
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import baritone.utils.schematic.format.defaults.MCEditSchematic;
|
||||
import baritone.utils.schematic.format.defaults.SpongeSchematic;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
@@ -66,27 +65,6 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
throw new UnsupportedOperationException("Unsupported Version of a Sponge Schematic");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The Litematica schematic specification. Commonly denoted by the ".litematic" file extension.
|
||||
*/
|
||||
LITEMATICA("litematic") {
|
||||
@Override
|
||||
public IStaticSchematic parse(InputStream input) throws IOException {
|
||||
CompoundTag nbt = NbtIo.readCompressed(input);
|
||||
int version = nbt.getInt("Version");
|
||||
switch (version) {
|
||||
case 4: //1.12
|
||||
throw new UnsupportedOperationException("This litematic Version is too old.");
|
||||
case 5: //1.13-1.17
|
||||
return new LitematicaSchematic(nbt, false);
|
||||
case 6: //1.18+
|
||||
throw new UnsupportedOperationException("This litematic Version is too new.");
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsuported Version of a Litematica Schematic");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final String extension;
|
||||
|
||||
@@ -1,347 +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.schematic.format.defaults;
|
||||
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Based on EmersonDove's work
|
||||
* <a href="https://github.com/cabaletta/baritone/pull/2544">...</a>
|
||||
*
|
||||
* @author rycbar
|
||||
* @since 22.09.2022
|
||||
*/
|
||||
public final class LitematicaSchematic extends StaticSchematic {
|
||||
private final Vec3i offsetMinCorner;
|
||||
private final CompoundTag nbt;
|
||||
|
||||
/**
|
||||
* @param nbtTagCompound a decompressed file stream aka nbt data.
|
||||
* @param rotated if the schematic is rotated by 90°.
|
||||
*/
|
||||
public LitematicaSchematic(CompoundTag nbtTagCompound, boolean rotated) {
|
||||
this.nbt = nbtTagCompound;
|
||||
this.offsetMinCorner = new Vec3i(getMinOfSchematic("x"), getMinOfSchematic("y"), getMinOfSchematic("z"));
|
||||
this.y = Math.abs(nbt.getCompound("Metadata").getCompound("EnclosingSize").getInt("y"));
|
||||
|
||||
if (rotated) {
|
||||
this.x = Math.abs(nbt.getCompound("Metadata").getCompound("EnclosingSize").getInt("z"));
|
||||
this.z = Math.abs(nbt.getCompound("Metadata").getCompound("EnclosingSize").getInt("x"));
|
||||
} else {
|
||||
this.x = Math.abs(nbt.getCompound("Metadata").getCompound("EnclosingSize").getInt("x"));
|
||||
this.z = Math.abs(nbt.getCompound("Metadata").getCompound("EnclosingSize").getInt("z"));
|
||||
}
|
||||
this.states = new BlockState[this.x][this.z][this.y];
|
||||
fillInSchematic();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array of subregion names.
|
||||
*/
|
||||
private static String[] getRegions(CompoundTag nbt) {
|
||||
return nbt.getCompound("Regions").getAllKeys().toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets both ends from a region box for a given axis and returns the lower one.
|
||||
*
|
||||
* @param s axis that should be read.
|
||||
* @return the lower coord of the requested axis.
|
||||
*/
|
||||
private static int getMinOfSubregion(CompoundTag nbt, String subReg, String s) {
|
||||
int a = nbt.getCompound("Regions").getCompound(subReg).getCompound("Position").getInt(s);
|
||||
int b = nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt(s);
|
||||
if (b < 0) {
|
||||
b++;
|
||||
}
|
||||
return Math.min(a, a + b);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blockStatePalette List of all different block types used in the schematic.
|
||||
* @return Array of BlockStates.
|
||||
*/
|
||||
private static BlockState[] getBlockList(ListTag blockStatePalette) {
|
||||
BlockState[] blockList = new BlockState[blockStatePalette.size()];
|
||||
|
||||
for (int i = 0; i < blockStatePalette.size(); i++) {
|
||||
Block block = Registry.BLOCK.get(new ResourceLocation((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
|
||||
|
||||
blockList[i] = getBlockState(block, properties);
|
||||
}
|
||||
return blockList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param block block.
|
||||
* @param properties List of Properties the block has.
|
||||
* @return A blockState.
|
||||
*/
|
||||
private static BlockState getBlockState(Block block, CompoundTag properties) {
|
||||
BlockState blockState = block.defaultBlockState();
|
||||
|
||||
for (Object key : properties.getAllKeys().toArray()) {
|
||||
Property<?> property = block.getStateDefinition().getProperty((String) key);
|
||||
String propertyValue = properties.getString((String) key);
|
||||
if (property != null) {
|
||||
blockState = setPropertyValue(blockState, property, propertyValue);
|
||||
}
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Emerson
|
||||
*/
|
||||
private static <T extends Comparable<T>> BlockState setPropertyValue(BlockState state, Property<T> property, String value) {
|
||||
Optional<T> parsed = property.getValue(value);
|
||||
if (parsed.isPresent()) {
|
||||
return state.setValue(property, parsed.get());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid value for property " + property);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amountOfBlockTypes amount of block types in the schematic.
|
||||
* @return amount of bits used to encode a block.
|
||||
*/
|
||||
private static int getBitsPerBlock(int amountOfBlockTypes) {
|
||||
return (int) Math.max(2, Math.ceil(Math.log(amountOfBlockTypes) / Math.log(2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the volume of the subregion. As size can be a negative value we take the absolute value of the
|
||||
* multiplication as the volume still holds a positive amount of blocks.
|
||||
*
|
||||
* @return the volume of the subregion.
|
||||
*/
|
||||
private static long getVolume(CompoundTag nbt, String subReg) {
|
||||
return Math.abs(
|
||||
nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("x") *
|
||||
nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("y") *
|
||||
nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("z"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array of Long values.
|
||||
*/
|
||||
private static long[] getBlockStates(CompoundTag nbt, String subReg) {
|
||||
return nbt.getCompound("Regions").getCompound(subReg).getLongArray("BlockStates");
|
||||
}
|
||||
|
||||
/**
|
||||
* Subregion don't have to be the same size as the enclosing size of the schematic. If they are smaller we check here if the current block is part of the subregion.
|
||||
*
|
||||
* @param x coord of the block relative to the minimum corner.
|
||||
* @param y coord of the block relative to the minimum corner.
|
||||
* @param z coord of the block relative to the minimum corner.
|
||||
* @return if the current block is part of the subregion.
|
||||
*/
|
||||
private static boolean inSubregion(CompoundTag nbt, String subReg, int x, int y, int z) {
|
||||
return x >= 0 && y >= 0 && z >= 0 &&
|
||||
x < Math.abs(nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("x")) &&
|
||||
y < Math.abs(nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("y")) &&
|
||||
z < Math.abs(nbt.getCompound("Regions").getCompound(subReg).getCompound("Size").getInt("z"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s axis.
|
||||
* @return the lowest coordinate of that axis of the schematic.
|
||||
*/
|
||||
private int getMinOfSchematic(String s) {
|
||||
int n = Integer.MAX_VALUE;
|
||||
for (String subReg : getRegions(nbt)) {
|
||||
n = Math.min(n, getMinOfSubregion(nbt, subReg, s));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* reads the file data.
|
||||
*/
|
||||
private void fillInSchematic() {
|
||||
for (String subReg : getRegions(nbt)) {
|
||||
ListTag usedBlockTypes = nbt.getCompound("Regions").getCompound(subReg).getList("BlockStatePalette", 10);
|
||||
BlockState[] blockList = getBlockList(usedBlockTypes);
|
||||
|
||||
int bitsPerBlock = getBitsPerBlock(usedBlockTypes.size());
|
||||
long regionVolume = getVolume(nbt, subReg);
|
||||
long[] blockStateArray = getBlockStates(nbt, subReg);
|
||||
|
||||
LitematicaBitArray bitArray = new LitematicaBitArray(bitsPerBlock, regionVolume, blockStateArray);
|
||||
|
||||
writeSubregionIntoSchematic(nbt, subReg, blockList, bitArray);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the file data in to the IBlockstate array.
|
||||
*
|
||||
* @param blockList list with the different block types used in the schematic.
|
||||
* @param bitArray bit array that holds the placement pattern.
|
||||
*/
|
||||
private void writeSubregionIntoSchematic(CompoundTag nbt, String subReg, BlockState[] blockList, LitematicaBitArray bitArray) {
|
||||
Vec3i offsetSubregion = new Vec3i(getMinOfSubregion(nbt, subReg, "x"), getMinOfSubregion(nbt, subReg, "y"), getMinOfSubregion(nbt, subReg, "z"));
|
||||
int index = 0;
|
||||
for (int y = 0; y < this.y; y++) {
|
||||
for (int z = 0; z < this.z; z++) {
|
||||
for (int x = 0; x < this.x; x++) {
|
||||
if (inSubregion(nbt, subReg, x, y, z)) {
|
||||
this.states[x - (offsetMinCorner.getX() - offsetSubregion.getX())][z - (offsetMinCorner.getZ() - offsetSubregion.getZ())][y - (offsetMinCorner.getY() - offsetSubregion.getY())] = blockList[bitArray.getAt(index)];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return offset from the schematic origin to the minimum Corner as a Vec3i.
|
||||
*/
|
||||
public Vec3i getOffsetMinCorner() {
|
||||
return offsetMinCorner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return x size of the schematic.
|
||||
*/
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return y size of the schematic.
|
||||
*/
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return z size of the schematic.
|
||||
*/
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x position relative to the minimum corner of the schematic.
|
||||
* @param y position relative to the minimum corner of the schematic.
|
||||
* @param z position relative to the minimum corner of the schematic.
|
||||
* @param blockState new blockstate of the block at this position.
|
||||
*/
|
||||
public void setDirect(int x, int y, int z, BlockState blockState) {
|
||||
this.states[x][z][y] = blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rotated if the schematic is rotated by 90°.
|
||||
* @return a copy of the schematic.
|
||||
*/
|
||||
public LitematicaSchematic getCopy(boolean rotated) {
|
||||
return new LitematicaSchematic(nbt, rotated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author maruohon
|
||||
* Class from the Litematica mod by maruohon
|
||||
* Usage under LGPLv3 with the permission of the author.
|
||||
* <a href="https://github.com/maruohon/litematica">...</a>
|
||||
*/
|
||||
private static class LitematicaBitArray {
|
||||
/**
|
||||
* The long array that is used to store the data for this BitArray.
|
||||
*/
|
||||
private final long[] longArray;
|
||||
/**
|
||||
* Number of bits a single entry takes up
|
||||
*/
|
||||
private final int bitsPerEntry;
|
||||
/**
|
||||
* The maximum value for a single entry. This also works as a bitmask for a single entry.
|
||||
* For instance, if bitsPerEntry were 5, this value would be 31 (ie, {@code 0b00011111}).
|
||||
*/
|
||||
private final long maxEntryValue;
|
||||
/**
|
||||
* Number of entries in this array (<b>not</b> the length of the long array that internally backs this array)
|
||||
*/
|
||||
private final long arraySize;
|
||||
|
||||
public LitematicaBitArray(int bitsPerEntryIn, long arraySizeIn, @Nullable long[] longArrayIn) {
|
||||
Validate.inclusiveBetween(1L, 32L, bitsPerEntryIn);
|
||||
this.arraySize = arraySizeIn;
|
||||
this.bitsPerEntry = bitsPerEntryIn;
|
||||
this.maxEntryValue = (1L << bitsPerEntryIn) - 1L;
|
||||
|
||||
if (longArrayIn != null) {
|
||||
this.longArray = longArrayIn;
|
||||
} else {
|
||||
this.longArray = new long[(int) (roundUp(arraySizeIn * (long) bitsPerEntryIn, 64L) / 64L)];
|
||||
}
|
||||
}
|
||||
|
||||
public static long roundUp(long number, long interval) {
|
||||
int sign = 1;
|
||||
if (interval == 0) {
|
||||
return 0;
|
||||
} else if (number == 0) {
|
||||
return interval;
|
||||
} else {
|
||||
if (number < 0) {
|
||||
sign = -1;
|
||||
}
|
||||
|
||||
long i = number % (interval * sign);
|
||||
return i == 0 ? number : number + (interval * sign) - i;
|
||||
}
|
||||
}
|
||||
|
||||
public int getAt(long index) {
|
||||
Validate.inclusiveBetween(0L, this.arraySize - 1L, index);
|
||||
long startOffset = index * (long) this.bitsPerEntry;
|
||||
int startArrIndex = (int) (startOffset >> 6); // startOffset / 64
|
||||
int endArrIndex = (int) (((index + 1L) * (long) this.bitsPerEntry - 1L) >> 6);
|
||||
int startBitOffset = (int) (startOffset & 0x3F); // startOffset % 64
|
||||
|
||||
if (startArrIndex == endArrIndex) {
|
||||
return (int) (this.longArray[startArrIndex] >>> startBitOffset & this.maxEntryValue);
|
||||
} else {
|
||||
int endOffset = 64 - startBitOffset;
|
||||
return (int) ((this.longArray[startArrIndex] >>> startBitOffset | this.longArray[endArrIndex] << endOffset) & this.maxEntryValue);
|
||||
}
|
||||
}
|
||||
|
||||
public long size() {
|
||||
return this.arraySize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,215 +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.schematic.litematica;
|
||||
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import fi.dy.masa.litematica.Litematica;
|
||||
import fi.dy.masa.litematica.data.DataManager;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Helper class that provides access or processes data related to Litmatica schematics.
|
||||
*
|
||||
* @author rycbar
|
||||
* @since 28.09.2022
|
||||
*/
|
||||
public final class LitematicaHelper {
|
||||
|
||||
/**
|
||||
* @return if Litmatica is installed.
|
||||
*/
|
||||
public static boolean isLitematicaPresent() {
|
||||
try {
|
||||
Class.forName(Litematica.class.getName());
|
||||
return true;
|
||||
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if there are loaded schematics.
|
||||
*/
|
||||
public static boolean hasLoadedSchematic() {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return the name of the requested schematic.
|
||||
*/
|
||||
public static String getName(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return the world coordinates of the schematic origin. This can but does not have to be the minimum corner.
|
||||
*/
|
||||
public static Vec3i getOrigin(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getOrigin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return Filepath of the schematic file.
|
||||
*/
|
||||
public static File getSchematicFile(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getSchematicFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return rotation of the schematic placement.
|
||||
*/
|
||||
public static Rotation getRotation(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getRotation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return the mirroring of the schematic placement.
|
||||
*/
|
||||
public static Mirror getMirror(int i) {
|
||||
return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getMirror();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schematic original schematic.
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return the minimum corner coordinates of the schematic, after the original schematic got rotated and mirrored.
|
||||
*/
|
||||
public static Vec3i getCorrectedOrigin(LitematicaSchematic schematic, int i) {
|
||||
int x = LitematicaHelper.getOrigin(i).getX();
|
||||
int y = LitematicaHelper.getOrigin(i).getY();
|
||||
int z = LitematicaHelper.getOrigin(i).getZ();
|
||||
int mx = schematic.getOffsetMinCorner().getX();
|
||||
int my = schematic.getOffsetMinCorner().getY();
|
||||
int mz = schematic.getOffsetMinCorner().getZ();
|
||||
int sx = (schematic.getX() - 1) * -1;
|
||||
int sz = (schematic.getZ() - 1) * -1;
|
||||
|
||||
Vec3i correctedOrigin;
|
||||
Mirror mirror = LitematicaHelper.getMirror(i);
|
||||
Rotation rotation = LitematicaHelper.getRotation(i);
|
||||
|
||||
//todo there has to be a better way to do this but i cant finde it atm
|
||||
switch (mirror) {
|
||||
case FRONT_BACK:
|
||||
case LEFT_RIGHT:
|
||||
switch ((mirror.ordinal() * 2 + rotation.ordinal()) % 4) {
|
||||
case 1:
|
||||
correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + (sx - mx));
|
||||
break;
|
||||
case 2:
|
||||
correctedOrigin = new Vec3i(x + mx, y + my, z + (sz - mz));
|
||||
break;
|
||||
case 3:
|
||||
correctedOrigin = new Vec3i(x + mz, y + my, z + mx);
|
||||
break;
|
||||
default:
|
||||
correctedOrigin = new Vec3i(x + (sx - mx), y + my, z + mz);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (rotation) {
|
||||
case CLOCKWISE_90:
|
||||
correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + mx);
|
||||
break;
|
||||
case CLOCKWISE_180:
|
||||
correctedOrigin = new Vec3i(x + (sx - mx), y + my, z + (sz - mz));
|
||||
break;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
correctedOrigin = new Vec3i(x + mz, y + my, z + (sx - mx));
|
||||
break;
|
||||
default:
|
||||
correctedOrigin = new Vec3i(x + mx, y + my, z + mz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return correctedOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in the xyz offsets of the block relative to the schematic minimum corner.
|
||||
* @param sizeX size of the schematic in the x-axis direction.
|
||||
* @param sizeZ size of the schematic in the z-axis direction.
|
||||
* @param mirror the mirroring of the schematic placement.
|
||||
* @return the corresponding xyz coordinates after mirroring them according to the given mirroring.
|
||||
*/
|
||||
public static Vec3i doMirroring(Vec3i in, int sizeX, int sizeZ, Mirror mirror) {
|
||||
int xOut = in.getX();
|
||||
int zOut = in.getZ();
|
||||
if (mirror == Mirror.LEFT_RIGHT) {
|
||||
zOut = sizeZ - in.getZ();
|
||||
} else if (mirror == Mirror.FRONT_BACK) {
|
||||
xOut = sizeX - in.getX();
|
||||
}
|
||||
return new Vec3i(xOut, in.getY(), zOut);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in the xyz offsets of the block relative to the schematic minimum corner.
|
||||
* @param sizeX size of the schematic in the x-axis direction.
|
||||
* @param sizeZ size of the schematic in the z-axis direction.
|
||||
* @return the corresponding xyz coordinates after rotation them 90° clockwise.
|
||||
*/
|
||||
public static Vec3i rotate(Vec3i in, int sizeX, int sizeZ) {
|
||||
return new Vec3i(sizeX - (sizeX - sizeZ) - in.getZ(), in.getY(), in.getX());
|
||||
}
|
||||
|
||||
/**
|
||||
* IDFK this just grew and it somehow works. If you understand how, pls tell me.
|
||||
*
|
||||
* @param schemIn give in the original schematic.
|
||||
* @param i index of the Schematic in the schematic placement list.
|
||||
* @return get it out rotated and mirrored.
|
||||
*/
|
||||
public static LitematicaSchematic blackMagicFuckery(LitematicaSchematic schemIn, int i) {
|
||||
LitematicaSchematic tempSchem = schemIn.getCopy(LitematicaHelper.getRotation(i).ordinal() % 2 == 1);
|
||||
for (int yCounter = 0; yCounter < schemIn.getY(); yCounter++) {
|
||||
for (int zCounter = 0; zCounter < schemIn.getZ(); zCounter++) {
|
||||
for (int xCounter = 0; xCounter < schemIn.getX(); xCounter++) {
|
||||
Vec3i xyzHolder = new Vec3i(xCounter, yCounter, zCounter);
|
||||
xyzHolder = LitematicaHelper.doMirroring(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1, LitematicaHelper.getMirror(i));
|
||||
for (int turns = 0; turns < LitematicaHelper.getRotation(i).ordinal(); turns++) {
|
||||
if ((turns % 2) == 0) {
|
||||
xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getX() - 1, schemIn.getZ() - 1);
|
||||
} else {
|
||||
xyzHolder = LitematicaHelper.rotate(xyzHolder, schemIn.getZ() - 1, schemIn.getX() - 1);
|
||||
}
|
||||
}
|
||||
BlockState state = schemIn.getDirect(xCounter, yCounter, zCounter);
|
||||
try {
|
||||
state = state.mirror(LitematicaHelper.getMirror(i)).rotate(LitematicaHelper.getRotation(i));
|
||||
} catch (NullPointerException e) {
|
||||
//nothing to worry about it's just a hole in the schematic.
|
||||
}
|
||||
tempSchem.setDirect(xyzHolder.getX(), xyzHolder.getY(), xyzHolder.getZ(), state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempSchem;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +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 fi.dy.masa.litematica;
|
||||
|
||||
public class Litematica {
|
||||
}
|
||||
@@ -1,33 +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 fi.dy.masa.litematica.data;
|
||||
|
||||
import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager;
|
||||
|
||||
public class DataManager {
|
||||
public static final DataManager INSTANCE = new DataManager();
|
||||
private final SchematicPlacementManager schematicPlacementManager = new SchematicPlacementManager();
|
||||
|
||||
private static DataManager getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static SchematicPlacementManager getSchematicPlacementManager() {
|
||||
return getInstance().schematicPlacementManager;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +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 fi.dy.masa.litematica.schematic.placement;
|
||||
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
|
||||
public class SchematicPlacement extends SchematicPlacementUnloaded {
|
||||
private Rotation rotation;
|
||||
private Mirror mirror;
|
||||
|
||||
public Rotation getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public Mirror getMirror() {
|
||||
return this.mirror;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +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 fi.dy.masa.litematica.schematic.placement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SchematicPlacementManager {
|
||||
private final List<SchematicPlacement> schematicPlacements = new ArrayList<>();
|
||||
|
||||
//in case of a java.lang.NoSuchMethodError try change the name of this method to getAllSchematicPlacements()
|
||||
//there are inconsistencies in the litematica mod about the naming of this method
|
||||
public List<SchematicPlacement> getAllSchematicsPlacements() {
|
||||
return schematicPlacements;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +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 fi.dy.masa.litematica.schematic.placement;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
public class SchematicPlacementUnloaded {
|
||||
protected String name = "?";
|
||||
@Nullable
|
||||
protected File schematicFile;
|
||||
protected BlockPos origin = BlockPos.ZERO;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public File getSchematicFile() {
|
||||
return this.schematicFile;
|
||||
}
|
||||
|
||||
public BlockPos getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,10 @@ public class ActionCostsTest {
|
||||
|
||||
@Test
|
||||
public void testFallNBlocksCost() {
|
||||
assertEquals(FALL_N_BLOCKS_COST.length, 4097); // Fall 0 blocks through fall 4096 blocks
|
||||
for (int i = 0; i < 4097; i++) {
|
||||
assertEquals(FALL_N_BLOCKS_COST.length, 257); // Fall 0 blocks through fall 256 blocks
|
||||
for (int i = 0; i < 257; i++) {
|
||||
double blocks = ticksToBlocks(FALL_N_BLOCKS_COST[i]);
|
||||
assertEquals(blocks, i, 0.00000000001); // If you add another 0 the test fails at i=989 LOL
|
||||
assertEquals(blocks, i, 0.000000000001); // If you add another 0 the test fails at i=217 LOL
|
||||
}
|
||||
assertEquals(FALL_1_25_BLOCKS_COST, 6.2344, 0.00001);
|
||||
assertEquals(FALL_0_25_BLOCKS_COST, 3.0710, 0.00001);
|
||||
|
||||
Reference in New Issue
Block a user