Compare commits

...

90 Commits

Author SHA1 Message Date
Leijurv
2d421e66dc v1.5.2 2020-03-25 17:51:56 -07:00
Leijurv
e8370f1348 Merge branch '1.14.4' into 1.15.2 2020-03-25 17:51:42 -07:00
Leijurv
16f6baf216 v1.4.5 2020-03-25 17:39:01 -07:00
Leijurv
89ab959fb4 Merge branch '1.13.2' into 1.14.4 2020-03-25 17:38:28 -07:00
Leijurv
b9a7efc25b v1.3.7 2020-03-25 17:26:18 -07:00
Leijurv
3b7f13babd Merge branch 'master' into 1.13.2 2020-03-25 17:25:25 -07:00
Leijurv
dff92beea1 v1.2.13 2020-03-25 17:17:10 -07:00
Leijurv
62b808ad48 nickhasbugs 2020-03-18 19:15:47 -07:00
Leijurv
e926ff2a16 Merge branch '1.14.4' into 1.15.2 2020-03-14 12:35:33 -07:00
Leijurv
8794bfd79a fix javadoc errors 2020-03-14 12:35:03 -07:00
Leijurv
500643aec7 Merge branch '1.14.4' into 1.15.2 2020-03-14 12:25:46 -07:00
Leijurv
58bb6c4357 Merge branch '1.13.2' into 1.14.4 2020-03-14 12:25:36 -07:00
Leijurv
520142427d Merge branch 'master' into 1.13.2 2020-03-14 12:25:22 -07:00
Leijurv
69e871eaad we can copy from this image sure 2020-03-14 12:19:39 -07:00
Leijurv
d759c676f7 disable broken code 2020-03-14 12:13:45 -07:00
Leijurv
12481cc491 v1.2.12 2020-03-14 12:09:35 -07:00
Leijurv
43f11aaf0c finally update usage to furry code 2020-03-14 12:09:19 -07:00
Leijurv
f4842aa512 fix actual underlying sneak issue 2020-03-14 11:51:26 -07:00
Leijurv
bcd3fd3266 Merge pull request #1401 from S-B99/patch-1
Add modified settings to bug template
2020-03-14 10:59:39 -07:00
Bella Who
67256c17cf Add modified settings to bug template 2020-03-14 12:10:26 -04:00
Brady
369d726a96 Merge branch '1.14.4' into 1.15.2 2020-03-07 20:45:07 -06:00
Brady
e0beba38af Merge branch '1.13.2' into 1.14.4 2020-03-07 20:37:47 -06:00
Brady
ebe3f457c6 Fix additional injection points in 1.13.2 2020-03-07 20:27:29 -06:00
Brady
6289e540b8 Merge branch 'master' into 1.13.2 2020-03-07 20:23:09 -06:00
Brady
eda1820773 Fix Cubecraft Crash (Affects 1.13.2+) 2020-03-07 20:17:53 -06:00
Brady
c8856cfea4 Fix #1250 2020-03-07 17:34:27 -06:00
Brady
e0bd82d7ff lol? 2020-03-02 17:15:01 -06:00
Leijurv
217e0da4a6 Merge pull request #1340 from fw4hre0xxq/issue-1339-trapchest-pathing
fix #1339
2020-03-02 12:50:35 -08:00
Brady
96a8bb90c9 Fix tunnel usage in USAGE.md 2020-03-02 13:41:21 -06:00
Brady
0ca3c496de Fix tunnel command usage 2020-03-02 13:40:43 -06:00
Leijurv
d9fc825b0f Merge pull request #1336 from S-B99/patch-1
Update USAGE.md as per #1332
2020-02-27 18:07:16 -08:00
Leijurv
17c691b1cf the whole point is its better to do something nonsensical than to crash, so lets continue in that direction 2020-02-27 18:06:11 -08:00
Leijurv
9fb46946b5 fix sprint while paused bug, fixes #1331 2020-02-27 18:05:48 -08:00
fw4hre0xxq
220fa79057 fix #1339 2020-02-27 17:14:41 -08:00
Bella Who
f1f4adf8a6 Update USAGE.md as per #1332 2020-02-27 17:42:12 -05:00
Leijurv
448dd979a2 Merge pull request #1332 from aUniqueUser/master
#740 (Custom tunneling) Updated for new command system
2020-02-27 14:29:18 -08:00
Leijurv
3386947522 Merge pull request #1020 from Xephorix/patch-1
Update USAGE.md
2020-02-27 09:25:25 -08:00
aUniqueUser
628ec0f2b5 updated longDesc 2020-02-26 13:04:10 -05:00
aUniqueUser
e3b91c884a More logical argument order 2020-02-26 12:30:07 -05:00
aUniqueUser
10bb935a42 Merge pull request #1 from CDAGaming/CDAGaming-patch-1
[Change] Adjustments
2020-02-26 11:14:45 -05:00
CDAGaming
6f136a90a2 [Change] Adjustments 2020-02-26 07:55:21 -06:00
aUniqueUser
acd9bcceeb Codacy 2020-02-25 21:47:35 -05:00
aUniqueUser
3c2838df9e lol 2020-02-25 21:22:35 -05:00
aUniqueUser
4b526f7242 Custom Tunneling 2020-02-25 21:13:20 -05:00
Leijurv
5ec4b89caa Merge branch '1.14.4' into 1.15.2 2020-02-24 19:28:51 -08:00
Leijurv
5fd3e236e2 Merge branch '1.13.2' into 1.14.4 2020-02-24 19:28:42 -08:00
Leijurv
399037b866 Merge branch 'master' into 1.13.2 2020-02-24 19:28:05 -08:00
Leijurv
61563c9359 builderprocess should use hypothetical sneaking 2020-02-24 19:27:11 -08:00
Leijurv
2d941f6264 Merge branch '1.14.4' into 1.15.2 2020-02-24 19:02:20 -08:00
Leijurv
1a8d93b946 Merge branch '1.13.2' into 1.14.4 2020-02-24 18:56:56 -08:00
Leijurv
50783e65a9 Merge branch 'master' into 1.13.2 2020-02-24 18:39:36 -08:00
Leijurv
e854bf59f8 fix sneaking based issues 2020-02-24 18:31:42 -08:00
Leijurv
393a3a87b6 Update USAGE.md 2020-02-24 12:20:13 -08:00
Brady
888b2723e0 Fix critical prefix tag bug 2020-02-23 21:13:51 -06:00
Leijurv
6ed03d0858 Merge pull request #1328 from babbaj/baritoe
toe
2020-02-23 18:55:22 -08:00
Babbaj
ee33666b38 3 days 2020-02-23 21:54:18 -05:00
Babbaj
07c406aa16 baritoe 2020-02-23 21:48:15 -05:00
Brady
c578d5c1a3 Fix additional TrayIcon creation and support Mac notifs 2020-02-23 12:51:14 -06:00
Leijurv
2ea66ea8fc Merge pull request #1324 from aUniqueUser/master
Desktop Notification System
2020-02-23 10:05:30 -08:00
Leijurv
27440fc147 Update README.md 2020-02-22 22:42:22 -08:00
Leijurv
b1f5429db9 Update README.md 2020-02-22 18:37:29 -08:00
Leijurv
042b1ed6d7 Update README.md 2020-02-22 18:37:10 -08:00
aUniqueUser
a8645afbdb Revert "mfw"
This reverts commit 25b85f17a3.
2020-02-22 21:09:36 -05:00
aUniqueUser
25b85f17a3 mfw 2020-02-22 20:41:06 -05:00
aUniqueUser
cf691118b9 comment fixed 2020-02-22 20:19:25 -05:00
aUniqueUser
0dcb9d4b69 Formatting 2020-02-22 20:12:43 -05:00
aUniqueUser
2d2571cff5 Desktop Notification System 2020-02-22 18:31:41 -05:00
Leijurv
ec8d5c0f4d Merge pull request #1314 from babbaj/proguard-patch
Remove string parsing functions from -assumenosideeffects
2020-02-20 17:35:21 -08:00
Babbaj
85d63c9d7f Exceptions are side effects 2020-02-20 20:29:36 -05:00
Leijurv
19f70f5a79 Merge pull request #1306 from S-B99/patch-1
Make setup instructions more clear
2020-02-17 14:43:05 -08:00
Bella Who
80955cad8b Make setup instructions more clear 2020-02-17 17:42:05 -05:00
Leijurv
606e9bf97c v1.5.1 2020-02-14 15:28:37 -08:00
Leijurv
47ae75a9d6 Merge branch '1.14.4' into 1.15.2 2020-02-14 15:26:34 -08:00
Leijurv
25587e317a fix link click crash 2020-02-14 15:26:03 -08:00
Leijurv
01ba712d33 Update README.md 2020-02-14 13:49:53 -08:00
Leijurv
e0985d3b68 Update README.md 2020-02-14 13:49:15 -08:00
Leijurv
b3ba129fc5 honey is stupid lets just not 2020-02-13 18:59:08 -08:00
Leijurv
746b7b5c88 not unscuffed, just differently scuffed 2020-02-13 18:57:32 -08:00
Brady
db2f6ec78d Update mappings to 20200213-1.15.1 2020-02-13 14:44:29 -06:00
Leijurv
7181d2c91a Merge pull request #1287 from S-B99/master
Add Linux support to issue templates
2020-02-09 17:15:52 -08:00
Bella Who
e66d8616ce fixed space 2020-02-09 19:28:19 -05:00
Bella Who
656dd91004 Update bug.md 2020-02-09 19:12:40 -05:00
Leijurv
d88b3a7799 Merge pull request #1286 from S-B99/master
Make how to use checkboxes more clear in issue templates
2020-02-09 14:54:35 -08:00
Bella Who
7cdbc4acca Update suggestion.md 2020-02-09 17:45:28 -05:00
Bella Who
de68e6630e Update question.md 2020-02-09 17:45:09 -05:00
Bella Who
de89da20b2 Update bug.md 2020-02-09 17:44:50 -05:00
Leijurv
17a06621f5 rootnet shill 2020-02-01 16:42:14 -08:00
Leijurv
b3de840e04 no reason for this now that impact is 1.14.4 for all 2020-01-26 12:41:15 -08:00
Leijurv
539b8ef973 fix oversight in coordinate censorship 2020-01-25 22:35:01 -08:00
Xennex
bd345ae041 Update USAGE.md
added a few commands to the list of "fun / interesting / important ones that you might want to look at"
2019-10-07 09:50:10 -06:00
45 changed files with 379 additions and 158 deletions

