Compare commits
228 Commits
pr/elytra/
...
1.15.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae4702367 | ||
|
|
34501f5af3 | ||
|
|
5ce006170d | ||
|
|
ffd7d7a23a | ||
|
|
62fe9888a2 | ||
|
|
08c00b8a42 | ||
|
|
7320c3fd7e | ||
|
|
c37cdf78e4 | ||
|
|
6a1f716dc8 | ||
|
|
1b3799d4d7 | ||
|
|
a61eabd60c | ||
|
|
bb75e68b0a | ||
|
|
e9b9977674 | ||
|
|
825bad47ef | ||
|
|
78acd2f945 | ||
|
|
1183196e0d | ||
|
|
4b45cc6f0b | ||
|
|
a3da25ca27 | ||
|
|
eae6e4d804 | ||
|
|
37cd50d435 | ||
|
|
3f65d46e12 | ||
|
|
15fd313757 | ||
|
|
c98c54c985 | ||
|
|
4c9689fe19 | ||
|
|
f41c873852 | ||
|
|
eb8a673165 | ||
|
|
9a7b07befc | ||
|
|
2c3f352d0d | ||
|
|
7fbe9c062e | ||
|
|
c1d7683896 | ||
|
|
b493c2ce89 | ||
|
|
82436f30e1 | ||
|
|
f549e0e2d4 | ||
|
|
5494c43290 | ||
|
|
f5d5457100 | ||
|
|
d6cbb58e7e | ||
|
|
6e78384bcf | ||
|
|
47501ab8e1 | ||
|
|
682de71ab7 | ||
|
|
410ea059fc | ||
|
|
b7870d059c | ||
|
|
06865f1561 | ||
|
|
fe0b54cfb4 | ||
|
|
0bf7bb4b39 | ||
|
|
2a830b6b68 | ||
|
|
fc620f8ba8 | ||
|
|
315977e1f2 | ||
|
|
e7658b75ef | ||
|
|
8c3fac977e | ||
|
|
be2ee1a07c | ||
|
|
a4f7207089 | ||
|
|
aead997b13 | ||
|
|
2d421e66dc | ||
|
|
e8370f1348 | ||
|
|
16f6baf216 | ||
|
|
89ab959fb4 | ||
|
|
b13b86b67a | ||
|
|
b9a7efc25b | ||
|
|
3b7f13babd | ||
|
|
6cc31a9422 | ||
|
|
592a01f3e4 | ||
|
|
db718a1781 | ||
|
|
261bf005f6 | ||
|
|
e926ff2a16 | ||
|
|
8794bfd79a | ||
|
|
500643aec7 | ||
|
|
58bb6c4357 | ||
|
|
520142427d | ||
|
|
369d726a96 | ||
|
|
e0beba38af | ||
|
|
ebe3f457c6 | ||
|
|
6289e540b8 | ||
|
|
e0bd82d7ff | ||
|
|
5ec4b89caa | ||
|
|
5fd3e236e2 | ||
|
|
399037b866 | ||
|
|
2d941f6264 | ||
|
|
1a8d93b946 | ||
|
|
50783e65a9 | ||
|
|
606e9bf97c | ||
|
|
47ae75a9d6 | ||
|
|
25587e317a | ||
|
|
b3ba129fc5 | ||
|
|
746b7b5c88 | ||
|
|
db2f6ec78d | ||
|
|
96bcabff8b | ||
|
|
0a1fe857dc | ||
|
|
49aaa55172 | ||
|
|
e03e251541 | ||
|
|
f5380881f4 | ||
|
|
a022778fb6 | ||
|
|
8543a99fba | ||
|
|
997888fe85 | ||
|
|
94a2e13561 | ||
|
|
f7041022d0 | ||
|
|
2d2030ecdf | ||
|
|
a3dec3a47e | ||
|
|
eb348120d9 | ||
|
|
27cb708d40 | ||
|
|
36bbe430d4 | ||
|
|
80952e091d | ||
|
|
760ac5dd8f | ||
|
|
dd76d2eabc | ||
|
|
92966dc57c | ||
|
|
e3d3407de5 | ||
|
|
f3d860e8fa | ||
|
|
1edd7126fd | ||
|
|
a57668bd15 | ||
|
|
a324b58f55 | ||
|
|
214225c08d | ||
|
|
05b5894348 | ||
|
|
c528dba0ea | ||
|
|
105c7d438a | ||
|
|
2b3a302a5f | ||
|
|
1c00e167ca | ||
|
|
861ee5049a | ||
|
|
c1fe588de4 | ||
|
|
8fa2dac261 | ||
|
|
f0ae31f455 | ||
|
|
dc7d64fb88 | ||
|
|
62df244db7 | ||
|
|
84a257faf4 | ||
|
|
34620a448e | ||
|
|
2b4d6f4aa0 | ||
|
|
e54d63576f | ||
|
|
7e505fc68f | ||
|
|
9c323aba91 | ||
|
|
ae9671bff0 | ||
|
|
d256f05787 | ||
|
|
02419f8b07 | ||
|
|
ddeb2a5c14 | ||
|
|
8973b73bfa | ||
|
|
4557bab3c4 | ||
|
|
6e185b580c | ||
|
|
a9ba05bf5e | ||
|
|
4e73880d4a | ||
|
|
0bb148844d | ||
|
|
e53b207148 | ||
|
|
7c9b812a5b | ||
|
|
afc639ab4b | ||
|
|
afebdce1f8 | ||
|
|
2ca4c3042a | ||
|
|
a8226ba4c8 | ||
|
|
e34b2d1392 | ||
|
|
6bee5828a0 | ||
|
|
8a5cc5b17d | ||
|
|
4e563c6130 | ||
|
|
01cf3c67a6 | ||
|
|
36315c5151 | ||
|
|
9f951f261d | ||
|
|
4c8907c629 | ||
|
|
223791cea7 | ||
|
|
de6e96b952 | ||
|
|
9dd6856872 | ||
|
|
ed4753e968 | ||
|
|
1a4635df16 | ||
|
|
1390af20b6 | ||
|
|
1427cf57a8 | ||
|
|
d70243b4c0 | ||
|
|
8f63dd4ba6 | ||
|
|
c7e1c917c3 | ||
|
|
8758c77ac0 | ||
|
|
dba496471e | ||
|
|
125facfbb6 | ||
|
|
16b74ff53c | ||
|
|
9297e98ac3 | ||
|
|
b521d7bee1 | ||
|
|
4e96c5e5ee | ||
|
|
ec819220b7 | ||
|
|
3d3a5f420e | ||
|
|
9c9c9d4387 | ||
|
|
82d09a536d | ||
|
|
6e49adea33 | ||
|
|
f85afdbc70 | ||
|
|
563028a5b3 | ||
|
|
d5c317b88b | ||
|
|
c59ec9da10 | ||
|
|
3a675836da | ||
|
|
7e0fc81246 | ||
|
|
f970f932c7 | ||
|
|
52d2741f52 | ||
|
|
7bc6765cac | ||
|
|
85b2aea6e9 | ||
|
|
c6ba5481d9 | ||
|
|
81f47d5632 | ||
|
|
9b1440ed2c | ||
|
|
2a8dcee028 | ||
|
|
277ba3643c | ||
|
|
e5fbaf60f3 | ||
|
|
0deb854e1b | ||
|
|
8268e3ec1b | ||
|
|
af91da6a28 | ||
|
|
9a15a65ad5 | ||
|
|
0cbe9f81c8 | ||
|
|
42afd2dd54 | ||
|
|
315929f31c | ||
|
|
358aa80280 | ||
|
|
1dd9e11994 | ||
|
|
5a8f02c944 | ||
|
|
f248a5b677 | ||
|
|
e4a49c5529 | ||
|
|
449b44ba50 | ||
|
|
a00eec402e | ||
|
|
717779f742 | ||
|
|
6f843bd24d | ||
|
|
d79fbea433 | ||
|
|
4d22c10ddb | ||
|
|
1ea92a6092 | ||
|
|
66eba84d06 | ||
|
|
92e39b5d1d | ||
|
|
0ddc47f473 | ||
|
|
ddfeca6947 | ||
|
|
6bd2e90cfd | ||
|
|
82505ddb01 | ||
|
|
2790d1d308 | ||
|
|
11e503a022 | ||
|
|
6fe49380ba | ||
|
|
1f2e267e3d | ||
|
|
4cf6783622 | ||
|
|
82d77a7bac | ||
|
|
841a927033 | ||
|
|
5a16561954 | ||
|
|
e2cc51908b | ||
|
|
1390e04435 | ||
|
|
84d961cbab | ||
|
|
87b9d3915c | ||
|
|
c38d17563d | ||
|
|
0c2af85ac0 |
2
.github/ISSUE_TEMPLATE/bug.md
vendored
2
.github/ISSUE_TEMPLATE/bug.md
vendored
@@ -11,7 +11,7 @@ Operating system:
|
|||||||
Java version:
|
Java version:
|
||||||
Minecraft version:
|
Minecraft version:
|
||||||
Baritone version:
|
Baritone version:
|
||||||
Other mods (if used):
|
Forge mods (if used):
|
||||||
|
|
||||||
## Exception, error or logs
|
## Exception, error or logs
|
||||||
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue
|
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
|
|
||||||
|
|
||||||
14
.gitignore
vendored
14
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
run/
|
run/
|
||||||
autotest/
|
autotest/
|
||||||
dist/
|
dist/
|
||||||
|
volderyarn/
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
build/
|
build/
|
||||||
@@ -11,6 +12,8 @@ build/
|
|||||||
classes/
|
classes/
|
||||||
*.class
|
*.class
|
||||||
|
|
||||||
|
/out
|
||||||
|
|
||||||
# IntelliJ Files
|
# IntelliJ Files
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
@@ -18,17 +21,6 @@ classes/
|
|||||||
*.iws
|
*.iws
|
||||||
/logs/
|
/logs/
|
||||||
|
|
||||||
# Eclipse Files
|
|
||||||
.classpath
|
|
||||||
.project
|
|
||||||
.settings/
|
|
||||||
baritone_Client.launch
|
|
||||||
|
|
||||||
# Copyright Files
|
# Copyright Files
|
||||||
!/.idea/copyright/Baritone.xml
|
!/.idea/copyright/Baritone.xml
|
||||||
!/.idea/copyright/profiles_settings.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
|
|
||||||
|
|||||||
28
.travis.yml
Normal file
28
.travis.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
language: java
|
||||||
|
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
install:
|
||||||
|
- travis_retry docker build -t cabaletta/baritone .
|
||||||
|
|
||||||
|
script:
|
||||||
|
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
|
||||||
|
- 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
|
||||||
@@ -13,3 +13,5 @@ COPY . /code
|
|||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|
||||||
RUN ./gradlew build
|
RUN ./gradlew build
|
||||||
|
RUN ./gradlew build -Pbaritone.forge_build
|
||||||
|
RUN ./gradlew build -Pbaritone.fabric_build
|
||||||
|
|||||||
138
README.md
138
README.md
@@ -1,137 +1 @@
|
|||||||
# Baritone
|
This branch of Baritone is deprecated. It will no longer recieve updates. Updates to older versions of Minecraft will not be merged into this branch, even if a newer branch is not deprecated (this branch will be skipped). Bug reports that only affect deprecated branches will not be addressed.
|
||||||
<p align="center">
|
|
||||||
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/downloads/cabaletta/baritone/total.svg" alt="GitHub All Releases"/></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
|
|
||||||
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
A Minecraft pathfinder bot.
|
|
||||||
|
|
||||||
Baritone 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.
|
|
||||||
|
|
||||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
|
||||||
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
|
||||||
|
|
||||||
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
|
|
||||||
|
|
||||||
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
|
|
||||||
|
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
Here are some links to help to get started:
|
|
||||||
|
|
||||||
- [Features](FEATURES.md)
|
|
||||||
|
|
||||||
- [Installation & setup](SETUP.md)
|
|
||||||
|
|
||||||
- [API Javadocs](https://baritone.leijurv.com/)
|
|
||||||
|
|
||||||
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
|
|
||||||
|
|
||||||
- [Usage (chat control)](USAGE.md)
|
|
||||||
|
|
||||||
## Stars over time
|
|
||||||
|
|
||||||
[](https://starchart.cc/cabaletta/baritone)
|
|
||||||
|
|
||||||
# API
|
|
||||||
|
|
||||||
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
|
|
||||||
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
|
|
||||||
jar.
|
|
||||||
|
|
||||||
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
|
|
||||||
|
|
||||||
```java
|
|
||||||
BaritoneAPI.getSettings().allowSprint.value = true;
|
|
||||||
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
|
|
||||||
|
|
||||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
|
|
||||||
```
|
|
||||||
|
|
||||||
# FAQ
|
|
||||||
|
|
||||||
## Can I use Baritone as a library in my custom utility client?
|
|
||||||
|
|
||||||
That's what it's for, sure! (As long as usage complies with the LGPL 3.0 License)
|
|
||||||
|
|
||||||
## How is it so fast?
|
|
||||||
|
|
||||||
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
|
|
||||||
|
|
||||||
### Additional Special Thanks To:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications.
|
|
||||||
|
|
||||||
YourKit is the creator of the [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/), and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
|
||||||
|
|
||||||
We thank them for granting Baritone an OSS license so that we can make our software the best it can be.
|
|
||||||
|
|
||||||
## Why is it called Baritone?
|
|
||||||
|
|
||||||
It's named for FitMC's deep sultry voice.
|
|
||||||
81
SETUP.md
81
SETUP.md
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
|
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.
|
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)
|
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).
|
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).
|
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`
|
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.
|
- **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.
|
- **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.
|
- **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
|
## Build it yourself
|
||||||
- Clone or download Baritone
|
- Clone or download Baritone
|
||||||
@@ -43,13 +47,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone
|
|||||||
## Command Line
|
## Command Line
|
||||||
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
|
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
|
To check which java you are using do
|
||||||
`java -version` in a command prompt or terminal.
|
`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
|
#### macOS guide
|
||||||
In order to get JDK 8, Try running the following command:
|
In order to get JDK 8, Try running the following command:
|
||||||
`% /usr/libexec/java_home -V`
|
`% /usr/libexec/java_home -V`
|
||||||
@@ -66,13 +70,62 @@ 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
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
For minecraft 1.15.2+, run the following instead to include the Forge jars:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gradlew build -Pbaritone.forge_build
|
||||||
|
```
|
||||||
|
|
||||||
|
Running Baritone:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gradlew runClient
|
||||||
|
```
|
||||||
|
|
||||||
|
For information on how to build baritone, see [Building Baritone](#building-baritone)
|
||||||
|
|
||||||
## IntelliJ
|
## IntelliJ
|
||||||
- Open the project in IntelliJ as a Gradle project
|
- 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)
|
- 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
|
||||||
|
|||||||
18
USAGE.md
18
USAGE.md
@@ -32,13 +32,13 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
|
|||||||
|
|
||||||
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
|
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
|
- `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
|
- `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)
|
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
|
||||||
- `goal` to set the goal to your player's feet
|
- `goal` to set the goal to your player's feet
|
||||||
- `goal clear` to clear the goal
|
- `goal clear` to clear the goal
|
||||||
- `cancel` or `stop` to stop everything, `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)
|
- `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`.
|
- `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).
|
- `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).
|
||||||
@@ -47,23 +47,15 @@ Commands in Baritone:
|
|||||||
- `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).
|
- `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
|
- `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.
|
- `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).
|
- `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.
|
- `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.
|
- `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
|
- `version` to get the version of Baritone you're running
|
||||||
- `damn` daniel
|
- `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>.
|
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.
|
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.
|
||||||
|
|||||||
308
build.gradle
308
build.gradle
@@ -16,36 +16,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.2.17'
|
version '1.5.3'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = 'forge'
|
name = 'forge'
|
||||||
url = 'https://files.minecraftforge.net/maven'
|
url = 'http://files.minecraftforge.net/maven'
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'SpongePowered'
|
name = 'impactdevelopment-repo'
|
||||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
url = 'https://impactdevelopment.github.io/maven/'
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url = 'https://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url = 'https://libraries.minecraft.net/'
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' // TODO: 5.+. `doHackyStuff` relies on 4.x internals.
|
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
|
||||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
|
||||||
|
classpath group: 'net.fabricmc', name: 'fabric-loom', version: '0.7-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
import baritone.gradle.fabric.CreateVolderYarn
|
||||||
import baritone.gradle.task.CreateDistTask
|
import baritone.gradle.task.CreateDistTask
|
||||||
import baritone.gradle.task.ProguardTask
|
import baritone.gradle.task.ProguardTask
|
||||||
|
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
def mcpVersion = [channel: 'snapshot', version: '20200515-1.15.1']
|
||||||
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'))`
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
apply plugin: 'org.spongepowered.mixin'
|
CreateVolderYarn.genMappings("1.15.2", mcpVersion)
|
||||||
|
apply plugin: 'fabric-loom'
|
||||||
|
} else {
|
||||||
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
compileJava {
|
compileJava {
|
||||||
@@ -53,6 +71,7 @@ compileJava {
|
|||||||
options.encoding = "UTF-8" // allow emoji in comments :^)
|
options.encoding = "UTF-8" // allow emoji in comments :^)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
api {
|
api {
|
||||||
compileClasspath += main.compileClasspath
|
compileClasspath += main.compileClasspath
|
||||||
@@ -78,26 +97,63 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
task sourceJar(type: Jar, dependsOn: classes) {
|
||||||
mappings channel: 'stable', version: '39-1.12'
|
classifier = 'sources'
|
||||||
runs {
|
from sourceSets.api.allSource
|
||||||
def nativesOutput = extractNatives.output // TODO: fg 5.0 - `def nativesOutput = extractNatives.output.get()`
|
}
|
||||||
println("[Baritoe] Detected natives: ${nativesOutput}")
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
client {
|
minecraft.refmapName = "mixins.baritone.refmap.json"
|
||||||
workingDirectory project.file('run')
|
} else {
|
||||||
source sourceSets.launch
|
minecraft {
|
||||||
|
mappings mcpVersion
|
||||||
|
|
||||||
main 'net.minecraft.launchwrapper.Launch'
|
if (getProject().hasProperty("baritone.forge_build")) {
|
||||||
|
reobfMappings 'searge'
|
||||||
args '--gameDir', '.'
|
} else {
|
||||||
args '--version', '1.12.2'
|
reobfMappings 'notch'
|
||||||
args '--assetsDir', downloadAssets.output
|
|
||||||
args '--assetIndex', '{asset_index}'
|
|
||||||
args '--accessToken', 'INVALID'
|
|
||||||
|
|
||||||
args '--tweakClass', 'baritone.launch.BaritoneTweaker'
|
|
||||||
jvmArgs "-Dorg.lwjgl.librarypath=${nativesOutput}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runs {
|
||||||
|
client {
|
||||||
|
workingDirectory project.file('run')
|
||||||
|
source sourceSets.launch
|
||||||
|
|
||||||
|
main 'baritone.launch.LaunchTesting'
|
||||||
|
|
||||||
|
environment 'assetIndex', '{asset_index}'
|
||||||
|
environment 'assetDirectory', downloadAssets.output
|
||||||
|
environment 'nativesDirectory', extractNatives.output
|
||||||
|
|
||||||
|
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||||
|
|
||||||
|
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||||
|
jvmArgs "-XstartOnFirstThread"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoTest {
|
||||||
|
workingDirectory project.file('autotest')
|
||||||
|
source sourceSets.launch
|
||||||
|
|
||||||
|
main 'baritone.launch.LaunchTesting'
|
||||||
|
|
||||||
|
environment 'assetIndex', '{asset_index}'
|
||||||
|
environment 'assetDirectory', downloadAssets.output
|
||||||
|
environment 'nativesDirectory', extractNatives.output
|
||||||
|
|
||||||
|
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||||
|
environment 'BARITONE_AUTO_TEST', 'true'
|
||||||
|
|
||||||
|
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||||
|
jvmArgs "-XstartOnFirstThread"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
defaultObfuscationEnv searge
|
||||||
|
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +161,7 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
name = 'spongepowered-repo'
|
name = 'SpongePowered'
|
||||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,77 +169,42 @@ repositories {
|
|||||||
name = 'impactdevelopment-repo'
|
name = 'impactdevelopment-repo'
|
||||||
url = 'https://impactdevelopment.github.io/maven/'
|
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 {
|
dependencies {
|
||||||
minecraft group: 'net.minecraft', name: 'joined', version: '1.12.2'
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
implementation(group: 'net.minecraft', name: 'launchwrapper', version: '1.12') {
|
minecraft "com.mojang:minecraft:1.15.2"
|
||||||
transitive = false
|
mappings fileTree(dir: "./build/volderyarn", include: "**.jar")
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:0.9.1+build.205"
|
||||||
|
|
||||||
|
// this makes it compile with the forge tweak stuff
|
||||||
|
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||||
|
implementation('net.minecraft:launchwrapper:1.12') {
|
||||||
|
exclude module: 'lwjgl'
|
||||||
|
}
|
||||||
|
|
||||||
|
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
|
} else {
|
||||||
|
minecraft 'com.github.ImpactDevelopment:Vanilla:1.15.2'
|
||||||
|
|
||||||
|
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||||
|
exclude module: 'lwjgl'
|
||||||
|
}
|
||||||
|
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
|
||||||
|
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||||
|
runtime launchCompile('org.spongepowered:mixin:0.8.+') {
|
||||||
|
// Mixin includes a lot of dependencies that are too up-to-date
|
||||||
|
exclude module: 'launchwrapper'
|
||||||
|
exclude module: 'guava'
|
||||||
|
exclude module: 'gson'
|
||||||
|
exclude module: 'commons-io'
|
||||||
|
exclude module: 'log4j-core'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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') {
|
|
||||||
// Mixin includes a lot of dependencies that are too up-to-date
|
|
||||||
transitive = false
|
|
||||||
}
|
|
||||||
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'
|
testImplementation 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
|
||||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
|
||||||
}
|
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
|
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
|
||||||
options.linkSource true
|
options.linkSource true
|
||||||
@@ -192,6 +213,25 @@ javadoc {
|
|||||||
classpath += sourceSets.api.compileClasspath
|
classpath += sourceSets.api.compileClasspath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
|
// skidded from fabric-example-mod (comments and all)
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
// If Javadoc is generated, this must be specified in that task too.
|
||||||
|
it.options.encoding = "UTF-8"
|
||||||
|
|
||||||
|
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||||
|
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||||
|
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||||
|
def targetVersion = 8
|
||||||
|
if (JavaVersion.current().isJava9Compatible()) {
|
||||||
|
it.options.release = targetVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from sourceSets.launch.output, sourceSets.api.output
|
from sourceSets.launch.output, sourceSets.api.output
|
||||||
|
|
||||||
@@ -203,21 +243,91 @@ jar {
|
|||||||
preserveFileTimestamps = false
|
preserveFileTimestamps = false
|
||||||
reproducibleFileOrder = true
|
reproducibleFileOrder = true
|
||||||
|
|
||||||
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": version
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exclude("fabric.mod.json")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
'MixinConfigs': 'mixins.baritone.json',
|
'MixinConfigs': 'mixins.baritone.json',
|
||||||
'TweakClass': 'baritone.launch.BaritoneTweaker',
|
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
|
||||||
|
|
||||||
'Implementation-Title': 'Baritone',
|
'Implementation-Title': 'Baritone',
|
||||||
'Implementation-Version': version
|
'Implementation-Version': version,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task proguard(type: ProguardTask) {
|
// skidded from ProguardTask
|
||||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
File getClientJar() {
|
||||||
extract 'proguard6.0.3/lib/proguard.jar'
|
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||||
|
.stream()
|
||||||
|
.filter({ f -> f.toString().endsWith("client-extra.jar") })
|
||||||
|
.map({ f -> new File(f.getParentFile(), "client.jar") })
|
||||||
|
.findFirst()
|
||||||
|
.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
File getClientJarFabric() {
|
||||||
|
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||||
|
.stream()
|
||||||
|
.filter({ f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") })
|
||||||
|
.map({ f -> new File(f.getParentFile().getParentFile(), f.getName().toString().replace("mapped", "intermediary")) })
|
||||||
|
.findFirst()
|
||||||
|
.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
|
task copyMcJar(type: Copy) {
|
||||||
|
def mcJar = { getClientJarFabric() }
|
||||||
|
|
||||||
|
from mcJar
|
||||||
|
into 'build/createMcIntermediaryJar/'
|
||||||
|
rename { 'client.jar' }
|
||||||
|
}
|
||||||
|
|
||||||
|
task proguard(type: ProguardTask, dependsOn: copyMcJar) {
|
||||||
|
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||||
|
extract 'proguard6.0.3/lib/proguard.jar'
|
||||||
|
}
|
||||||
|
|
||||||
|
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
task copyMcJar(type: Copy) {
|
||||||
|
def mcJar = { getClientJar() }
|
||||||
|
|
||||||
|
from mcJar
|
||||||
|
into 'build/createMcSrgJar/'
|
||||||
|
rename { 'client-srg.jar' }
|
||||||
|
}
|
||||||
|
|
||||||
|
task createSrgMc(type: RenameJarInPlace) {
|
||||||
|
setInput(new File(copyMcJar.getOutputs().getFiles().getSingleFile(), "client-srg.jar"))
|
||||||
|
setClasspath(files({ getClientJar() }))
|
||||||
|
|
||||||
|
// fork
|
||||||
|
setMappingType(net.minecraftforge.gradle.common.util.MappingFile.Mapping.SEARGE)
|
||||||
|
setJarTask('trans alaska pipeline')
|
||||||
|
}
|
||||||
|
|
||||||
|
project.afterEvaluate {
|
||||||
|
createSrgMc.dependsOn(extractSrg, copyMcJar)
|
||||||
|
createSrgMc.setMappings(extractSrg.getOutput())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task proguard(type: ProguardTask, dependsOn: createSrgMc) { // TODO: dont need to create srg mc if doing notch build
|
||||||
|
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||||
|
extract 'proguard6.0.3/lib/proguard.jar'
|
||||||
|
}
|
||||||
|
|
||||||
|
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||||
|
|
||||||
|
}
|
||||||
build.finalizedBy(createDist)
|
build.finalizedBy(createDist)
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||||
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
compile group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
/*
|
||||||
|
* 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.fabric;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author Wagyourtail
|
||||||
|
*/
|
||||||
|
public class CreateVolderYarn {
|
||||||
|
public static String VOLDERYARNFOLDER = "./build/volderyarn/";
|
||||||
|
public static String VOLDERYARN = "volderyarn-%s-%s-%s.jar";
|
||||||
|
|
||||||
|
public static void genMappings(String mcVersion, Map<String, String> mcpVersion) throws IOException {
|
||||||
|
//download yarn intermediary
|
||||||
|
URL intURL = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%s/intermediary-%s-v2.jar", mcVersion, mcVersion));
|
||||||
|
String intermediary = readZipContentFromURL(intURL, "mappings/mappings.tiny").get("mappings/mappings.tiny");
|
||||||
|
Map<String, ClassData> mappings = parseTinyMap(intermediary);
|
||||||
|
|
||||||
|
//download srg
|
||||||
|
URL srgURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_config/%s/mcp_config-%s.zip", mcVersion, mcVersion));
|
||||||
|
String tsrg = readZipContentFromURL(srgURL, "config/joined.tsrg").get("config/joined.tsrg");
|
||||||
|
MCPData mcpData = addTSRGData(mappings, tsrg);
|
||||||
|
|
||||||
|
//download mcp
|
||||||
|
URL mcpURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_%s/%s/mcp_%s-%s.zip", mcpVersion.get("channel"), mcpVersion.get("version"), mcpVersion.get("channel"), mcpVersion.get("version")));
|
||||||
|
Map<String, String> mcpfiles = readZipContentFromURL(mcpURL, "fields.csv", "methods.csv");
|
||||||
|
addMCPData(mcpData, mcpfiles.get("fields.csv"), mcpfiles.get("methods.csv"));
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder("tiny\t2\t0\tintermediary\tnamed");
|
||||||
|
for (ClassData clazz : mappings.values()) {
|
||||||
|
builder.append("\n").append(clazz.getIntToMCP());
|
||||||
|
}
|
||||||
|
|
||||||
|
File outputFolder = new File(VOLDERYARNFOLDER);
|
||||||
|
if (!outputFolder.exists() && !outputFolder.mkdirs())
|
||||||
|
throw new RuntimeException("Failed to create dir for volderyarn mappings.");
|
||||||
|
|
||||||
|
for (File f : outputFolder.listFiles()) {
|
||||||
|
if (!f.isDirectory()) f.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
File outputFile = new File(outputFolder, String.format(VOLDERYARN, mcVersion, mcpVersion.get("channel"), mcpVersion.get("version")));
|
||||||
|
if (!outputFile.getParentFile().exists()) {
|
||||||
|
if (!outputFile.getParentFile().mkdir())
|
||||||
|
throw new FileNotFoundException("Failed to create folder for volderyarn!");
|
||||||
|
}
|
||||||
|
|
||||||
|
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outputFile))) {
|
||||||
|
output.putNextEntry(new ZipEntry("mappings/mappings.tiny"));
|
||||||
|
byte[] outData = builder.toString().getBytes(StandardCharsets.UTF_8);
|
||||||
|
output.write(outData, 0, outData.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, ClassData> parseTinyMap(String map) {
|
||||||
|
Map<String, ClassData> mappings = new LinkedHashMap<>();
|
||||||
|
ClassData clazzdata = null;
|
||||||
|
for (String line : map.split("\n")) {
|
||||||
|
String[] parts = line.trim().split("\t");
|
||||||
|
switch (parts[0]) {
|
||||||
|
case "c":
|
||||||
|
mappings.put(parts[1], clazzdata = new ClassData(mappings, parts[1], parts[2]));
|
||||||
|
break;
|
||||||
|
case "m":
|
||||||
|
assert clazzdata != null;
|
||||||
|
clazzdata.addMethod(parts[2], parts[1], parts[3]);
|
||||||
|
break;
|
||||||
|
case "f":
|
||||||
|
assert clazzdata != null;
|
||||||
|
clazzdata.addField(parts[2], parts[1], parts[3]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MCPData addTSRGData(Map<String, ClassData> mappings, String tsrg) {
|
||||||
|
MCPData mcpData = new MCPData();
|
||||||
|
String[] classes = String.join("\t", tsrg.split("\n\t")).split("\n");
|
||||||
|
for (String c : classes) {
|
||||||
|
String[] lines = c.split("\t");
|
||||||
|
String[] classData = lines[0].split("\\s+");
|
||||||
|
ClassData clazz = mappings.get(classData[0]);
|
||||||
|
if (clazz == null) continue;
|
||||||
|
clazz.mcpName = classData[1];
|
||||||
|
for (int i = 1; i < lines.length; ++i) {
|
||||||
|
String[] lineData = lines[i].split("\\s+");
|
||||||
|
//method
|
||||||
|
if (lineData.length == 3) {
|
||||||
|
if (!mcpData.methods.containsKey(lineData[2])) mcpData.methods.put(lineData[2], new LinkedList<>());
|
||||||
|
MethodData d = clazz.methods.get(lineData[0] + lineData[1]);
|
||||||
|
if (d == null) continue;
|
||||||
|
d.mcpName = lineData[2];
|
||||||
|
mcpData.methods.get(lineData[2]).add(d);
|
||||||
|
//field
|
||||||
|
} else {
|
||||||
|
if (!mcpData.fields.containsKey(lineData[1])) mcpData.fields.put(lineData[1], new LinkedList<>());
|
||||||
|
FieldData d = clazz.fields.get(lineData[0]);
|
||||||
|
if (d == null) continue;
|
||||||
|
d.mcpName = lineData[1];
|
||||||
|
mcpData.fields.get(lineData[1]).add(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mcpData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addMCPData(MCPData mcpData, String fields, String methods) {
|
||||||
|
for (String field : fields.split("\n")) {
|
||||||
|
String[] fieldData = field.split(",");
|
||||||
|
mcpData.fields.getOrDefault(fieldData[0].trim(), new LinkedList<>()).forEach(f -> f.mcpName = fieldData[1].trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String method : methods.split("\n")) {
|
||||||
|
String[] methodData = method.split(",");
|
||||||
|
mcpData.methods.getOrDefault(methodData[0].trim(), new LinkedList<>()).forEach(m -> m.mcpName = methodData[1].trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> readZipContentFromURL(URL remote, String... files) throws IOException {
|
||||||
|
try (ZipInputStream is = new ZipInputStream(new BufferedInputStream(remote.openStream(), 1024))) {
|
||||||
|
byte[] buff = new byte[1024];
|
||||||
|
ZipEntry entry;
|
||||||
|
Set<String> fileList = new HashSet<>(Arrays.asList(files));
|
||||||
|
Map<String, String> fileContents = new HashMap<>();
|
||||||
|
while ((entry = is.getNextEntry()) != null) {
|
||||||
|
if (fileList.contains(entry.getName())) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
int read;
|
||||||
|
while ((read = is.read(buff, 0, 1024)) > 0) {
|
||||||
|
builder.append(new String(buff, 0, read));
|
||||||
|
}
|
||||||
|
fileContents.put(entry.getName(), builder.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileContents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ClassData {
|
||||||
|
final Map<String, ClassData> classMap;
|
||||||
|
final String obf;
|
||||||
|
final String intermediary;
|
||||||
|
String mcpName;
|
||||||
|
|
||||||
|
final Map<String, MethodData> methods = new LinkedHashMap<>();
|
||||||
|
final Map<String, FieldData> fields = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
public ClassData(Map<String, ClassData> classMap, String obf, String intermediary) {
|
||||||
|
this.classMap = classMap;
|
||||||
|
this.obf = obf;
|
||||||
|
this.intermediary = intermediary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMethod(String obf, String obfSig, String intermediary) {
|
||||||
|
methods.put(obf + obfSig, new MethodData(classMap, obf, obfSig, intermediary));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addField(String obf, String obfSig, String intermediary) {
|
||||||
|
fields.put(obf, new FieldData(classMap, obf, obfSig, intermediary));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIntToMCP() {
|
||||||
|
StringBuilder builder = new StringBuilder("c\t").append(intermediary).append("\t").append(mcpName);
|
||||||
|
for (MethodData method : methods.values()) {
|
||||||
|
builder.append("\n\tm\t").append(method.getIntermediarySig()).append("\t").append(method.intermediary).append("\t").append(method.mcpName);
|
||||||
|
}
|
||||||
|
for (FieldData field : fields.values()) {
|
||||||
|
builder.append("\n\tf\t").append(field.getIntermediarySig()).append("\t").append(field.intermediary).append("\t").append(field.mcpName);
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MethodData {
|
||||||
|
final Map<String, ClassData> classMap;
|
||||||
|
final String obf;
|
||||||
|
final String intermediary;
|
||||||
|
String mcpName;
|
||||||
|
|
||||||
|
final String obfSig;
|
||||||
|
|
||||||
|
public MethodData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
|
||||||
|
this.classMap = classMap;
|
||||||
|
this.obf = obf;
|
||||||
|
this.obfSig = obfSig;
|
||||||
|
this.intermediary = intermediary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIntermediarySig() {
|
||||||
|
int offset = 0;
|
||||||
|
Matcher m = Pattern.compile("L(.+?);").matcher(obfSig);
|
||||||
|
String intSig = obfSig;
|
||||||
|
while (m.find()) {
|
||||||
|
if (!classMap.containsKey(m.group(1))) continue;
|
||||||
|
String intName = classMap.get(m.group(1)).intermediary;
|
||||||
|
intSig = intSig.substring(0, m.start(1) + offset) + intName + intSig.substring(m.end(1) + offset);
|
||||||
|
offset += intName.length() - m.group(1).length();
|
||||||
|
}
|
||||||
|
return intSig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class FieldData {
|
||||||
|
final Map<String, ClassData> classMap;
|
||||||
|
final String obf;
|
||||||
|
final String intermediary;
|
||||||
|
String mcpName;
|
||||||
|
|
||||||
|
final String obfSig;
|
||||||
|
|
||||||
|
public FieldData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
|
||||||
|
this.classMap = classMap;
|
||||||
|
this.obf = obf;
|
||||||
|
this.obfSig = obfSig;
|
||||||
|
this.intermediary = intermediary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIntermediarySig() {
|
||||||
|
Matcher m = Pattern.compile("(\\[*)L(.+?);").matcher(obfSig);
|
||||||
|
if (m.find()) {
|
||||||
|
if (!classMap.containsKey(m.group(2))) return obfSig;
|
||||||
|
return m.group(1) + "L" + classMap.get(m.group(2)).intermediary + ";";
|
||||||
|
} else {
|
||||||
|
return obfSig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MCPData {
|
||||||
|
final Map<String, List<MethodData>> methods = new HashMap<>();
|
||||||
|
final Map<String, List<FieldData>> fields = new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ package baritone.gradle.task;
|
|||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -32,45 +33,61 @@ import java.nio.file.Paths;
|
|||||||
class BaritoneGradleTask extends DefaultTask {
|
class BaritoneGradleTask extends DefaultTask {
|
||||||
|
|
||||||
protected static final String
|
protected static final String
|
||||||
PROGUARD_ZIP = "proguard.zip",
|
PROGUARD_ZIP = "proguard.zip",
|
||||||
PROGUARD_JAR = "proguard.jar",
|
PROGUARD_JAR = "proguard.jar",
|
||||||
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
||||||
PROGUARD_CONFIG_DEST = "template.pro",
|
PROGUARD_CONFIG_DEST = "template.pro",
|
||||||
PROGUARD_API_CONFIG = "api.pro",
|
PROGUARD_API_CONFIG = "api.pro",
|
||||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||||
|
|
||||||
TEMP_LIBRARY_DIR = "tempLibraries/",
|
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||||
|
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
ARTIFACT_API = "%s-api-%s.jar",
|
||||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
||||||
ARTIFACT_API = "%s-api-%s.jar",
|
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
|
||||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
||||||
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
|
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
|
||||||
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar";
|
ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
|
||||||
|
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
|
||||||
|
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
|
||||||
|
|
||||||
protected String artifactName, artifactVersion;
|
protected String artifactName, artifactVersion;
|
||||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgeApiPath, artifactForgeStandalonePath, proguardOut;
|
protected final Path
|
||||||
|
artifactPath,
|
||||||
|
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
|
||||||
|
proguardOut;
|
||||||
|
|
||||||
protected void verifyArtifacts() throws IllegalStateException {
|
public BaritoneGradleTask() {
|
||||||
this.artifactName = getProject().getName();
|
this.artifactName = getProject().getName();
|
||||||
this.artifactVersion = getProject().getVersion().toString();
|
this.artifactVersion = getProject().getVersion().toString();
|
||||||
|
|
||||||
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
|
||||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
|
||||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
if (getProject().hasProperty("baritone.forge_build")) {
|
||||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
|
||||||
this.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||||
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||||
|
} else if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
|
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
|
||||||
|
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
|
||||||
|
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
|
||||||
|
} else {
|
||||||
|
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||||
|
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||||
|
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||||
|
}
|
||||||
|
|
||||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void verifyArtifacts() throws IllegalStateException {
|
||||||
if (!Files.exists(this.artifactPath)) {
|
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!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void write(InputStream stream, Path file) throws Exception {
|
protected void write(InputStream stream, Path file) throws IOException {
|
||||||
if (Files.exists(file)) {
|
if (Files.exists(file)) {
|
||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
}
|
}
|
||||||
@@ -82,7 +99,7 @@ class BaritoneGradleTask extends DefaultTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Path getRelativeFile(String file) {
|
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) {
|
protected Path getTemporaryFile(String file) {
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import javax.xml.bind.DatatypeConverter;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||||
|
|
||||||
@@ -42,11 +42,9 @@ public class CreateDistTask extends BaritoneGradleTask {
|
|||||||
super.verifyArtifacts();
|
super.verifyArtifacts();
|
||||||
|
|
||||||
// Define the distribution file paths
|
// Define the distribution file paths
|
||||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
|
||||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
|
||||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
|
||||||
Path forgeApi = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API));
|
|
||||||
Path forgeStandalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE));
|
|
||||||
|
|
||||||
// NIO will not automatically create directories
|
// NIO will not automatically create directories
|
||||||
Path dir = getRelativeFile("dist/");
|
Path dir = getRelativeFile("dist/");
|
||||||
@@ -55,14 +53,14 @@ public class CreateDistTask extends BaritoneGradleTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy build jars to dist/
|
// Copy build jars to dist/
|
||||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
// TODO: dont copy files that dont exist
|
||||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactForgeApiPath, forgeApi, REPLACE_EXISTING);
|
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactForgeStandalonePath, forgeStandalone, REPLACE_EXISTING);
|
|
||||||
|
|
||||||
// Calculate all checksums and format them like "shasum"
|
// Calculate all checksums and format them like "shasum"
|
||||||
List<String> shasum = Stream.of(api, forgeApi, standalone, forgeStandalone, unoptimized)
|
List<String> shasum = getAllDistJars().stream()
|
||||||
|
.filter(Files::exists)
|
||||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -72,6 +70,24 @@ public class CreateDistTask extends BaritoneGradleTask {
|
|||||||
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
|
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getFileName(Path p) {
|
||||||
|
return p.getFileName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Path> getAllDistJars() {
|
||||||
|
return Arrays.asList(
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
|
||||||
|
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private static synchronized String sha1(Path path) {
|
private static synchronized String sha1(Path path) {
|
||||||
try {
|
try {
|
||||||
if (SHA1_DIGEST == null) {
|
if (SHA1_DIGEST == null) {
|
||||||
|
|||||||
@@ -19,61 +19,58 @@ package baritone.gradle.task;
|
|||||||
|
|
||||||
import baritone.gradle.util.Determinizer;
|
import baritone.gradle.util.Determinizer;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.plugins.JavaPluginConvention;
|
||||||
|
import org.gradle.api.tasks.Input;
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
import org.gradle.api.JavaVersion;
|
||||||
|
import org.gradle.api.NamedDomainObjectContainer;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.artifacts.Dependency;
|
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.Input;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.gradle.api.tasks.TaskCollection;
|
import org.gradle.api.tasks.TaskCollection;
|
||||||
import org.gradle.api.tasks.compile.ForkOptions;
|
import org.gradle.api.tasks.compile.ForkOptions;
|
||||||
import org.gradle.api.tasks.compile.JavaCompile;
|
import org.gradle.api.tasks.compile.JavaCompile;
|
||||||
|
import org.gradle.internal.Pair;
|
||||||
import org.gradle.internal.jvm.Jvm;
|
import org.gradle.internal.jvm.Jvm;
|
||||||
|
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
|
||||||
import java.io.File;
|
import org.gradle.process.internal.DefaultExecActionFactory;
|
||||||
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 java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.nio.file.Path;
|
||||||
import java.util.regex.Matcher;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Pattern;
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 10/11/2018
|
* @since 10/11/2018
|
||||||
*/
|
*/
|
||||||
public class ProguardTask extends BaritoneGradleTask {
|
public class ProguardTask extends BaritoneGradleTask {
|
||||||
|
|
||||||
private static final Pattern TEMP_LIBRARY_PATTERN = Pattern.compile("-libraryjars 'tempLibraries\\/([a-zA-Z0-9/_\\-\\.]+)\\.jar'");
|
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
private String extract;
|
private String extract;
|
||||||
|
|
||||||
private List<String> requiredLibraries;
|
|
||||||
|
|
||||||
private File mixin;
|
|
||||||
private File pathfinder;
|
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
protected void exec() throws Exception {
|
protected void exec() throws Exception {
|
||||||
super.verifyArtifacts();
|
super.verifyArtifacts();
|
||||||
|
|
||||||
// "Haha brady why don't you make separate tasks"
|
// "Haha brady why don't you make separate tasks"
|
||||||
|
processArtifact();
|
||||||
downloadProguard();
|
downloadProguard();
|
||||||
extractProguard();
|
extractProguard();
|
||||||
generateConfigs();
|
generateConfigs();
|
||||||
acquireDependencies();
|
|
||||||
processArtifact();
|
|
||||||
proguardApi();
|
proguardApi();
|
||||||
proguardStandalone();
|
proguardStandalone();
|
||||||
cleanup();
|
cleanup();
|
||||||
@@ -84,7 +81,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
Files.delete(this.artifactUnoptimizedPath);
|
Files.delete(this.artifactUnoptimizedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Arrays.asList(pathfinder), false);
|
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadProguard() throws Exception {
|
private void downloadProguard() throws Exception {
|
||||||
@@ -109,7 +106,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
try {
|
try {
|
||||||
path = findJavaPathByGradleConfig();
|
path = findJavaPathByGradleConfig();
|
||||||
if (path != null) return path;
|
if (path != null) return path;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
System.err.println("Unable to find java by javaCompile options");
|
System.err.println("Unable to find java by javaCompile options");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -117,7 +115,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
try {
|
try {
|
||||||
path = findJavaByJavaHome();
|
path = findJavaByJavaHome();
|
||||||
if (path != null) return path;
|
if (path != null) return path;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
System.err.println("Unable to find java by JAVA_HOME");
|
System.err.println("Unable to find java by JAVA_HOME");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -132,16 +131,23 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
|
|
||||||
private String findJavaByGradleCurrentRuntime() {
|
private String findJavaByGradleCurrentRuntime() {
|
||||||
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
|
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() {
|
private String findJavaByJavaHome() {
|
||||||
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
||||||
if (javaHomeEnv != null) {
|
if (javaHomeEnv != null) {
|
||||||
|
|
||||||
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
||||||
System.out.println("Detected Java path by JAVA_HOME");
|
if (this.validateJavaVersion(path)) {
|
||||||
return path;
|
System.out.println("Detected Java path by JAVA_HOME");
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -157,11 +163,19 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
if (javacPath != null) {
|
if (javacPath != null) {
|
||||||
File javacFile = new File(javacPath);
|
File javacFile = new File(javacPath);
|
||||||
if (javacFile.exists()) {
|
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) {
|
if (maybeJava != null && maybeJava.length > 0) {
|
||||||
String path = maybeJava[0].getAbsolutePath();
|
String path = maybeJava[0].getAbsolutePath();
|
||||||
System.out.println("Detected Java path by forkOptions");
|
if (this.validateJavaVersion(path)) {
|
||||||
return path;
|
System.out.println("Detected Java path by forkOptions");
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,19 +183,57 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
return null;
|
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 {
|
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
|
// Setup the template that will be used to derive the API and Standalone configs
|
||||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||||
template.add(0, "-injars '" + this.artifactPath.toString() + "'");
|
template.add(0, "-injars " + this.artifactPath.toString());
|
||||||
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
|
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
|
||||||
|
|
||||||
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
|
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
|
||||||
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
|
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
|
||||||
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
||||||
template.add(2, "-libraryjars '" + out + "'");
|
template.add(2, "-libraryjars '" + out + "'");
|
||||||
|
|
||||||
|
{
|
||||||
|
final Stream<File> libraries;
|
||||||
|
{
|
||||||
|
// Discover all of the libraries that we will need to acquire from gradle
|
||||||
|
final Stream<File> dependencies = acquireDependencies()
|
||||||
|
// remove MCP mapped jar
|
||||||
|
.filter(f -> !f.toString().endsWith("-recomp.jar"))
|
||||||
|
// go from the extra to the original downloaded client
|
||||||
|
.map(f -> f.toString().endsWith("client-extra.jar") ? new File(f.getParentFile(), "client.jar") : f);
|
||||||
|
|
||||||
|
if (getProject().hasProperty("baritone.forge_build")) {
|
||||||
|
libraries = dependencies
|
||||||
|
.map(f -> f.toString().endsWith("client.jar") ? getSrgMcJar() : f);
|
||||||
|
} else if (getProject().hasProperty("baritone.fabric_build")) {
|
||||||
|
libraries = dependencies
|
||||||
|
.map(f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") ? getSrgMcJar() : f);
|
||||||
|
} else {
|
||||||
|
libraries = dependencies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
libraries.forEach(f -> {
|
||||||
|
template.add(2, "-libraryjars '" + f + "'");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// API config doesn't require any changes from the changes that we made to the template
|
// API config doesn't require any changes from the changes that we made to the template
|
||||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||||
|
|
||||||
@@ -189,147 +241,26 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
List<String> standalone = new ArrayList<>(template);
|
List<String> standalone = new ArrayList<>(template);
|
||||||
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
||||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||||
|
|
||||||
// Discover all of the libraries that we will need to acquire from gradle
|
|
||||||
this.requiredLibraries = new ArrayList<>();
|
|
||||||
template.forEach(line -> {
|
|
||||||
if (!line.startsWith("#")) {
|
|
||||||
Matcher m = TEMP_LIBRARY_PATTERN.matcher(line);
|
|
||||||
if (m.find()) {
|
|
||||||
this.requiredLibraries.add(m.group(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Pair<A, B> {
|
private File getSrgMcJar() {
|
||||||
public final A a;
|
return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
|
||||||
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 {
|
private Stream<File> acquireDependencies() {
|
||||||
// Create a map of all of the dependencies that we are able to access in this project
|
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
|
||||||
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
.stream()
|
||||||
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
.filter(File::isFile);
|
||||||
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)));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the directory if it doesn't already exist
|
|
||||||
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
|
||||||
if (!Files.exists(tempLibraries)) {
|
|
||||||
Files.createDirectory(tempLibraries);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate the required libraries to copy them to tempLibraries
|
|
||||||
for (String lib : this.requiredLibraries) {
|
|
||||||
// copy from the forgegradle cache
|
|
||||||
if (lib.equals("minecraft")) {
|
|
||||||
Path cachedJar = getMinecraftJar();
|
|
||||||
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
|
||||||
// TODO: maybe try not to copy every time
|
|
||||||
Files.copy(cachedJar, inTempDir, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a configuration/dependency pair that matches the desired library
|
|
||||||
Pair<Configuration, Dependency> pair = null;
|
|
||||||
for (Map.Entry<String, Pair<Configuration, Dependency>> entry : dependencyLookupMap.entrySet()) {
|
|
||||||
if (entry.getKey().startsWith(lib)) {
|
|
||||||
pair = entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.
|
|
||||||
}
|
|
||||||
|
|
||||||
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.");
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 void proguardApi() throws Exception {
|
private void proguardApi() throws Exception {
|
||||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Arrays.asList(pathfinder), false);
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Arrays.asList(pathfinder, mixin), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void proguardStandalone() throws Exception {
|
private void proguardStandalone() throws Exception {
|
||||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Arrays.asList(pathfinder), false);
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Arrays.asList(pathfinder, mixin), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
@@ -342,33 +273,19 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExtract(String extract) {
|
public void setExtract(String extract) {
|
||||||
this.extract = extract;
|
this.extract = extract;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExtract() {
|
|
||||||
return extract;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runProguard(Path config) throws Exception {
|
private void runProguard(Path config) throws Exception {
|
||||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||||
if (Files.exists(this.proguardOut)) {
|
if (Files.exists(this.proguardOut)) {
|
||||||
Files.delete(this.proguardOut);
|
Files.delete(this.proguardOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make paths relative to work directory; fixes spaces in path to config, @"" doesn't work
|
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
|
||||||
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.
|
|
||||||
|
|
||||||
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
|
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();
|
.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
|
// 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 +295,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
|
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
|
||||||
int exitCode = p.waitFor();
|
int exitCode = p.waitFor();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
Thread.sleep(1000);
|
|
||||||
throw new IllegalStateException("Proguard exited with code " + exitCode);
|
throw new IllegalStateException("Proguard exited with code " + exitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,10 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class Determinizer {
|
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) throws IOException {
|
||||||
System.out.println("Running Determinizer");
|
System.out.println("Running Determinizer");
|
||||||
System.out.println(" Input path: " + inputPath);
|
System.out.println(" Input path: " + inputPath);
|
||||||
System.out.println(" Output path: " + outputPath);
|
System.out.println(" Output path: " + outputPath);
|
||||||
System.out.println(" Shade: " + toInclude);
|
|
||||||
|
|
||||||
try (
|
try (
|
||||||
JarFile jarFile = new JarFile(new File(inputPath));
|
JarFile jarFile = new JarFile(new File(inputPath));
|
||||||
@@ -64,36 +63,15 @@ public class Determinizer {
|
|||||||
JarEntry clone = new JarEntry(entry.getName());
|
JarEntry clone = new JarEntry(entry.getName());
|
||||||
clone.setTime(42069);
|
clone.setTime(42069);
|
||||||
jos.putNextEntry(clone);
|
jos.putNextEntry(clone);
|
||||||
if (entry.getName().endsWith(".json")) {
|
if (entry.getName().endsWith(".refmap.json")) {
|
||||||
JsonElement json = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry)));
|
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
||||||
jos.write(writeSorted(json).getBytes());
|
jos.write(writeSorted(object).getBytes());
|
||||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && doForgeReplacementOfMetaInf) { // only replace for forge jar
|
|
||||||
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
|
|
||||||
copy(jarFile.getInputStream(entry), cancer);
|
|
||||||
String manifest = new String(cancer.toByteArray());
|
|
||||||
if (!manifest.contains("baritone.launch.BaritoneTweaker")) {
|
|
||||||
throw new IllegalStateException("unable to replace");
|
|
||||||
}
|
|
||||||
manifest = manifest.replace("baritone.launch.BaritoneTweaker", "org.spongepowered.asm.launch.MixinTweaker");
|
|
||||||
jos.write(manifest.getBytes());
|
|
||||||
} else {
|
} else {
|
||||||
copy(jarFile.getInputStream(entry), jos);
|
copy(jarFile.getInputStream(entry), jos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (File file : toInclude) {
|
|
||||||
try (JarFile mixin = new JarFile(file)) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
jos.putNextEntry(entry);
|
|
||||||
copy(mixin.getInputStream(entry), jos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jos.finish();
|
jos.finish();
|
||||||
}
|
}
|
||||||
System.out.println("Done with determinizer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copy(InputStream is, OutputStream os) throws IOException {
|
private static void copy(InputStream is, OutputStream os) throws IOException {
|
||||||
@@ -104,7 +82,7 @@ public class Determinizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String writeSorted(JsonElement in) throws IOException {
|
private static String writeSorted(JsonObject in) throws IOException {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
JsonWriter jw = new JsonWriter(writer);
|
JsonWriter jw = new JsonWriter(writer);
|
||||||
ORDERED_JSON_WRITER.write(jw, in);
|
ORDERED_JSON_WRITER.write(jw, in);
|
||||||
|
|||||||
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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
#!/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
|
## Gradle start up script for UN*X
|
||||||
@@ -44,7 +28,7 @@ APP_NAME="Gradle"
|
|||||||
APP_BASE_NAME=`basename "$0"`
|
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.
|
# 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.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
@@ -72,7 +56,7 @@ case "`uname`" in
|
|||||||
Darwin* )
|
Darwin* )
|
||||||
darwin=true
|
darwin=true
|
||||||
;;
|
;;
|
||||||
MSYS* | MINGW* )
|
MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
NONSTOP* )
|
NONSTOP* )
|
||||||
@@ -82,7 +66,6 @@ esac
|
|||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; 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\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
if $cygwin ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
@@ -156,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=`expr $i + 1`
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
0) set -- ;;
|
(0) set -- ;;
|
||||||
1) set -- "$args0" ;;
|
(1) set -- "$args0" ;;
|
||||||
2) set -- "$args0" "$args1" ;;
|
(2) set -- "$args0" "$args1" ;;
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -177,9 +159,14 @@ save () {
|
|||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=`save "$@"`
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# 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"
|
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" "$@"
|
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
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -29,18 +13,15 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
|||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
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.
|
@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
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,14 +45,28 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
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
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@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}")
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
60
scripts/proguard.pro
vendored
60
scripts/proguard.pro
vendored
@@ -1,6 +1,5 @@
|
|||||||
-keepattributes Signature
|
-keepattributes Signature
|
||||||
-keepattributes *Annotation*
|
-keepattributes *Annotation*
|
||||||
-keepattributes InnerClasses
|
|
||||||
|
|
||||||
-optimizationpasses 5
|
-optimizationpasses 5
|
||||||
-verbose
|
-verbose
|
||||||
@@ -15,7 +14,12 @@
|
|||||||
|
|
||||||
# lwjgl is weird
|
# lwjgl is weird
|
||||||
-dontwarn org.lwjgl.**
|
-dontwarn org.lwjgl.**
|
||||||
|
# also lwjgl lol
|
||||||
|
-dontwarn module-info
|
||||||
|
# we dont have forge
|
||||||
|
-dontwarn baritone.launch.BaritoneForgeModXD
|
||||||
|
|
||||||
|
# please do not change the comment below
|
||||||
-keep class baritone.api.** { *; } # this is the keep api
|
-keep class baritone.api.** { *; } # this is the keep api
|
||||||
|
|
||||||
# service provider needs these class names
|
# service provider needs these class names
|
||||||
@@ -23,7 +27,6 @@
|
|||||||
-keep class baritone.api.IBaritoneProvider
|
-keep class baritone.api.IBaritoneProvider
|
||||||
|
|
||||||
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
-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 any class or member annotated with @KeepName so we dont have to put everything in the script
|
||||||
-keep,allowobfuscation @interface baritone.KeepName
|
-keep,allowobfuscation @interface baritone.KeepName
|
||||||
@@ -42,59 +45,8 @@
|
|||||||
|
|
||||||
#try to keep usage of schematica in separate classes
|
#try to keep usage of schematica in separate classes
|
||||||
-keep class baritone.utils.schematic.schematica.**
|
-keep class baritone.utils.schematic.schematica.**
|
||||||
-keep class baritone.utils.schematic.litematica.**
|
|
||||||
#proguard doesnt like it when it cant find our fake schematica classes
|
#proguard doesnt like it when it cant find our fake schematica classes
|
||||||
-dontwarn baritone.utils.schematic.schematica.**
|
-dontwarn baritone.utils.schematic.schematica.**
|
||||||
-dontwarn baritone.utils.schematic.litematica.**
|
|
||||||
|
|
||||||
# copy all necessary libraries into tempLibraries to build
|
|
||||||
|
|
||||||
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
|
||||||
-libraryjars 'tempLibraries/minecraft.jar'
|
|
||||||
|
|
||||||
-libraryjars 'tempLibraries/SimpleTweaker-1.2.jar'
|
|
||||||
|
|
||||||
-libraryjars 'tempLibraries/authlib-1.5.25.jar'
|
|
||||||
-libraryjars 'tempLibraries/codecjorbis-20101023.jar'
|
|
||||||
-libraryjars 'tempLibraries/codecwav-20101023.jar'
|
|
||||||
-libraryjars 'tempLibraries/commons-codec-1.10.jar'
|
|
||||||
-libraryjars 'tempLibraries/commons-compress-1.8.1.jar'
|
|
||||||
-libraryjars 'tempLibraries/commons-io-2.5.jar'
|
|
||||||
-libraryjars 'tempLibraries/commons-lang3-3.5.jar'
|
|
||||||
-libraryjars 'tempLibraries/commons-logging-1.1.3.jar'
|
|
||||||
-libraryjars 'tempLibraries/fastutil-7.1.0.jar'
|
|
||||||
-libraryjars 'tempLibraries/gson-2.8.0.jar'
|
|
||||||
-libraryjars 'tempLibraries/guava-21.0.jar'
|
|
||||||
-libraryjars 'tempLibraries/httpclient-4.3.3.jar'
|
|
||||||
-libraryjars 'tempLibraries/httpcore-4.3.2.jar'
|
|
||||||
-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar'
|
|
||||||
-libraryjars 'tempLibraries/jinput-2.0.5.jar'
|
|
||||||
-libraryjars 'tempLibraries/jna-4.4.0.jar'
|
|
||||||
-libraryjars 'tempLibraries/jopt-simple-5.0.3.jar'
|
|
||||||
-libraryjars 'tempLibraries/jsr305-3.0.1.jar'
|
|
||||||
-libraryjars 'tempLibraries/jutils-1.0.0.jar'
|
|
||||||
-libraryjars 'tempLibraries/libraryjavasound-20101123.jar'
|
|
||||||
-libraryjars 'tempLibraries/librarylwjglopenal-20100824.jar'
|
|
||||||
-libraryjars 'tempLibraries/log4j-api-2.8.1.jar'
|
|
||||||
-libraryjars 'tempLibraries/log4j-core-2.8.1.jar'
|
|
||||||
|
|
||||||
# startsWith is used to check the library, and mac/linux differ in which version they use
|
|
||||||
# this is FINE
|
|
||||||
-libraryjars 'tempLibraries/lwjgl-.jar'
|
|
||||||
-libraryjars 'tempLibraries/lwjgl_util-.jar'
|
|
||||||
|
|
||||||
-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/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/nether-pathfinder-.jar'
|
|
||||||
|
|
||||||
|
|
||||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||||
@@ -385,5 +337,3 @@
|
|||||||
public java.lang.String substring(int);
|
public java.lang.String substring(int);
|
||||||
public java.lang.String substring(int,int);
|
public java.lang.String substring(int,int);
|
||||||
}
|
}
|
||||||
|
|
||||||
-printmapping mapping.txt
|
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ package baritone.api;
|
|||||||
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.ServiceLoader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
|
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
|
||||||
*
|
*
|
||||||
@@ -35,11 +32,13 @@ public final class BaritoneAPI {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
settings = new Settings();
|
settings = new Settings();
|
||||||
SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME);
|
SettingsUtil.readAndApply(settings);
|
||||||
|
|
||||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
try {
|
||||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
provider = (IBaritoneProvider) Class.forName("baritone.BaritoneProvider").newInstance();
|
||||||
provider = instances.next();
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBaritoneProvider getProvider() {
|
public static IBaritoneProvider getProvider() {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.behavior.IElytraBehavior;
|
|
||||||
import baritone.api.behavior.ILookBehavior;
|
import baritone.api.behavior.ILookBehavior;
|
||||||
import baritone.api.behavior.IPathingBehavior;
|
import baritone.api.behavior.IPathingBehavior;
|
||||||
import baritone.api.cache.IWorldProvider;
|
import baritone.api.cache.IWorldProvider;
|
||||||
@@ -41,12 +40,6 @@ public interface IBaritone {
|
|||||||
*/
|
*/
|
||||||
IPathingBehavior getPathingBehavior();
|
IPathingBehavior getPathingBehavior();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The {@link IElytraBehavior} instance
|
|
||||||
* @see IElytraBehavior
|
|
||||||
*/
|
|
||||||
IElytraBehavior getElytraBehavior();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The {@link ILookBehavior} instance
|
* @return The {@link ILookBehavior} instance
|
||||||
* @see ILookBehavior
|
* @see ILookBehavior
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ import baritone.api.cache.IWorldScanner;
|
|||||||
import baritone.api.command.ICommand;
|
import baritone.api.command.ICommand;
|
||||||
import baritone.api.command.ICommandSystem;
|
import baritone.api.command.ICommandSystem;
|
||||||
import baritone.api.schematic.ISchematicSystem;
|
import baritone.api.schematic.ISchematicSystem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -49,18 +47,20 @@ public interface IBaritoneProvider {
|
|||||||
* returned by {@link #getPrimaryBaritone()}.
|
* returned by {@link #getPrimaryBaritone()}.
|
||||||
*
|
*
|
||||||
* @return All active {@link IBaritone} instances.
|
* @return All active {@link IBaritone} instances.
|
||||||
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
* @see #getBaritoneForPlayer(ClientPlayerEntity)
|
||||||
*/
|
*/
|
||||||
List<IBaritone> getAllBaritones();
|
List<IBaritone> getAllBaritones();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}.
|
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}. 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
|
* @param player The player
|
||||||
* @return The {@link IBaritone} instance.
|
* @return The {@link IBaritone} instance.
|
||||||
*/
|
*/
|
||||||
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
|
||||||
for (IBaritone baritone : this.getAllBaritones()) {
|
for (IBaritone baritone : getAllBaritones()) {
|
||||||
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
if (Objects.equals(player, baritone.getPlayerContext().player())) {
|
||||||
return baritone;
|
return baritone;
|
||||||
}
|
}
|
||||||
@@ -68,55 +68,6 @@ public interface IBaritoneProvider {
|
|||||||
return null;
|
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
|
* Returns the {@link IWorldScanner} instance. This is not a type returned by
|
||||||
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
|
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
|
||||||
|
|||||||
@@ -17,29 +17,21 @@
|
|||||||
|
|
||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.utils.NotificationHelper;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.TypeUtils;
|
import baritone.api.utils.TypeUtils;
|
||||||
import baritone.api.utils.gui.BaritoneToast;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
import java.awt.*;
|
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.Field;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,11 +46,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> allowBreak = new Setting<>(true);
|
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
|
* Allow Baritone to sprint
|
||||||
*/
|
*/
|
||||||
@@ -74,16 +61,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> allowInventory = new Setting<>(false);
|
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
|
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
|
||||||
* <p>
|
* <p>
|
||||||
@@ -93,9 +70,9 @@ public final class Settings {
|
|||||||
public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);
|
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
|
* 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);
|
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.
|
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
|
||||||
* Reliability: questionable.
|
* 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.
|
* 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.
|
* 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);
|
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
|
||||||
|
|
||||||
@@ -203,10 +171,10 @@ public final class Settings {
|
|||||||
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
||||||
*/
|
*/
|
||||||
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||||
Item.getItemFromBlock(Blocks.DIRT),
|
Blocks.DIRT.asItem(),
|
||||||
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
Blocks.COBBLESTONE.asItem(),
|
||||||
Item.getItemFromBlock(Blocks.NETHERRACK),
|
Blocks.NETHERRACK.asItem(),
|
||||||
Item.getItemFromBlock(Blocks.STONE)
|
Blocks.STONE.asItem()
|
||||||
)));
|
)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,28 +187,13 @@ public final class Settings {
|
|||||||
/**
|
/**
|
||||||
* Blocks that Baritone is not allowed to break
|
* 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?
|
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
|
||||||
Blocks.CRAFTING_TABLE,
|
Blocks.CRAFTING_TABLE,
|
||||||
Blocks.FURNACE,
|
Blocks.FURNACE,
|
||||||
Blocks.LIT_FURNACE,
|
|
||||||
Blocks.CHEST,
|
Blocks.CHEST,
|
||||||
Blocks.TRAPPED_CHEST,
|
Blocks.TRAPPED_CHEST
|
||||||
Blocks.STANDING_SIGN,
|
|
||||||
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.
|
* A list of blocks to be treated as if they're air.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -250,40 +203,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
|
* A list of blocks to become air
|
||||||
* <p>
|
* <p>
|
||||||
@@ -298,17 +217,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> buildIgnoreExisting = new Setting<>(false);
|
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.
|
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -373,6 +281,11 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Integer> rightClickSpeed = new Setting<>(4);
|
public final Setting<Integer> rightClickSpeed = new Setting<>(4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many degrees to randomize the yaw every tick. Set to 0 to disable
|
||||||
|
*/
|
||||||
|
public final Setting<Double> randomLooking113 = new Setting<>(2d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block reach distance
|
* Block reach distance
|
||||||
*/
|
*/
|
||||||
@@ -431,9 +344,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
|
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
|
||||||
|
|
||||||
/**
|
|
||||||
* Distance to avoid mob spawners.
|
|
||||||
*/
|
|
||||||
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
|
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -443,9 +353,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
|
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
|
||||||
|
|
||||||
/**
|
|
||||||
* Distance to avoid mobs.
|
|
||||||
*/
|
|
||||||
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -596,17 +503,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
|
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.
|
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
|
||||||
*/
|
*/
|
||||||
@@ -624,11 +520,11 @@ public final class Settings {
|
|||||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
|
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>
|
* <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
|
* Fill in blocks behind you
|
||||||
@@ -678,12 +574,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> renderGoal = new Setting<>(true);
|
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
|
* Render selection boxes
|
||||||
*/
|
*/
|
||||||
@@ -731,28 +621,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> freeLook = new Setting<>(true);
|
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.
|
* Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -775,7 +643,7 @@ public final class Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
|
* 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)
|
* 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.
|
* Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
|
||||||
*/
|
*/
|
||||||
@@ -830,16 +698,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> censorRanCommands = new Setting<>(false);
|
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
|
* 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.
|
* touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
|
||||||
@@ -887,11 +745,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
|
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.
|
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
|
||||||
*/
|
*/
|
||||||
@@ -905,7 +758,7 @@ public final class Settings {
|
|||||||
public final Setting<Integer> allowOnlyExposedOresDistance = new Setting<>(1);
|
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);
|
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
||||||
|
|
||||||
@@ -957,11 +810,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> layerOrder = new Setting<>(false);
|
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.
|
* Start building the schematic at a specific layer.
|
||||||
* Can help on larger builds when schematic wants to break things its already built
|
* Can help on larger builds when schematic wants to break things its already built
|
||||||
@@ -973,11 +821,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> skipFailedLayers = new Setting<>(false);
|
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
|
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
|
||||||
*/
|
*/
|
||||||
@@ -988,13 +831,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Integer> buildRepeatCount = new Setting<>(-1);
|
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
|
* Allow standing above a block while mining it, in BuilderProcess
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1103,7 +939,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"
|
* 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
|
* 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
|
* 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);
|
public final Setting<Boolean> legitMine = new Setting<>(false);
|
||||||
|
|
||||||
@@ -1188,24 +1023,12 @@ public final class Settings {
|
|||||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||||
* {@link Setting#value};
|
* {@link Setting#value};
|
||||||
*/
|
*/
|
||||||
@JavaOnly
|
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
||||||
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
|
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors
|
||||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
|
||||||
* {@link Setting#value};
|
|
||||||
*/
|
*/
|
||||||
@JavaOnly
|
public final Setting<Boolean> verboseCommandExceptions = new Setting<>(false);
|
||||||
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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||||
@@ -1297,11 +1120,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
|
||||||
* Use sword to mine.
|
|
||||||
*/
|
|
||||||
public final Setting<Boolean> useSwordToMine = new Setting<>(true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Desktop notifications
|
* Desktop notifications
|
||||||
*/
|
*/
|
||||||
@@ -1332,89 +1150,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
|
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
|
* A map of lowercase setting field names to their respective setting
|
||||||
*/
|
*/
|
||||||
@@ -1432,7 +1167,6 @@ public final class Settings {
|
|||||||
public T value;
|
public T value;
|
||||||
public final T defaultValue;
|
public final T defaultValue;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean javaOnly;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Setting(T value) {
|
private Setting(T value) {
|
||||||
@@ -1441,7 +1175,6 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.defaultValue = value;
|
this.defaultValue = value;
|
||||||
this.javaOnly = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1478,25 +1211,8 @@ public final class Settings {
|
|||||||
public final Type getType() {
|
public final Type getType() {
|
||||||
return settingTypes.get(this);
|
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
|
// here be dragons
|
||||||
|
|
||||||
Settings() {
|
Settings() {
|
||||||
@@ -1512,7 +1228,6 @@ public final class Settings {
|
|||||||
Setting<?> setting = (Setting<?>) field.get(this);
|
Setting<?> setting = (Setting<?>) field.get(this);
|
||||||
String name = field.getName();
|
String name = field.getName();
|
||||||
setting.name = name;
|
setting.name = name;
|
||||||
setting.javaOnly = field.isAnnotationPresent(JavaOnly.class);
|
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
if (tmpByName.containsKey(name)) {
|
if (tmpByName.containsKey(name)) {
|
||||||
throw new IllegalStateException("Duplicate setting name");
|
throw new IllegalStateException("Duplicate setting name");
|
||||||
|
|||||||
@@ -27,10 +27,4 @@ import baritone.api.event.listener.IGameEventListener;
|
|||||||
* @see IGameEventListener
|
* @see IGameEventListener
|
||||||
* @since 9/23/2018
|
* @since 9/23/2018
|
||||||
*/
|
*/
|
||||||
public interface IBehavior extends AbstractGameEventListener {
|
public interface IBehavior extends AbstractGameEventListener {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after Baritone's initialization is complete
|
|
||||||
*/
|
|
||||||
default void onLoad() {}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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;
|
package baritone.api.behavior;
|
||||||
|
|
||||||
import baritone.api.Settings;
|
|
||||||
import baritone.api.behavior.look.IAimProcessor;
|
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,23 +26,14 @@ import baritone.api.utils.Rotation;
|
|||||||
public interface ILookBehavior extends IBehavior {
|
public interface ILookBehavior extends IBehavior {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the current {@link ILookBehavior} target to target the specified rotations on the next tick. If any sort
|
* Updates the current {@link ILookBehavior} target to target
|
||||||
* of block interaction is required, {@code blockInteract} should be {@code true}. It is not guaranteed that the
|
* the specified rotations on the next tick. If force is {@code true},
|
||||||
* rotations set by the caller will be the exact rotations expressed by the client (This is due to settings like
|
* then freeLook will be overriden and angles will be set regardless.
|
||||||
* {@link Settings#randomLooking}). If the rotations produced by this behavior are required, then the
|
* If any sort of block interaction is required, force should be {@code true},
|
||||||
* {@link #getAimProcessor() aim processor} should be used.
|
* otherwise, it should be {@code false};
|
||||||
*
|
*
|
||||||
* @param rotation The target rotations
|
* @param rotation The target rotations
|
||||||
* @param blockInteract Whether the target rotations are needed for a block interaction
|
* @param force Whether or not to "force" the rotations
|
||||||
*/
|
*/
|
||||||
void updateTarget(Rotation rotation, boolean blockInteract);
|
void updateTarget(Rotation rotation, boolean force);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,15 +58,6 @@ public interface IPathingBehavior extends IBehavior {
|
|||||||
return Optional.of(current.getPath().ticksRemainingFrom(start));
|
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
|
* @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);
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.cache;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*/
|
*/
|
||||||
public interface IBlockTypeAccess {
|
public interface IBlockTypeAccess {
|
||||||
|
|
||||||
IBlockState getBlock(int x, int y, int z);
|
BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
default IBlockState getBlock(BlockPos pos) {
|
default BlockState getBlock(BlockPos pos) {
|
||||||
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,29 +15,30 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* 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 net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.Map;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class SchematicPlacementUnloaded {
|
/**
|
||||||
protected String name = "?";
|
* @author Brady
|
||||||
@Nullable
|
* @since 9/23/2018
|
||||||
protected File schematicFile;
|
*/
|
||||||
protected BlockPos origin = BlockPos.ORIGIN;
|
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() {
|
* Gets the map of all block positions to their remembered inventories.
|
||||||
return this.schematicFile;
|
*
|
||||||
}
|
* @return Map of block positions to their respective remembered inventories
|
||||||
|
*/
|
||||||
public BlockPos getOrigin() {
|
Map<BlockPos, IRememberedInventory> getRememberedInventories();
|
||||||
return this.origin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -15,17 +15,25 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils.accessor;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import net.minecraft.world.WorldProvider;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @see WorldProvider
|
* @since 9/23/2018
|
||||||
* @since 8/4/2018
|
|
||||||
*/
|
*/
|
||||||
public interface IChunkProviderServer {
|
public interface IRememberedInventory {
|
||||||
|
|
||||||
IChunkLoader getChunkLoader();
|
/**
|
||||||
|
* @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();
|
IWaypointCollection getWaypoints();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The {@link IContainerMemory} instance
|
||||||
|
* @see IContainerMemory
|
||||||
|
*/
|
||||||
|
IContainerMemory getContainerMemory();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.cache;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 9/24/2018
|
* @since 9/24/2018
|
||||||
@@ -31,11 +29,4 @@ public interface IWorldProvider {
|
|||||||
* @return The current world data
|
* @return The current world data
|
||||||
*/
|
*/
|
||||||
IWorldData getCurrentWorld();
|
IWorldData getCurrentWorld();
|
||||||
|
|
||||||
default void ifWorldLoaded(Consumer<IWorldData> callback) {
|
|
||||||
final IWorldData currentWorld = this.getCurrentWorld();
|
|
||||||
if (currentWorld != null) {
|
|
||||||
callback.accept(currentWorld);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import baritone.api.command.exception.CommandInvalidTypeException;
|
|||||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -404,8 +404,8 @@ public interface IArgConsumer {
|
|||||||
/**
|
/**
|
||||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||||
* <p>
|
* <p>
|
||||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||||
* {@link EnumFacing#UP}
|
* {@link Direction#UP}
|
||||||
*
|
*
|
||||||
* @param enumClass The enum class to search
|
* @param enumClass The enum class to search
|
||||||
* @return An enum constant of that class with the same name as the next argument's value
|
* @return An enum constant of that class with the same name as the next argument's value
|
||||||
@@ -419,8 +419,8 @@ public interface IArgConsumer {
|
|||||||
/**
|
/**
|
||||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||||
* <p>
|
* <p>
|
||||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||||
* {@link EnumFacing#UP}
|
* {@link Direction#UP}
|
||||||
*
|
*
|
||||||
* @param enumClass The enum class to search
|
* @param enumClass The enum class to search
|
||||||
* @param def The default value
|
* @param def The default value
|
||||||
@@ -436,8 +436,8 @@ public interface IArgConsumer {
|
|||||||
/**
|
/**
|
||||||
* Gets an enum value from the enum class with the same name as the next argument's value
|
* Gets an enum value from the enum class with the same name as the next argument's value
|
||||||
* <p>
|
* <p>
|
||||||
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
|
* For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
|
||||||
* {@link EnumFacing#UP}
|
* {@link Direction#UP}
|
||||||
*
|
*
|
||||||
* @param enumClass The enum class to search
|
* @param enumClass The enum class to search
|
||||||
* @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it
|
* @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package baritone.api.command.argument;
|
|||||||
|
|
||||||
import baritone.api.command.argparser.IArgParser;
|
import baritone.api.command.argparser.IArgParser;
|
||||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
|
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
|
||||||
@@ -50,8 +50,8 @@ public interface ICommandArgument {
|
|||||||
/**
|
/**
|
||||||
* Gets an enum value from the enum class with the same name as this argument's value
|
* Gets an enum value from the enum class with the same name as this argument's value
|
||||||
* <p>
|
* <p>
|
||||||
* For example if you getEnum as an {@link EnumFacing}, and this argument's value is "up", it will return {@link
|
* For example if you getEnum as an {@link Direction}, and this argument's value is "up", it will return {@link
|
||||||
* EnumFacing#UP}
|
* Direction#UP}
|
||||||
*
|
*
|
||||||
* @param enumClass The enum class to search
|
* @param enumClass The enum class to search
|
||||||
* @return An enum constant of that class with the same name as this argument's value
|
* @return An enum constant of that class with the same name as this argument's value
|
||||||
|
|||||||
@@ -20,25 +20,19 @@ package baritone.api.command.datatypes;
|
|||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.command.helpers.TabCompleteHelper;
|
import baritone.api.command.helpers.TabCompleteHelper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public enum BlockById implements IDatatypeFor<Block> {
|
public enum BlockById implements IDatatypeFor<Block> {
|
||||||
INSTANCE;
|
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
|
@Override
|
||||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||||
Block block;
|
Block block;
|
||||||
if ((block = Block.REGISTRY.getObject(id)) == Blocks.AIR) {
|
if ((block = Registry.BLOCK.getValue(id).orElse(null)) == null) {
|
||||||
throw new IllegalArgumentException("no block found by that id");
|
throw new IllegalArgumentException("no block found by that id");
|
||||||
}
|
}
|
||||||
return block;
|
return block;
|
||||||
@@ -46,19 +40,13 @@ public enum BlockById implements IDatatypeFor<Block> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||||
String arg = ctx.getConsumer().getString();
|
|
||||||
|
|
||||||
if (!PATTERN.matcher(arg).matches()) {
|
|
||||||
return Stream.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.append(
|
.append(
|
||||||
Block.REGISTRY.getKeys()
|
Registry.BLOCK.keySet()
|
||||||
.stream()
|
.stream()
|
||||||
.map(Object::toString)
|
.map(Object::toString)
|
||||||
)
|
)
|
||||||
.filterPrefixNamespaced(arg)
|
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||||
.sortAlphabetically()
|
.sortAlphabetically()
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,32 +19,20 @@ package baritone.api.command.datatypes;
|
|||||||
|
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.command.helpers.TabCompleteHelper;
|
import baritone.api.command.helpers.TabCompleteHelper;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public enum EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Entity> get(IDatatypeContext ctx) throws CommandException {
|
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||||
Class<? extends Entity> entity;
|
EntityType entity;
|
||||||
try {
|
if ((entity = Registry.ENTITY_TYPE.getValue(id).orElse(null)) == null) {
|
||||||
entity = EntityList.REGISTRY.getObject(id);
|
|
||||||
} 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 {
|
|
||||||
entity = (Class<? extends Entity>) EntityList.class.getMethod("getClass", ResourceLocation.class).invoke(null, id);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new RuntimeException("EntityList.REGISTRY does not exist and failed to call the Forge-replacement method", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity == null) {
|
|
||||||
throw new IllegalArgumentException("no entity found by that id");
|
throw new IllegalArgumentException("no entity found by that id");
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
@@ -53,7 +41,7 @@ public enum EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
|
|||||||
@Override
|
@Override
|
||||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.append(EntityList.getEntityNameList().stream().map(Object::toString))
|
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
|
||||||
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
.filterPrefixNamespaced(ctx.getConsumer().getString())
|
||||||
.sortAlphabetically()
|
.sortAlphabetically()
|
||||||
.stream();
|
.stream();
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,136 +18,20 @@
|
|||||||
package baritone.api.command.datatypes;
|
package baritone.api.command.datatypes;
|
||||||
|
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.command.helpers.TabCompleteHelper;
|
|
||||||
import baritone.api.utils.BlockOptionalMeta;
|
import baritone.api.utils.BlockOptionalMeta;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||||
INSTANCE;
|
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
|
@Override
|
||||||
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
|
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
|
||||||
return new BlockOptionalMeta(ctx.getConsumer().getString());
|
return new BlockOptionalMeta(ctx.getConsumer().getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
public Stream<String> tabComplete(IDatatypeContext ctx) {
|
||||||
String arg = ctx.getConsumer().peekString();
|
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,24 +19,24 @@ package baritone.api.command.datatypes;
|
|||||||
|
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.command.helpers.TabCompleteHelper;
|
import baritone.api.command.helpers.TabCompleteHelper;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public enum ForEnumFacing implements IDatatypeFor<EnumFacing> {
|
public enum ForDirection implements IDatatypeFor<Direction> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumFacing get(IDatatypeContext ctx) throws CommandException {
|
public Direction get(IDatatypeContext ctx) throws CommandException {
|
||||||
return EnumFacing.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
return Direction.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.append(Stream.of(EnumFacing.values())
|
.append(Stream.of(Direction.values())
|
||||||
.map(EnumFacing::getName).map(String::toLowerCase))
|
.map(Direction::getName).map(String::toLowerCase))
|
||||||
.filterPrefix(ctx.getConsumer().getString())
|
.filterPrefix(ctx.getConsumer().getString())
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ package baritone.api.command.datatypes;
|
|||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.command.helpers.TabCompleteHelper;
|
import baritone.api.command.helpers.TabCompleteHelper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -29,27 +30,27 @@ import java.util.stream.Stream;
|
|||||||
* An {@link IDatatype} used to resolve nearby players, those within
|
* An {@link IDatatype} used to resolve nearby players, those within
|
||||||
* render distance of the target {@link IBaritone} instance.
|
* render distance of the target {@link IBaritone} instance.
|
||||||
*/
|
*/
|
||||||
public enum NearbyPlayer implements IDatatypeFor<EntityPlayer> {
|
public enum NearbyPlayer implements IDatatypeFor<PlayerEntity> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPlayer get(IDatatypeContext ctx) throws CommandException {
|
public PlayerEntity get(IDatatypeContext ctx) throws CommandException {
|
||||||
final String username = ctx.getConsumer().getString();
|
final String username = ctx.getConsumer().getString();
|
||||||
return getPlayers(ctx).stream()
|
return getPlayers(ctx).stream()
|
||||||
.filter(s -> s.getName().equalsIgnoreCase(username))
|
.filter(s -> s.getName().getString().equalsIgnoreCase(username))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
|
||||||
return new TabCompleteHelper()
|
return new TabCompleteHelper()
|
||||||
.append(getPlayers(ctx).stream().map(EntityPlayer::getName))
|
.append(getPlayers(ctx).stream().map(PlayerEntity::getName).map(ITextComponent::getString))
|
||||||
.filterPrefix(ctx.getConsumer().getString())
|
.filterPrefix(ctx.getConsumer().getString())
|
||||||
.sortAlphabetically()
|
.sortAlphabetically()
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<EntityPlayer> getPlayers(IDatatypeContext ctx) {
|
private static List<? extends PlayerEntity> getPlayers(IDatatypeContext ctx) {
|
||||||
return ctx.getBaritone().getPlayerContext().world().playerEntities;
|
return ctx.getBaritone().getPlayerContext().world().getPlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
private static String ScalesAliasRegex = "[kKmM]";
|
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
|
||||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + ScalesAliasRegex + "?)|)$");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
|
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();
|
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;
|
offset *= 1000;
|
||||||
}
|
}
|
||||||
if (matcher.group(2).toLowerCase().contains("m")) {
|
|
||||||
offset *= 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (isRelative) {
|
if (isRelative) {
|
||||||
return origin + offset;
|
return origin + offset;
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ package baritone.api.command.datatypes;
|
|||||||
|
|
||||||
import baritone.api.command.argument.IArgConsumer;
|
import baritone.api.command.argument.IArgConsumer;
|
||||||
import baritone.api.command.exception.CommandException;
|
import baritone.api.command.exception.CommandException;
|
||||||
import baritone.api.utils.Helper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -85,23 +83,18 @@ public enum RelativeFile implements IDatatypePost<File, File> {
|
|||||||
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
|
||||||
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
|
||||||
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
|
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
|
||||||
useParent
|
useParent
|
||||||
? currentFile.getParentFile()
|
? currentFile.getParentFile()
|
||||||
: currentFile
|
: currentFile
|
||||||
).listFiles()))
|
).listFiles()))
|
||||||
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
|
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
|
||||||
(f.isDirectory() ? File.separator : ""))
|
(f.isDirectory() ? File.separator : ""))
|
||||||
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
|
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
|
||||||
.filter(s -> !s.contains(" "));
|
.filter(s -> !s.contains(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static File gameDir() {
|
public static File gameDir() {
|
||||||
return gameDir(Helper.mc);
|
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
|
||||||
}
|
|
||||||
|
|
||||||
public static File gameDir(Minecraft mc) {
|
|
||||||
File gameDir = mc.gameDir.getAbsoluteFile();
|
|
||||||
if (gameDir.getName().equals(".")) {
|
if (gameDir.getName().equals(".")) {
|
||||||
return gameDir.getParentFile();
|
return gameDir.getParentFile();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.api.command.exception;
|
|||||||
|
|
||||||
import baritone.api.command.ICommand;
|
import baritone.api.command.ICommand;
|
||||||
import baritone.api.command.argument.ICommandArgument;
|
import baritone.api.command.argument.ICommandArgument;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -36,6 +37,10 @@ public class CommandUnhandledException extends RuntimeException implements IComm
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ICommand command, List<ICommandArgument> args) {
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import baritone.api.command.exception.CommandException;
|
|||||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
import net.minecraft.util.text.event.ClickEvent;
|
||||||
import net.minecraft.util.text.event.HoverEvent;
|
import net.minecraft.util.text.event.HoverEvent;
|
||||||
@@ -74,7 +74,7 @@ public class Paginator<E> implements Helper {
|
|||||||
}
|
}
|
||||||
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
|
||||||
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
|
||||||
ITextComponent prevPageComponent = new TextComponentString("<<");
|
ITextComponent prevPageComponent = new StringTextComponent("<<");
|
||||||
if (hasPrevPage) {
|
if (hasPrevPage) {
|
||||||
prevPageComponent.getStyle()
|
prevPageComponent.getStyle()
|
||||||
.setClickEvent(new ClickEvent(
|
.setClickEvent(new ClickEvent(
|
||||||
@@ -83,12 +83,12 @@ public class Paginator<E> implements Helper {
|
|||||||
))
|
))
|
||||||
.setHoverEvent(new HoverEvent(
|
.setHoverEvent(new HoverEvent(
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
HoverEvent.Action.SHOW_TEXT,
|
||||||
new TextComponentString("Click to view previous page")
|
new StringTextComponent("Click to view previous page")
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
ITextComponent nextPageComponent = new TextComponentString(">>");
|
ITextComponent nextPageComponent = new StringTextComponent(">>");
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
nextPageComponent.getStyle()
|
nextPageComponent.getStyle()
|
||||||
.setClickEvent(new ClickEvent(
|
.setClickEvent(new ClickEvent(
|
||||||
@@ -97,12 +97,12 @@ public class Paginator<E> implements Helper {
|
|||||||
))
|
))
|
||||||
.setHoverEvent(new HoverEvent(
|
.setHoverEvent(new HoverEvent(
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
HoverEvent.Action.SHOW_TEXT,
|
||||||
new TextComponentString("Click to view next page")
|
new StringTextComponent("Click to view next page")
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||||
}
|
}
|
||||||
ITextComponent pagerComponent = new TextComponentString("");
|
ITextComponent pagerComponent = new StringTextComponent("");
|
||||||
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
pagerComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||||
pagerComponent.appendSibling(prevPageComponent);
|
pagerComponent.appendSibling(prevPageComponent);
|
||||||
pagerComponent.appendText(" | ");
|
pagerComponent.appendText(" | ");
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ public class TabCompleteHelper {
|
|||||||
public TabCompleteHelper addSettings() {
|
public TabCompleteHelper addSettings() {
|
||||||
return append(
|
return append(
|
||||||
BaritoneAPI.getSettings().allSettings.stream()
|
BaritoneAPI.getSettings().allSettings.stream()
|
||||||
.filter(s -> !s.isJavaOnly())
|
|
||||||
.map(Settings.Setting::getName)
|
.map(Settings.Setting::getName)
|
||||||
|
.filter(s -> !s.equalsIgnoreCase("logger"))
|
||||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class Registry<V> {
|
|||||||
* @param entry The entry to unregister.
|
* @param entry The entry to unregister.
|
||||||
*/
|
*/
|
||||||
public void unregister(V entry) {
|
public void unregister(V entry) {
|
||||||
if (!registered(entry)) {
|
if (registered(entry)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_entries.remove(entry);
|
_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
|
* @return The state of the event
|
||||||
*/
|
*/
|
||||||
public EventState getState() {
|
public final EventState getState() {
|
||||||
return this.state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The type of chunk event that occurred;
|
* @return The type of chunk event that occurred;
|
||||||
*/
|
*/
|
||||||
public Type getType() {
|
public final Type getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The Chunk X position.
|
* @return The Chunk X position.
|
||||||
*/
|
*/
|
||||||
public int getX() {
|
public final int getX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The Chunk Z position.
|
* @return The Chunk Z position.
|
||||||
*/
|
*/
|
||||||
public int getZ() {
|
public final int getZ() {
|
||||||
return this.z;
|
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 {
|
public enum Type {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,10 +106,6 @@ public final class ChunkEvent {
|
|||||||
* <p>
|
* <p>
|
||||||
* And it's a partial chunk
|
* And it's a partial chunk
|
||||||
*/
|
*/
|
||||||
POPULATE_PARTIAL;
|
POPULATE_PARTIAL
|
||||||
|
|
||||||
public final boolean isPopulate() {
|
|
||||||
return this == POPULATE_FULL || this == POPULATE_PARTIAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
|
import net.minecraft.network.IPacket;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -31,9 +31,9 @@ public final class PacketEvent {
|
|||||||
|
|
||||||
private final EventState state;
|
private final EventState state;
|
||||||
|
|
||||||
private final Packet<?> packet;
|
private final IPacket<?> packet;
|
||||||
|
|
||||||
public PacketEvent(NetworkManager networkManager, EventState state, Packet<?> packet) {
|
public PacketEvent(NetworkManager networkManager, EventState state, IPacket<?> packet) {
|
||||||
this.networkManager = networkManager;
|
this.networkManager = networkManager;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
@@ -47,12 +47,12 @@ public final class PacketEvent {
|
|||||||
return this.state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Packet<?> getPacket() {
|
public final IPacket<?> getPacket() {
|
||||||
return this.packet;
|
return this.packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final <T extends Packet<?>> T cast() {
|
public final <T extends IPacket<?>> T cast() {
|
||||||
return (T) this.packet;
|
return (T) this.packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import net.minecraft.client.renderer.Matrix4f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/5/2018
|
* @since 8/5/2018
|
||||||
@@ -28,8 +31,13 @@ public final class RenderEvent {
|
|||||||
*/
|
*/
|
||||||
private final float partialTicks;
|
private final float partialTicks;
|
||||||
|
|
||||||
public RenderEvent(float partialTicks) {
|
private final Matrix4f projectionMatrix;
|
||||||
|
private final MatrixStack modelViewStack;
|
||||||
|
|
||||||
|
public RenderEvent(float partialTicks, MatrixStack modelViewStack, Matrix4f projectionMatrix) {
|
||||||
this.partialTicks = partialTicks;
|
this.partialTicks = partialTicks;
|
||||||
|
this.modelViewStack = modelViewStack;
|
||||||
|
this.projectionMatrix = projectionMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,4 +46,12 @@ public final class RenderEvent {
|
|||||||
public final float getPartialTicks() {
|
public final float getPartialTicks() {
|
||||||
return this.partialTicks;
|
return this.partialTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MatrixStack getModelViewStack() {
|
||||||
|
return this.modelViewStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Matrix4f getProjectionMatrix() {
|
||||||
|
return this.projectionMatrix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import baritone.api.utils.Rotation;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -32,27 +32,14 @@ public final class RotationMoveEvent {
|
|||||||
*/
|
*/
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
private final Rotation original;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The yaw rotation
|
* The yaw rotation
|
||||||
*/
|
*/
|
||||||
private float yaw;
|
private float yaw;
|
||||||
|
|
||||||
/**
|
public RotationMoveEvent(Type type, float yaw) {
|
||||||
* The pitch rotation
|
|
||||||
*/
|
|
||||||
private float pitch;
|
|
||||||
|
|
||||||
public RotationMoveEvent(Type type, float yaw, float pitch) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.original = new Rotation(yaw, pitch);
|
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
this.pitch = pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rotation getOriginal() {
|
|
||||||
return this.original;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,37 +47,21 @@ public final class RotationMoveEvent {
|
|||||||
*
|
*
|
||||||
* @param yaw Yaw rotation
|
* @param yaw Yaw rotation
|
||||||
*/
|
*/
|
||||||
public void setYaw(float yaw) {
|
public final void setYaw(float yaw) {
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The yaw rotation
|
* @return The yaw rotation
|
||||||
*/
|
*/
|
||||||
public float getYaw() {
|
public final float getYaw() {
|
||||||
return this.yaw;
|
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
|
* @return The type of the event
|
||||||
*/
|
*/
|
||||||
public Type getType() {
|
public final Type getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,14 +70,14 @@ public final class RotationMoveEvent {
|
|||||||
/**
|
/**
|
||||||
* Called when the player's motion is updated.
|
* Called when the player's motion is updated.
|
||||||
*
|
*
|
||||||
* @see Entity#moveRelative(float, float, float, float)
|
* @see Entity#moveRelative(float, Vec3d)
|
||||||
*/
|
*/
|
||||||
MOTION_UPDATE,
|
MOTION_UPDATE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player jumps.
|
* Called when the player jumps.
|
||||||
*
|
*
|
||||||
* @see EntityLivingBase#jump
|
* @see LivingEntity
|
||||||
*/
|
*/
|
||||||
JUMP
|
JUMP
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import baritone.api.event.events.type.Cancellable;
|
|||||||
/**
|
/**
|
||||||
* @author LoganDark
|
* @author LoganDark
|
||||||
*/
|
*/
|
||||||
public class TabCompleteEvent extends Cancellable {
|
public final class TabCompleteEvent extends Cancellable {
|
||||||
|
|
||||||
public final String prefix;
|
public final String prefix;
|
||||||
public String[] completions;
|
public String[] completions;
|
||||||
|
|||||||
@@ -18,18 +18,9 @@
|
|||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
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 {
|
public final class TickEvent {
|
||||||
|
|
||||||
private static int overallTickCount;
|
private static int overallTickCount;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -29,14 +29,14 @@ public final class WorldEvent {
|
|||||||
/**
|
/**
|
||||||
* The new world that is being loaded. {@code null} if being unloaded.
|
* The new world that is being loaded. {@code null} if being unloaded.
|
||||||
*/
|
*/
|
||||||
private final WorldClient world;
|
private final ClientWorld world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state of the event
|
* The state of the event
|
||||||
*/
|
*/
|
||||||
private final EventState state;
|
private final EventState state;
|
||||||
|
|
||||||
public WorldEvent(WorldClient world, EventState state) {
|
public WorldEvent(ClientWorld world, EventState state) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public final class WorldEvent {
|
|||||||
/**
|
/**
|
||||||
* @return The new world that is being loaded. {@code null} if being unloaded.
|
* @return The new world that is being loaded. {@code null} if being unloaded.
|
||||||
*/
|
*/
|
||||||
public final WorldClient getWorld() {
|
public final ClientWorld getWorld() {
|
||||||
return this.world;
|
return this.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
|||||||
@Override
|
@Override
|
||||||
default void onTick(TickEvent event) {}
|
default void onTick(TickEvent event) {}
|
||||||
|
|
||||||
@Override
|
|
||||||
default void onPostTick(TickEvent event) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onPlayerUpdate(PlayerUpdateEvent event) {}
|
default void onPlayerUpdate(PlayerUpdateEvent event) {}
|
||||||
|
|
||||||
@@ -48,9 +45,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
|||||||
@Override
|
@Override
|
||||||
default void onChunkEvent(ChunkEvent event) {}
|
default void onChunkEvent(ChunkEvent event) {}
|
||||||
|
|
||||||
@Override
|
|
||||||
default void onBlockChange(BlockChangeEvent event) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onRenderPass(RenderEvent event) {}
|
default void onRenderPass(RenderEvent event) {}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,13 @@
|
|||||||
package baritone.api.event.listener;
|
package baritone.api.event.listener;
|
||||||
|
|
||||||
import baritone.api.event.events.*;
|
import baritone.api.event.events.*;
|
||||||
import io.netty.util.concurrent.GenericFutureListener;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.GuiGameOver;
|
import net.minecraft.client.gui.screen.DeathScreen;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.IPacket;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@@ -41,19 +40,11 @@ public interface IGameEventListener {
|
|||||||
*/
|
*/
|
||||||
void onTick(TickEvent event);
|
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.
|
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#onUpdate()
|
* @see ClientPlayerEntity#tick()
|
||||||
*/
|
*/
|
||||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||||
|
|
||||||
@@ -61,7 +52,7 @@ public interface IGameEventListener {
|
|||||||
* Runs whenever the client player sends a message to the server.
|
* Runs whenever the client player sends a message to the server.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#sendChatMessage(String)
|
* @see ClientPlayerEntity#sendChatMessage(String)
|
||||||
*/
|
*/
|
||||||
void onSendChatMessage(ChatEvent event);
|
void onSendChatMessage(ChatEvent event);
|
||||||
|
|
||||||
@@ -76,21 +67,11 @@ public interface IGameEventListener {
|
|||||||
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
|
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see WorldClient#doPreChunk(int, int, boolean)
|
|
||||||
*/
|
*/
|
||||||
void onChunkEvent(ChunkEvent event);
|
void onChunkEvent(ChunkEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs after a single or multi block change packet is received and processed.
|
* Runs once per world render pass.
|
||||||
*
|
|
||||||
* @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>
|
|
||||||
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
|
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
*/
|
*/
|
||||||
@@ -100,7 +81,7 @@ public interface IGameEventListener {
|
|||||||
* Runs before and after whenever a new world is loaded
|
* Runs before and after whenever a new world is loaded
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Minecraft#loadWorld(WorldClient, String)
|
* @see Minecraft#loadWorld(ClientWorld)
|
||||||
*/
|
*/
|
||||||
void onWorldEvent(WorldEvent event);
|
void onWorldEvent(WorldEvent event);
|
||||||
|
|
||||||
@@ -108,8 +89,7 @@ public interface IGameEventListener {
|
|||||||
* Runs before a outbound packet is sent
|
* Runs before a outbound packet is sent
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Packet
|
* @see IPacket
|
||||||
* @see GenericFutureListener
|
|
||||||
*/
|
*/
|
||||||
void onSendPacket(PacketEvent event);
|
void onSendPacket(PacketEvent event);
|
||||||
|
|
||||||
@@ -117,8 +97,7 @@ public interface IGameEventListener {
|
|||||||
* Runs before an inbound packet is processed
|
* Runs before an inbound packet is processed
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Packet
|
* @see IPacket
|
||||||
* @see GenericFutureListener
|
|
||||||
*/
|
*/
|
||||||
void onReceivePacket(PacketEvent event);
|
void onReceivePacket(PacketEvent event);
|
||||||
|
|
||||||
@@ -127,15 +106,15 @@ public interface IGameEventListener {
|
|||||||
* and before and after the player jumps.
|
* and before and after the player jumps.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Entity#moveRelative(float, float, float, float)
|
* @see Entity#moveRelative(float, Vec3d)
|
||||||
*/
|
*/
|
||||||
void onPlayerRotationMove(RotationMoveEvent event);
|
void onPlayerRotationMove(RotationMoveEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate}
|
* Called whenever the sprint keybind state is checked in {@link ClientPlayerEntity#livingTick}
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#onLivingUpdate()
|
* @see ClientPlayerEntity#livingTick()
|
||||||
*/
|
*/
|
||||||
void onPlayerSprintState(SprintStateEvent event);
|
void onPlayerSprintState(SprintStateEvent event);
|
||||||
|
|
||||||
@@ -147,9 +126,9 @@ public interface IGameEventListener {
|
|||||||
void onBlockInteract(BlockInteractEvent event);
|
void onBlockInteract(BlockInteractEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the local player dies, as indicated by the creation of the {@link GuiGameOver} screen.
|
* Called when the local player dies, as indicated by the creation of the {@link DeathScreen} screen.
|
||||||
*
|
*
|
||||||
* @see GuiGameOver
|
* @see DeathScreen
|
||||||
*/
|
*/
|
||||||
void onPlayerDeath();
|
void onPlayerDeath();
|
||||||
|
|
||||||
|
|||||||
@@ -54,18 +54,4 @@ public interface Goal {
|
|||||||
default double heuristic(BlockPos pos) {
|
default double heuristic(BlockPos pos) {
|
||||||
return heuristic(pos.getX(), pos.getY(), pos.getZ());
|
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);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GoalAxis";
|
return "GoalAxis";
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -67,26 +66,6 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
|||||||
return calculate(xDiff, yDiff, zDiff);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
@@ -108,9 +87,9 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
|||||||
public static double calculate(double xDiff, int yDiff, double zDiff) {
|
public static double calculate(double xDiff, int yDiff, double zDiff) {
|
||||||
double heuristic = 0;
|
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
|
// 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,yDiff,0 to a GoalYLevel of 0 is accurate
|
// therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
|
||||||
heuristic += GoalYLevel.calculate(0, yDiff);
|
heuristic += GoalYLevel.calculate(yDiff, 0);
|
||||||
|
|
||||||
//use the pythagorean and manhattan mixture from GoalXZ
|
//use the pythagorean and manhattan mixture from GoalXZ
|
||||||
heuristic += GoalXZ.calculate(xDiff, zDiff);
|
heuristic += GoalXZ.calculate(xDiff, zDiff);
|
||||||
|
|||||||
@@ -57,34 +57,6 @@ public class GoalComposite implements Goal {
|
|||||||
return min;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GoalComposite" + Arrays.toString(goals);
|
return "GoalComposite" + Arrays.toString(goals);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
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);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invert any goal.
|
* Invert any goal.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -47,29 +45,6 @@ public class GoalInverted implements Goal {
|
|||||||
return -origin.heuristic(x, y, z);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("GoalInverted{%s}", origin.toString());
|
return String.format("GoalInverted{%s}", origin.toString());
|
||||||
|
|||||||
@@ -17,11 +17,8 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
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;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class GoalNear implements Goal, IGoalRenderPos {
|
public class GoalNear implements Goal, IGoalRenderPos {
|
||||||
@@ -54,60 +51,11 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
|||||||
return GoalBlock.calculate(xDiff, yDiff, zDiff);
|
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
|
@Override
|
||||||
public BlockPos getGoalPos() {
|
public BlockPos getGoalPos() {
|
||||||
return new BlockPos(x, y, z);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -18,12 +18,9 @@
|
|||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
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 net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Useful for automated combat (retreating specifically)
|
* Useful for automated combat (retreating specifically)
|
||||||
@@ -68,7 +65,7 @@ public class GoalRunAway implements Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
double min = Double.MAX_VALUE;
|
||||||
for (BlockPos p : from) {
|
for (BlockPos p : from) {
|
||||||
double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
|
double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
|
||||||
@@ -83,71 +80,6 @@ public class GoalRunAway implements Goal {
|
|||||||
return min;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (maintainY != null) {
|
if (maintainY != null) {
|
||||||
|
|||||||
@@ -17,9 +17,8 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +32,7 @@ public class GoalStrictDirection implements Goal {
|
|||||||
public final int dx;
|
public final int dx;
|
||||||
public final int dz;
|
public final int dz;
|
||||||
|
|
||||||
public GoalStrictDirection(BlockPos origin, EnumFacing direction) {
|
public GoalStrictDirection(BlockPos origin, Direction direction) {
|
||||||
x = origin.getX();
|
x = origin.getX();
|
||||||
y = origin.getY();
|
y = origin.getY();
|
||||||
z = origin.getZ();
|
z = origin.getZ();
|
||||||
@@ -65,36 +64,6 @@ public class GoalStrictDirection implements Goal {
|
|||||||
return heuristic;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -73,26 +72,6 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
|||||||
return new BlockPos(x, y, z);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -64,27 +64,6 @@ public class GoalXZ implements Goal {
|
|||||||
return calculate(xDiff, zDiff);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -58,24 +58,6 @@ public class GoalYLevel implements Goal, ActionCosts {
|
|||||||
return 0;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.process;
|
package baritone.api.process;
|
||||||
|
|
||||||
import baritone.api.schematic.ISchematic;
|
import baritone.api.schematic.ISchematic;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
@@ -51,16 +51,13 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
|||||||
*/
|
*/
|
||||||
boolean build(String name, File schematic, Vec3i origin);
|
boolean build(String name, File schematic, Vec3i origin);
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
default boolean build(String schematicFile, BlockPos origin) {
|
default boolean build(String schematicFile, BlockPos origin) {
|
||||||
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
|
File file = new File(new File(Minecraft.getInstance().gameDir, "schematics"), schematicFile);
|
||||||
return build(schematicFile, file, origin);
|
return build(schematicFile, file, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildOpenSchematic();
|
void buildOpenSchematic();
|
||||||
|
|
||||||
void buildOpenLitematic(int i);
|
|
||||||
|
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
boolean isPaused();
|
boolean isPaused();
|
||||||
@@ -74,5 +71,5 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
|||||||
* schematics, for example, to pick a state that the builder process will be happy with, because any variation will
|
* schematics, for example, to pick a state that the builder process will be happy with, because any variation will
|
||||||
* cause it to give up. This is updated every tick, but only while the builder process is active.
|
* cause it to give up. This is updated every tick, but only while the builder process is active.
|
||||||
*/
|
*/
|
||||||
List<IBlockState> getApproxPlaceable();
|
List<BlockState> getApproxPlaceable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ public interface ICustomGoalProcess extends IBaritoneProcess {
|
|||||||
*/
|
*/
|
||||||
Goal getGoal();
|
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.
|
* Sets the goal and begins the path execution.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,10 +56,5 @@ public enum PathingCommandType {
|
|||||||
/**
|
/**
|
||||||
* Go and ask the next process what to do
|
* Go and ask the next process what to do
|
||||||
*/
|
*/
|
||||||
DEFER,
|
DEFER
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the goal and calculates a path, but pauses instead of immediately starting the path.
|
|
||||||
*/
|
|
||||||
SET_GOAL_AND_PAUSE
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,7 +47,7 @@ public class CompositeSchematic extends AbstractSchematic {
|
|||||||
recalcArr();
|
recalcArr();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) {
|
private CompositeSchematicEntry getSchematic(int x, int y, int z, BlockState currentState) {
|
||||||
for (CompositeSchematicEntry entry : schematicArr) {
|
for (CompositeSchematicEntry entry : schematicArr) {
|
||||||
if (x >= entry.x && y >= entry.y && z >= entry.z &&
|
if (x >= entry.x && y >= entry.y && z >= entry.z &&
|
||||||
entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
|
entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
|
||||||
@@ -58,24 +58,17 @@ public class CompositeSchematic extends AbstractSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||||
CompositeSchematicEntry entry = getSchematic(x, y, z, currentState);
|
CompositeSchematicEntry entry = getSchematic(x, y, z, currentState);
|
||||||
return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState);
|
return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||||
CompositeSchematicEntry entry = getSchematic(x, y, z, current);
|
CompositeSchematicEntry entry = getSchematic(x, y, z, current);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new IllegalStateException("couldn't find schematic for this position");
|
throw new IllegalStateException("couldn't find schematic for this position");
|
||||||
}
|
}
|
||||||
return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import baritone.api.utils.BlockOptionalMeta;
|
import baritone.api.utils.BlockOptionalMeta;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -31,8 +32,8 @@ public class FillSchematic extends AbstractSchematic {
|
|||||||
this.bom = bom;
|
this.bom = bom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FillSchematic(int x, int y, int z, IBlockState state) {
|
public FillSchematic(int x, int y, int z, BlockState state) {
|
||||||
this(x, y, z, new BlockOptionalMeta(state.getBlock(), state.getBlock().getMetaFromState(state)));
|
this(x, y, z, new BlockOptionalMeta(state.getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOptionalMeta getBom() {
|
public BlockOptionalMeta getBom() {
|
||||||
@@ -40,11 +41,13 @@ public class FillSchematic extends AbstractSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||||
if (bom.matches(current)) {
|
if (bom.matches(current)) {
|
||||||
return current;
|
return current;
|
||||||
|
} else if (current.getBlock() != Blocks.AIR) {
|
||||||
|
return Blocks.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
for (IBlockState placeable : approxPlaceable) {
|
for (BlockState placeable : approxPlaceable) {
|
||||||
if (bom.matches(placeable)) {
|
if (bom.matches(placeable)) {
|
||||||
return placeable;
|
return placeable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -44,11 +44,11 @@ public interface ISchematic {
|
|||||||
* @param currentState The current state of that block in the world, or null
|
* @param currentState The current state of that block in the world, or null
|
||||||
* @return Whether or not the specified position is within the bounds of this schematic
|
* @return Whether or not the specified position is within the bounds of this schematic
|
||||||
*/
|
*/
|
||||||
default boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
default boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||||
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
default int size(EnumFacing.Axis axis) {
|
default int size(Direction.Axis axis) {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X:
|
case X:
|
||||||
return widthX();
|
return widthX();
|
||||||
@@ -71,12 +71,7 @@ public interface ISchematic {
|
|||||||
* @param approxPlaceable The list of blockstates estimated to be placeable
|
* @param approxPlaceable The list of blockstates estimated to be placeable
|
||||||
* @return The desired block state at the specified position
|
* @return The desired block state at the specified position
|
||||||
*/
|
*/
|
||||||
IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable);
|
BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> 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
|
* @return The width (X axis length) of this schematic
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A static schematic is capable of providing the desired state at a given position without
|
* A static schematic is capable of providing the desired state at a given position without
|
||||||
@@ -30,7 +30,7 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
public interface IStaticSchematic extends ISchematic {
|
public interface IStaticSchematic extends ISchematic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link IBlockState} for a given position in this schematic. It should be guaranteed
|
* Gets the {@link BlockState} for a given position in this schematic. It should be guaranteed
|
||||||
* that the return value of this method will not change given that the parameters are the same.
|
* that the return value of this method will not change given that the parameters are the same.
|
||||||
*
|
*
|
||||||
* @param x The X block position
|
* @param x The X block position
|
||||||
@@ -38,19 +38,19 @@ public interface IStaticSchematic extends ISchematic {
|
|||||||
* @param z The Z block position
|
* @param z The Z block position
|
||||||
* @return The desired state at the specified position.
|
* @return The desired state at the specified position.
|
||||||
*/
|
*/
|
||||||
IBlockState getDirect(int x, int y, int z);
|
BlockState getDirect(int x, int y, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link IBlockState} array of size {@link #heightY()} which contains all
|
* Returns an {@link BlockState} array of size {@link #heightY()} which contains all
|
||||||
* desired block states in the specified vertical column. The index of {@link IBlockState}s
|
* desired block states in the specified vertical column. The index of {@link BlockState}s
|
||||||
* in the array are equivalent to their Y position in the schematic.
|
* in the array are equivalent to their Y position in the schematic.
|
||||||
*
|
*
|
||||||
* @param x The X column position
|
* @param x The X column position
|
||||||
* @param z The Z column position
|
* @param z The Z column position
|
||||||
* @return An {@link IBlockState} array
|
* @return An {@link BlockState} array
|
||||||
*/
|
*/
|
||||||
default IBlockState[] getColumn(int x, int z) {
|
default BlockState[] getColumn(int x, int z) {
|
||||||
IBlockState[] column = new IBlockState[this.heightY()];
|
BlockState[] column = new BlockState[this.heightY()];
|
||||||
for (int i = 0; i < this.heightY(); i++) {
|
for (int i = 0; i < this.heightY(); i++) {
|
||||||
column[i] = getDirect(x, i, z);
|
column[i] = getDirect(x, i, z);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import baritone.api.schematic.mask.Mask;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -31,25 +30,15 @@ public abstract class MaskSchematic extends AbstractSchematic {
|
|||||||
this.schematic = schematic;
|
this.schematic = schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean partOfMask(int x, int y, int z, IBlockState currentState);
|
protected abstract boolean partOfMask(int x, int y, int z, BlockState currentState);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
|
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
|
||||||
return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState);
|
return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) {
|
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
|
||||||
return schematic.desiredState(x, y, z, current, 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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public class ReplaceSchematic extends MaskSchematic {
|
public class ReplaceSchematic extends MaskSchematic {
|
||||||
|
|
||||||
@@ -32,19 +32,7 @@ public class ReplaceSchematic extends MaskSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||||
// 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) {
|
if (cache[x][y][z] == null) {
|
||||||
cache[x][y][z] = filter.has(currentState);
|
cache[x][y][z] = filter.has(currentState);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public class ShellSchematic extends MaskSchematic {
|
public class ShellSchematic extends MaskSchematic {
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class ShellSchematic extends MaskSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||||
return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1;
|
return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.schematic;
|
package baritone.api.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public class WallsSchematic extends MaskSchematic {
|
public class WallsSchematic extends MaskSchematic {
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class WallsSchematic extends MaskSchematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
|
||||||
return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1;
|
return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
*/
|
|
||||||
public final class SphereMask extends AbstractMask implements StaticMask {
|
|
||||||
|
|
||||||
private final double centerX;
|
|
||||||
private final double centerY;
|
|
||||||
private final double centerZ;
|
|
||||||
private final double radiusSqX;
|
|
||||||
private final double radiusSqY;
|
|
||||||
private final double radiusSqZ;
|
|
||||||
private final boolean filled;
|
|
||||||
|
|
||||||
public SphereMask(int widthX, int heightY, int lengthZ, boolean filled) {
|
|
||||||
super(widthX, heightY, lengthZ);
|
|
||||||
this.centerX = widthX / 2.0;
|
|
||||||
this.centerY = heightY / 2.0;
|
|
||||||
this.centerZ = lengthZ / 2.0;
|
|
||||||
this.radiusSqX = this.centerX * this.centerX;
|
|
||||||
this.radiusSqY = this.centerY * this.centerY;
|
|
||||||
this.radiusSqZ = this.centerZ * this.centerZ;
|
|
||||||
this.filled = filled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean partOfMask(int x, int y, int z) {
|
|
||||||
double dx = Math.abs((x + 0.5) - this.centerX);
|
|
||||||
double dy = Math.abs((y + 0.5) - this.centerY);
|
|
||||||
double dz = Math.abs((z + 0.5) - this.centerZ);
|
|
||||||
if (this.outside(dx, dy, dz)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.filled
|
|
||||||
|| this.outside(dx + 1, dy, dz)
|
|
||||||
|| this.outside(dx, dy + 1, dz)
|
|
||||||
|| this.outside(dx, dy, dz + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean outside(double dx, double dy, double dz) {
|
|
||||||
return dx * dx / this.radiusSqX + dy * dy / this.radiusSqY + dz * dz / this.radiusSqZ > 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.selection;
|
package baritone.api.selection;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public interface ISelection {
|
|||||||
* @param blocks How many blocks to expand it.
|
* @param blocks How many blocks to expand it.
|
||||||
* @return A new selection, expanded as specified.
|
* @return A new selection, expanded as specified.
|
||||||
*/
|
*/
|
||||||
ISelection expand(EnumFacing direction, int blocks);
|
ISelection expand(Direction direction, int blocks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
|
* Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
|
||||||
@@ -77,7 +77,7 @@ public interface ISelection {
|
|||||||
* @param blocks How many blocks to contract it.
|
* @param blocks How many blocks to contract it.
|
||||||
* @return A new selection, contracted as specified.
|
* @return A new selection, contracted as specified.
|
||||||
*/
|
*/
|
||||||
ISelection contract(EnumFacing direction, int blocks);
|
ISelection contract(Direction direction, int blocks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves
|
* Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves
|
||||||
@@ -87,5 +87,5 @@ public interface ISelection {
|
|||||||
* @param blocks How many blocks to shift it.
|
* @param blocks How many blocks to shift it.
|
||||||
* @return A new selection, shifted as specified.
|
* @return A new selection, shifted as specified.
|
||||||
*/
|
*/
|
||||||
ISelection shift(EnumFacing direction, int blocks);
|
ISelection shift(Direction direction, int blocks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package baritone.api.selection;
|
package baritone.api.selection;
|
||||||
|
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving
|
* The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving
|
||||||
@@ -87,7 +87,7 @@ public interface ISelectionManager {
|
|||||||
* @param blocks How many blocks to expand it.
|
* @param blocks How many blocks to expand it.
|
||||||
* @return The new selection, expanded as specified.
|
* @return The new selection, expanded as specified.
|
||||||
*/
|
*/
|
||||||
ISelection expand(ISelection selection, EnumFacing direction, int blocks);
|
ISelection expand(ISelection selection, Direction direction, int blocks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
|
* Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
|
||||||
@@ -101,7 +101,7 @@ public interface ISelectionManager {
|
|||||||
* @param blocks How many blocks to contract it.
|
* @param blocks How many blocks to contract it.
|
||||||
* @return The new selection, contracted as specified.
|
* @return The new selection, contracted as specified.
|
||||||
*/
|
*/
|
||||||
ISelection contract(ISelection selection, EnumFacing direction, int blocks);
|
ISelection contract(ISelection selection, Direction direction, int blocks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of
|
* Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of
|
||||||
@@ -112,5 +112,5 @@ public interface ISelectionManager {
|
|||||||
* @param blocks How many blocks to shift it.
|
* @param blocks How many blocks to shift it.
|
||||||
* @return The new selection, shifted as specified.
|
* @return The new selection, shifted as specified.
|
||||||
*/
|
*/
|
||||||
ISelection shift(ISelection selection, EnumFacing direction, int blocks);
|
ISelection shift(ISelection selection, Direction direction, int blocks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
@@ -35,15 +35,6 @@ import javax.annotation.Nonnull;
|
|||||||
*/
|
*/
|
||||||
public final class BetterBlockPos extends BlockPos {
|
public final class BetterBlockPos extends BlockPos {
|
||||||
|
|
||||||
private static final int NUM_X_BITS = 26;
|
|
||||||
private static final int NUM_Z_BITS = NUM_X_BITS;
|
|
||||||
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
|
||||||
private static final int Y_SHIFT = NUM_Z_BITS;
|
|
||||||
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
|
|
||||||
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
|
|
||||||
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
|
|
||||||
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
|
|
||||||
|
|
||||||
public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0);
|
public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0);
|
||||||
|
|
||||||
public final int x;
|
public final int x;
|
||||||
@@ -129,10 +120,10 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
// this is unimaginably faster than blockpos.up
|
// this is unimaginably faster than blockpos.up
|
||||||
// that literally calls
|
// that literally calls
|
||||||
// this.up(1)
|
// this.up(1)
|
||||||
// which calls this.offset(EnumFacing.UP, 1)
|
// which calls this.offset(Direction.UP, 1)
|
||||||
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
|
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
|
||||||
|
|
||||||
// how many function calls is that? up(), up(int), offset(EnumFacing, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
// how many function calls is that? up(), up(int), offset(Direction, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
|
||||||
// that's ten.
|
// that's ten.
|
||||||
// this is one function call.
|
// this is one function call.
|
||||||
return new BetterBlockPos(x, y + 1, z);
|
return new BetterBlockPos(x, y + 1, z);
|
||||||
@@ -157,13 +148,13 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BetterBlockPos offset(EnumFacing dir) {
|
public BetterBlockPos offset(Direction dir) {
|
||||||
Vec3i vec = dir.getDirectionVec();
|
Vec3i vec = dir.getDirectionVec();
|
||||||
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BetterBlockPos offset(EnumFacing dir, int dist) {
|
public BetterBlockPos offset(Direction dir, int dist) {
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -211,20 +202,6 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
|
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double distanceSq(final BetterBlockPos to) {
|
|
||||||
double dx = (double) this.x - to.x;
|
|
||||||
double dy = (double) this.y - to.y;
|
|
||||||
double dz = (double) this.z - to.z;
|
|
||||||
return dx * dx + dy * dy + dz * dz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double distanceTo(final BetterBlockPos to) {
|
|
||||||
double dx = (double) this.x - to.x;
|
|
||||||
double dy = (double) this.y - to.y;
|
|
||||||
double dz = (double) this.z - to.z;
|
|
||||||
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -235,15 +212,4 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
SettingsUtil.maybeCensor(z)
|
SettingsUtil.maybeCensor(z)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long serializeToLong(final int x, final int y, final int z) {
|
|
||||||
return ((long) x & X_MASK) << X_SHIFT | ((long) y & Y_MASK) << Y_SHIFT | ((long) z & Z_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BetterBlockPos deserializeFromLong(final long serialized) {
|
|
||||||
final int x = (int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
|
|
||||||
final int y = (int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
|
|
||||||
final int z = (int) (serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
|
|
||||||
return new BetterBlockPos(x, y, z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,282 +19,77 @@ package baritone.api.utils;
|
|||||||
|
|
||||||
import baritone.api.utils.accessor.IItemStack;
|
import baritone.api.utils.accessor.IItemStack;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.resources.*;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.Unit;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.storage.loot.*;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.regex.MatchResult;
|
import java.util.regex.MatchResult;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class BlockOptionalMeta {
|
public final class BlockOptionalMeta {
|
||||||
// id:meta or id[] or id[properties] where id and properties are any text with at least one character and meta is a one or two digit number
|
|
||||||
private static final Pattern PATTERN = Pattern.compile("^(?<id>.+?)(?::(?<meta>\\d\\d?)|\\[(?<properties>.+?)?\\])?$");
|
|
||||||
|
|
||||||
private final Block block;
|
private final Block block;
|
||||||
private final int meta;
|
private final Set<BlockState> blockstates;
|
||||||
private final boolean noMeta;
|
private final ImmutableSet<Integer> stateHashes;
|
||||||
private final String propertiesDescription; // exists so toString() can return something more useful than a list of all blockstates
|
private final ImmutableSet<Integer> stackHashes;
|
||||||
private final Set<IBlockState> blockstates;
|
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||||
private final Set<Integer> stateHashes;
|
private static LootTableManager manager;
|
||||||
private final Set<Integer> stackHashes;
|
private static LootPredicateManager predicate = new LootPredicateManager();
|
||||||
private static final Map<Object, Object> normalizations;
|
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||||
|
|
||||||
public BlockOptionalMeta(@Nonnull Block block, @Nullable Integer meta) {
|
public BlockOptionalMeta(@Nonnull Block block) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.noMeta = meta == null;
|
this.blockstates = getStates(block);
|
||||||
this.meta = noMeta ? 0 : meta;
|
|
||||||
this.propertiesDescription = "{}";
|
|
||||||
this.blockstates = getStates(block, meta, Collections.emptyMap());
|
|
||||||
this.stateHashes = getStateHashes(blockstates);
|
this.stateHashes = getStateHashes(blockstates);
|
||||||
this.stackHashes = getStackHashes(blockstates);
|
this.stackHashes = getStackHashes(blockstates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOptionalMeta(@Nonnull Block block) {
|
|
||||||
this(block, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockOptionalMeta(@Nonnull String selector) {
|
public BlockOptionalMeta(@Nonnull String selector) {
|
||||||
Matcher matcher = PATTERN.matcher(selector);
|
Matcher matcher = pattern.matcher(selector);
|
||||||
|
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
throw new IllegalArgumentException("invalid block selector");
|
throw new IllegalArgumentException("invalid block selector");
|
||||||
}
|
}
|
||||||
|
|
||||||
noMeta = matcher.group("meta") == null;
|
MatchResult matchResult = matcher.toMatchResult();
|
||||||
|
|
||||||
ResourceLocation id = new ResourceLocation(matcher.group("id"));
|
block = BlockUtils.stringToBlockRequired(matchResult.group(1));
|
||||||
|
blockstates = getStates(block);
|
||||||
if (!Block.REGISTRY.containsKey(id)) {
|
|
||||||
throw new IllegalArgumentException("Invalid block ID");
|
|
||||||
}
|
|
||||||
block = Block.REGISTRY.getObject(id);
|
|
||||||
|
|
||||||
String props = matcher.group("properties");
|
|
||||||
Map<IProperty<?>, ?> properties = props == null || props.equals("") ? Collections.emptyMap() : parseProperties(block, props);
|
|
||||||
|
|
||||||
propertiesDescription = props == null ? "{}" : "{" + props.replace("=", ":") + "}";
|
|
||||||
meta = noMeta ? 0 : Integer.parseInt(matcher.group("meta"));
|
|
||||||
blockstates = getStates(block, getMeta(), properties);
|
|
||||||
stateHashes = getStateHashes(blockstates);
|
stateHashes = getStateHashes(blockstates);
|
||||||
stackHashes = getStackHashes(blockstates);
|
stackHashes = getStackHashes(blockstates);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
private static Set<BlockState> getStates(@Nonnull Block block) {
|
||||||
Map<Object, Object> _normalizations = new HashMap<>();
|
return new HashSet<>(block.getStateContainer().getValidStates());
|
||||||
Consumer<Enum> put = instance -> _normalizations.put(instance.getClass(), instance);
|
|
||||||
put.accept(EnumFacing.NORTH);
|
|
||||||
put.accept(EnumFacing.Axis.Y);
|
|
||||||
put.accept(BlockLog.EnumAxis.Y);
|
|
||||||
put.accept(BlockStairs.EnumHalf.BOTTOM);
|
|
||||||
put.accept(BlockStairs.EnumShape.STRAIGHT);
|
|
||||||
put.accept(BlockLever.EnumOrientation.DOWN_X);
|
|
||||||
put.accept(BlockDoublePlant.EnumBlockHalf.LOWER);
|
|
||||||
put.accept(BlockSlab.EnumBlockHalf.BOTTOM);
|
|
||||||
put.accept(BlockDoor.EnumDoorHalf.LOWER);
|
|
||||||
put.accept(BlockDoor.EnumHingePosition.LEFT);
|
|
||||||
put.accept(BlockBed.EnumPartType.HEAD);
|
|
||||||
put.accept(BlockRailBase.EnumRailDirection.NORTH_SOUTH);
|
|
||||||
put.accept(BlockTrapDoor.DoorHalf.BOTTOM);
|
|
||||||
_normalizations.put(BlockBanner.ROTATION, 0);
|
|
||||||
_normalizations.put(BlockBed.OCCUPIED, false);
|
|
||||||
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[0], false);
|
|
||||||
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[1], false);
|
|
||||||
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[2], false);
|
|
||||||
_normalizations.put(BlockButton.POWERED, false);
|
|
||||||
// _normalizations.put(BlockCactus.AGE, 0);
|
|
||||||
// _normalizations.put(BlockCauldron.LEVEL, 0);
|
|
||||||
// _normalizations.put(BlockChorusFlower.AGE, 0);
|
|
||||||
_normalizations.put(BlockChorusPlant.NORTH, false);
|
|
||||||
_normalizations.put(BlockChorusPlant.EAST, false);
|
|
||||||
_normalizations.put(BlockChorusPlant.SOUTH, false);
|
|
||||||
_normalizations.put(BlockChorusPlant.WEST, false);
|
|
||||||
_normalizations.put(BlockChorusPlant.UP, false);
|
|
||||||
_normalizations.put(BlockChorusPlant.DOWN, false);
|
|
||||||
// _normalizations.put(BlockCocoa.AGE, 0);
|
|
||||||
// _normalizations.put(BlockCrops.AGE, 0);
|
|
||||||
_normalizations.put(BlockDirt.SNOWY, false);
|
|
||||||
_normalizations.put(BlockDoor.OPEN, false);
|
|
||||||
_normalizations.put(BlockDoor.POWERED, false);
|
|
||||||
// _normalizations.put(BlockFarmland.MOISTURE, 0);
|
|
||||||
_normalizations.put(BlockFence.NORTH, false);
|
|
||||||
_normalizations.put(BlockFence.EAST, false);
|
|
||||||
_normalizations.put(BlockFence.WEST, false);
|
|
||||||
_normalizations.put(BlockFence.SOUTH, false);
|
|
||||||
// _normalizations.put(BlockFenceGate.POWERED, false);
|
|
||||||
// _normalizations.put(BlockFenceGate.IN_WALL, false);
|
|
||||||
_normalizations.put(BlockFire.AGE, 0);
|
|
||||||
_normalizations.put(BlockFire.NORTH, false);
|
|
||||||
_normalizations.put(BlockFire.EAST, false);
|
|
||||||
_normalizations.put(BlockFire.SOUTH, false);
|
|
||||||
_normalizations.put(BlockFire.WEST, false);
|
|
||||||
_normalizations.put(BlockFire.UPPER, false);
|
|
||||||
// _normalizations.put(BlockFrostedIce.AGE, 0);
|
|
||||||
_normalizations.put(BlockGrass.SNOWY, false);
|
|
||||||
// _normalizations.put(BlockHopper.ENABLED, true);
|
|
||||||
// _normalizations.put(BlockLever.POWERED, false);
|
|
||||||
// _normalizations.put(BlockLiquid.LEVEL, 0);
|
|
||||||
// _normalizations.put(BlockMycelium.SNOWY, false);
|
|
||||||
// _normalizations.put(BlockNetherWart.AGE, false);
|
|
||||||
_normalizations.put(BlockLeaves.CHECK_DECAY, false);
|
|
||||||
// _normalizations.put(BlockLeaves.DECAYABLE, false);
|
|
||||||
// _normalizations.put(BlockObserver.POWERED, false);
|
|
||||||
_normalizations.put(BlockPane.NORTH, false);
|
|
||||||
_normalizations.put(BlockPane.EAST, false);
|
|
||||||
_normalizations.put(BlockPane.WEST, false);
|
|
||||||
_normalizations.put(BlockPane.SOUTH, false);
|
|
||||||
// _normalizations.put(BlockPistonBase.EXTENDED, false);
|
|
||||||
// _normalizations.put(BlockPressurePlate.POWERED, false);
|
|
||||||
// _normalizations.put(BlockPressurePlateWeighted.POWER, false);
|
|
||||||
_normalizations.put(BlockQuartz.EnumType.LINES_X, BlockQuartz.EnumType.LINES_Y);
|
|
||||||
_normalizations.put(BlockQuartz.EnumType.LINES_Z, BlockQuartz.EnumType.LINES_Y);
|
|
||||||
// _normalizations.put(BlockRailDetector.POWERED, false);
|
|
||||||
// _normalizations.put(BlockRailPowered.POWERED, false);
|
|
||||||
_normalizations.put(BlockRedstoneWire.NORTH, false);
|
|
||||||
_normalizations.put(BlockRedstoneWire.EAST, false);
|
|
||||||
_normalizations.put(BlockRedstoneWire.SOUTH, false);
|
|
||||||
_normalizations.put(BlockRedstoneWire.WEST, false);
|
|
||||||
// _normalizations.put(BlockReed.AGE, false);
|
|
||||||
_normalizations.put(BlockSapling.STAGE, 0);
|
|
||||||
_normalizations.put(BlockSkull.NODROP, false);
|
|
||||||
_normalizations.put(BlockStandingSign.ROTATION, 0);
|
|
||||||
_normalizations.put(BlockStem.AGE, 0);
|
|
||||||
_normalizations.put(BlockTripWire.NORTH, false);
|
|
||||||
_normalizations.put(BlockTripWire.EAST, false);
|
|
||||||
_normalizations.put(BlockTripWire.WEST, false);
|
|
||||||
_normalizations.put(BlockTripWire.SOUTH, false);
|
|
||||||
_normalizations.put(BlockVine.NORTH, false);
|
|
||||||
_normalizations.put(BlockVine.EAST, false);
|
|
||||||
_normalizations.put(BlockVine.SOUTH, false);
|
|
||||||
_normalizations.put(BlockVine.WEST, false);
|
|
||||||
_normalizations.put(BlockVine.UP, false);
|
|
||||||
_normalizations.put(BlockWall.UP, false);
|
|
||||||
_normalizations.put(BlockWall.NORTH, false);
|
|
||||||
_normalizations.put(BlockWall.EAST, false);
|
|
||||||
_normalizations.put(BlockWall.WEST, false);
|
|
||||||
_normalizations.put(BlockWall.SOUTH, false);
|
|
||||||
normalizations = Collections.unmodifiableMap(_normalizations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <C extends Comparable<C>, P extends IProperty<C>> P castToIProperty(Object value) {
|
private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
|
||||||
//noinspection unchecked
|
|
||||||
return (P) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <C extends Comparable<C>, P extends IProperty<C>> C castToIPropertyValue(P iproperty, Object value) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (C) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes the specified blockstate by setting meta-affecting properties which
|
|
||||||
* are not being targeted by the meta parameter to their default values.
|
|
||||||
* <p>
|
|
||||||
* For example, block variant/color is the primary target for the meta value, so properties
|
|
||||||
* such as rotation/facing direction will be set to default values in order to nullify
|
|
||||||
* the effect that they have on the state's meta value.
|
|
||||||
*
|
|
||||||
* @param state The state to normalize
|
|
||||||
* @return The normalized block state
|
|
||||||
*/
|
|
||||||
public static IBlockState normalize(IBlockState state) {
|
|
||||||
IBlockState newState = state;
|
|
||||||
|
|
||||||
for (IProperty<?> property : state.getProperties().keySet()) {
|
|
||||||
Class<?> valueClass = property.getValueClass();
|
|
||||||
if (normalizations.containsKey(property)) {
|
|
||||||
try {
|
|
||||||
newState = newState.withProperty(
|
|
||||||
castToIProperty(property),
|
|
||||||
castToIPropertyValue(property, normalizations.get(property))
|
|
||||||
);
|
|
||||||
} catch (IllegalArgumentException ignored) {}
|
|
||||||
} else if (normalizations.containsKey(state.getValue(property))) {
|
|
||||||
try {
|
|
||||||
newState = newState.withProperty(
|
|
||||||
castToIProperty(property),
|
|
||||||
castToIPropertyValue(property, normalizations.get(state.getValue(property)))
|
|
||||||
);
|
|
||||||
} catch (IllegalArgumentException ignored) {}
|
|
||||||
} else if (normalizations.containsKey(valueClass)) {
|
|
||||||
try {
|
|
||||||
newState = newState.withProperty(
|
|
||||||
castToIProperty(property),
|
|
||||||
castToIPropertyValue(property, normalizations.get(valueClass))
|
|
||||||
);
|
|
||||||
} catch (IllegalArgumentException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluate the target meta value for the specified state. The target meta value is
|
|
||||||
* most often that which is influenced by the variant/color property of the block state.
|
|
||||||
*
|
|
||||||
* @param state The state to check
|
|
||||||
* @return The target meta of the state
|
|
||||||
* @see #normalize(IBlockState)
|
|
||||||
*/
|
|
||||||
public static int stateMeta(IBlockState state) {
|
|
||||||
return state.getBlock().getMetaFromState(normalize(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<IProperty<?>, ?> parseProperties(Block block, String raw) {
|
|
||||||
ImmutableMap.Builder<IProperty<?>, Object> builder = ImmutableMap.builder();
|
|
||||||
for (String pair : raw.split(",")) {
|
|
||||||
String[] parts = pair.split("=");
|
|
||||||
if (parts.length != 2) {
|
|
||||||
throw new IllegalArgumentException(String.format("\"%s\" is not a valid property-value pair", pair));
|
|
||||||
}
|
|
||||||
String rawKey = parts[0];
|
|
||||||
String rawValue = parts[1];
|
|
||||||
IProperty<?> key = block.getBlockState().getProperty(rawKey);
|
|
||||||
Comparable<?> value = castToIProperty(key).parseValue(rawValue)
|
|
||||||
.toJavaUtil().orElseThrow(() -> new IllegalArgumentException(String.format(
|
|
||||||
"\"%s\" is not a valid value for %s on %s",
|
|
||||||
rawValue, key, block
|
|
||||||
)));
|
|
||||||
builder.put(key, value);
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<IBlockState> getStates(@Nonnull Block block, @Nullable Integer meta, @Nonnull Map<IProperty<?>, ?> properties) {
|
|
||||||
return block.getBlockState().getValidStates().stream()
|
|
||||||
.filter(blockstate -> meta == null || stateMeta(blockstate) == meta)
|
|
||||||
.filter(blockstate -> properties.entrySet().stream().allMatch(entry ->
|
|
||||||
blockstate.getValue(entry.getKey()) == entry.getValue()
|
|
||||||
))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ImmutableSet<Integer> getStateHashes(Set<IBlockState> blockstates) {
|
|
||||||
return ImmutableSet.copyOf(
|
return ImmutableSet.copyOf(
|
||||||
blockstates.stream()
|
blockstates.stream()
|
||||||
.map(IBlockState::hashCode)
|
.map(BlockState::hashCode)
|
||||||
.toArray(Integer[]::new)
|
.toArray(Integer[]::new)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableSet<Integer> getStackHashes(Set<IBlockState> blockstates) {
|
private static ImmutableSet<Integer> getStackHashes(Set<BlockState> blockstates) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return ImmutableSet.copyOf(
|
return ImmutableSet.copyOf(
|
||||||
blockstates.stream()
|
blockstates.stream()
|
||||||
.map(state -> new ItemStack(
|
.flatMap(state -> drops(state.getBlock())
|
||||||
state.getBlock().getItemDropped(state, new Random(), 0),
|
.stream()
|
||||||
state.getBlock().damageDropped(state)
|
.map(item -> new ItemStack(item, 1))
|
||||||
))
|
)
|
||||||
.map(stack -> ((IItemStack) (Object) stack).getBaritoneHash())
|
.map(stack -> ((IItemStack) (Object) stack).getBaritoneHash())
|
||||||
.toArray(Integer[]::new)
|
.toArray(Integer[]::new)
|
||||||
);
|
);
|
||||||
@@ -304,16 +99,11 @@ public final class BlockOptionalMeta {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated // deprecated because getMeta() == null no longer implies that this BOM only cares about the block
|
|
||||||
public Integer getMeta() {
|
|
||||||
return noMeta ? null : meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean matches(@Nonnull Block block) {
|
public boolean matches(@Nonnull Block block) {
|
||||||
return block == this.block;
|
return block == this.block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(@Nonnull IBlockState blockstate) {
|
public boolean matches(@Nonnull BlockState blockstate) {
|
||||||
Block block = blockstate.getBlock();
|
Block block = blockstate.getBlock();
|
||||||
return block == this.block && stateHashes.contains(blockstate.hashCode());
|
return block == this.block && stateHashes.contains(blockstate.hashCode());
|
||||||
}
|
}
|
||||||
@@ -322,28 +112,17 @@ public final class BlockOptionalMeta {
|
|||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
|
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
|
||||||
|
|
||||||
if (noMeta) {
|
hash -= stack.getDamage();
|
||||||
hash -= stack.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
return stackHashes.contains(hash);
|
return stackHashes.contains(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (noMeta) {
|
return String.format("BlockOptionalMeta{block=%s}", block);
|
||||||
return String.format("BlockOptionalMeta{block=%s,properties=%s}", block, propertiesDescription);
|
|
||||||
} else {
|
|
||||||
return String.format("BlockOptionalMeta{block=%s,meta=%s}", block, getMeta());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBlockState blockStateFromStack(ItemStack stack) {
|
public BlockState getAnyBlockState() {
|
||||||
//noinspection deprecation
|
|
||||||
return Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBlockState getAnyBlockState() {
|
|
||||||
if (blockstates.size() > 0) {
|
if (blockstates.size() > 0) {
|
||||||
return blockstates.iterator().next();
|
return blockstates.iterator().next();
|
||||||
}
|
}
|
||||||
@@ -351,11 +130,49 @@ public final class BlockOptionalMeta {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<IBlockState> getAllBlockStates() {
|
public static LootTableManager getManager() {
|
||||||
return blockstates;
|
if (manager == null) {
|
||||||
|
ResourcePackList rpl = new ResourcePackList<>(ResourcePackInfo::new);
|
||||||
|
rpl.addPackFinder(new ServerPackFinder());
|
||||||
|
rpl.reloadPacksFromFinders();
|
||||||
|
IResourcePack thePack = ((ResourcePackInfo) rpl.getAllPacks().iterator().next()).getResourcePack();
|
||||||
|
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA, null);
|
||||||
|
manager = new LootTableManager(predicate);
|
||||||
|
resourceManager.addReloadListener(manager);
|
||||||
|
try {
|
||||||
|
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw new RuntimeException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> stackHashes() {
|
public static LootPredicateManager getPredicateManager() {
|
||||||
return stackHashes;
|
return predicate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static synchronized List<Item> drops(Block b) {
|
||||||
|
return drops.computeIfAbsent(b, block -> {
|
||||||
|
ResourceLocation lootTableLocation = block.getLootTable();
|
||||||
|
if (lootTableLocation == LootTables.EMPTY) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
List<Item> items = new ArrayList<>();
|
||||||
|
|
||||||
|
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
|
||||||
|
getManager().getLootTableFromLocation(lootTableLocation).generate(
|
||||||
|
new LootContext.Builder(null)
|
||||||
|
.withRandom(new Random())
|
||||||
|
.withParameter(LootParameters.POSITION, BlockPos.ZERO)
|
||||||
|
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
|
||||||
|
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
|
||||||
|
.withParameter(LootParameters.BLOCK_STATE, block.getDefaultState())
|
||||||
|
.build(LootParameterSets.BLOCK),
|
||||||
|
stack -> items.add(stack.getItem())
|
||||||
|
);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,70 +17,68 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import baritone.api.utils.accessor.IItemStack;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class BlockOptionalMetaLookup {
|
public class BlockOptionalMetaLookup {
|
||||||
private final ImmutableSet<Block> blockSet;
|
|
||||||
private final ImmutableSet<IBlockState> blockStateSet;
|
|
||||||
private final ImmutableSet<Integer> stackHashes;
|
|
||||||
private final BlockOptionalMeta[] boms;
|
private final BlockOptionalMeta[] boms;
|
||||||
|
|
||||||
public BlockOptionalMetaLookup(BlockOptionalMeta... boms) {
|
public BlockOptionalMetaLookup(BlockOptionalMeta... boms) {
|
||||||
this.boms = boms;
|
this.boms = boms;
|
||||||
Set<Block> blocks = new HashSet<>();
|
|
||||||
Set<IBlockState> blockStates = new HashSet<>();
|
|
||||||
Set<Integer> stacks = new HashSet<>();
|
|
||||||
for (BlockOptionalMeta bom : boms) {
|
|
||||||
blocks.add(bom.getBlock());
|
|
||||||
blockStates.addAll(bom.getAllBlockStates());
|
|
||||||
stacks.addAll(bom.stackHashes());
|
|
||||||
}
|
|
||||||
this.blockSet = ImmutableSet.copyOf(blocks);
|
|
||||||
this.blockStateSet = ImmutableSet.copyOf(blockStates);
|
|
||||||
this.stackHashes = ImmutableSet.copyOf(stacks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOptionalMetaLookup(Block... blocks) {
|
public BlockOptionalMetaLookup(Block... blocks) {
|
||||||
this(Stream.of(blocks)
|
this.boms = Stream.of(blocks)
|
||||||
.map(BlockOptionalMeta::new)
|
.map(BlockOptionalMeta::new)
|
||||||
.toArray(BlockOptionalMeta[]::new));
|
.toArray(BlockOptionalMeta[]::new);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOptionalMetaLookup(List<Block> blocks) {
|
public BlockOptionalMetaLookup(List<Block> blocks) {
|
||||||
this(blocks.stream()
|
this.boms = blocks.stream()
|
||||||
.map(BlockOptionalMeta::new)
|
.map(BlockOptionalMeta::new)
|
||||||
.toArray(BlockOptionalMeta[]::new));
|
.toArray(BlockOptionalMeta[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOptionalMetaLookup(String... blocks) {
|
public BlockOptionalMetaLookup(String... blocks) {
|
||||||
this(Stream.of(blocks)
|
this.boms = Stream.of(blocks)
|
||||||
.map(BlockOptionalMeta::new)
|
.map(BlockOptionalMeta::new)
|
||||||
.toArray(BlockOptionalMeta[]::new));
|
.toArray(BlockOptionalMeta[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(Block block) {
|
public boolean has(Block block) {
|
||||||
return blockSet.contains(block);
|
for (BlockOptionalMeta bom : boms) {
|
||||||
|
if (bom.getBlock() == block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(IBlockState state) {
|
public boolean has(BlockState state) {
|
||||||
return blockStateSet.contains(state);
|
for (BlockOptionalMeta bom : boms) {
|
||||||
|
if (bom.matches(state)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(ItemStack stack) {
|
public boolean has(ItemStack stack) {
|
||||||
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
|
for (BlockOptionalMeta bom : boms) {
|
||||||
return stackHashes.contains(hash)
|
if (bom.matches(stack)) {
|
||||||
|| stackHashes.contains(hash - stack.getItemDamage());
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockOptionalMeta> blocks() {
|
public List<BlockOptionalMeta> blocks() {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.api.utils;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -28,7 +29,7 @@ public class BlockUtils {
|
|||||||
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||||
|
|
||||||
public static String blockToString(Block block) {
|
public static String blockToString(Block block) {
|
||||||
ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
|
ResourceLocation loc = Registry.BLOCK.getKey(block);
|
||||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||||
if (!loc.getNamespace().equals("minecraft")) {
|
if (!loc.getNamespace().equals("minecraft")) {
|
||||||
// Baritone is running on top of forge with mods installed, perhaps?
|
// Baritone is running on top of forge with mods installed, perhaps?
|
||||||
@@ -56,7 +57,7 @@ public class BlockUtils {
|
|||||||
if (resourceCache.containsKey(name)) {
|
if (resourceCache.containsKey(name)) {
|
||||||
return null; // cached as null
|
return null; // cached as null
|
||||||
}
|
}
|
||||||
block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
|
block = Registry.BLOCK.getValue(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
|
||||||
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||||
copy.put(name, block);
|
copy.put(name, block);
|
||||||
resourceCache = copy;
|
resourceCache = copy;
|
||||||
|
|||||||
@@ -1,27 +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.utils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface BooleanBinaryOperator {
|
|
||||||
|
|
||||||
boolean applyAsBoolean(boolean a, boolean b);
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user