Compare commits
2 Commits
pr/elytra/
...
zephreo-su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0082990e9 | ||
|
|
4a489d29de |
2
.github/ISSUE_TEMPLATE/bug.md
vendored
2
.github/ISSUE_TEMPLATE/bug.md
vendored
@@ -11,7 +11,7 @@ Operating system:
|
||||
Java version:
|
||||
Minecraft version:
|
||||
Baritone version:
|
||||
Other mods (if used):
|
||||
Forge mods (if used):
|
||||
|
||||
## Exception, error or logs
|
||||
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue
|
||||
|
||||
39
.github/workflows/gradle_build.yml
vendored
39
.github/workflows/gradle_build.yml
vendored
@@ -1,39 +0,0 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: dist/
|
||||
|
||||
- name: Archive mapping.txt
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Mappings
|
||||
path: build/tmp/proguard/mapping.txt
|
||||
26
.github/workflows/run_tests.yml
vendored
26
.github/workflows/run_tests.yml
vendored
@@ -1,26 +0,0 @@
|
||||
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Executing tests
|
||||
run: ./gradlew test
|
||||
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -18,17 +18,6 @@ classes/
|
||||
*.iws
|
||||
/logs/
|
||||
|
||||
# Eclipse Files
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
baritone_Client.launch
|
||||
|
||||
# Copyright Files
|
||||
!/.idea/copyright/Baritone.xml
|
||||
!/.idea/copyright/profiles_settings.xml
|
||||
|
||||
.vscode/launch.json
|
||||
|
||||
libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
|
||||
libs/java-objc-bridge-1.1.jar
|
||||
|
||||
29
.travis.yml
Normal file
29
.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
language: java
|
||||
|
||||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
install:
|
||||
- travis_retry docker build -t cabaletta/baritone .
|
||||
|
||||
script:
|
||||
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
|
||||
#- docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||
- docker cp baritone:/code/dist dist
|
||||
- ls dist
|
||||
- cat dist/checksums.txt
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s=
|
||||
all_branches: true
|
||||
file_glob: true
|
||||
file:
|
||||
- dist/*
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
repo: cabaletta/baritone
|
||||
@@ -1,5 +1,7 @@
|
||||
FROM debian:stretch
|
||||
|
||||
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update -y
|
||||
@@ -8,8 +10,14 @@ RUN apt install \
|
||||
openjdk-8-jdk \
|
||||
--assume-yes
|
||||
|
||||
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
|
||||
COPY . /code
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# this .deb is specially patched to support lwjgl
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
|
||||
105
README.md
105
README.md
@@ -1,79 +1,46 @@
|
||||
# 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>
|
||||
[](http://hits.dwyl.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
|
||||
<p align="center">
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.17.1-yellow.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.2-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.4-brightgreen.svg" alt="Minecraft"/></a>
|
||||
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.20.1-brightgreen.svg" alt="Minecraft"/></a>
|
||||
</p>
|
||||
[](https://travis-ci.com/cabaletta/baritone/)
|
||||
[](https://github.com/cabaletta/baritone/releases/)
|
||||
[](LICENSE)
|
||||
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
|
||||
[](https://github.com/cabaletta/baritone/tree/master/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.13.2/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.14.4/)
|
||||
[](https://github.com/cabaletta/baritone/tree/1.15.2/)
|
||||
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
|
||||
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues/)
|
||||
[](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
|
||||
[](https://github.com/cabaletta/baritone/pulls/)
|
||||

|
||||

|
||||

|
||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||
[](https://github.com/cabaletta/baritone/commit/)
|
||||
[](https://impactclient.net/)
|
||||
[](https://github.com/kami-blue/client)
|
||||
[](https://github.com/fr1kin/ForgeHax/)
|
||||
[](https://gitlab.com/emc-mods-indrit/baritone_api)
|
||||
[](https://rootnet.dev/)
|
||||
[](https://futureclient.net/)
|
||||
[](https://rusherhack.org/)
|
||||
[](http://forthebadge.com/)
|
||||
[](http://forthebadge.com/)
|
||||
|
||||
<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/gh/cabaletta/baritone/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/cadab857dab049438b6e28b3cfc5570e" 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>
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
<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/lambda-client/lambda"><img src="https://img.shields.io/badge/Lambda%20integration-v1.2.17-brightgreen.svg" alt="Lambda 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>
|
||||
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)
|
||||
|
||||
<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>
|
||||
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.14/baritone-api-forge-1.2.14.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
A Minecraft pathfinder bot.
|
||||
|
||||
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
|
||||
|
||||
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
|
||||
|
||||
**Quick download links:**
|
||||
|
||||
| Forge | Fabric |
|
||||
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||
| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.17/baritone-api-forge-1.2.17.jar) | |
|
||||
| [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-forge-1.6.4.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-fabric-1.6.4.jar) |
|
||||
| [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) |
|
||||
| [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-forge-1.8.4.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-fabric-1.8.4.jar) |
|
||||
| [1.19.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-forge-1.9.4.jar) | [1.19.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-fabric-1.9.4.jar) |
|
||||
| [1.19.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-forge-1.9.1.jar) | [1.19.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-fabric-1.9.1.jar) |
|
||||
| [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) |
|
||||
| [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) |
|
||||
|
||||
**How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
|
||||
|
||||
For other versions of Minecraft or more complicated situations or for development, see [Installation & setup](SETUP.md). Also consider just installing [Impact](https://impactclient.net/), which comes with Baritone and is easier to install than wrangling with version JSONs and zips. For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#6313 on Baritone which I recommend.
|
||||
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.
|
||||
|
||||
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).
|
||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
|
||||
|
||||
@@ -105,7 +72,7 @@ jar.
|
||||
|
||||
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
|
||||
|
||||
```java
|
||||
```
|
||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
||||
|
||||
|
||||
75
SETUP.md
75
SETUP.md
@@ -2,7 +2,7 @@
|
||||
|
||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
|
||||
|
||||
You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version or the [1.16.5](https://www.dropbox.com/s/i6f292o2i7o9acp/1.16.5-Baritone.zip?dl=1) version.
|
||||
You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version
|
||||
|
||||
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
|
||||
|
||||
@@ -11,9 +11,9 @@ 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
|
||||
|
||||
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`.
|
||||
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`.
|
||||
|
||||
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
|
||||
|
||||
@@ -22,16 +22,20 @@ 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.
|
||||
|
||||
## More Info
|
||||
To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal.
|
||||
|
||||
You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`.
|
||||
|
||||
## Build it yourself
|
||||
- Clone or download Baritone
|
||||
@@ -43,13 +47,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.
|
||||
|
||||
Download java: https://adoptium.net/
|
||||
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`
|
||||
@@ -66,13 +70,56 @@ In order to get JDK 8 running in the **current terminal window** you will have t
|
||||
|
||||
To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc
|
||||
|
||||
### Building Baritone
|
||||
Setting up the Environment:
|
||||
|
||||
These tasks depend on the minecraft version, but are (for the most part) standard for building mods.
|
||||
```
|
||||
$ gradlew setupDecompWorkspace
|
||||
$ gradlew --refresh-dependencies
|
||||
```
|
||||
|
||||
for more details, see [the build ci action](/.github/workflows/gradle_build.yml)
|
||||
Building Baritone:
|
||||
|
||||
```
|
||||
$ gradlew build
|
||||
```
|
||||
|
||||
Running Baritone:
|
||||
|
||||
```
|
||||
$ gradlew runClient
|
||||
```
|
||||
|
||||
For information on how to build baritone, see [Building Baritone](#building-baritone)
|
||||
|
||||
## IntelliJ
|
||||
- Open the project in IntelliJ as a Gradle project
|
||||
|
||||

|
||||
|
||||
- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns`
|
||||
|
||||

|
||||
|
||||
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
|
||||
- depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working
|
||||
|
||||

|
||||
|
||||
- Select the "Minecraft Client" launch config
|
||||
|
||||

|
||||
|
||||
- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config
|
||||
|
||||

|
||||
|
||||
- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`.
|
||||
|
||||

|
||||
|
||||
## IntelliJ
|
||||
|
||||
- Navigate to the gradle tasks on the right tab as follows
|
||||
|
||||

|
||||
|
||||
- Double click on **build** to run it
|
||||
|
||||
22
USAGE.md
22
USAGE.md
@@ -32,38 +32,30 @@ 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).
|
||||
- `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 diamond_ore 64`.
|
||||
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
|
||||
- `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type.
|
||||
- `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)
|
||||
- `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `schematica` to build the schematic that is currently open in schematica
|
||||
- `tunnel` to dig and make a tunnel, 1x2. It will only deviate from the straight line if necessary such as to avoid lava. For a dumber tunnel that is really just cleararea, you can `tunnel 3 2 100`, to clear an area 3 high, 2 wide, and 100 deep.
|
||||
- `farm` to automatically harvest, replant, or bone meal crops. Use `farm <range>` or `farm <range> <waypoint>` to limit the max distance from the starting point or a waypoint.
|
||||
- `farm` to automatically harvest, replant, or bone meal crops
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `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.
|
||||
|
||||
123
build.gradle
123
build.gradle
@@ -16,35 +16,33 @@
|
||||
*/
|
||||
|
||||
group 'baritone'
|
||||
version '1.2.17'
|
||||
version '1.2.14'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'forge'
|
||||
url = 'https://files.minecraftforge.net/maven'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'SpongePowered'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
url = 'http://repo.spongepowered.org/maven'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' // TODO: 5.+. `doHackyStuff` relies on 4.x internals.
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import baritone.gradle.task.CreateDistTask
|
||||
import baritone.gradle.task.ProguardTask
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply from: 'hacks.gradle'
|
||||
ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.task.GenerateSRG')) // TODO: fg 5.0 - `ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.tasks.GenerateSRG'))`
|
||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
@@ -54,19 +52,8 @@ compileJava {
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
api {
|
||||
compileClasspath += main.compileClasspath
|
||||
}
|
||||
main {
|
||||
compileClasspath += api.output
|
||||
}
|
||||
test {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
launch {
|
||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||
}
|
||||
|
||||
schematica_api {
|
||||
@@ -79,26 +66,13 @@ sourceSets {
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'stable', version: '39-1.12'
|
||||
runs {
|
||||
def nativesOutput = extractNatives.output // TODO: fg 5.0 - `def nativesOutput = extractNatives.output.get()`
|
||||
println("[Baritoe] Detected natives: ${nativesOutput}")
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
source sourceSets.launch
|
||||
version = '1.12.2'
|
||||
mappings = 'stable_39'
|
||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||
runDir = 'run'
|
||||
|
||||
main 'net.minecraft.launchwrapper.Launch'
|
||||
|
||||
args '--gameDir', '.'
|
||||
args '--version', '1.12.2'
|
||||
args '--assetsDir', downloadAssets.output
|
||||
args '--assetIndex', '{asset_index}'
|
||||
args '--accessToken', 'INVALID'
|
||||
|
||||
args '--tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||
jvmArgs "-Dorg.lwjgl.librarypath=${nativesOutput}"
|
||||
}
|
||||
}
|
||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||
makeObfSourceJar = true
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -106,81 +80,30 @@ repositories {
|
||||
|
||||
maven {
|
||||
name = 'spongepowered-repo'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
url = 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'impactdevelopment-repo'
|
||||
url = 'https://impactdevelopment.github.io/maven/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'babbaj-repo'
|
||||
url = 'https://babbaj.github.io/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
// fix forge gradle 4+ bug with 1.12.2
|
||||
afterEvaluate {
|
||||
configurations.minecraft {
|
||||
exclude group: 'net.minecraftforge', module: 'mergetool'
|
||||
}
|
||||
}
|
||||
|
||||
// lwjgl2 hack for running game on arm64 mac os
|
||||
afterEvaluate {
|
||||
def os = org.gradle.internal.os.OperatingSystem.current()
|
||||
if (os.isMacOsX()) {
|
||||
def arch = System.getProperty("os.arch").toLowerCase()
|
||||
println("Detected Mac OS X running on ${arch}")
|
||||
if (arch == "aarch64") {
|
||||
println("Configurating aarch64 dependencies.")
|
||||
|
||||
configurations.minecraft {
|
||||
exclude group: 'ca.weblite', module: 'java-objc-bridge'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// https://github.com/MinecraftMachina/lwjgl/releases/download/2.9.4-20150209-mmachina.2/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
|
||||
minecraft files("libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")
|
||||
// TODO: use prism launcher maven
|
||||
// https://github.com/MinecraftMachina/Java-Objective-C-Bridge/releases/download/1.1.0-mmachina.1/java-objc-bridge-1.1.jar
|
||||
minecraft files("libs/java-objc-bridge-1.1.jar") // TODO: use prism launcher maven
|
||||
minecraft(group: 'net.java.dev.jna', name: 'jna') {
|
||||
version {
|
||||
strictly '5.12.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft group: 'net.minecraft', name: 'joined', version: '1.12.2'
|
||||
implementation(group: 'net.minecraft', name: 'launchwrapper', version: '1.12') {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
def asmVersion = '9.5'
|
||||
implementation group: 'org.ow2.asm', name: 'asm', version: asmVersion
|
||||
implementation group: 'org.ow2.asm', name: 'asm-tree', version: asmVersion
|
||||
implementation group: 'org.ow2.asm', name: 'asm-commons', version: asmVersion
|
||||
implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion
|
||||
implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion
|
||||
|
||||
launchImplementation('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
launchImplementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
transitive = false
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
||||
launchImplementation('dev.babbaj:nether-pathfinder:0.34')
|
||||
implementation 'dev.babbaj:nether-pathfinder:0.34'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultObfuscationEnv searge
|
||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||
}
|
||||
|
||||
@@ -206,7 +129,7 @@ jar {
|
||||
manifest {
|
||||
attributes(
|
||||
'MixinConfigs': 'mixins.baritone.json',
|
||||
'TweakClass': 'baritone.launch.BaritoneTweaker',
|
||||
|
||||
'Implementation-Title': 'Baritone',
|
||||
'Implementation-Version': version
|
||||
)
|
||||
|
||||
@@ -20,6 +20,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
compile group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||
}
|
||||
@@ -32,21 +32,21 @@ import java.nio.file.Paths;
|
||||
class BaritoneGradleTask extends DefaultTask {
|
||||
|
||||
protected static final String
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
||||
PROGUARD_CONFIG_DEST = "template.pro",
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
||||
PROGUARD_CONFIG_DEST = "template.pro",
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||
|
||||
TEMP_LIBRARY_DIR = "tempLibraries/",
|
||||
TEMP_LIBRARY_DIR = "tempLibraries/",
|
||||
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||
ARTIFACT_API = "%s-api-%s.jar",
|
||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar";
|
||||
|
||||
protected String artifactName, artifactVersion;
|
||||
@@ -56,17 +56,17 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
this.artifactName = getProject().getName();
|
||||
this.artifactVersion = getProject().getVersion().toString();
|
||||
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
this.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||
this.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||
|
||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||
|
||||
if (!Files.exists(this.artifactPath)) {
|
||||
throw new IllegalStateException("Artifact not found! Run build first! " + this.artifactPath);
|
||||
throw new IllegalStateException("Artifact not found! Run build first!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class BaritoneGradleTask extends DefaultTask {
|
||||
}
|
||||
|
||||
protected Path getRelativeFile(String file) {
|
||||
return Paths.get(this.getProject().file(file).getAbsolutePath());
|
||||
return Paths.get(new File(file).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected Path getTemporaryFile(String file) {
|
||||
|
||||
@@ -18,33 +18,39 @@
|
||||
package baritone.gradle.task;
|
||||
|
||||
import baritone.gradle.util.Determinizer;
|
||||
import baritone.gradle.util.MappingType;
|
||||
import baritone.gradle.util.ReobfWrapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.internal.file.IdentityFileResolver;
|
||||
import org.gradle.api.internal.plugins.DefaultConvention;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.TaskCollection;
|
||||
import org.gradle.api.tasks.compile.ForkOptions;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.internal.Pair;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Objects;
|
||||
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
|
||||
import org.gradle.process.internal.DefaultExecActionFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/11/2018
|
||||
@@ -62,18 +68,17 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
private List<String> requiredLibraries;
|
||||
|
||||
private File mixin;
|
||||
private File pathfinder;
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.verifyArtifacts();
|
||||
|
||||
// "Haha brady why don't you make separate tasks"
|
||||
processArtifact();
|
||||
downloadProguard();
|
||||
extractProguard();
|
||||
generateConfigs();
|
||||
acquireDependencies();
|
||||
processArtifact();
|
||||
proguardApi();
|
||||
proguardStandalone();
|
||||
cleanup();
|
||||
@@ -84,7 +89,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Files.delete(this.artifactUnoptimizedPath);
|
||||
}
|
||||
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Arrays.asList(pathfinder), false);
|
||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
||||
}
|
||||
|
||||
private void downloadProguard() throws Exception {
|
||||
@@ -109,7 +114,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
try {
|
||||
path = findJavaPathByGradleConfig();
|
||||
if (path != null) return path;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Unable to find java by javaCompile options");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -117,7 +123,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
try {
|
||||
path = findJavaByJavaHome();
|
||||
if (path != null) return path;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch(Exception ex) {
|
||||
System.err.println("Unable to find java by JAVA_HOME");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -125,23 +132,30 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
|
||||
path = findJavaByGradleCurrentRuntime();
|
||||
if (path != null) return path;
|
||||
|
||||
|
||||
throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," +
|
||||
" JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)");
|
||||
}
|
||||
|
||||
private String findJavaByGradleCurrentRuntime() {
|
||||
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
|
||||
System.out.println("Using Gradle's runtime Java for ProGuard");
|
||||
return path;
|
||||
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Using Gradle's runtime Java for ProGuard");
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String findJavaByJavaHome() {
|
||||
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
||||
if (javaHomeEnv != null) {
|
||||
|
||||
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
||||
System.out.println("Detected Java path by JAVA_HOME");
|
||||
return path;
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Detected Java path by JAVA_HOME");
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -157,11 +171,19 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
if (javacPath != null) {
|
||||
File javacFile = new File(javacPath);
|
||||
if (javacFile.exists()) {
|
||||
File[] maybeJava = javacFile.getParentFile().listFiles((dir, name) -> name.equals("java"));
|
||||
File[] maybeJava = javacFile.getParentFile().listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.equals("java");
|
||||
}
|
||||
});
|
||||
|
||||
if (maybeJava != null && maybeJava.length > 0) {
|
||||
String path = maybeJava[0].getAbsolutePath();
|
||||
System.out.println("Detected Java path by forkOptions");
|
||||
return path;
|
||||
if (this.validateJavaVersion(path)) {
|
||||
System.out.println("Detected Java path by forkOptions");
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,13 +191,26 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean validateJavaVersion(String java) {
|
||||
final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
|
||||
|
||||
if (!javaVersion.getMajorVersion().equals("8")) {
|
||||
System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
||||
// throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generateConfigs() throws Exception {
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
||||
|
||||
// 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));
|
||||
|
||||
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
|
||||
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
|
||||
@@ -202,37 +237,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
});
|
||||
}
|
||||
|
||||
private static final class Pair<A, B> {
|
||||
public final A a;
|
||||
public final B b;
|
||||
|
||||
private Pair(final A a, final B b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pair{" +
|
||||
"a=" + this.a +
|
||||
", " +
|
||||
"b=" + this.b +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
private void acquireDependencies() throws Exception {
|
||||
|
||||
// Create a map of all of the dependencies that we are able to access in this project
|
||||
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
||||
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
||||
Map<String, File> files = new HashMap<>();
|
||||
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config -> {
|
||||
for (File file : config.getFiles()) {
|
||||
files.put(file.getName(), file);
|
||||
}
|
||||
config.getAllDependencies().forEach(dependency ->
|
||||
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), new Pair<>(config, dependency)));
|
||||
});
|
||||
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config ->
|
||||
config.getAllDependencies().forEach(dependency ->
|
||||
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), Pair.of(config, dependency))));
|
||||
|
||||
// Create the directory if it doesn't already exist
|
||||
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
||||
@@ -247,7 +259,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
Path cachedJar = getMinecraftJar();
|
||||
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
||||
// TODO: maybe try not to copy every time
|
||||
Files.copy(cachedJar, inTempDir, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.copy(cachedJar, inTempDir, REPLACE_EXISTING);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -259,77 +271,118 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
pair = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// The pair must be non-null
|
||||
Objects.requireNonNull(pair);
|
||||
|
||||
// Find the library jar file, and copy it to tempLibraries
|
||||
if (pair == null) {
|
||||
File libFile = files.get(lib + ".jar");
|
||||
if (libFile == null) {
|
||||
libFile = files.values().stream().filter(file -> file.getName().startsWith(lib)).findFirst().orElse(null);
|
||||
if (libFile == null) {
|
||||
throw new IllegalStateException(lib);
|
||||
}
|
||||
}
|
||||
copyTempLib(lib, libFile);
|
||||
} else {
|
||||
for (File file : pair.a.files(pair.b)) {
|
||||
if (file.getName().startsWith(lib)) {
|
||||
copyTempLib(lib, file);
|
||||
for (File file : pair.getLeft().files(pair.getRight())) {
|
||||
if (file.getName().startsWith(lib)) {
|
||||
if (lib.contains("mixin")) {
|
||||
mixin = file;
|
||||
}
|
||||
Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mixin == null) {
|
||||
throw new IllegalStateException("Unable to find mixin jar");
|
||||
}
|
||||
if (pathfinder == null) {
|
||||
throw new IllegalStateException("Unable to find pathfinder jar");
|
||||
}
|
||||
}
|
||||
|
||||
private void copyTempLib(String lib, File libFile) throws IOException {
|
||||
if (lib.contains("mixin")) {
|
||||
mixin = libFile;
|
||||
}
|
||||
if (lib.contains("nether-pathfinder")) {
|
||||
pathfinder = libFile;
|
||||
}
|
||||
Files.copy(libFile.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
// a bunch of epic stuff to get the path to the cached jar
|
||||
private Path getMinecraftJar() throws Exception {
|
||||
return getObfuscatedMinecraftJar(getProject(), false); // always notch jar for now.
|
||||
MappingType mappingType;
|
||||
try {
|
||||
mappingType = getMappingType();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to get mapping type, assuming NOTCH.");
|
||||
mappingType = MappingType.NOTCH;
|
||||
}
|
||||
|
||||
String suffix;
|
||||
switch (mappingType) {
|
||||
case NOTCH:
|
||||
suffix = "";
|
||||
break;
|
||||
case SEARGE:
|
||||
suffix = "-srgBin";
|
||||
break;
|
||||
case CUSTOM:
|
||||
throw new IllegalStateException("Custom mappings not supported!");
|
||||
default:
|
||||
throw new IllegalStateException("Unknown mapping type: " + mappingType);
|
||||
}
|
||||
|
||||
DefaultConvention convention = (DefaultConvention) this.getProject().getConvention();
|
||||
Object extension = convention.getAsMap().get("minecraft");
|
||||
Objects.requireNonNull(extension);
|
||||
|
||||
// for some reason cant use Class.forName
|
||||
Class<?> class_baseExtension = extension.getClass().getSuperclass().getSuperclass().getSuperclass(); // <-- cursed
|
||||
Field f_replacer = class_baseExtension.getDeclaredField("replacer");
|
||||
f_replacer.setAccessible(true);
|
||||
Object replacer = f_replacer.get(extension);
|
||||
Class<?> class_replacementProvider = replacer.getClass();
|
||||
Field replacement_replaceMap = class_replacementProvider.getDeclaredField("replaceMap");
|
||||
replacement_replaceMap.setAccessible(true);
|
||||
|
||||
Map<String, Object> replacements = (Map) replacement_replaceMap.get(replacer);
|
||||
String cacheDir = replacements.get("CACHE_DIR").toString() + "/net/minecraft";
|
||||
String mcVersion = replacements.get("MC_VERSION").toString();
|
||||
String mcpInsert = replacements.get("MAPPING_CHANNEL").toString() + "/" + replacements.get("MAPPING_VERSION").toString();
|
||||
String fullJarName = "minecraft-" + mcVersion + suffix + ".jar";
|
||||
|
||||
String baseDir = String.format("%s/minecraft/%s/", cacheDir, mcVersion);
|
||||
|
||||
String jarPath;
|
||||
if (mappingType == MappingType.SEARGE) {
|
||||
jarPath = String.format("%s/%s/%s", baseDir, mcpInsert, fullJarName);
|
||||
} else {
|
||||
jarPath = baseDir + fullJarName;
|
||||
}
|
||||
jarPath = jarPath
|
||||
.replace("/", File.separator)
|
||||
.replace("\\", File.separator); // hecking regex
|
||||
|
||||
return new File(jarPath).toPath();
|
||||
}
|
||||
|
||||
private static Path getObfuscatedMinecraftJar(final Project project, final boolean srg) throws Exception {
|
||||
final Object extension = Objects.requireNonNull(project.getExtensions().findByName("minecraft"), "Unable to find Minecraft extension.");
|
||||
// throws IllegalStateException if mapping type is ambiguous or it fails to find it
|
||||
private MappingType getMappingType() {
|
||||
// if it fails to find this then its probably a forgegradle version problem
|
||||
Set<Object> reobf = (NamedDomainObjectContainer<Object>) this.getProject().getExtensions().getByName("reobf");
|
||||
|
||||
final Class<?> mcpRepoClass = mcpRepoClass(extension.getClass().getClassLoader());
|
||||
final Field mcpRepoInstanceField = mcpRepoClass.getDeclaredField("INSTANCE");
|
||||
mcpRepoInstanceField.setAccessible(true);
|
||||
final Method findMethod = mcpRepoClass.getDeclaredMethod(srg ? "findSrg" : "findRaw", String.class, String.class);
|
||||
findMethod.setAccessible(true);
|
||||
List<MappingType> mappingTypes = getUsedMappingTypes(reobf);
|
||||
long mappingTypesUsed = mappingTypes.size();
|
||||
if (mappingTypesUsed == 0) {
|
||||
throw new IllegalStateException("Failed to find mapping type (no jar task?)");
|
||||
}
|
||||
if (mappingTypesUsed > 1) {
|
||||
throw new IllegalStateException("Ambiguous mapping type (multiple jars with different mapping types?)");
|
||||
}
|
||||
|
||||
final Object mcpRepo = mcpRepoInstanceField.get(null);
|
||||
final String mcpVersion = (String) Objects.requireNonNull(project.getExtensions().getExtraProperties().get("MCP_VERSION"), "Extra property \"MCP_VERSION\" not found");
|
||||
return ((File) findMethod.invoke(mcpRepo, "joined", mcpVersion)).toPath();
|
||||
return mappingTypes.get(0);
|
||||
}
|
||||
|
||||
private static Class<?> mcpRepoClass(final ClassLoader loader) throws Exception {
|
||||
final Method forName0 = Class.class.getDeclaredMethod("forName0", String.class, boolean.class, ClassLoader.class, Class.class);
|
||||
forName0.setAccessible(true);
|
||||
return (Class<?>) forName0.invoke(null, "net.minecraftforge.gradle.mcp.MCPRepo", true, loader, null);
|
||||
private List<MappingType> getUsedMappingTypes(Set<Object> reobf) {
|
||||
return reobf.stream()
|
||||
.map(ReobfWrapper::new)
|
||||
.map(ReobfWrapper::getMappingType)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void proguardApi() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Arrays.asList(pathfinder), false);
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Arrays.asList(pathfinder, mixin), true);
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Optional.empty());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Optional.of(mixin));
|
||||
}
|
||||
|
||||
private void proguardStandalone() throws Exception {
|
||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Arrays.asList(pathfinder), false);
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Arrays.asList(pathfinder, mixin), true);
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Optional.empty());
|
||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Optional.of(mixin));
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
@@ -342,33 +395,19 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setExtract(String extract) {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
public String getExtract() {
|
||||
return extract;
|
||||
}
|
||||
|
||||
private void runProguard(Path config) throws Exception {
|
||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||
if (Files.exists(this.proguardOut)) {
|
||||
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
|
||||
@@ -378,7 +417,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
|
||||
int exitCode = p.waitFor();
|
||||
if (exitCode != 0) {
|
||||
Thread.sleep(1000);
|
||||
throw new IllegalStateException("Proguard exited with code " + exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
@@ -39,11 +36,10 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class Determinizer {
|
||||
|
||||
public static void determinize(String inputPath, String outputPath, List<File> toInclude, boolean doForgeReplacementOfMetaInf) throws IOException {
|
||||
public static void determinize(String inputPath, String outputPath, Optional<File> toInclude) throws IOException {
|
||||
System.out.println("Running Determinizer");
|
||||
System.out.println(" Input path: " + inputPath);
|
||||
System.out.println(" Output path: " + outputPath);
|
||||
System.out.println(" Shade: " + toInclude);
|
||||
|
||||
try (
|
||||
JarFile jarFile = new JarFile(new File(inputPath));
|
||||
@@ -64,10 +60,10 @@ public class Determinizer {
|
||||
JarEntry clone = new JarEntry(entry.getName());
|
||||
clone.setTime(42069);
|
||||
jos.putNextEntry(clone);
|
||||
if (entry.getName().endsWith(".json")) {
|
||||
JsonElement json = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry)));
|
||||
jos.write(writeSorted(json).getBytes());
|
||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && doForgeReplacementOfMetaInf) { // only replace for forge jar
|
||||
if (entry.getName().endsWith(".refmap.json")) {
|
||||
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
||||
jos.write(writeSorted(object).getBytes());
|
||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && toInclude.isPresent()) { // only replace for forge jar
|
||||
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
|
||||
copy(jarFile.getInputStream(entry), cancer);
|
||||
String manifest = new String(cancer.toByteArray());
|
||||
@@ -80,8 +76,8 @@ public class Determinizer {
|
||||
copy(jarFile.getInputStream(entry), jos);
|
||||
}
|
||||
}
|
||||
for (File file : toInclude) {
|
||||
try (JarFile mixin = new JarFile(file)) {
|
||||
if (toInclude.isPresent()) {
|
||||
try (JarFile mixin = new JarFile(toInclude.get())) {
|
||||
for (JarEntry entry : mixin.stream().sorted(Comparator.comparing(JarEntry::getName)).collect(Collectors.toList())) {
|
||||
if (entry.getName().startsWith("META-INF") && !entry.getName().startsWith("META-INF/services")) {
|
||||
continue;
|
||||
@@ -93,7 +89,6 @@ public class Determinizer {
|
||||
}
|
||||
jos.finish();
|
||||
}
|
||||
System.out.println("Done with determinizer");
|
||||
}
|
||||
|
||||
private static void copy(InputStream is, OutputStream os) throws IOException {
|
||||
@@ -104,7 +99,7 @@ public class Determinizer {
|
||||
}
|
||||
}
|
||||
|
||||
private static String writeSorted(JsonElement in) throws IOException {
|
||||
private static String writeSorted(JsonObject in) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
||||
JsonWriter jw = new JsonWriter(writer);
|
||||
ORDERED_JSON_WRITER.write(jw, in);
|
||||
|
||||
@@ -15,14 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.behavior.elytra;
|
||||
package baritone.gradle.util;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* All credits go to AsmLibGradle and its contributors.
|
||||
*
|
||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/MappingType.java">Original Source</a>
|
||||
*/
|
||||
public final class PathCalculationException extends RuntimeException {
|
||||
|
||||
public PathCalculationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
public enum MappingType {
|
||||
SEARGE,
|
||||
NOTCH,
|
||||
CUSTOM // forgegradle
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.gradle.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* All credits go to AsmLibGradle and its contributors.
|
||||
*
|
||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/ReobfWrapper.java">Original Source</a>
|
||||
*/
|
||||
public class ReobfWrapper {
|
||||
|
||||
private final Object instance;
|
||||
private final Class<?> type;
|
||||
|
||||
public ReobfWrapper(Object instance) {
|
||||
this.instance = instance;
|
||||
Objects.requireNonNull(instance);
|
||||
this.type = instance.getClass();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
try {
|
||||
Field nameField = type.getDeclaredField("name");
|
||||
nameField.setAccessible(true);
|
||||
return (String) nameField.get(this.instance);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public MappingType getMappingType() {
|
||||
try {
|
||||
Field enumField = type.getDeclaredField("mappingType");
|
||||
enumField.setAccessible(true);
|
||||
Enum<?> aEnum = (Enum<?>) enumField.get(this.instance);
|
||||
MappingType mappingType = MappingType.values()[aEnum.ordinal()];
|
||||
if (!aEnum.name().equals(mappingType.name())) {
|
||||
throw new IllegalStateException("ForgeGradle ReobfMappingType is not equivalent to MappingType (version error?)");
|
||||
}
|
||||
return mappingType;
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
||||
#Tue Jul 31 21:56:56 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
|
||||
55
gradlew
vendored
55
gradlew
vendored
@@ -1,21 +1,5 @@
|
||||
#!/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
|
||||
@@ -44,7 +28,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='"-Xmx64m" "-Xms64m"'
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -72,7 +56,7 @@ case "`uname`" in
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MSYS* | MINGW* )
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
@@ -82,7 +66,6 @@ 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
|
||||
@@ -126,11 +109,10 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; 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
|
||||
@@ -156,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
i=$((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
|
||||
|
||||
@@ -177,9 +159,14 @@ 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,19 +1,3 @@
|
||||
@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
|
||||
@@ -29,18 +13,15 @@ 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="-Xmx64m" "-Xms64m"
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@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 execute
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -54,7 +35,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -64,14 +45,28 @@ 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 %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
161
hacks.gradle
161
hacks.gradle
@@ -1,161 +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/>.
|
||||
*/
|
||||
|
||||
ext.doHackyStuff = { final Class<?> clazz ->
|
||||
def withExtension = { final File file, final String extension ->
|
||||
def i = file.getName().lastIndexOf('.')
|
||||
def name = file.getName().substring(0, i)
|
||||
return new File(file.getParent(), "$name.$extension")
|
||||
}
|
||||
|
||||
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/patcher/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java#L545
|
||||
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/UserDevPlugin.java#L149
|
||||
// create createMcp2Obf task
|
||||
this.tasks.register('createMcpToObf', clazz)
|
||||
.configure { task ->
|
||||
task.setNotch(true)
|
||||
task.setReverse(true)
|
||||
}
|
||||
afterEvaluate {
|
||||
def createMcp2Obf = this.tasks.getByName('createMcpToObf')
|
||||
def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
|
||||
|
||||
// configure createMcp2Obf task
|
||||
if (createMcp2Obf.getSrg() == null) {
|
||||
createMcp2Obf.setSrg(createMcp2Srg.getSrg())
|
||||
createMcp2Obf.setMappings(createMcp2Srg.getMappings())
|
||||
createMcp2Obf.dependsOn(createMcp2Srg)
|
||||
}
|
||||
|
||||
def createSrgCopyTask = { final Task tsrgTask ->
|
||||
def srgCopyTask = this.tasks.register("${tsrgTask.name}Srg", tsrgTask.getClass())
|
||||
tsrgTask.getDependsOn().forEach({ dep ->
|
||||
srgCopyTask.get().dependsOn(dep)
|
||||
})
|
||||
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/mcp/java/net/minecraftforge/gradle/mcp/task/GenerateSRG.java#L39
|
||||
srgCopyTask.configure { task ->
|
||||
task.setSrg(tsrgTask.getSrg())
|
||||
task.setMappings(tsrgTask.getMappings())
|
||||
// https://github.com/MinecraftForge/SrgUtils/blob/bb2ca35bb8d349a122ef512dedd24f54f7cd0bdf/src/main/java/net/minecraftforge/srgutils/IMappingFile.java#L44
|
||||
task.setFormat('SRG')
|
||||
task.setNotch(tsrgTask.getNotch())
|
||||
task.setReverse(tsrgTask.getReverse())
|
||||
task.setOutput(withExtension(tsrgTask.getOutput(), 'srg'))
|
||||
}
|
||||
return srgCopyTask
|
||||
}
|
||||
def createMcp2ObfSrgCopyTask = createSrgCopyTask(createMcp2Obf)
|
||||
createMcp2Obf.dependsOn(createMcp2ObfSrgCopyTask)
|
||||
def createMcp2SrgSrgCopyTask = createSrgCopyTask(createMcp2Srg)
|
||||
createMcp2Srg.dependsOn(createMcp2SrgSrgCopyTask)
|
||||
|
||||
this.sourceSets.forEach({ set ->
|
||||
def compileTask = this.project.tasks[set.compileJavaTaskName]
|
||||
if (!(compileTask instanceof JavaCompile)) {
|
||||
println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
|
||||
return
|
||||
}
|
||||
compileTask.dependsOn(createMcp2Obf)
|
||||
compileTask.doFirst {
|
||||
// inject legacy notch srg file
|
||||
def createMcp2ObfSrgCopy = createMcp2ObfSrgCopyTask.get()
|
||||
def reobfNotchSrgFileArgument = "-AreobfNotchSrgFile=${createMcp2ObfSrgCopy.output.canonicalPath}"
|
||||
compileTask.options.compilerArgs += reobfNotchSrgFileArgument
|
||||
println("[Baritoe] Injecting compiler argument: ${reobfNotchSrgFileArgument}")
|
||||
|
||||
// inject legacy notch srg out file
|
||||
def outTSrgFileArgument = '-AoutTsrgFile='
|
||||
def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
|
||||
while (compilerArgsIterator.hasNext()) {
|
||||
def compilerArg = compilerArgsIterator.next()
|
||||
if (compilerArg.startsWith(outTSrgFileArgument)) {
|
||||
def argumentFileValue = new File(compilerArg.substring(outTSrgFileArgument.length(), compilerArg.length()))
|
||||
def outNotchSrgFile = withExtension(argumentFileValue, 'notch.srg')
|
||||
def outNotchSrgFileArgument = "-AoutNotchSrgFile=${outNotchSrgFile.canonicalPath}"
|
||||
println("[Baritoe] Injecting compiler argument: ${outNotchSrgFileArgument}")
|
||||
compilerArgsIterator.add(outNotchSrgFileArgument)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// register reobf jars
|
||||
def reobfExtension = this.project.getExtensions().getByName('reobf')
|
||||
if (!reobfExtension) {
|
||||
throw new IllegalStateException("Could not find \"reobf\" extension")
|
||||
}
|
||||
def reobfNotchJar = reobfExtension.create(jar.getName())
|
||||
reobfNotchJar.dependsOn(createMcp2Obf)
|
||||
reobfNotchJar.setMappings(createMcp2Obf.getOutput())
|
||||
|
||||
// even more horrible hack :) for outNotchSrgFile injection
|
||||
reobfNotchJar.doFirst {
|
||||
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/tasks/RenameJar.java#L96
|
||||
def extraMappings = reobfNotchJar.getExtraMappings()
|
||||
println("[Baritoe] Extra mappings: ${extraMappings}")
|
||||
def copy = new ArrayList<>()
|
||||
extraMappings.forEach { extraMapping ->
|
||||
copy.add(withExtension(extraMapping, 'notch.srg'))
|
||||
}
|
||||
println("[Baritoe] New extra mappings: ${copy}")
|
||||
reobfNotchJar.setExtraMappings(copy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: In-complete fg 5.0 port. Currently doesn't handle mixin notch srg mapping hack.
|
||||
//ext.doHackyStuff = { final Class<?> clazz ->
|
||||
// afterEvaluate {
|
||||
// def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
|
||||
// def createMcpToObf = this.tasks.register('createMcpToObf', clazz)
|
||||
// createMcpToObf.configure { task ->
|
||||
// task.setNotch(true)
|
||||
// task.setReverse(true)
|
||||
// task.getSrg().set(createMcp2Srg.getSrg().get())
|
||||
// task.getMappings().set(createMcp2Srg.getMappings().get())
|
||||
// task.dependsOn(createMcp2Srg)
|
||||
// }
|
||||
// reobf {
|
||||
// jar {
|
||||
// dependsOn(createMcpToObf)
|
||||
// getMappings().set(createMcpToObf.get().getOutput().get())
|
||||
// }
|
||||
// }
|
||||
// this.sourceSets.forEach({ set ->
|
||||
// def compileTask = this.project.tasks[set.compileJavaTaskName]
|
||||
// if (!(compileTask instanceof JavaCompile)) {
|
||||
// println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
|
||||
// return
|
||||
// }
|
||||
// compileTask.dependsOn(createMcpToObf)
|
||||
// compileTask.doFirst {
|
||||
// def reobfTSrgFile = '-AreobfTsrgFile='
|
||||
// def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
|
||||
// while (compilerArgsIterator.hasNext()) {
|
||||
// def compilerArg = compilerArgsIterator.next()
|
||||
// if (compilerArg.startsWith(reobfTSrgFile)) {
|
||||
// compilerArgsIterator.remove()
|
||||
// def toInject = "-AreobfTsrgFile=${createMcpToObf.get().output.get().asFile.canonicalPath}"
|
||||
// compilerArgsIterator.add(toInject)
|
||||
// println("[Baritoe] Injecting compiler argument: ${toInject}")
|
||||
// }
|
||||
// }
|
||||
// println("[Baritoe] Compiler arguments: ${compileTask.options.compilerArgs}")
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
12
scripts/proguard.pro
vendored
12
scripts/proguard.pro
vendored
@@ -1,6 +1,5 @@
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes InnerClasses
|
||||
|
||||
-optimizationpasses 5
|
||||
-verbose
|
||||
@@ -23,7 +22,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
|
||||
@@ -42,10 +40,8 @@
|
||||
|
||||
#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.**
|
||||
|
||||
# copy all necessary libraries into tempLibraries to build
|
||||
|
||||
@@ -85,16 +81,16 @@
|
||||
|
||||
-libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar'
|
||||
-libraryjars 'tempLibraries/oshi-core-1.1.jar'
|
||||
-libraryjars 'tempLibraries/patchy-1.3.9.jar'
|
||||
-libraryjars 'tempLibraries/patchy-1.1.jar'
|
||||
-libraryjars 'tempLibraries/platform-3.4.0.jar'
|
||||
-libraryjars 'tempLibraries/realms-1.10.22.jar'
|
||||
-libraryjars 'tempLibraries/soundsystem-20120107.jar'
|
||||
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
||||
|
||||
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
||||
-libraryjars 'tempLibraries/launchwrapper-1.12.jar'
|
||||
-libraryjars 'tempLibraries/launchwrapper-1.11.jar' # TODO why does only 1.11.jar exist?
|
||||
|
||||
|
||||
-libraryjars 'tempLibraries/nether-pathfinder-.jar'
|
||||
|
||||
|
||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||
@@ -385,5 +381,3 @@
|
||||
public java.lang.String substring(int);
|
||||
public java.lang.String substring(int,int);
|
||||
}
|
||||
|
||||
-printmapping mapping.txt
|
||||
|
||||
BIN
scripts/xvfb_1.16.4-1_amd64.deb
Normal file
BIN
scripts/xvfb_1.16.4-1_amd64.deb
Normal file
Binary file not shown.
@@ -35,7 +35,7 @@ public final class BaritoneAPI {
|
||||
|
||||
static {
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME);
|
||||
SettingsUtil.readAndApply(settings);
|
||||
|
||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||
|
||||
@@ -17,17 +17,16 @@
|
||||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.behavior.IElytraBehavior;
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.cache.IWorldProvider;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.*;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -41,12 +40,6 @@ public interface IBaritone {
|
||||
*/
|
||||
IPathingBehavior getPathingBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link IElytraBehavior} instance
|
||||
* @see IElytraBehavior
|
||||
*/
|
||||
IElytraBehavior getElytraBehavior();
|
||||
|
||||
/**
|
||||
* @return The {@link ILookBehavior} instance
|
||||
* @see ILookBehavior
|
||||
|
||||
@@ -21,9 +21,7 @@ import baritone.api.cache.IWorldScanner;
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.api.schematic.ISchematicSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -54,13 +52,15 @@ public interface IBaritoneProvider {
|
||||
List<IBaritone> getAllBaritones();
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}.
|
||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
||||
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
|
||||
* {@code bot-system} is merged into {@code master}.
|
||||
*
|
||||
* @param player The player
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||
for (IBaritone baritone : this.getAllBaritones()) {
|
||||
for (IBaritone baritone : getAllBaritones()) {
|
||||
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
||||
return baritone;
|
||||
}
|
||||
@@ -68,55 +68,6 @@ public interface IBaritoneProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance for a given {@link Minecraft}.
|
||||
*
|
||||
* @param minecraft The minecraft
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForMinecraft(Minecraft minecraft) {
|
||||
for (IBaritone baritone : this.getAllBaritones()) {
|
||||
if (Objects.equals(minecraft, baritone.getPlayerContext().minecraft())) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@link IBaritone} instance for the player with the specified connection.
|
||||
*
|
||||
* @param connection The connection
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
default IBaritone getBaritoneForConnection(NetHandlerPlayClient connection) {
|
||||
for (IBaritone baritone : this.getAllBaritones()) {
|
||||
final EntityPlayerSP player = baritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == connection) {
|
||||
return baritone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and registers a new {@link IBaritone} instance using the specified {@link Minecraft}. The existing
|
||||
* instance is returned if already registered.
|
||||
*
|
||||
* @param minecraft The minecraft
|
||||
* @return The {@link IBaritone} instance
|
||||
*/
|
||||
IBaritone createBaritone(Minecraft minecraft);
|
||||
|
||||
/**
|
||||
* Destroys and removes the specified {@link IBaritone} instance. If the specified instance is the
|
||||
* {@link #getPrimaryBaritone() primary baritone}, this operation has no effect and will return {@code false}.
|
||||
*
|
||||
* @param baritone The baritone instance to remove
|
||||
* @return Whether the baritone instance was removed
|
||||
*/
|
||||
boolean destroyBaritone(IBaritone baritone);
|
||||
|
||||
/**
|
||||
* Returns the {@link IWorldScanner} instance. This is not a type returned by
|
||||
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.utils.NotificationHelper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.TypeUtils;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -29,17 +27,11 @@ import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -54,11 +46,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
|
||||
*/
|
||||
@@ -74,16 +61,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> allowInventory = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Wait this many ticks between InventoryBehavior moving inventory items
|
||||
*/
|
||||
public final Setting<Integer> ticksBetweenInventoryMoves = new Setting<>(1);
|
||||
|
||||
/**
|
||||
* Come to a halt before doing any inventory moves. Intended for anticheat such as 2b2t
|
||||
*/
|
||||
public final Setting<Boolean> inventoryMoveOnlyIfStationary = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
|
||||
* <p>
|
||||
@@ -93,9 +70,9 @@ public final class Settings {
|
||||
public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Automatically select the best available tool
|
||||
* If this setting is on, no auto tool will occur at all, not at calculation time nor execution time
|
||||
*/
|
||||
public final Setting<Boolean> autoTool = new Setting<>(true);
|
||||
public final Setting<Boolean> disableAutoTool = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* It doesn't actually take twenty ticks to place a block, this cost is so high
|
||||
@@ -122,13 +99,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.
|
||||
@@ -138,8 +108,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);
|
||||
|
||||
@@ -219,13 +187,6 @@ 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
|
||||
));
|
||||
|
||||
/**
|
||||
* blocks that baritone shouldn't break, but can if it needs to.
|
||||
*/
|
||||
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
|
||||
Blocks.CRAFTING_TABLE,
|
||||
Blocks.FURNACE,
|
||||
@@ -236,11 +197,6 @@ public final class Settings {
|
||||
Blocks.WALL_SIGN
|
||||
)));
|
||||
|
||||
/**
|
||||
* this multiplies the break speed, if set above 1 it's "encourage breaking" instead
|
||||
*/
|
||||
public final Setting<Double> avoidBreakingMultiplier = new Setting<>(.1);
|
||||
|
||||
/**
|
||||
* A list of blocks to be treated as if they're air.
|
||||
* <p>
|
||||
@@ -250,40 +206,6 @@ public final class Settings {
|
||||
|
||||
)));
|
||||
|
||||
/**
|
||||
* A list of blocks to be treated as correct.
|
||||
* <p>
|
||||
* If a schematic asks for any block on this list at a certain position, it will be treated as correct, regardless of what it currently is.
|
||||
*/
|
||||
public final Setting<List<Block>> buildSkipBlocks = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||
|
||||
)));
|
||||
|
||||
/**
|
||||
* 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<>());
|
||||
|
||||
/**
|
||||
* 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<>());
|
||||
|
||||
/**
|
||||
* A list of blocks to become air
|
||||
* <p>
|
||||
@@ -298,17 +220,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> buildIgnoreExisting = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* If this is true, the builder will ignore directionality of certain blocks like glazed terracotta.
|
||||
*/
|
||||
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>
|
||||
@@ -431,9 +342,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);
|
||||
|
||||
/**
|
||||
@@ -443,9 +351,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);
|
||||
|
||||
/**
|
||||
@@ -596,17 +501,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.
|
||||
*/
|
||||
@@ -624,11 +518,11 @@ public final class Settings {
|
||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The chunk packer queue can never grow to larger than this, if it does, the oldest chunks are discarded
|
||||
* Remember the contents of containers (chests, echests, furnaces)
|
||||
* <p>
|
||||
* The newest chunks are kept, so that if you're moving in a straight line quickly then stop, your immediate render distance is still included
|
||||
* Really buggy since the packet stuff is multithreaded badly thanks to brady
|
||||
*/
|
||||
public final Setting<Integer> chunkPackerQueueMaxSize = new Setting<>(2000);
|
||||
public final Setting<Boolean> containerMemory = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Fill in blocks behind you
|
||||
@@ -678,12 +572,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> renderGoal = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render the goal as a sick animated thingy instead of just a box
|
||||
* (also controls animation of GoalXZ if {@link #renderGoalXZBeacon} is enabled)
|
||||
*/
|
||||
public final Setting<Boolean> renderGoalAnimated = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Render selection boxes
|
||||
*/
|
||||
@@ -731,28 +619,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> freeLook = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Break and place blocks without having to force the client-sided rotations. Requires {@link #freeLook}.
|
||||
*/
|
||||
public final Setting<Boolean> blockFreeLook = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Automatically elytra fly without having to force the client-sided rotations. Requires {@link #freeLook}.
|
||||
*/
|
||||
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Forces the client-sided rotations to an average of the last 10 ticks of server-sided rotations.
|
||||
* Requires {@link #freeLook}.
|
||||
*/
|
||||
public final Setting<Boolean> smoothLook = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When true, the player will remain with its existing look direction as often as possible.
|
||||
* Although, in some cases this can get it stuck, hence this setting to disable that behavior.
|
||||
*/
|
||||
public final Setting<Boolean> remainWithExistingLookDirection = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
|
||||
* <p>
|
||||
@@ -775,7 +641,7 @@ public final class Settings {
|
||||
|
||||
/**
|
||||
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
|
||||
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this search to the whole "vein"; MineProcess does not.
|
||||
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not.
|
||||
* This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break)
|
||||
* Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
|
||||
*/
|
||||
@@ -830,16 +696,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> censorRanCommands = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Stop using tools just before they are going to break.
|
||||
*/
|
||||
public final Setting<Boolean> itemSaver = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Durability to leave on the tool when using itemSaver
|
||||
*/
|
||||
public final Setting<Integer> itemSaverThreshold = new Setting<>(10);
|
||||
|
||||
/**
|
||||
* Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk
|
||||
* touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
|
||||
@@ -887,11 +743,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
|
||||
|
||||
/**
|
||||
* Sets the maximum y level to mine ores at.
|
||||
*/
|
||||
public final Setting<Integer> maxYLevelWhileMining = new Setting<>(255); // 1.17+ defaults to maximum possible world height
|
||||
|
||||
/**
|
||||
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
|
||||
*/
|
||||
@@ -905,7 +756,7 @@ public final class Settings {
|
||||
public final Setting<Integer> allowOnlyExposedOresDistance = new Setting<>(1);
|
||||
|
||||
/**
|
||||
* When GetToBlock or non-legit Mine doesn't know any locations for the desired block, explore randomly instead of giving up.
|
||||
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
|
||||
*/
|
||||
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
||||
|
||||
@@ -957,11 +808,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> layerOrder = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* How high should the individual layers be?
|
||||
*/
|
||||
public final Setting<Integer> layerHeight = new Setting<>(1);
|
||||
|
||||
/**
|
||||
* Start building the schematic at a specific layer.
|
||||
* Can help on larger builds when schematic wants to break things its already built
|
||||
@@ -973,11 +819,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> skipFailedLayers = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Only build the selected part of schematics
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -988,13 +829,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> buildRepeatCount = new Setting<>(-1);
|
||||
|
||||
/**
|
||||
* Don't notify schematics that they are moved.
|
||||
* e.g. replacing will replace the same spots for every repetition
|
||||
* Mainly for backward compatibility.
|
||||
*/
|
||||
public final Setting<Boolean> buildRepeatSneaky = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Allow standing above a block while mining it, in BuilderProcess
|
||||
* <p>
|
||||
@@ -1103,7 +937,6 @@ public final class Settings {
|
||||
* Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit"
|
||||
* where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player
|
||||
* couldn't. If you don't want it to look like you're X-Raying, turn this on
|
||||
* This will always explore, regardless of exploreForBlocks
|
||||
*/
|
||||
public final Setting<Boolean> legitMine = new Setting<>(false);
|
||||
|
||||
@@ -1188,24 +1021,7 @@ public final class Settings {
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
@JavaOnly
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(msg -> Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(msg));
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will send a desktop notification. This function can be added to
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
@JavaOnly
|
||||
public final Setting<BiConsumer<String, Boolean>> notifier = new Setting<>(NotificationHelper::notify);
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will show a toast. This function can be added to
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
@JavaOnly
|
||||
public final Setting<BiConsumer<ITextComponent, ITextComponent>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
|
||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||
|
||||
/**
|
||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||
@@ -1297,11 +1113,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Use sword to mine.
|
||||
*/
|
||||
public final Setting<Boolean> useSwordToMine = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Desktop notifications
|
||||
*/
|
||||
@@ -1332,89 +1143,6 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The number of ticks of elytra movement to simulate while firework boost is not active. Higher values are
|
||||
* computationally more expensive.
|
||||
*/
|
||||
public final Setting<Integer> elytraSimulationTicks = new Setting<>(20);
|
||||
|
||||
/**
|
||||
* The maximum allowed deviation in pitch from a direct line-of-sight to the flight target. Higher values are
|
||||
* computationally more expensive.
|
||||
*/
|
||||
public final Setting<Integer> elytraPitchRange = new Setting<>(25);
|
||||
|
||||
/**
|
||||
* The minimum speed that the player can drop to (in blocks/tick) before a firework is automatically deployed.
|
||||
*/
|
||||
public final Setting<Double> elytraFireworkSpeed = new Setting<>(0.6);
|
||||
|
||||
/**
|
||||
* The delay after the player's position is set-back by the server that a firework may be automatically deployed.
|
||||
* Value is in ticks.
|
||||
*/
|
||||
public final Setting<Integer> elytraFireworkSetbackUseDelay = new Setting<>(15);
|
||||
|
||||
/**
|
||||
* The minimum padding value that is added to the player's hitbox when considering which point to fly to on the
|
||||
* path. High values can result in points not being considered which are otherwise safe to fly to. Low values can
|
||||
* result in flight paths which are extremely tight, and there's the possibility of crashing due to getting too low
|
||||
* to the ground.
|
||||
*/
|
||||
public final Setting<Double> elytraMinimumAvoidance = new Setting<>(0.2);
|
||||
|
||||
/**
|
||||
* If enabled, avoids using fireworks when descending along the flight path.
|
||||
*/
|
||||
public final Setting<Boolean> conserveFireworks = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Renders the raytraces that are performed by the elytra fly calculation.
|
||||
*/
|
||||
public final Setting<Boolean> renderRaytraces = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Renders the raytraces that are used in the hitbox part of the elytra fly calculation.
|
||||
* Requires {@link #renderRaytraces}.
|
||||
*/
|
||||
public final Setting<Boolean> renderHitboxRaytraces = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Renders the best elytra flight path that was simulated each tick.
|
||||
*/
|
||||
public final Setting<Boolean> renderElytraSimulation = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Automatically path to and jump off of ledges to initiate elytra flight when grounded.
|
||||
*/
|
||||
public final Setting<Boolean> elytraAutoJump = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* The seed used to generate chunks for long distance elytra path-finding in the nether.
|
||||
* Defaults to 2b2t's nether seed.
|
||||
*/
|
||||
public final Setting<Long> elytraNetherSeed = new Setting<>(146008555100680L);
|
||||
|
||||
/**
|
||||
* Automatically swap the current elytra with a new one when the durability gets too low
|
||||
*/
|
||||
public final Setting<Boolean> elytraAutoSwap = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* The minimum durability an elytra can have before being swapped
|
||||
*/
|
||||
public final Setting<Integer> elytraMinimumDurability = new Setting<>(5);
|
||||
|
||||
/**
|
||||
* Time between culling far away chunks from the nether pathfinder chunk cache
|
||||
*/
|
||||
public final Setting<Long> elytraTimeBetweenCacheCullSecs = new Setting<>(TimeUnit.MINUTES.toSeconds(3));
|
||||
|
||||
/**
|
||||
* Maximum distance chunks can be before being culled from the nether pathfinder chunk cache
|
||||
*/
|
||||
public final Setting<Integer> elytraCacheCullDistance = new Setting<>(5000);
|
||||
|
||||
/**
|
||||
* A map of lowercase setting field names to their respective setting
|
||||
*/
|
||||
@@ -1432,7 +1160,6 @@ public final class Settings {
|
||||
public T value;
|
||||
public final T defaultValue;
|
||||
private String name;
|
||||
private boolean javaOnly;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Setting(T value) {
|
||||
@@ -1441,7 +1168,6 @@ public final class Settings {
|
||||
}
|
||||
this.value = value;
|
||||
this.defaultValue = value;
|
||||
this.javaOnly = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1478,25 +1204,8 @@ public final class Settings {
|
||||
public final Type getType() {
|
||||
return settingTypes.get(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should always be the same as whether the setting can be parsed from or serialized to a string; in other
|
||||
* words, the only way to modify it is by writing to {@link #value} programatically.
|
||||
*
|
||||
* @return {@code true} if the setting can not be set or read by the user
|
||||
*/
|
||||
public boolean isJavaOnly() {
|
||||
return javaOnly;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a {@link Setting} field as being {@link Setting#isJavaOnly() Java-only}
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
private @interface JavaOnly {}
|
||||
|
||||
// here be dragons
|
||||
|
||||
Settings() {
|
||||
@@ -1512,7 +1221,6 @@ public final class Settings {
|
||||
Setting<?> setting = (Setting<?>) field.get(this);
|
||||
String name = field.getName();
|
||||
setting.name = name;
|
||||
setting.javaOnly = field.isAnnotationPresent(JavaOnly.class);
|
||||
name = name.toLowerCase();
|
||||
if (tmpByName.containsKey(name)) {
|
||||
throw new IllegalStateException("Duplicate setting name");
|
||||
|
||||
@@ -27,10 +27,4 @@ import baritone.api.event.listener.IGameEventListener;
|
||||
* @see IGameEventListener
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IBehavior extends AbstractGameEventListener {
|
||||
|
||||
/**
|
||||
* Called after Baritone's initialization is complete
|
||||
*/
|
||||
default void onLoad() {}
|
||||
}
|
||||
public interface IBehavior extends AbstractGameEventListener {}
|
||||
|
||||
@@ -1,54 +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.api.behavior;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface IElytraBehavior extends IBehavior {
|
||||
|
||||
/**
|
||||
* Marks the nether pathfinder context to be reset when it is safe to do so. Because this operation is not
|
||||
* immediate, a {@link CompletableFuture} is returned that will complete after the context has been reset.
|
||||
*
|
||||
* @return A {@link CompletableFuture} that is completed when the context is reset
|
||||
*/
|
||||
CompletableFuture<Void> resetContext();
|
||||
|
||||
void repackChunks();
|
||||
|
||||
void pathTo(BlockPos destination);
|
||||
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the current {@link IElytraBehavior} is actively pathing.
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
/**
|
||||
* @return {@code true} if the native library loaded and elytra is actually usable
|
||||
*/
|
||||
boolean isLoaded();
|
||||
|
||||
/*
|
||||
* FOR INTERNAL USE ONLY. MAY BE REMOVED AT ANY TIME.
|
||||
*/
|
||||
boolean isSafeToCancel();
|
||||
}
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.api.behavior;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.look.IAimProcessor;
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
/**
|
||||
@@ -28,23 +26,14 @@ import baritone.api.utils.Rotation;
|
||||
public interface ILookBehavior extends IBehavior {
|
||||
|
||||
/**
|
||||
* Updates the current {@link ILookBehavior} target to target the specified rotations on the next tick. If any sort
|
||||
* of block interaction is required, {@code blockInteract} should be {@code true}. It is not guaranteed that the
|
||||
* rotations set by the caller will be the exact rotations expressed by the client (This is due to settings like
|
||||
* {@link Settings#randomLooking}). If the rotations produced by this behavior are required, then the
|
||||
* {@link #getAimProcessor() aim processor} should be used.
|
||||
* Updates the current {@link ILookBehavior} target to target
|
||||
* the specified rotations on the next tick. If force is {@code true},
|
||||
* then freeLook will be overriden and angles will be set regardless.
|
||||
* If any sort of block interaction is required, force should be {@code true},
|
||||
* otherwise, it should be {@code false};
|
||||
*
|
||||
* @param rotation The target rotations
|
||||
* @param blockInteract Whether the target rotations are needed for a block interaction
|
||||
* @param rotation The target rotations
|
||||
* @param force Whether or not to "force" the rotations
|
||||
*/
|
||||
void updateTarget(Rotation rotation, boolean blockInteract);
|
||||
|
||||
/**
|
||||
* The aim processor instance for this {@link ILookBehavior}, which is responsible for applying additional,
|
||||
* deterministic transformations to the target rotation set by {@link #updateTarget}.
|
||||
*
|
||||
* @return The aim processor
|
||||
* @see IAimProcessor#fork
|
||||
*/
|
||||
IAimProcessor getAimProcessor();
|
||||
void updateTarget(Rotation rotation, boolean force);
|
||||
}
|
||||
|
||||
@@ -58,15 +58,6 @@ public interface IPathingBehavior extends IBehavior {
|
||||
return Optional.of(current.getPath().ticksRemainingFrom(start));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the estimated remaining ticks to the current goal.
|
||||
* Given that the return type is an optional, {@link Optional#empty()}
|
||||
* will be returned in the case that there is no current goal.
|
||||
*
|
||||
* @return The estimated remaining ticks to the current goal.
|
||||
*/
|
||||
Optional<Double> estimatedTicksToGoal();
|
||||
|
||||
/**
|
||||
* @return The current pathing goal
|
||||
*/
|
||||
|
||||
@@ -1,45 +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.api.behavior.look;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public interface IAimProcessor {
|
||||
|
||||
/**
|
||||
* Returns the actual rotation that will be used when the desired rotation is requested. The returned rotation
|
||||
* always reflects what would happen in the upcoming tick. In other words, it is a pure function, and no internal
|
||||
* state changes. If simulation of the rotation states beyond the next tick is required, then a
|
||||
* {@link IAimProcessor#fork fork} should be created.
|
||||
*
|
||||
* @param desired The desired rotation to set
|
||||
* @return The actual rotation
|
||||
*/
|
||||
Rotation peekRotation(Rotation desired);
|
||||
|
||||
/**
|
||||
* Returns a copy of this {@link IAimProcessor} which has its own internal state and is manually tickable.
|
||||
*
|
||||
* @return The forked processor
|
||||
* @see ITickableAimProcessor
|
||||
*/
|
||||
ITickableAimProcessor fork();
|
||||
}
|
||||
@@ -1,47 +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.api.behavior.look;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public interface ITickableAimProcessor extends IAimProcessor {
|
||||
|
||||
/**
|
||||
* Advances the internal state of this aim processor by a single tick.
|
||||
*/
|
||||
void tick();
|
||||
|
||||
/**
|
||||
* Calls {@link #tick()} the specified number of times.
|
||||
*
|
||||
* @param ticks The number of calls
|
||||
*/
|
||||
void advance(int ticks);
|
||||
|
||||
/**
|
||||
* Returns the actual rotation as provided by {@link #peekRotation(Rotation)}, and then automatically advances the
|
||||
* internal state by one {@link #tick() tick}.
|
||||
*
|
||||
* @param rotation The desired rotation to set
|
||||
* @return The actual rotation
|
||||
*/
|
||||
Rotation nextRotation(Rotation rotation);
|
||||
}
|
||||
@@ -15,29 +15,30 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package fi.dy.masa.litematica.schematic.placement;
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public class SchematicPlacementUnloaded {
|
||||
protected String name = "?";
|
||||
@Nullable
|
||||
protected File schematicFile;
|
||||
protected BlockPos origin = BlockPos.ORIGIN;
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public interface IContainerMemory {
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
/**
|
||||
* Gets a remembered inventory by its block position.
|
||||
*
|
||||
* @param pos The position of the container block
|
||||
* @return The remembered inventory
|
||||
*/
|
||||
IRememberedInventory getInventoryByPos(BlockPos pos);
|
||||
|
||||
@Nullable
|
||||
public File getSchematicFile() {
|
||||
return this.schematicFile;
|
||||
}
|
||||
|
||||
public BlockPos getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
/**
|
||||
* Gets the map of all block positions to their remembered inventories.
|
||||
*
|
||||
* @return Map of block positions to their respective remembered inventories
|
||||
*/
|
||||
Map<BlockPos, IRememberedInventory> getRememberedInventories();
|
||||
}
|
||||
@@ -15,13 +15,25 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
package baritone.api.cache;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface BooleanBinaryOperator {
|
||||
public interface IRememberedInventory {
|
||||
|
||||
boolean applyAsBoolean(boolean a, boolean b);
|
||||
/**
|
||||
* @return The contents of this inventory
|
||||
*/
|
||||
List<ItemStack> getContents();
|
||||
|
||||
/**
|
||||
* @return The number of slots in this inventory
|
||||
*/
|
||||
int getSize();
|
||||
}
|
||||
@@ -37,4 +37,9 @@ public interface IWorldData {
|
||||
*/
|
||||
IWaypointCollection getWaypoints();
|
||||
|
||||
/**
|
||||
* @return The {@link IContainerMemory} instance
|
||||
* @see IContainerMemory
|
||||
*/
|
||||
IContainerMemory getContainerMemory();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.api.cache;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/24/2018
|
||||
@@ -31,11 +29,4 @@ public interface IWorldProvider {
|
||||
* @return The current world data
|
||||
*/
|
||||
IWorldData getCurrentWorld();
|
||||
|
||||
default void ifWorldLoaded(Consumer<IWorldData> callback) {
|
||||
final IWorldData currentWorld = this.getCurrentWorld();
|
||||
if (currentWorld != null) {
|
||||
callback.accept(currentWorld);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public interface IWorldScanner {
|
||||
* Queues the chunks in a square formation around the specified player, using the specified
|
||||
* range, which represents 1/2 the square's dimensions, where the player is in the center.
|
||||
*
|
||||
* @param ctx The player, describing the origin
|
||||
* @param ctx The player, describing the origin
|
||||
* @param range The range to repack
|
||||
* @return The amount of chunks successfully queued for repacking
|
||||
*/
|
||||
|
||||
@@ -34,8 +34,9 @@ import java.util.stream.Stream;
|
||||
* So basically, you should use it because it provides a small amount of boilerplate,
|
||||
* but you're not forced to use it.
|
||||
*
|
||||
* @author LoganDark
|
||||
* @see ICommand
|
||||
*
|
||||
* @author LoganDark
|
||||
*/
|
||||
public abstract class Command implements ICommand {
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public interface IArgParserManager {
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
@@ -25,8 +27,6 @@ import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Deque;
|
||||
@@ -223,7 +223,7 @@ public interface IArgConsumer {
|
||||
* @param type The type to peek as
|
||||
* @param index The index to peek
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class)
|
||||
* @see #peekAsOrDefault(Class, Object, int)
|
||||
@@ -240,7 +240,7 @@ public interface IArgConsumer {
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #peekAs(Class, int)
|
||||
* @see #peekAsOrDefault(Class, Object)
|
||||
@@ -458,7 +458,7 @@ public interface IArgConsumer {
|
||||
*
|
||||
* @param type The type to peek as
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser
|
||||
* @see #get()
|
||||
* @see #getAsOrDefault(Class, Object)
|
||||
|
||||
@@ -87,7 +87,7 @@ public interface ICommandArgument {
|
||||
*
|
||||
* @param type The class to parse this argument into
|
||||
* @return An instance of the specified type
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T, S> T getAs(Class<T> type, Class<S> stateType, S state) throws CommandInvalidTypeException;
|
||||
|
||||
|
||||
@@ -17,23 +17,17 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum BlockById implements IDatatypeFor<Block> {
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* Matches (domain:)?name? where domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ respectively.
|
||||
*/
|
||||
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?[a-z0-9/_.-]*");
|
||||
|
||||
@Override
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
@@ -46,19 +40,13 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
String arg = ctx.getConsumer().getString();
|
||||
|
||||
if (!PATTERN.matcher(arg).matches()) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
Block.REGISTRY.getKeys()
|
||||
.stream()
|
||||
.map(Object::toString)
|
||||
)
|
||||
.filterPrefixNamespaced(arg)
|
||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -34,7 +34,7 @@ public enum EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
||||
Class<? extends Entity> entity;
|
||||
try {
|
||||
entity = EntityList.REGISTRY.getObject(id);
|
||||
} catch (NoSuchFieldError e) {
|
||||
} catch(NoSuchFieldError e) {
|
||||
// Forge removes EntityList.REGISTRY field and provides the getClass method as a replacement
|
||||
// See https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/patches/minecraft/net/minecraft/entity/EntityList.java.patch
|
||||
try {
|
||||
|
||||
@@ -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 baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForAxis implements IDatatypeFor<EnumFacing.Axis> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public EnumFacing.Axis get(IDatatypeContext ctx) throws CommandException {
|
||||
return EnumFacing.Axis.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
return new TabCompleteHelper()
|
||||
.append(Stream.of(EnumFacing.Axis.values())
|
||||
.map(EnumFacing.Axis::getName).map(String::toLowerCase))
|
||||
.filterPrefix(ctx.getConsumer().getString())
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
@@ -17,137 +17,21 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* Matches (domain:)?name([(property=value)*])? but the input can be truncated at any position.
|
||||
* domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ because that's what mc 1.13+ accepts.
|
||||
* property and value use the same format as domain.
|
||||
*/
|
||||
// Good luck reading this.
|
||||
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?(?:[a-z0-9/_.-]+(?:\\[(?:(?:[a-z0-9_.-]+=[a-z0-9_.-]+,)*(?:[a-z0-9_.-]+(?:=(?:[a-z0-9_.-]+(?:\\])?)?)?)?|\\])?)?)?");
|
||||
|
||||
@Override
|
||||
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
|
||||
return new BlockOptionalMeta(ctx.getConsumer().getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||
String arg = ctx.getConsumer().peekString();
|
||||
|
||||
if (!PATTERN.matcher(arg).matches()) {
|
||||
// Invalid format; we can't complete this.
|
||||
ctx.getConsumer().getString();
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
if (arg.endsWith("]")) {
|
||||
// We are already done.
|
||||
ctx.getConsumer().getString();
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
if (!arg.contains("[")) {
|
||||
// no properties so we are completing the block id
|
||||
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
|
||||
}
|
||||
|
||||
ctx.getConsumer().getString();
|
||||
|
||||
// destructuring assignment? Please?
|
||||
String blockId, properties;
|
||||
{
|
||||
String[] parts = splitLast(arg, '[');
|
||||
blockId = parts[0];
|
||||
properties = parts[1];
|
||||
}
|
||||
|
||||
Block block = Block.REGISTRY.getObject(new ResourceLocation(blockId));
|
||||
if (block == null) {
|
||||
// This block doesn't exist so there's no properties to complete.
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
String leadingProperties, lastProperty;
|
||||
{
|
||||
String[] parts = splitLast(properties, ',');
|
||||
leadingProperties = parts[0];
|
||||
lastProperty = parts[1];
|
||||
}
|
||||
|
||||
if (!lastProperty.contains("=")) {
|
||||
// The last property-value pair doesn't have a value yet so we are completing its name
|
||||
Set<String> usedProps = Stream.of(leadingProperties.split(","))
|
||||
.map(pair -> pair.split("=")[0])
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
String prefix = arg.substring(0, arg.length() - lastProperty.length());
|
||||
return new TabCompleteHelper()
|
||||
.append(
|
||||
block.getBlockState()
|
||||
.getProperties()
|
||||
.stream()
|
||||
.map(IProperty::getName)
|
||||
)
|
||||
.filter(prop -> !usedProps.contains(prop))
|
||||
.filterPrefix(lastProperty)
|
||||
.sortAlphabetically()
|
||||
.map(prop -> prefix + prop)
|
||||
.stream();
|
||||
}
|
||||
|
||||
String lastName, lastValue;
|
||||
{
|
||||
String[] parts = splitLast(lastProperty, '=');
|
||||
lastName = parts[0];
|
||||
lastValue = parts[1];
|
||||
}
|
||||
|
||||
// We are completing the value of a property
|
||||
String prefix = arg.substring(0, arg.length() - lastValue.length());
|
||||
|
||||
IProperty<?> property = block.getBlockState().getProperty(lastName);
|
||||
if (property == null) {
|
||||
// The property does not exist so there's no values to complete
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
return new TabCompleteHelper()
|
||||
.append(getValues(property))
|
||||
.filterPrefix(lastValue)
|
||||
.sortAlphabetically()
|
||||
.map(val -> prefix + val)
|
||||
.stream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns exactly two strings.
|
||||
* If the separator is not found the FIRST returned string is empty.
|
||||
*/
|
||||
private static String[] splitLast(String string, char chr) {
|
||||
int idx = string.lastIndexOf(chr);
|
||||
if (idx == -1) {
|
||||
return new String[]{"", string};
|
||||
}
|
||||
return new String[]{string.substring(0, idx), string.substring(idx + 1)};
|
||||
}
|
||||
|
||||
// this shouldn't need to be a separate method?
|
||||
private static <T extends Comparable<T>> Stream<String> getValues(IProperty<T> property) {
|
||||
return property.getAllowedValues().stream().map(property::getName);
|
||||
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -20,8 +20,8 @@ package baritone.api.command.datatypes;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -24,8 +24,9 @@ import baritone.api.command.argument.IArgConsumer;
|
||||
* Provides an {@link IDatatype} with contextual information so
|
||||
* that it can perform the desired operation on the target level.
|
||||
*
|
||||
* @author Brady
|
||||
* @see IDatatype
|
||||
*
|
||||
* @author Brady
|
||||
* @since 9/26/2019
|
||||
*/
|
||||
public interface IDatatypeContext {
|
||||
|
||||
@@ -34,10 +34,11 @@ public interface IDatatypeFor<T> extends IDatatype {
|
||||
* if the expected input does not conform to a parseable value. As far as a {@link CommandException} being
|
||||
* thrown is concerned, see the note below for specifics.
|
||||
*
|
||||
* @see IDatatypeContext
|
||||
*
|
||||
* @param ctx The context
|
||||
* @return The parsed data-type
|
||||
* @throws CommandException If there was an issue parsing using another type or arguments could not be polled.
|
||||
* @see IDatatypeContext
|
||||
*/
|
||||
T get(IDatatypeContext ctx) throws CommandException;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,8 +19,6 @@ package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.utils.Helper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -85,23 +83,18 @@ 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)))
|
||||
.filter(s -> !s.contains(" "));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static File gameDir() {
|
||||
return gameDir(Helper.mc);
|
||||
}
|
||||
|
||||
public static File gameDir(Minecraft mc) {
|
||||
File gameDir = mc.gameDir.getAbsoluteFile();
|
||||
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
|
||||
if (gameDir.getName().equals(".")) {
|
||||
return gameDir.getParentFile();
|
||||
}
|
||||
|
||||
@@ -18,13 +18,16 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -19,6 +19,7 @@ package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.command.ICommand;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +37,10 @@ public class CommandUnhandledException extends RuntimeException implements IComm
|
||||
|
||||
@Override
|
||||
public void handle(ICommand command, List<ICommandArgument> args) {
|
||||
HELPER.logUnhandledException(this);
|
||||
HELPER.logDirect("An unhandled exception occurred. " +
|
||||
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
|
||||
TextFormatting.RED);
|
||||
|
||||
this.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ import static baritone.api.utils.Helper.HELPER;
|
||||
public interface ICommandException {
|
||||
|
||||
/**
|
||||
* @return The exception details
|
||||
* @see Exception#getMessage()
|
||||
* @return The exception details
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
@@ -19,10 +19,10 @@ package baritone.api.command.helpers;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -236,6 +236,7 @@ public class TabCompleteHelper {
|
||||
* Appends every command in the specified {@link ICommandManager} to this {@link TabCompleteHelper}
|
||||
*
|
||||
* @param manager A command manager
|
||||
*
|
||||
* @return This {@link TabCompleteHelper}
|
||||
*/
|
||||
public TabCompleteHelper addCommands(ICommandManager manager) {
|
||||
@@ -253,8 +254,8 @@ public class TabCompleteHelper {
|
||||
public TabCompleteHelper addSettings() {
|
||||
return append(
|
||||
BaritoneAPI.getSettings().allSettings.stream()
|
||||
.filter(s -> !s.isJavaOnly())
|
||||
.map(Settings.Setting::getName)
|
||||
.filter(s -> !s.equalsIgnoreCase("logger"))
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,49 +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.api.event.events;
|
||||
|
||||
import baritone.api.utils.Pair;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public final class BlockChangeEvent {
|
||||
|
||||
private final ChunkPos chunk;
|
||||
private final List<Pair<BlockPos, IBlockState>> blocks;
|
||||
|
||||
public BlockChangeEvent(ChunkPos pos, List<Pair<BlockPos, IBlockState>> blocks) {
|
||||
this.chunk = pos;
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos() {
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
public List<Pair<BlockPos, IBlockState>> getBlocks() {
|
||||
return this.blocks;
|
||||
}
|
||||
}
|
||||
@@ -57,38 +57,31 @@ public final class ChunkEvent {
|
||||
/**
|
||||
* @return The state of the event
|
||||
*/
|
||||
public EventState getState() {
|
||||
public final EventState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The type of chunk event that occurred;
|
||||
*/
|
||||
public Type getType() {
|
||||
public final Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Chunk X position.
|
||||
*/
|
||||
public int getX() {
|
||||
public final int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Chunk Z position.
|
||||
*/
|
||||
public int getZ() {
|
||||
public final int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the event was fired after a chunk population
|
||||
*/
|
||||
public boolean isPostPopulate() {
|
||||
return this.state == EventState.POST && this.type.isPopulate();
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
@@ -113,10 +106,6 @@ public final class ChunkEvent {
|
||||
* <p>
|
||||
* And it's a partial chunk
|
||||
*/
|
||||
POPULATE_PARTIAL;
|
||||
|
||||
public final boolean isPopulate() {
|
||||
return this == POPULATE_FULL || this == POPULATE_PARTIAL;
|
||||
}
|
||||
POPULATE_PARTIAL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.utils.Rotation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -32,27 +31,14 @@ public final class RotationMoveEvent {
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
private final Rotation original;
|
||||
|
||||
/**
|
||||
* The yaw rotation
|
||||
*/
|
||||
private float yaw;
|
||||
|
||||
/**
|
||||
* The pitch rotation
|
||||
*/
|
||||
private float pitch;
|
||||
|
||||
public RotationMoveEvent(Type type, float yaw, float pitch) {
|
||||
public RotationMoveEvent(Type type, float yaw) {
|
||||
this.type = type;
|
||||
this.original = new Rotation(yaw, pitch);
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public Rotation getOriginal() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,37 +46,21 @@ public final class RotationMoveEvent {
|
||||
*
|
||||
* @param yaw Yaw rotation
|
||||
*/
|
||||
public void setYaw(float yaw) {
|
||||
public final void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The yaw rotation
|
||||
*/
|
||||
public float getYaw() {
|
||||
public final float getYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pitch movement rotation
|
||||
*
|
||||
* @param pitch Pitch rotation
|
||||
*/
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The pitch rotation
|
||||
*/
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The type of the event
|
||||
*/
|
||||
public Type getType() {
|
||||
public final Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.Cancellable;
|
||||
import baritone.api.event.events.type.Overrideable;
|
||||
|
||||
/**
|
||||
* @author LoganDark
|
||||
|
||||
@@ -18,18 +18,9 @@
|
||||
package baritone.api.event.events;
|
||||
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* Called on and after each game tick of the primary {@link Minecraft} instance and dispatched to all Baritone
|
||||
* instances.
|
||||
* <p>
|
||||
* When {@link #state} is {@link EventState#PRE}, the event is being called just prior to when the current in-game
|
||||
* screen is ticked. When {@link #state} is {@link EventState#POST}, the event is being called at the very end
|
||||
* of the {@link Minecraft#runTick()} method.
|
||||
*/
|
||||
public final class TickEvent {
|
||||
|
||||
private static int overallTickCount;
|
||||
|
||||
@@ -33,9 +33,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
||||
@Override
|
||||
default void onTick(TickEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onPostTick(TickEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onPlayerUpdate(PlayerUpdateEvent event) {}
|
||||
|
||||
@@ -48,9 +45,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
||||
@Override
|
||||
default void onChunkEvent(ChunkEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onBlockChange(BlockChangeEvent event) {}
|
||||
|
||||
@Override
|
||||
default void onRenderPass(RenderEvent event) {}
|
||||
|
||||
|
||||
@@ -41,14 +41,6 @@ public interface IGameEventListener {
|
||||
*/
|
||||
void onTick(TickEvent event);
|
||||
|
||||
/**
|
||||
* Run once per game tick after the tick is completed
|
||||
*
|
||||
* @param event The event
|
||||
* @see Minecraft#runTick()
|
||||
*/
|
||||
void onPostTick(TickEvent event);
|
||||
|
||||
/**
|
||||
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||
*
|
||||
@@ -80,13 +72,6 @@ public interface IGameEventListener {
|
||||
*/
|
||||
void onChunkEvent(ChunkEvent event);
|
||||
|
||||
/**
|
||||
* Runs after a single or multi block change packet is received and processed.
|
||||
*
|
||||
* @param event The event
|
||||
*/
|
||||
void onBlockChange(BlockChangeEvent event);
|
||||
|
||||
/**
|
||||
* Runs once per world render pass. Two passes are made when {@link GameSettings#anaglyph} is on.
|
||||
* <p>
|
||||
|
||||
@@ -54,18 +54,4 @@ public interface Goal {
|
||||
default double heuristic(BlockPos pos) {
|
||||
return heuristic(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heuristic at the goal.
|
||||
* i.e. {@code heuristic() == heuristic(x,y,z)}
|
||||
* when {@code isInGoal(x,y,z) == true}
|
||||
* This is needed by {@code PathingBehavior#estimatedTicksToGoal} because
|
||||
* some Goals actually do not have a heuristic of 0 when that condition is met
|
||||
*
|
||||
* @return The estimate number of ticks to satisfy the goal when the goal
|
||||
* is already satisfied
|
||||
*/
|
||||
default double heuristic() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,16 +42,6 @@ public class GoalAxis implements Goal {
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o.getClass() == GoalAxis.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 201385781;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalAxis";
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -67,26 +66,6 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
return calculate(xDiff, yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalBlock goal = (GoalBlock) o;
|
||||
return x == goal.x
|
||||
&& y == goal.y
|
||||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * 905165533;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
@@ -108,9 +87,9 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
public static double calculate(double xDiff, int yDiff, double zDiff) {
|
||||
double heuristic = 0;
|
||||
|
||||
// if yDiff is 1 that means that currentY-goalY==1 which means that we're 1 block above where we should be
|
||||
// therefore going from 0,yDiff,0 to a GoalYLevel of 0 is accurate
|
||||
heuristic += GoalYLevel.calculate(0, yDiff);
|
||||
// if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be
|
||||
// therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
|
||||
heuristic += GoalYLevel.calculate(yDiff, 0);
|
||||
|
||||
//use the pythagorean and manhattan mixture from GoalXZ
|
||||
heuristic += GoalXZ.calculate(xDiff, zDiff);
|
||||
|
||||
@@ -57,34 +57,6 @@ public class GoalComposite implements Goal {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
double min = Double.MAX_VALUE;
|
||||
for (Goal g : goals) {
|
||||
// just take the highest value that is guaranteed to be inside the goal
|
||||
min = Math.min(min, g.heuristic());
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalComposite goal = (GoalComposite) o;
|
||||
return Arrays.equals(goals, goal.goals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(goals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalComposite" + Arrays.toString(goals);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -61,26 +60,6 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalGetToBlock goal = (GoalGetToBlock) o;
|
||||
return x == goal.x
|
||||
&& y == goal.y
|
||||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * -49639096;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Invert any goal.
|
||||
* <p>
|
||||
@@ -47,29 +45,6 @@ public class GoalInverted implements Goal {
|
||||
return -origin.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalInverted goal = (GoalInverted) o;
|
||||
return Objects.equals(origin, goal.origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return origin.hashCode() * 495796690;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("GoalInverted{%s}", origin.toString());
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
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 net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
@@ -54,60 +51,11 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {// TODO less hacky solution
|
||||
int range = (int) Math.ceil(Math.sqrt(rangeSq));
|
||||
DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978
|
||||
double minOutside = Double.POSITIVE_INFINITY;
|
||||
for (int dx = -range; dx <= range; dx++) {
|
||||
for (int dy = -range; dy <= range; dy++) {
|
||||
for (int dz = -range; dz <= range; dz++) {
|
||||
double h = heuristic(x + dx, y + dy, z + dz);
|
||||
if (h < minOutside && isInGoal(x + dx, y + dy, z + dz)) {
|
||||
maybeAlwaysInside.add(h);
|
||||
} else {
|
||||
minOutside = Math.min(minOutside, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double maxInside = Double.NEGATIVE_INFINITY;
|
||||
DoubleIterator it = maybeAlwaysInside.iterator();
|
||||
while (it.hasNext()) {
|
||||
double inside = it.nextDouble();
|
||||
if (inside < minOutside) {
|
||||
maxInside = Math.max(maxInside, inside);
|
||||
}
|
||||
}
|
||||
return maxInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getGoalPos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalNear goal = (GoalNear) o;
|
||||
return x == goal.x
|
||||
&& y == goal.y
|
||||
&& z == goal.z
|
||||
&& rangeSq == goal.rangeSq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) + rangeSq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
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.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Useful for automated combat (retreating specifically)
|
||||
@@ -34,7 +31,7 @@ public class GoalRunAway implements Goal {
|
||||
|
||||
private final BlockPos[] from;
|
||||
|
||||
private final int distanceSq;
|
||||
private final double distanceSq;
|
||||
|
||||
private final Integer maintainY;
|
||||
|
||||
@@ -47,7 +44,7 @@ public class GoalRunAway implements Goal {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.from = from;
|
||||
this.distanceSq = (int) (distance * distance);
|
||||
this.distanceSq = distance * distance;
|
||||
this.maintainY = maintainY;
|
||||
}
|
||||
|
||||
@@ -59,7 +56,7 @@ public class GoalRunAway implements Goal {
|
||||
for (BlockPos p : from) {
|
||||
int diffX = x - p.getX();
|
||||
int diffZ = z - p.getZ();
|
||||
int distSq = diffX * diffX + diffZ * diffZ;
|
||||
double distSq = diffX * diffX + diffZ * diffZ;
|
||||
if (distSq < distanceSq) {
|
||||
return false;
|
||||
}
|
||||
@@ -68,7 +65,7 @@ public class GoalRunAway implements Goal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {// mostly copied from GoalBlock
|
||||
public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock
|
||||
double min = Double.MAX_VALUE;
|
||||
for (BlockPos p : from) {
|
||||
double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
|
||||
@@ -83,71 +80,6 @@ public class GoalRunAway implements Goal {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {// TODO less hacky solution
|
||||
int distance = (int) Math.ceil(Math.sqrt(distanceSq));
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int minZ = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (BlockPos p : from) {
|
||||
minX = Math.min(minX, p.getX() - distance);
|
||||
minY = Math.min(minY, p.getY() - distance);
|
||||
minZ = Math.min(minZ, p.getZ() - distance);
|
||||
maxX = Math.max(minX, p.getX() + distance);
|
||||
maxY = Math.max(minY, p.getY() + distance);
|
||||
maxZ = Math.max(minZ, p.getZ() + distance);
|
||||
}
|
||||
DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978
|
||||
double minOutside = Double.POSITIVE_INFINITY;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
double h = heuristic(x, y, z);
|
||||
if (h < minOutside && isInGoal(x, y, z)) {
|
||||
maybeAlwaysInside.add(h);
|
||||
} else {
|
||||
minOutside = Math.min(minOutside, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double maxInside = Double.NEGATIVE_INFINITY;
|
||||
DoubleIterator it = maybeAlwaysInside.iterator();
|
||||
while (it.hasNext()) {
|
||||
double inside = it.nextDouble();
|
||||
if (inside < minOutside) {
|
||||
maxInside = Math.max(maxInside, inside);
|
||||
}
|
||||
}
|
||||
return maxInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalRunAway goal = (GoalRunAway) o;
|
||||
return distanceSq == goal.distanceSq
|
||||
&& Arrays.equals(from, goal.from)
|
||||
&& Objects.equals(maintainY, goal.maintainY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = Arrays.hashCode(from);
|
||||
hash = hash * 1196803141 + distanceSq;
|
||||
hash = hash * -2053788840 + maintainY;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (maintainY != null) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -65,36 +64,6 @@ public class GoalStrictDirection implements Goal {
|
||||
return heuristic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic() {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalStrictDirection goal = (GoalStrictDirection) o;
|
||||
return x == goal.x
|
||||
&& y == goal.y
|
||||
&& z == goal.z
|
||||
&& dx == goal.dx
|
||||
&& dz == goal.dz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = (int) BetterBlockPos.longHash(x, y, z);
|
||||
hash = hash * 630627507 + dx;
|
||||
hash = hash * -283028380 + dz;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -73,26 +72,6 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalTwoBlocks goal = (GoalTwoBlocks) o;
|
||||
return x == goal.x
|
||||
&& y == goal.y
|
||||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * 516508351;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -64,27 +64,6 @@ public class GoalXZ implements Goal {
|
||||
return calculate(xDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalXZ goal = (GoalXZ) o;
|
||||
return x == goal.x && z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1791873246;
|
||||
hash = hash * 222601791 + x;
|
||||
hash = hash * -1331679453 + z;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -58,24 +58,6 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GoalYLevel goal = (GoalYLevel) o;
|
||||
return level == goal.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return level * 1271009915;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -51,7 +51,6 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
*/
|
||||
boolean build(String name, File schematic, Vec3i origin);
|
||||
|
||||
@Deprecated
|
||||
default boolean build(String schematicFile, BlockPos origin) {
|
||||
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
|
||||
return build(schematicFile, file, origin);
|
||||
@@ -59,8 +58,6 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
||||
|
||||
void buildOpenSchematic();
|
||||
|
||||
void buildOpenLitematic(int i);
|
||||
|
||||
void pause();
|
||||
|
||||
boolean isPaused();
|
||||
|
||||
@@ -38,11 +38,6 @@ public interface ICustomGoalProcess extends IBaritoneProcess {
|
||||
*/
|
||||
Goal getGoal();
|
||||
|
||||
/**
|
||||
* @return The most recent set goal, which doesn't invalidate upon {@link #onLostControl()}
|
||||
*/
|
||||
Goal mostRecentGoal();
|
||||
|
||||
/**
|
||||
* Sets the goal and begins the path execution.
|
||||
*
|
||||
|
||||
@@ -17,29 +17,7 @@
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IFarmProcess extends IBaritoneProcess {
|
||||
|
||||
/**
|
||||
* Begin to search for crops to farm with in specified aria
|
||||
* from specified location.
|
||||
*
|
||||
* @param range The distance from center to farm from
|
||||
* @param pos The center position to base the range from
|
||||
*/
|
||||
void farm(int range, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Begin to search for nearby crops to farm.
|
||||
*/
|
||||
default void farm() {farm(0, null);}
|
||||
|
||||
/**
|
||||
* Begin to search for crops to farm with in specified aria
|
||||
* from the position the command was executed.
|
||||
*
|
||||
* @param range The distance to search for crops to farm
|
||||
*/
|
||||
default void farm(int range) {farm(range, null);}
|
||||
void farm();
|
||||
}
|
||||
|
||||
@@ -56,10 +56,5 @@ public enum PathingCommandType {
|
||||
/**
|
||||
* Go and ask the next process what to do
|
||||
*/
|
||||
DEFER,
|
||||
|
||||
/**
|
||||
* Sets the goal and calculates a path, but pauses instead of immediately starting the path.
|
||||
*/
|
||||
SET_GOAL_AND_PAUSE
|
||||
DEFER
|
||||
}
|
||||
|
||||
@@ -71,11 +71,4 @@ public class CompositeSchematic extends AbstractSchematic {
|
||||
}
|
||||
return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
for (CompositeSchematicEntry entry : schematicArr) {
|
||||
entry.schematic.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package baritone.api.schematic;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,6 +44,8 @@ public class FillSchematic extends AbstractSchematic {
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
if (bom.matches(current)) {
|
||||
return current;
|
||||
} else if (current.getBlock() != Blocks.AIR) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
for (IBlockState placeable : approxPlaceable) {
|
||||
if (bom.matches(placeable)) {
|
||||
|
||||
@@ -73,11 +73,6 @@ public interface ISchematic {
|
||||
*/
|
||||
IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable);
|
||||
|
||||
/**
|
||||
* Resets possible caches to avoid wrong behavior when moving the schematic around
|
||||
*/
|
||||
default void reset() {}
|
||||
|
||||
/**
|
||||
* @return The width (X axis length) of this schematic
|
||||
*/
|
||||
|
||||
@@ -22,9 +22,10 @@ import net.minecraft.block.state.IBlockState;
|
||||
/**
|
||||
* A static schematic is capable of providing the desired state at a given position without
|
||||
* additional context. Schematics of this type are expected to have non-varying contents.
|
||||
*
|
||||
* @see #getDirect(int, int, int)
|
||||
*
|
||||
* @author Brady
|
||||
* @see #getDirect(int, int, int)
|
||||
* @since 12/24/2019
|
||||
*/
|
||||
public interface IStaticSchematic extends ISchematic {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package baritone.api.schematic;
|
||||
|
||||
import baritone.api.schematic.mask.Mask;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,14 +41,4 @@ public abstract class MaskSchematic extends AbstractSchematic {
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
return schematic.desiredState(x, y, z, current, approxPlaceable);
|
||||
}
|
||||
|
||||
public static MaskSchematic create(ISchematic schematic, Mask function) {
|
||||
return new MaskSchematic(schematic) {
|
||||
|
||||
@Override
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
return function.partOfMask(x, y, z, currentState);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,18 +31,6 @@ public class ReplaceSchematic extends MaskSchematic {
|
||||
this.cache = new Boolean[widthX()][heightY()][lengthZ()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
// it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()]
|
||||
for (int x = 0; x < cache.length; x++) {
|
||||
for (int y = 0; y < cache[0].length; y++) {
|
||||
for (int z = 0; z < cache[0][0].length; z++) {
|
||||
cache[x][y][z] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
if (cache[x][y][z] == null) {
|
||||
|
||||
@@ -1,91 +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.api.schematic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SubstituteSchematic extends AbstractSchematic {
|
||||
|
||||
private final ISchematic schematic;
|
||||
private final Map<Block, List<Block>> substitutions;
|
||||
private final Map<IBlockState, Map<Block, IBlockState>> blockStateCache = new HashMap<>();
|
||||
|
||||
public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
|
||||
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
|
||||
this.schematic = schematic;
|
||||
this.substitutions = substitutions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
||||
return schematic.inSchematic(x, y, z, currentState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
||||
IBlockState desired = schematic.desiredState(x, y, z, current, approxPlaceable);
|
||||
Block desiredBlock = desired.getBlock();
|
||||
if (!substitutions.containsKey(desiredBlock)) {
|
||||
return desired;
|
||||
}
|
||||
List<Block> substitutes = substitutions.get(desiredBlock);
|
||||
if (substitutes.contains(current.getBlock()) && !(current.getBlock() instanceof BlockAir)) {// don't preserve air, it's almost always there and almost never wanted
|
||||
return withBlock(desired, current.getBlock());
|
||||
}
|
||||
for (Block substitute : substitutes) {
|
||||
if (substitute instanceof BlockAir) {
|
||||
return current.getBlock() instanceof BlockAir ? current : Blocks.AIR.getDefaultState(); // can always "place" air
|
||||
}
|
||||
for (IBlockState placeable : approxPlaceable) {
|
||||
if (substitute.equals(placeable.getBlock())) {
|
||||
return withBlock(desired, placeable.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
return substitutes.get(0).getDefaultState();
|
||||
}
|
||||
|
||||
private IBlockState withBlock(IBlockState state, Block block) {
|
||||
if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) {
|
||||
return blockStateCache.get(state).get(block);
|
||||
}
|
||||
Collection<IProperty<?>> properties = state.getPropertyKeys();
|
||||
IBlockState newState = block.getDefaultState();
|
||||
for (IProperty<?> property : properties) {
|
||||
try {
|
||||
newState = copySingleProp(state, newState, property);
|
||||
} catch (IllegalArgumentException e) { //property does not exist for target block
|
||||
}
|
||||
}
|
||||
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, IBlockState>()).put(block, newState);
|
||||
return newState;
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty<T> prop) {
|
||||
return toState.withProperty(prop, fromState.getValue(prop));
|
||||
}
|
||||
}
|
||||
@@ -1,49 +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.api.schematic.mask;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public abstract class AbstractMask implements Mask {
|
||||
|
||||
private final int widthX;
|
||||
private final int heightY;
|
||||
private final int lengthZ;
|
||||
|
||||
public AbstractMask(int widthX, int heightY, int lengthZ) {
|
||||
this.widthX = widthX;
|
||||
this.heightY = heightY;
|
||||
this.lengthZ = lengthZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int widthX() {
|
||||
return this.widthX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int heightY() {
|
||||
return this.heightY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lengthZ() {
|
||||
return this.lengthZ;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +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.api.schematic.mask;
|
||||
|
||||
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
|
||||
import baritone.api.schematic.mask.operator.NotMask;
|
||||
import baritone.api.utils.BooleanBinaryOperators;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public interface Mask {
|
||||
|
||||
/**
|
||||
* @param x The relative x position of the block
|
||||
* @param y The relative y position of the block
|
||||
* @param z The relative z position of the block
|
||||
* @param currentState The current state of that block in the world, may be {@code null}
|
||||
* @return Whether the given position is included in this mask
|
||||
*/
|
||||
boolean partOfMask(int x, int y, int z, IBlockState currentState);
|
||||
|
||||
int widthX();
|
||||
|
||||
int heightY();
|
||||
|
||||
int lengthZ();
|
||||
|
||||
default Mask not() {
|
||||
return new NotMask(this);
|
||||
}
|
||||
|
||||
default Mask union(Mask other) {
|
||||
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.OR);
|
||||
}
|
||||
|
||||
default Mask intersection(Mask other) {
|
||||
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.AND);
|
||||
}
|
||||
|
||||
default Mask xor(Mask other) {
|
||||
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.XOR);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +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.api.schematic.mask;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
final class PreComputedMask extends AbstractMask implements StaticMask {
|
||||
|
||||
private final boolean[][][] mask;
|
||||
|
||||
public PreComputedMask(StaticMask mask) {
|
||||
super(mask.widthX(), mask.heightY(), mask.lengthZ());
|
||||
|
||||
this.mask = new boolean[this.heightY()][this.lengthZ()][this.widthX()];
|
||||
for (int y = 0; y < this.heightY(); y++) {
|
||||
for (int z = 0; z < this.lengthZ(); z++) {
|
||||
for (int x = 0; x < this.widthX(); x++) {
|
||||
this.mask[y][z][x] = mask.partOfMask(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z) {
|
||||
return this.mask[y][z][x];
|
||||
}
|
||||
}
|
||||
@@ -1,82 +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.api.schematic.mask;
|
||||
|
||||
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
|
||||
import baritone.api.schematic.mask.operator.NotMask;
|
||||
import baritone.api.utils.BooleanBinaryOperators;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* A mask that is context-free. In other words, it doesn't require the current block state to determine if a relative
|
||||
* position is a part of the mask.
|
||||
*
|
||||
* @author Brady
|
||||
*/
|
||||
public interface StaticMask extends Mask {
|
||||
|
||||
/**
|
||||
* Determines if a given relative coordinate is included in this mask, without the need for the current block state.
|
||||
*
|
||||
* @param x The relative x position of the block
|
||||
* @param y The relative y position of the block
|
||||
* @param z The relative z position of the block
|
||||
* @return Whether the given position is included in this mask
|
||||
*/
|
||||
boolean partOfMask(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Implements the parent {@link Mask#partOfMask partOfMask function} by calling the static function
|
||||
* provided in this functional interface without needing the {@link IBlockState} argument. This {@code default}
|
||||
* implementation should <b><u>NOT</u></b> be overriden.
|
||||
*
|
||||
* @param x The relative x position of the block
|
||||
* @param y The relative y position of the block
|
||||
* @param z The relative z position of the block
|
||||
* @param currentState The current state of that block in the world, may be {@code null}
|
||||
* @return Whether the given position is included in this mask
|
||||
*/
|
||||
@Override
|
||||
default boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
return this.partOfMask(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
default StaticMask not() {
|
||||
return new NotMask.Static(this);
|
||||
}
|
||||
|
||||
default StaticMask union(StaticMask other) {
|
||||
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.OR);
|
||||
}
|
||||
|
||||
default StaticMask intersection(StaticMask other) {
|
||||
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.AND);
|
||||
}
|
||||
|
||||
default StaticMask xor(StaticMask other) {
|
||||
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.XOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pre-computed mask using {@code this} function, with the specified size parameters.
|
||||
*/
|
||||
default StaticMask compute() {
|
||||
return new PreComputedMask(this);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +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.api.schematic.mask.operator;
|
||||
|
||||
import baritone.api.schematic.mask.AbstractMask;
|
||||
import baritone.api.schematic.mask.Mask;
|
||||
import baritone.api.schematic.mask.StaticMask;
|
||||
import baritone.api.utils.BooleanBinaryOperator;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public final class BinaryOperatorMask extends AbstractMask {
|
||||
|
||||
private final Mask a;
|
||||
private final Mask b;
|
||||
private final BooleanBinaryOperator operator;
|
||||
|
||||
public BinaryOperatorMask(Mask a, Mask b, BooleanBinaryOperator operator) {
|
||||
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
return this.operator.applyAsBoolean(
|
||||
partOfMask(a, x, y, z, currentState),
|
||||
partOfMask(b, x, y, z, currentState)
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean partOfMask(Mask mask, int x, int y, int z, IBlockState currentState) {
|
||||
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z, currentState);
|
||||
}
|
||||
|
||||
public static final class Static extends AbstractMask implements StaticMask {
|
||||
|
||||
private final StaticMask a;
|
||||
private final StaticMask b;
|
||||
private final BooleanBinaryOperator operator;
|
||||
|
||||
public Static(StaticMask a, StaticMask b, BooleanBinaryOperator operator) {
|
||||
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z) {
|
||||
return this.operator.applyAsBoolean(
|
||||
partOfMask(a, x, y, z),
|
||||
partOfMask(b, x, y, z)
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean partOfMask(StaticMask mask, int x, int y, int z) {
|
||||
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +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.api.schematic.mask.operator;
|
||||
|
||||
import baritone.api.schematic.mask.AbstractMask;
|
||||
import baritone.api.schematic.mask.Mask;
|
||||
import baritone.api.schematic.mask.StaticMask;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public final class NotMask extends AbstractMask {
|
||||
|
||||
private final Mask source;
|
||||
|
||||
public NotMask(Mask source) {
|
||||
super(source.widthX(), source.heightY(), source.lengthZ());
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
return !this.source.partOfMask(x, y, z, currentState);
|
||||
}
|
||||
|
||||
public static final class Static extends AbstractMask implements StaticMask {
|
||||
|
||||
private final StaticMask source;
|
||||
|
||||
public Static(StaticMask source) {
|
||||
super(source.widthX(), source.heightY(), source.lengthZ());
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z) {
|
||||
return !this.source.partOfMask(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +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.api.schematic.mask.shape;
|
||||
|
||||
import baritone.api.schematic.mask.AbstractMask;
|
||||
import baritone.api.schematic.mask.StaticMask;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
*/
|
||||
public final class CylinderMask extends AbstractMask implements StaticMask {
|
||||
|
||||
private final double centerA;
|
||||
private final double centerB;
|
||||
private final double radiusSqA;
|
||||
private final double radiusSqB;
|
||||
private final boolean filled;
|
||||
private final EnumFacing.Axis alignment;
|
||||
|
||||
public CylinderMask(int widthX, int heightY, int lengthZ, boolean filled, EnumFacing.Axis alignment) {
|
||||
super(widthX, heightY, lengthZ);
|
||||
this.centerA = this.getA(widthX, heightY, alignment) / 2.0;
|
||||
this.centerB = this.getB(heightY, lengthZ, alignment) / 2.0;
|
||||
this.radiusSqA = (this.centerA - 1) * (this.centerA - 1);
|
||||
this.radiusSqB = (this.centerB - 1) * (this.centerB - 1);
|
||||
this.filled = filled;
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z) {
|
||||
double da = Math.abs((this.getA(x, y, this.alignment) + 0.5) - this.centerA);
|
||||
double db = Math.abs((this.getB(y, z, this.alignment) + 0.5) - this.centerB);
|
||||
if (this.outside(da, db)) {
|
||||
return false;
|
||||
}
|
||||
return this.filled
|
||||
|| this.outside(da + 1, db)
|
||||
|| this.outside(da, db + 1);
|
||||
}
|
||||
|
||||
private boolean outside(double da, double db) {
|
||||
return da * da / this.radiusSqA + db * db / this.radiusSqB > 1;
|
||||
}
|
||||
|
||||
private static int getA(int x, int y, EnumFacing.Axis alignment) {
|
||||
return alignment == EnumFacing.Axis.X ? y : x;
|
||||
}
|
||||
|
||||
private static int getB(int y, int z, EnumFacing.Axis alignment) {
|
||||
return alignment == EnumFacing.Axis.Z ? y : z;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user