View File

@@ -14,12 +14,22 @@ Baritone version:
Forge mods (if used):
## Exception, error or logs
You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac).
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue
Linux: `~/.minecraft/logs/`
Windows: `%appdata%/.minecraft/logs/`
Mac: `/Library/Application\ Support/minecraft/logs/`
## How to reproduce
Add your steps to reproduce the issue/bug experienced here.
## Modified settings
To get the modified settings run `#modified` in game
## Final checklist
- [x] I know how to properly use check boxes
- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
- [ ] I have included logs, exceptions and / or steps to reproduce the issue.
- [ ] I have not used any OwO's or UwU's in this issue.
- [ ] I have not used any OwO's or UwU's in this issue.

View File

@@ -10,4 +10,5 @@ assignees: ''
With as much detail as possible, describe your question and what you may need help with.
## Final checklist
- [ ] I have not used any OwO's or UwU's in this issue.
- [x] I know how to properly use check boxes
- [ ] I have not used any OwO's or UwU's in this issue.

View File

@@ -16,4 +16,5 @@ If applicable, what settings/customizability should be offered to tweak the func
Describe how your suggestion would improve Baritone, or the reason behind it being added.
## Final checklist
- [ ] I have not used any OwO's or UwU's in this issue.
- [x] I know how to properly use check boxes
- [ ] I have not used any OwO's or UwU's in this issue.

View File

@@ -9,8 +9,8 @@ install:
- travis_retry docker build -t cabaletta/baritone .
script:
- docker run --rm cabaletta/baritone ./gradlew javadoc
- docker run --name baritone cabaletta/baritone /bin/sh -c "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runAutoTest; cat /code/autotest/success"
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
#- docker run --name baritone cabaletta/baritone /bin/sh -c "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runAutoTest; cat /code/autotest/success"
- docker cp baritone:/code/dist dist
- ls dist
- cat dist/checksums.txt

View File

@@ -8,6 +8,7 @@
[![Minecraft](https://img.shields.io/badge/MC-1.12.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/master/)
[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/)
[![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/)
[![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/)
[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
[![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/)
@@ -22,6 +23,7 @@
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.10%20/%20v1.3.5%20/%20v1.4.3-brightgreen.svg)](https://impactclient.net/)
[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/)
[![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api)
[![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.11-green.svg)](https://rootnet.dev/)
[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/)
[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/)
[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/)
@@ -29,14 +31,14 @@
A Minecraft pathfinder bot.
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do.
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
@@ -56,6 +58,10 @@ Here are some links to help to get started:
- [Usage (chat control)](USAGE.md)
## Stars over time
[![Stargazers over time](https://starchart.cc/cabaletta/baritone.svg)](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/).

View File

@@ -47,6 +47,8 @@ You can verify whether or not it worked by running `.b version` in chat (only va
## Command Line
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8.
Setting up the Environment:
```
@@ -54,6 +56,12 @@ $ gradlew setupDecompWorkspace
$ gradlew --refresh-dependencies
```
Building Baritone:
```
$ gradlew build
```
Running Baritone:
```
@@ -87,16 +95,6 @@ For information on how to build baritone, see [Building Baritone](#building-bari
![Image](https://i.imgur.com/hrLhG9u.png)
# Building
Make sure that you have properly [setup](#setup) the environment before trying to build it.
## Command Line
```
$ gradlew build
```
## IntelliJ
- Navigate to the gradle tasks on the right tab as follows

View File

@@ -16,10 +16,12 @@ Try `#help` I promise it won't just send you back here =)
"wtf where is cleararea" -> look at `#help sel`
"wtf where is goto death, goto waypoint" -> look at `#help wp` (a "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually)). So you might want `#wp save user coolbiome` then, to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` (remember stuff is clickable!).
"wtf where is goto death, goto waypoint" -> look at `#help wp`
just look at `#help` lmao
Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
# Commands
**All** of these commands may need a prefix before them, as above ^.
@@ -38,11 +40,11 @@ Some common examples:
- `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 diamond_ore 64`.
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
- `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type.
- `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)
- `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
- `schematica` to build the schematic that is currently open in schematica
- `tunnel` to dig just straight ahead and make a tunnel
- `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
- `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.
@@ -71,6 +73,8 @@ There are about a hundred settings, but here are some fun / interesting / import
- `worldExploringChunkOffset`
- `acceptableThrowawayItems`
- `blocksToAvoidBreaking`
- `mineScanDroppedItems`
- `allowDiagonalAscend`
@@ -90,4 +94,4 @@ So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Min
## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?
These are custom commands that they added; those aren't from Baritone.
The equivalent you're looking for is `goal x z` then `path`.
The equivalent you're looking for is `goto x z`.

View File

@@ -16,7 +16,7 @@
*/
group 'baritone'
version '1.5.0'
version '1.5.2'
buildscript {
repositories {
@@ -82,7 +82,7 @@ task sourceJar(type: Jar, dependsOn: classes) {
}
minecraft {
mappings channel: 'snapshot', version: '20200205-1.15.1'
mappings channel: 'snapshot', version: '20200213-1.15.1'
reobfMappings 'notch'
runs {

48
scripts/proguard.pro vendored
View File

@@ -134,19 +134,19 @@
-assumenosideeffects public class java.lang.* extends java.lang.Number {
public static java.lang.String toString(byte);
public static java.lang.Byte valueOf(byte);
public static byte parseByte(java.lang.String);
public static byte parseByte(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String);
public static java.lang.Byte decode(java.lang.String);
# public static byte parseByte(java.lang.String);
# public static byte parseByte(java.lang.String,int);
# public static java.lang.Byte valueOf(java.lang.String,int);
# public static java.lang.Byte valueOf(java.lang.String);
# public static java.lang.Byte decode(java.lang.String);
public int compareTo(java.lang.Byte);
public static java.lang.String toString(short);
public static short parseShort(java.lang.String);
public static short parseShort(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String);
# public static short parseShort(java.lang.String);
# public static short parseShort(java.lang.String,int);
# public static java.lang.Short valueOf(java.lang.String,int);
# public static java.lang.Short valueOf(java.lang.String);
public static java.lang.Short valueOf(short);
public static java.lang.Short decode(java.lang.String);
# public static java.lang.Short decode(java.lang.String);
public static short reverseBytes(short);
public int compareTo(java.lang.Short);
public static java.lang.String toString(int,int);
@@ -154,10 +154,10 @@
public static java.lang.String toOctalString(int);
public static java.lang.String toBinaryString(int);
public static java.lang.String toString(int);
public static int parseInt(java.lang.String,int);
public static int parseInt(java.lang.String);
public static java.lang.Integer valueOf(java.lang.String,int);
public static java.lang.Integer valueOf(java.lang.String);
# public static int parseInt(java.lang.String,int);
# public static int parseInt(java.lang.String);
# public static java.lang.Integer valueOf(java.lang.String,int);
# public static java.lang.Integer valueOf(java.lang.String);
public static java.lang.Integer valueOf(int);
public static java.lang.Integer getInteger(java.lang.String);
public static java.lang.Integer getInteger(java.lang.String,int);
@@ -179,12 +179,12 @@
public static java.lang.String toOctalString(long);
public static java.lang.String toBinaryString(long);
public static java.lang.String toString(long);
public static long parseLong(java.lang.String,int);
public static long parseLong(java.lang.String);
public static java.lang.Long valueOf(java.lang.String,int);
public static java.lang.Long valueOf(java.lang.String);
# public static long parseLong(java.lang.String,int);
# public static long parseLong(java.lang.String);
# public static java.lang.Long valueOf(java.lang.String,int);
# public static java.lang.Long valueOf(java.lang.String);
public static java.lang.Long valueOf(long);
public static java.lang.Long decode(java.lang.String);
# public static java.lang.Long decode(java.lang.String);
public static java.lang.Long getLong(java.lang.String);
public static java.lang.Long getLong(java.lang.String,long);
public static java.lang.Long getLong(java.lang.String,java.lang.Long);
@@ -201,9 +201,9 @@
public int compareTo(java.lang.Long);
public static java.lang.String toString(float);
public static java.lang.String toHexString(float);
public static java.lang.Float valueOf(java.lang.String);
# public static java.lang.Float valueOf(java.lang.String);
public static java.lang.Float valueOf(float);
public static float parseFloat(java.lang.String);
# public static float parseFloat(java.lang.String);
public static boolean isNaN(float);
public static boolean isInfinite(float);
public static int floatToIntBits(float);
@@ -215,9 +215,9 @@
public int compareTo(java.lang.Float);
public static java.lang.String toString(double);
public static java.lang.String toHexString(double);
public static java.lang.Double valueOf(java.lang.String);
public static java.lang.Double valueOf(double);
public static double parseDouble(java.lang.String);
# public static java.lang.Double valueOf(java.lang.String);
# public static java.lang.Double valueOf(double);
# public static double parseDouble(java.lang.String);
public static boolean isNaN(double);
public static boolean isInfinite(double);
public static long doubleToLongBits(double);

View File

@@ -1053,6 +1053,10 @@ public final class Settings {
*/
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
/**
* Desktop Notifications
*/
public final Setting<Boolean> desktopNotifications = new Setting<>(false);
/**
* A map of lowercase setting field names to their respective setting

View File

@@ -18,6 +18,7 @@
package baritone.api.event.events;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.Matrix4f;
/**
* @author Brady
@@ -30,12 +31,13 @@ public final class RenderEvent {
*/
private final float partialTicks;
private final MatrixStack modelViewStack, projectionStack;
private final Matrix4f projectionMatrix;
private final MatrixStack modelViewStack;
public RenderEvent(float partialTicks, MatrixStack modelViewStack, MatrixStack projectionStack) {
public RenderEvent(float partialTicks, MatrixStack modelViewStack, Matrix4f projectionMatrix) {
this.partialTicks = partialTicks;
this.modelViewStack = modelViewStack;
this.projectionStack = projectionStack;
this.projectionMatrix = projectionMatrix;
}
/**
@@ -45,11 +47,11 @@ public final class RenderEvent {
return this.partialTicks;
}
public final MatrixStack getModelViewStack() {
public MatrixStack getModelViewStack() {
return this.modelViewStack;
}
public final MatrixStack getProjectionStack() {
return this.projectionStack;
public Matrix4f getProjectionMatrix() {
return this.projectionMatrix;
}
}

View File

@@ -18,6 +18,8 @@
package baritone.api.event.events;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Vec3d;
/**
* @author Brady
@@ -68,14 +70,14 @@ public final class RotationMoveEvent {
/**
* Called when the player's motion is updated.
*
* @see Entity#moveRelative(float, float, float, float)
* @see Entity#moveRelative(float, Vec3d)
*/
MOTION_UPDATE,
/**
* Called when the player jumps.
*
* @see LivingEntity#jump
* @see LivingEntity
*/
JUMP
}

View File

@@ -21,9 +21,10 @@ import baritone.api.event.events.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.DeathScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.network.IPacket;
import net.minecraft.util.math.Vec3d;
/**
* @author Brady
@@ -80,7 +81,7 @@ public interface IGameEventListener {
* Runs before and after whenever a new world is loaded
*
* @param event The event
* @see Minecraft#loadWorld(ClientWorld, Screen)
* @see Minecraft#loadWorld(ClientWorld)
*/
void onWorldEvent(WorldEvent event);
@@ -88,7 +89,7 @@ public interface IGameEventListener {
* Runs before a outbound packet is sent
*
* @param event The event
* @see Packet
* @see IPacket
*/
void onSendPacket(PacketEvent event);
@@ -96,7 +97,7 @@ public interface IGameEventListener {
* Runs before an inbound packet is processed
*
* @param event The event
* @see Packet
* @see IPacket
*/
void onReceivePacket(PacketEvent event);
@@ -105,7 +106,7 @@ public interface IGameEventListener {
* and before and after the player jumps.
*
* @param event The event
* @see Entity#moveRelative(float, float, float, float)
* @see Entity#moveRelative(float, Vec3d)
*/
void onPlayerRotationMove(RotationMoveEvent event);
@@ -125,9 +126,9 @@ public interface IGameEventListener {
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();

View File

@@ -24,6 +24,7 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import java.util.Arrays;
import java.util.Calendar;
import java.util.stream.Stream;
/**
@@ -47,7 +48,9 @@ public interface Helper {
static ITextComponent getPrefix() {
// Inner text component
ITextComponent baritone = new StringTextComponent(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
final Calendar now = Calendar.getInstance();
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
ITextComponent baritone = new StringTextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE);
// Outer brackets

View File

@@ -87,6 +87,10 @@ public interface IPlayerContext {
return new Rotation(player().rotationYaw, player().rotationPitch);
}
static double eyeHeight(boolean ifSneaking) {
return ifSneaking ? 1.27 : 1.62;
}
/**
* Returns the block that the crosshair is currently placed over. Updated once per tick.
*

View File

@@ -41,7 +41,16 @@ public final class RayTraceUtils {
* @return The calculated raytrace result
*/
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
Vec3d start = entity.getEyePosition(1.0F);
return rayTraceTowards(entity, rotation, blockReachDistance, false);
}
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) {
Vec3d start;
if (wouldSneak) {
start = inferSneakingEyePosition(entity);
} else {
start = entity.getEyePosition(1.0F); // do whatever is correct
}
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
Vec3d end = start.add(
direction.x * blockReachDistance,
@@ -50,4 +59,8 @@ public final class RayTraceUtils {
);
return entity.world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
}
public static Vec3d inferSneakingEyePosition(Entity entity) {
return new Vec3d(entity.getPosX(), entity.getPosY() + IPlayerContext.eyeHeight(true), entity.getPosZ());
}
}

View File

@@ -143,6 +143,10 @@ public final class RotationUtils {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
}
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, boolean wouldSneak) {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance(), wouldSneak);
}
/**
* Determines if the specified entity is able to reach the center of any of the sides
* of the specified block. It first checks if the block center is reachable, and if so,
@@ -156,6 +160,10 @@ public final class RotationUtils {
* @return The optional rotation
*/
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false);
}
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
if (baritone.getPlayerContext().isLookingAt(pos)) {
/*
@@ -168,9 +176,18 @@ public final class RotationUtils {
*
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
*/
return Optional.of(new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F));
Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F);
if (wouldSneak) {
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(pos)) {
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
}
} else {
return Optional.of(hypothetical);
}
}
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance);
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance, wouldSneak);
//System.out.println("center: " + possibleRotation);
if (possibleRotation.isPresent()) {
return possibleRotation;
@@ -185,7 +202,7 @@ public final class RotationUtils {
double xDiff = shape.getStart(Direction.Axis.X) * sideOffset.x + shape.getEnd(Direction.Axis.X) * (1 - sideOffset.x);
double yDiff = shape.getStart(Direction.Axis.Y) * sideOffset.y + shape.getEnd(Direction.Axis.Y) * (1 - sideOffset.y);
double zDiff = shape.getStart(Direction.Axis.Z) * sideOffset.z + shape.getEnd(Direction.Axis.Z) * (1 - sideOffset.z);
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
if (possibleRotation.isPresent()) {
return possibleRotation;
}
@@ -204,9 +221,10 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
//System.out.println(result);
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
if (((BlockRayTraceResult) result).getPos().equals(pos)) {
@@ -228,7 +246,7 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance);
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
}
}

View File

@@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.network.play.server.SChunkDataPacket;
import net.minecraft.network.play.server.SCombatPacket;
@@ -47,7 +48,8 @@ public class MixinClientPlayNetHandler {
)
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.PRE,
@@ -66,7 +68,8 @@ public class MixinClientPlayNetHandler {
)
private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
@@ -85,7 +88,8 @@ public class MixinClientPlayNetHandler {
)
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@@ -99,7 +103,8 @@ public class MixinClientPlayNetHandler {
)
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@@ -116,7 +121,8 @@ public class MixinClientPlayNetHandler {
)
private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onPlayerDeath();
}
}

View File

@@ -136,7 +136,7 @@ public class MixinMinecraft {
)
private boolean passEvents(Screen screen) {
// allow user input is only the primary baritone
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents;
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
}
// TODO

View File

@@ -29,5 +29,5 @@ public abstract class MixinScreen implements IGuiScreen {
@Override
@Invoker("openLink")
public abstract void openLink(URI url);
public abstract void openLinkInvoker(URI url);
}

View File

@@ -21,30 +21,28 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(GameRenderer.class)
public class MixinGameRenderer {
/**
* @author Brady
* @since 2/13/2020
*/
@Mixin(WorldRenderer.class)
public class MixinWorldRenderer {
@Inject(
method = "renderWorld",
at = @At(
value = "INVOKE_STRING",
target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V",
args = {"ldc=hand"}
),
locals = LocalCapture.CAPTURE_FAILHARD
method = "updateCameraAndRender",
at = @At("RETURN"),
locals = LocalCapture.CAPTURE_FAILSOFT
)
private void renderWorldPass(float partialTicks, long finishTimeNano, MatrixStack modelViewMatrix, CallbackInfo ci, boolean flag, ActiveRenderInfo activerenderinfo, MatrixStack projectionMatrix, float f, Matrix4f matrix4f) {
private void onStartHand(MatrixStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, ActiveRenderInfo activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, modelViewMatrix, projectionMatrix));
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn));
}
}
}
}

View File

@@ -9,14 +9,13 @@
},
"client": [
"MixinBitArray",
"MixinCommandSuggestionHelper",
"MixinChunkArray",
"MixinClientChunkProvider",
"MixinClientPlayerEntity",
"MixinClientPlayNetHandler",
"MixinCommandSuggestionHelper",
"MixinEntity",
"MixinEntityRenderManager",
"MixinGameRenderer",
"MixinItemStack",
"MixinLivingEntity",
"MixinLootContext",
@@ -24,6 +23,7 @@
"MixinNetworkManager",
"MixinPalettedContainer",
"MixinPlayerController",
"MixinScreen"
"MixinScreen",
"MixinWorldRenderer"
]
}

View File

@@ -103,7 +103,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
@Override
public void onPlayerSprintState(SprintStateEvent event) {
if (current != null) {
if (isPathing()) {
event.setState(current.isSprinting());
}
}

View File

@@ -184,7 +184,9 @@ public final class CachedWorld implements ICachedWorld, Helper {
int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ();
double dist = Math.sqrt(distX * distX + distZ * distZ);
if (dist > 1024) {
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
if (!Baritone.settings().censorCoordinates.value) {
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
}
cachedRegions.remove(getRegionID(region.getX(), region.getZ()));
}
}

View File

@@ -100,7 +100,7 @@ public class BaritoneChatControl implements Helper, AbstractGameEventListener {
return false;
} else if (msg.trim().equalsIgnoreCase("orderpizza")) {
try {
((IGuiScreen) mc.currentScreen).openLink(new URI("https://www.dominos.com/en/pages/order/"));
((IGuiScreen) mc.currentScreen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/"));
} catch (NullPointerException | URISyntaxException ignored) {}
return false;
}

View File

@@ -19,13 +19,13 @@ package baritone.command.defaults;
import baritone.Baritone;
import baritone.api.IBaritone;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.datatypes.RelativeBlockPos;
import baritone.api.command.datatypes.RelativeFile;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.utils.BetterBlockPos;
import net.minecraft.client.Minecraft;
import org.apache.commons.io.FilenameUtils;
@@ -59,7 +59,7 @@ public class BuildCommand extends Command {
}
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
if (!success) {
throw new CommandInvalidStateException("Couldn't load the schematic");
throw new CommandInvalidStateException("Couldn't load the schematic. Make sure to use the FULL file name, including the extension (e.g. blah.schematic).");
}
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
}

View File

@@ -18,11 +18,13 @@
package baritone.command.defaults;
import baritone.api.IBaritone;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalStrictDirection;
import baritone.api.command.Command;
import baritone.api.command.exception.CommandException;
import baritone.api.command.argument.IArgConsumer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays;
import java.util.List;
@@ -36,13 +38,56 @@ public class TunnelCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.player().getHorizontalFacing()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);
logDirect(String.format("Goal: %s", goal.toString()));
args.requireMax(3);
if (args.hasExactly(3)) {
boolean cont = true;
int height = Integer.parseInt(args.getArgs().get(0).getValue());
int width = Integer.parseInt(args.getArgs().get(1).getValue());
int depth = Integer.parseInt(args.getArgs().get(2).getValue());
if (width < 1 || height < 2 || depth < 1 || height > 255) {
logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit.");
cont = false;
}
if (cont) {
height--;
width--;
BlockPos corner1;
BlockPos corner2;
Direction enumFacing = ctx.player().getHorizontalFacing();
int addition = ((width % 2 == 0) ? 0 : 1);
switch (enumFacing) {
case EAST:
corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2);
corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition);
break;
case WEST:
corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z + width / 2 + addition);
corner2 = new BlockPos(ctx.playerFeet().x - depth, ctx.playerFeet().y + height, ctx.playerFeet().z - width / 2);
break;
case NORTH:
corner1 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y, ctx.playerFeet().z);
corner2 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y + height, ctx.playerFeet().z - depth);
break;
case SOUTH:
corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z);
corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth);
break;
default:
throw new IllegalStateException("Unexpected value: " + enumFacing);
}
logDirect(String.format("Creating a tunnel %s block(s) high, %s block(s) wide, and %s block(s) deep", height+1, width+1, depth));
baritone.getBuilderProcess().clearArea(corner1, corner2);
}
} else {
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.player().getHorizontalFacing()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);
logDirect(String.format("Goal: %s", goal.toString()));
}
}
@Override
@@ -61,7 +106,8 @@ public class TunnelCommand extends Command {
"The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.",
"",
"Usage:",
"> tunnel"
"> tunnel - No arguments, mines in a 1x2 radius.",
"> tunnel <height> <width> <depth> - Tunnels in a user defined height, width and depth."
);
}
}

View File

@@ -26,6 +26,7 @@ import baritone.api.utils.Helper;
import baritone.api.utils.PathCalculationResult;
import baritone.pathing.movement.CalculationContext;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import baritone.utils.NotificationHelper;
import java.util.Optional;
@@ -216,6 +217,9 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper {
if (logInfo) {
logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks");
logDebug("No path found =(");
if (Baritone.settings().desktopNotifications.value) {
NotificationHelper.notify("No path found =(", true);
}
}
return Optional.empty();
}

View File

@@ -176,7 +176,7 @@ public abstract class Movement implements IMovement, MovementHelper {
//i'm doing it anyway
//i dont care if theres snow in the way!!!!!!!
//you dont own me!!!!
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(blockPos), ctx.playerRotations()), true)
);
// don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block

View File

@@ -91,7 +91,7 @@ public interface MovementHelper extends ActionCosts, Helper {
if (block instanceof AirBlock) { // early return for most common case
return true;
}
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK) {
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK || block == Blocks.END_ROD) {
return false;
}
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
@@ -295,7 +295,7 @@ public interface MovementHelper extends ActionCosts, Helper {
*/
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
Block block = state.getBlock();
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) {
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN || block == Blocks.HONEY_BLOCK) {
// early return for most common case (air)
// plus magma, which is a normal cube but it hurts you
return false;
@@ -309,7 +309,7 @@ public interface MovementHelper extends ActionCosts, Helper {
if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) {
return true;
}
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
return true;
}
if (isWater(state)) {
@@ -523,9 +523,9 @@ public interface MovementHelper extends ActionCosts, Helper {
return Block.isOpaque(state.getCollisionShape(null, null));
}
static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) {
static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown, boolean wouldSneak) {
IPlayerContext ctx = baritone.getPlayerContext();
Optional<Rotation> direct = RotationUtils.reachable(ctx, placeAt); // we assume that if there is a block there, it must be replacable
Optional<Rotation> direct = RotationUtils.reachable(ctx, placeAt, wouldSneak); // we assume that if there is a block there, it must be replacable
boolean found = false;
if (direct.isPresent()) {
state.setTarget(new MovementState.MovementTarget(direct.get(), true));
@@ -543,7 +543,7 @@ public interface MovementHelper extends ActionCosts, Helper {
double faceY = (placeAt.getY() + against1.getY() + 0.5D) * 0.5D;
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance(), wouldSneak);
if (res != null && res.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) res).getPos().equals(against1) && ((BlockRayTraceResult) res).getPos().offset(((BlockRayTraceResult) res).getFace()).equals(placeAt)) {
state.setTarget(new MovementState.MovementTarget(place, true));
found = true;
@@ -561,11 +561,17 @@ public interface MovementHelper extends ActionCosts, Helper {
Direction side = ((BlockRayTraceResult) ctx.objectMouseOver()).getFace();
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
if (wouldSneak) {
state.setInput(Input.SNEAK, true);
}
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
return PlaceResult.READY_TO_PLACE;
}
}
if (found) {
if (wouldSneak) {
state.setInput(Input.SNEAK, true);
}
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
return PlaceResult.ATTEMPTING;
}

View File

@@ -174,7 +174,7 @@ public class MovementAscend extends Movement {
BlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
ticksWithoutPlacement++;
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true) == PlaceResult.READY_TO_PLACE) {
state.setInput(Input.SNEAK, true);
if (ctx.player().isCrouching()) {
state.setInput(Input.CLICK_RIGHT, true);

View File

@@ -224,7 +224,7 @@ public class MovementDescend extends Movement {
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
ClientPlayerEntity player = ctx.player();
state.setTarget(new MovementState.MovementTarget(
new Rotation(RotationUtils.calcRotationFromVec3d(player.getEyePosition(1.0F),
new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
new Vec3d(destX, dest.getY(), destZ),
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
false

View File

@@ -251,7 +251,7 @@ public class MovementParkour extends Movement {
}
} else if (!ctx.playerFeet().equals(src)) {
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().getPositionVec().y - src.y > 0.0001) {
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) {
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
state.setInput(Input.CLICK_RIGHT, true);
}

View File

@@ -182,7 +182,7 @@ public class MovementPillar extends Movement {
}
boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE;
boolean vine = fromDown.getBlock() == Blocks.VINE;
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(positionToPlace),
new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch));
if (!ladder) {

View File

@@ -280,7 +280,7 @@ public class MovementTraverse extends Movement {
}
}
double dist1 = Math.max(Math.abs(ctx.player().getPositionVec().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().getPositionVec().z - (dest.getZ() + 0.5D)));
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false);
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true);
if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) {
state.setInput(Input.SNEAK, true);
}

View File

@@ -74,7 +74,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
baritone.getInputOverrideHandler().clearAllKeys();
for (BlockPos toPlace : toFillIn()) {
MovementState fake = new MovementState();
switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false)) {
switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false, false)) {
case NO_OPTION:
continue;
case READY_TO_PLACE:

View File

@@ -52,8 +52,6 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
@@ -212,7 +210,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
continue; // irrelevant
}
BlockState curr = bcc.bsi.get0(x, y, z);
if (!(curr.getBlock() instanceof AirBlock) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired)) {
if (!(curr.getBlock() instanceof AirBlock) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired, false)) {
BetterBlockPos pos = new BetterBlockPos(x, y, z);
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
if (rot.isPresent()) {
@@ -253,7 +251,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
continue; // irrelevant
}
BlockState curr = bcc.bsi.get0(x, y, z);
if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired, false)) {
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof AirBlock) {
continue;
}
@@ -292,8 +290,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x);
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance());
Rotation rot = RotationUtils.calcRotationFromVec3d(RayTraceUtils.inferSneakingEyePosition(ctx.player()), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance(), true);
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(placeAgainstPos) && ((BlockRayTraceResult) result).getFace() == against.getOpposite()) {
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
if (hotbar.isPresent()) {
@@ -332,7 +330,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (!meme.canPlace()) {
continue;
}
if (valid(wouldBePlaced, desired)) {
if (valid(wouldBePlaced, desired, true)) {
return OptionalInt.of(i);
}
}
@@ -475,7 +473,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
outer:
for (BlockState desired : desirableOnHotbar) {
for (int i = 0; i < 9; i++) {
if (valid(approxPlaceable.get(i), desired)) {
if (valid(approxPlaceable.get(i), desired, true)) {
usefulSlots.add(i);
continue outer;
}
@@ -486,7 +484,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
outer:
for (int i = 9; i < 36; i++) {
for (BlockState desired : noValidHotbarOption) {
if (valid(approxPlaceable.get(i), desired)) {
if (valid(approxPlaceable.get(i), desired, true)) {
baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains);
break outer;
}
@@ -542,7 +540,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (desired != null) {
// we care about this position
BetterBlockPos pos = new BetterBlockPos(x, y, z);
if (valid(bcc.bsi.get0(x, y, z), desired)) {
if (valid(bcc.bsi.get0(x, y, z), desired, false)) {
incorrectPositions.remove(pos);
observedCompleted.add(BetterBlockPos.longHash(pos));
} else {
@@ -569,7 +567,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
if (bcc.bsi.worldContainsLoadedChunk(blockX, blockZ)) { // check if its in render distance, not if its in cache
// we can directly observe this block, it is in render distance
if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable))) {
if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable), false)) {
observedCompleted.add(BetterBlockPos.longHash(blockX, blockY, blockZ));
} else {
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
@@ -787,7 +785,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return result;
}
private boolean valid(BlockState current, BlockState desired) {
private boolean valid(BlockState current, BlockState desired, boolean itemVerify) {
if (desired == null) {
return true;
}
@@ -801,7 +799,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (desired.getBlock() instanceof AirBlock && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) {
return true;
}
if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value) {
if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
return true;
}
return current.equals(desired);
@@ -883,7 +881,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
// it should be a real block
// is it already that block?
if (valid(bsi.get0(x, y, z), sch)) {
if (valid(bsi.get0(x, y, z), sch, false)) {
return Baritone.settings().breakCorrectBlockPenaltyMultiplier.value;
} else {
// can break if it's wrong

View File

@@ -229,7 +229,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
both.addAll(openSoulsand);
for (BlockPos pos : both) {
boolean soulsand = openSoulsand.contains(pos);
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false);
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance());
if (result instanceof BlockRayTraceResult && ((BlockRayTraceResult) result).getFace() == Direction.UP) {

View File

@@ -41,7 +41,7 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockReader {
@Nullable
@Override
public TileEntity getTileEntity(BlockPos pos) {
throw new UnsupportedOperationException("getTileEntity not supported by BlockStateInterfaceAccessWrapper");
return null;
}
@Override

View File

@@ -110,9 +110,9 @@ public class GuiClick extends Screen implements Helper {
return super.mouseClicked(mouseX, mouseY, mouseButton);
}
public void onRender(MatrixStack modelViewStack, MatrixStack projectionStack) {
this.projectionViewMatrix = projectionStack.getLast().getPositionMatrix().copy();
this.projectionViewMatrix.multiply(modelViewStack.getLast().getPositionMatrix());
public void onRender(MatrixStack modelViewStack, Matrix4f projectionMatrix) {
this.projectionViewMatrix = projectionMatrix.copy();
this.projectionViewMatrix.mul(modelViewStack.getLast().getMatrix());
this.projectionViewMatrix.invert();
if (currentMouseOver != null) {
@@ -144,8 +144,8 @@ public class GuiClick extends Screen implements Helper {
return null;
}
x /= mc.getMainWindow().getWidth();
y /= mc.getMainWindow().getHeight();
x /= mc.getMainWindow().getFramebufferWidth();
y /= mc.getMainWindow().getFramebufferHeight();
x = x * 2 - 1;
y = y * 2 - 1;

View File

@@ -77,7 +77,7 @@ public interface IRenderer {
static void drawAABB(MatrixStack stack, AxisAlignedBB aabb) {
AxisAlignedBB toDraw = aabb.offset(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
Matrix4f matrix4f = stack.getLast().getPositionMatrix();
Matrix4f matrix4f = stack.getLast().getMatrix();
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
// bottom
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();

View File

@@ -108,6 +108,11 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri
}
private boolean inControl() {
for (Input input : new Input[]{Input.MOVE_FORWARD, Input.MOVE_BACK, Input.MOVE_LEFT, Input.MOVE_RIGHT, Input.SNEAK}) {
if (isInputForcedDown(input)) {
return true;
}
}
// if we are not primary (a bot) we should set the movementinput even when idle (not pathing)
return baritone.getPathingBehavior().isPathing() || baritone != BaritoneAPI.getProvider().getPrimaryBaritone();
}

View File

@@ -0,0 +1,89 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils;
import org.apache.commons.lang3.SystemUtils;
import java.awt.*;
import java.io.IOException;
/**
* This class is not called from the main game thread.
* Do not refer to any Minecraft classes, it wouldn't be thread safe.
*
* @author aUniqueUser
*/
public class NotificationHelper {
private static TrayIcon trayIcon;
public static void notify(String text, boolean error) {
if (SystemUtils.IS_OS_WINDOWS) {
windows(text, error);
} else if (SystemUtils.IS_OS_MAC_OSX) {
mac(text);
} else if (SystemUtils.IS_OS_LINUX) {
linux(text);
}
}
private static void windows(String text, boolean error) {
if (SystemTray.isSupported()) {
try {
if (trayIcon == null) {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().createImage("");
trayIcon = new TrayIcon(image, "Baritone");
trayIcon.setImageAutoSize(true);
trayIcon.setToolTip("Baritone");
tray.add(trayIcon);
}
trayIcon.displayMessage("Baritone", text, error ? TrayIcon.MessageType.ERROR : TrayIcon.MessageType.INFO);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("SystemTray is not supported");
}
}
private static void mac(String text) {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("osascript", "-e", "display notification \"" + text + "\" with title \"Baritone\"");
try {
processBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
// The only way to display notifications on linux is to use the java-gnome library,
// or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome
// library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome)
private static void linux(String text) {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("notify-send", "-a", "Baritone", text);
try {
processBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -74,7 +74,7 @@ public final class PathRenderer implements IRenderer, Helper {
float partialTicks = event.getPartialTicks();
Goal goal = behavior.getGoal();
if (Helper.mc.currentScreen instanceof GuiClick) {
((GuiClick) Helper.mc.currentScreen).onRender(event.getModelViewStack(), event.getProjectionStack());
((GuiClick) Helper.mc.currentScreen).onRender(event.getModelViewStack(), event.getProjectionMatrix());
}
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();
@@ -181,7 +181,7 @@ public final class PathRenderer implements IRenderer, Helper {
public static void drawLine(MatrixStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
Matrix4f matrix4f = stack.getLast().getPositionMatrix();
Matrix4f matrix4f = stack.getLast().getMatrix();
double vpX = posX();
double vpY = posY();
@@ -319,7 +319,7 @@ public final class PathRenderer implements IRenderer, Helper {
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1);
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2);
Matrix4f matrix4f = stack.getLast().getPositionMatrix();
Matrix4f matrix4f = stack.getLast().getMatrix();
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
buffer.pos(matrix4f, (float) minX, (float) minY, (float) minZ).endVertex();
buffer.pos(matrix4f, (float) minX, (float) maxY, (float) minZ).endVertex();
@@ -336,7 +336,7 @@ public final class PathRenderer implements IRenderer, Helper {
private static void renderHorizontalQuad(MatrixStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
if (y != 0) {
Matrix4f matrix4f = stack.getLast().getPositionMatrix();
Matrix4f matrix4f = stack.getLast().getMatrix();
buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION);
buffer.pos(matrix4f, (float) minX, (float) y, (float) minZ).endVertex();
buffer.pos(matrix4f, (float) maxX, (float) y, (float) minZ).endVertex();

View File

@@ -21,5 +21,5 @@ import java.net.URI;
public interface IGuiScreen {
void openLink(URI url);
void openLinkInvoker(URI url);
}