Compare commits

...

391 Commits

Author SHA1 Message Date
Leijurv
8a0771e5f4 v1.8.3 2022-03-08 14:50:04 -08:00
Leijurv
9c6c977314 Merge pull request #3292 from wagyourtail/1.18.2
1.18.2
2022-03-08 14:47:42 -08:00
Wagyourtail
38c5388e00 forge updated (finally) 2022-03-01 16:36:09 -07:00
Wagyourtail
519a76a171 fix for 1.18.2 2022-02-28 15:29:37 -07:00
Leijurv
b6cc15e9ab v1.8.2 2022-02-02 15:55:22 -08:00
Leijurv
ebb9dd1aaf Merge branch '1.17.1' into 1.18.1 2022-02-02 15:47:50 -08:00
Leijurv
d4c4441cb6 Merge pull request #3238 from wagyourtail/1.17.1
Merge master into 1.17
2022-02-02 15:47:20 -08:00
Wagyourtail
91bfab30e0 fix tabbing 2022-02-02 14:10:20 -07:00
Wagyourtail
a32811942e merge master in 2022-02-02 11:17:02 -07:00
Leijurv
0908e509a1 simplify a bit more 2022-02-02 00:51:24 -08:00
Leijurv
ad14226c5c lets not keep updating this 2022-02-02 00:50:48 -08:00
Leijurv
3fcc032547 readme updates for new release 2022-02-02 00:50:12 -08:00
Leijurv
e077995332 v1.8.1 2022-02-02 00:38:06 -08:00
Leijurv
71e17d6c29 v1.7.1 2022-02-02 00:35:37 -08:00
Leijurv
c9ebc0191d Merge branch '1.17.1' into 1.18.1 2022-02-02 00:30:29 -08:00
Leijurv
2f7f15da77 gitignore vscode file 2022-02-02 00:30:25 -08:00
Leijurv
fa3f5ae521 rm vscode stuff 2022-02-02 00:30:12 -08:00
Leijurv
db0ebeebee Merge branch '1.17.1' into 1.18.1 2022-02-02 00:29:26 -08:00
Leijurv
dc4913d98d oopsie 2 2022-02-02 00:29:15 -08:00
Leijurv
70dc2a3009 Merge branch '1.17.1' into 1.18.1 2022-02-02 00:25:13 -08:00
Leijurv
33943dc473 oopsie 2022-02-02 00:24:32 -08:00
Leijurv
21022f30b6 Merge commit 'd4ae351065889bfe37f5a51f123d5cd9a3e173e0' into 1.17.1 2022-02-02 00:20:23 -08:00
Leijurv
d4ae351065 Merge branch '1.16.4' into 1.16.5 2022-02-02 00:19:06 -08:00
Leijurv
2b75241338 Merge branch '1.16.4' into 1.17.1 2022-02-02 00:17:09 -08:00
Leijurv
b52de9b197 Merge pull request #2621 from wagyourtail/replaymodfix-master
fix replaymod crash (on newer versions)
2022-02-02 00:15:50 -08:00
Leijurv
3de7fc81fb Merge branch '1.15.2' into 1.16.4 2022-02-02 00:15:04 -08:00
Leijurv
34501f5af3 Merge branch '1.14.4' into 1.15.2 2022-02-02 00:14:38 -08:00
Leijurv
696ec6756d Merge pull request #3077 from wagyourtail/1.18
1.18 support
2022-02-02 00:00:05 -08:00
Leijurv
6e03e6859c Merge pull request #3194 from wagyourtail/1.17.1
fix dripleaf and azalea behavior
2022-02-01 23:57:54 -08:00
Leijurv
c2de6e3f3d Merge pull request #3173 from scorbett123/patch-4
Add unpause as an alias for resume
2022-02-01 23:57:21 -08:00
Leijurv
a5638bdba1 Merge pull request #3137 from scorbett123/remove_container_memory
Remove container memory
2022-02-01 23:56:49 -08:00
Leijurv
5ce006170d Merge pull request #3068 from wagyourtail/fixfabricbuilding
Fix fabric building due to dependency issue
2022-02-01 23:55:13 -08:00
Leijurv
ffd7d7a23a Merge pull request #3067 from wagyourtail/collisionShapeFix
fix Null params on getCollisionShape causing NPEs
2022-02-01 23:55:01 -08:00
Wagyourtail
697c92ae77 Merge branch '1.17.1' into 1.18 2022-01-20 15:19:49 -07:00
Wagyourtail
e37d81d3fc fix runClient to actually have the right sourceSet by default 2022-01-20 15:19:35 -07:00
Wagyourtail
7f21362a2a fix dripleaf and azalea behavior
change so rebuilds
2022-01-10 16:58:17 -07:00
Wagyourtail
c4da682e84 Merge branch '1.17.1' into 1.18
change so rebuilds
2022-01-10 16:58:03 -07:00
Wagyourtail
33ee39dcce fix dripleaf and azalea behavior 2022-01-10 11:28:37 -07:00
scorbett123
bb8e4bd737 Add unpause as an alias for resume
Some people can't seem to find out what to do to unpause baritone, so this should hopefully help them figure it out, as for some reason unpause makes more sense to people than resume.
2022-01-02 12:45:03 +00:00
Leijurv
7a96772a9b Merge pull request #3159 from Entropy5/master
Better buildignoredirection
2021-12-23 11:21:44 -10:00
Entropy5
9b07aa17e4 Merge remote-tracking branch 'origin/master' 2021-12-23 22:00:17 +01:00
Entropy5
90c59d5b8e undo 2021-12-23 21:59:20 +01:00
Entropy
fd3d5b66e9 Merge branch 'cabaletta:master' into master 2021-12-23 14:09:03 +01:00
Entropy5
d97346be6c check union of keys 2021-12-23 13:39:13 +01:00
Entropy5
9d13bcfe11 formatting 2021-12-22 00:20:21 +01:00
Leijurv
724ee62246 Merge pull request #3151 from ZacSharp/patch-4
Make rightClickContainerOnArrival click lit furnaces
2021-12-21 11:03:35 -10:00
Entropy5
26e8f02e85 merge 2021-12-21 20:30:28 +01:00
Entropy5
b3ff3d2466 universal buildignoredirection 2021-12-21 20:09:22 +01:00
Entropy5
9c3882e91f to lazy to spell 2021-12-21 12:49:44 +01:00
Entropy5
32a7657c4f Zac suggested this option to work universally, regardless of block type 2021-12-21 12:42:39 +01:00
Leijurv
54617bf634 reorder for performance 2021-12-21 01:32:47 -10:00
Leijurv
61a00b3965 Merge pull request #3148 from Entropy5/master
Option to ignore direction of certain blocks during building
2021-12-21 01:31:41 -10:00
Entropy
0214ffd158 Merge branch 'cabaletta:master' into master 2021-12-21 12:15:43 +01:00
Leijurv
1919f7b2a7 fix build again 2021-12-20 22:31:06 -10:00
ZacSharp
c2f4e00314 Make rightClickContainerOnArrival click lit furnaces 2021-12-18 00:31:21 +01:00
Entropy5
3adfa16db8 Option to ignore direction of certain blocks during building (because otherwise baritone just keeps breaking and replacing the same block) 2021-12-17 06:24:34 +01:00
scorbett123
90fcffdf2a Remove container memory
Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2021-12-12 19:50:27 +00:00
Leijurv
0ca84a790b Merge pull request #3119 from wagyourtail/patch-1
LEIJURV STOP BEING LAZY
2021-12-05 21:55:35 -08:00
wagyourtail
04802fbb15 LEIJURV STOP BEING LAZY 2021-12-05 22:54:37 -07:00
Wagyourtail
587c2cc8e2 forge support 2021-12-02 11:13:56 -07:00
Wagyourtail
1c8899ceae 1.18 release
pre.5


pre.6


pre.7


rc.1


1.18 release
2021-11-30 14:06:03 -07:00
Wagyourtail
088009fe4a pre.3 2021-11-17 10:16:07 -07:00
Wagyourtail
90ac6f331e missed a spot 2021-11-16 16:47:37 -07:00
Wagyourtail
e80e4afa48 bump proguard version 2021-11-16 16:41:34 -07:00
Wagyourtail
b73295d180 bump to gradle 7.3, java 17 and 1.18-pre2 2021-11-16 16:30:37 -07:00
Wagyourtail
186a3cb6df shedainel says its fixed 2021-11-12 19:38:46 -07:00
Wagyourtail
b6fba56291 temp comment vanilla/forge 2021-11-12 19:38:46 -07:00
Wagyourtail
f52fee8254 revert this commit when shedaniel fixes arch-loom 2021-11-12 19:38:46 -07:00
Wagyourtail
f1061cfd31 fix baritone only ticking when screen open 2021-11-12 19:38:46 -07:00
Wagyourtail
9a9358bc78 WIP 2021-11-12 19:38:46 -07:00
Leijurv
749fd4fac3 Merge pull request #2850 from wagyourtail/1.17
1.17.X port, (uses changes from #2814)
2021-11-11 19:33:09 -08:00
Wagyourtail
62fe9888a2 eclipse dependency updated to java 11 on a minor version 2021-11-03 13:42:35 -06:00
Wagyourtail
08c00b8a42 surround with try/catch 2021-11-03 13:04:51 -06:00
Wagyourtail
43ecc906c7 cleanup 2021-10-28 08:03:37 -06:00
Leijurv
8579332cdf Merge pull request #3033 from wagyourtail/neverbreak
AvoidBreak means never.
2021-10-27 12:53:45 -07:00
Wagyourtail
9dc9edbbee fix tabbing 2021-10-27 13:53:13 -06:00
Wagyourtail
2980bb0320 match leij's backwards compat suggestion 2021-10-27 13:45:30 -06:00
wagyourtail
084798bd1b Update src/api/java/baritone/api/Settings.java 2021-10-26 13:41:24 -06:00
wagyourtail
1c27b9b712 Update src/api/java/baritone/api/Settings.java 2021-10-26 13:34:10 -06:00
Leijurv
129ec8472c Merge pull request #3042 from ZacSharp/waypointImprovements
Waypoint improvements
2021-10-25 15:03:33 -07:00
ZacSharp
724162f37f Store deleted waypoints per world
Different dimensions are actually different worlds and the user might expect the wapoints to be restorable until they leave the server, so discrading them when the world changes would be too early.
2021-10-19 01:17:23 +02:00
ZacSharp
3244b102ad Add a way to restore deleted waypoints
Makes using the clickable text less dangerous when there are others writing in chat.
2021-10-18 02:42:58 +02:00
ZacSharp
c8966d22ba Don't create a new waypoint every time a bed is clicked.
Just the first time and always for the head part.
2021-10-17 23:44:21 +02:00
ZacSharp
6669d49636 Add a way to get the creation command for a waypoint 2021-10-17 15:10:14 +02:00
ZacSharp
3b480dabdb Make the tag argument optional, defaulting to USER
Listing all possible combinations in the usage as done before would have beed 8 lines just for the save command so I made it one special case, one combined line and a line explaining the defaults in the general waypoint help.

Also tab completion does not work when omitting either tag or name, because it starting to tab complete a position right from the first argument would probably only cause confusion and would be harder to implement because of the variable start position (names can even be numbers so it's impossible to do it 100% correctly)
2021-10-17 14:47:03 +02:00
ZacSharp
3e69281d61 Update usage of #waypoint
It now properly reports when either a tag or name can be specified and includes the clear subcommand
2021-10-17 14:06:07 +02:00
ZacSharp
1b04386b01 Allow saving unnamed waypoints by position 2021-10-17 13:53:55 +02:00
wagyourtail
1ca736692d more closely match the existing docs and add discourageBreaking 2021-10-15 17:58:13 -06:00
wagyourtail
4dc4795cb7 AvoidBreak means never. 2021-10-15 00:00:48 -06:00
wagyourtail
64b647ea65 oops... .idea folder contains copyright in file stuff (I thought gradle did that) 2021-10-11 04:42:26 -06:00
Leijurv
bcc33362b8 Merge pull request #3024 from wagyourtail/followerror
better follow command error handling
2021-10-10 14:07:27 -07:00
wagyourtail
6ed3a88491 continue fix mine and a* for data driven world height 2021-10-09 15:29:02 -06:00
wagyourtail
bd5ffe8f31 put timeout back 2021-10-09 14:55:26 -06:00
wagyourtail
d22a52976b fix A* and scanner for data driven world height 2021-10-09 14:54:07 -06:00
wagyourtail
e055ef36d4 add parchment mappings 2021-10-09 14:16:57 -06:00
wagyourtail
5ec6b7b72e make chunk cache/scanning work with data driven worldheight 2021-10-09 14:16:49 -06:00
wagyourtail
ba0b5f929f cleanup 2021-10-08 15:49:22 -06:00
wagyourtail
89c960c455 better follow command error handling 2021-10-08 14:58:17 -06:00
wagyourtail
de27fb2f68 fix mc jar detection for forge build with loom 0.10.x 2021-09-23 19:43:23 -06:00
wagyourtail
2e2e725eb3 fix proguard to have proper loom 0.10.x minecraft jar locations 2021-09-23 19:10:52 -06:00
wagyourtail
202618a32a add forge build script 2021-09-22 12:22:00 -06:00
wagyourtail
462dbce665 prep forge support 2021-09-22 12:14:43 -06:00
Leijurv
14178fcd14 rewrite comment since we haven't used pos.getY() in literally YEARS 2021-08-25 22:20:13 -07:00
Leijurv
5e0fe6d897 fix the comment explaining the sign flip
bug originates from august 17 2018 in f3d9ada675 (diff-b9b328a67abb41c2f842f367f83d95a2793c95cba83ab2e4542b31ed4c157819R101-R103)

absolutely wild how long this took to notice, see PR #2954
2021-08-25 22:18:23 -07:00
Leijurv
53ef26dabd Merge pull request #2954 from StylexTV/master
Fixed vertical cost calculation
2021-08-25 22:14:14 -07:00
StylexTV
3db5f2a67f Update GoalBlock.java 2021-08-22 10:28:42 +02:00
Leijurv
13d0e2a5bf Merge pull request #2879 from scorbett123/fixProguard
Fix proguard from being broken.
2021-07-18 23:29:56 -07:00
scorbett123
c3085ae34f Fix proguard
Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2021-07-18 18:37:20 +01:00
Leijurv
ce2ec8047e Merge pull request #2825 from Zephreo/parkour-place
ParkourPlace for shorter parkour jumps
2021-07-16 20:50:23 -07:00
Harry
335cb7016e fix verifiedMaxJump
- remove redundant assignment by changing some values
- testing Co-Authors

Co-Authored-By: Leijurv <leijurv@gmail.com>
2021-07-17 13:28:12 +10:00
Harry
7a7b050615 weird verifiedMaxJump 2021-07-17 12:34:58 +10:00
Leijurv
6ff7ae800a Merge pull request #2833 from ZacSharp/layerHeight
 Add layerHeight setting
2021-07-16 18:47:15 -07:00
wagyourtail
0944e6255e add fabric build to git 2021-07-11 22:25:32 -06:00
wagyourtail
8be821746e update dockerfile to use java 16
debian doesn't provide it
2021-07-11 22:20:06 -06:00
wagyourtail
9c05133ac7 cherry pick (and update) pr #2801 2021-07-11 22:10:13 -06:00
wagyourtail
29f5eaa35f Amethyst Crystal and Pointed Dripstone 2021-07-11 14:28:23 -06:00
wagyourtail
c06fdec287 1.17.1 2021-07-07 15:43:48 -06:00
wagyourtail
c7d210bfd6 fix proguard maybe 2021-07-07 15:43:48 -06:00
wagyourtail
683e987b1d fix bad mapping breaking pathing on item entities. 2021-07-07 15:43:48 -06:00
wagyourtail
40c323f53d fix mis-mapping from manual mixin review and put this back 2021-07-07 15:43:48 -06:00
wagyourtail
2d2354730d fix movement, mixins and color, proguard 2021-07-07 15:43:48 -06:00
wagyourtail
a7b81940b3 fix j16 debug environment (may have to set cp to baritone.launch) 2021-07-07 15:43:48 -06:00
wagyourtail
8df87eb620 bump fabric loader to support j16 2021-07-07 15:43:48 -06:00
wagyourtail
41abda37c1 fix migration for 1.17. (also proguard broke with j16...) 2021-07-07 15:43:48 -06:00
wagyourtail
e6d8b268c7 migrate to mojmap 2021-07-07 15:43:48 -06:00
wagyourtail
f0130c7199 move to j16/gradle7 2021-07-07 15:43:48 -06:00
wagyourtail
de42109771 add check 2021-07-06 15:59:06 -06:00
wagyourtail
2e98eee7e0 fix dockerfile 2021-07-06 08:26:30 -06:00
wagyourtail
f6236bdc66 launchtweaker build shouldn't require forge 2021-07-06 08:25:30 -06:00
wagyourtail
d00249bbd6 checking again, this is fixed actually (somehow...). 2021-07-05 15:15:08 -06:00
Harry
2159773723 requested changes
- tabs changed to 4 spaces
- fixed checking if block place is behind player
2021-07-01 10:09:06 +10:00
ZacSharp
ab3a015d61 Add layerHeight setting 2021-06-24 23:33:48 +02:00
Harry
3142387e45 Fix collision early return
not tested yet
- fixes early returns
2021-06-23 06:25:10 +10:00
Harry
051325e10f allow smaller parkour place jumps
allows 2 and 1 block parkour place jumps
2021-06-21 10:58:11 +10:00
Harry
199d5d57d5 Update .gitignore 2021-06-21 09:49:18 +10:00
wagyourtail
a49f4ee858 cleanup 2021-06-16 02:51:56 -06:00
wagyourtail
998b84ef87 switch to forgified-fabric-loom 2021-06-16 02:12:47 -06:00
Leijurv
b96795c517 Merge pull request #2803 from scorbett123/farmInventory
Make farm use inventory when allowInventory is enabled.
2021-06-14 12:32:53 -10:00
scorbett123
64ba96daf2 Do edit suggested by leijurv 2021-06-14 20:44:32 +01:00
Leijurv
14b17d86e5 Merge pull request #2801 from scorbett123/master
Add github actions.
2021-06-13 10:21:51 -10:00
Leijurv
90d5f27026 Merge pull request #2804 from ZacSharp/selCopyPaste
 Add a clipboard to #sel
2021-06-13 10:21:10 -10:00
Leijurv
16386b8ddc Merge pull request #2796 from mankool0/itemSaverThreshold
Added itemSaverThreshold setting
2021-06-13 10:17:28 -10:00
Leijurv
cbef21b9ad Merge pull request #2800 from scorbett123/patch-3
Remove broken hit count badge
2021-06-13 10:16:51 -10:00
ZacSharp
cec44e3668 Add a clipboard to #sel 2021-06-13 00:21:52 +02:00
scorbett123
f09f1e7f85 Make farm use inventory when allowInventory is enabled. 2021-06-12 18:18:56 +01:00
scorbett123
95910bc6cb Cleanup - travis.org is now deprecated and can no longer be used. 2021-06-12 14:13:39 +01:00
scorbett123
cc488ccff0 Make actions run tests as well. 2021-06-12 14:09:50 +01:00
scorbett123
37e129bfb9 Create run_tests.yml 2021-06-12 14:08:04 +01:00
scorbett123
6adc923bcb Revert "update mapping.txt location"
This reverts commit 065470ce

Github doesn't seem to support ../
2021-06-12 14:07:35 +01:00
scorbett123
065470cecb update mapping.txt location 2021-06-12 14:02:31 +01:00
scorbett123
260989bda6 Update build java version for github actions. 2021-06-12 13:52:56 +01:00
scorbett123
64b6e0fd56 Remove broken hit count badge 2021-06-12 13:49:59 +01:00
scorbett123
8f45718b75 Try to create github actions
An attempt at github actions.
2021-06-12 11:27:27 +01:00
scorbett123
e66bb7a14b Make proguard output the mapping. 2021-06-12 11:14:59 +01:00
mankool
8bfe32eeef Added itemSaverThreshold 2021-06-09 10:34:45 -07:00
Leijurv
e85c1bbc0d Merge pull request #2736 from ZacSharp/exploreForBlocksForMining
Make MineProcess respect exploreForBlocks
2021-05-28 13:27:13 -07:00
ZacSharp
f99bf0d000 Make legitMode always explore 2021-05-28 22:18:33 +02:00
Leijurv
db24a2251f Merge pull request #2771 from ZacSharp/notificationCallback
More log callbacks
2021-05-26 11:32:53 -07:00
Leijurv
fcb3747690 Merge pull request #2776 from thecakeisalie25/master
Add "RenderGoalAsBox" Setting
2021-05-26 11:30:51 -07:00
Tabbs
dcc27a7447 oops forgot the javadoc 2021-05-25 14:52:16 -05:00
Tabbs
bea39bc613 Merge branch 'master' of https://github.com/thecakeisalie25/baritone 2021-05-25 14:44:59 -05:00
Tabbs
546493ba45 do our best to stop beacon animating
The game seems to animate the beacons anyway, so it does shake a little bit.
2021-05-25 14:44:54 -05:00
Tabbs
dda4928693 change name to renderGoalAnimated 2021-05-25 14:43:32 -05:00
Larson
7d144dd076 fix decimal
Co-authored-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2021-05-25 14:33:13 -05:00
Tabbs
73e0700ea3 fix weird rendering issue 2021-05-25 12:41:36 -05:00
Tabbs
3fc36cf798 fix y to 1 if animation is disabled 2021-05-25 12:34:17 -05:00
ZacSharp
dbc43b445b Replace unhandled exception with a helpful message 2021-05-24 03:38:14 +02:00
ZacSharp
638fcd393a Don't try to tab complete hidden settings 2021-05-24 03:20:31 +02:00
ZacSharp
7b5f419713 Treat the new callbacks like the old one 2021-05-24 03:14:33 +02:00
ZacSharp
253fbad3db Make MineProcess respect exploreForBlocks 2021-05-10 22:37:35 +02:00
ZacSharp
522de3d4b7 Add callback settings for toast pop-ups and desktop notifications 2021-05-10 00:31:37 +02:00
ZacSharp
dc9ae67657 Move NotificationHelper to api and give Helper some methods for notifications 2021-05-10 00:26:33 +02:00
Leijurv
fccac8ed74 Merge pull request #2664 from ZacSharp/buildSelectedSchematic
Add setting to only build selected part of schematica schematic
2021-04-20 23:27:57 -07:00
Leijurv
24c895084e Merge pull request #2647 from scorbett123/patch-2
switch from forge mods to just other mods.
2021-04-20 23:15:37 -07:00
Leijurv
16fbfdecb5 Merge pull request #2645 from millennIumAMbiguity/patch-1
Added missing information to USAGE.md
2021-04-20 23:15:25 -07:00
Leijurv
b79e281074 Merge pull request #2635 from ZacSharp/autoTool
Invert disableAutoTool to autoTool
2021-04-20 23:15:10 -07:00
Leijurv
93ac380fd6 Merge pull request #2634 from ZacSharp/patch-2
fix typo
2021-04-20 23:13:57 -07:00
ZacSharp
46066d4cac Misc
* Rename schematicaOnlyBuildSelection to buildOnlySelection
* Make it useable with #build as well
* remove debugging code I forgot
2021-04-14 23:36:16 +02:00
ZacSharp
c13cf4f29c Add setting to only build selected part of schematica schematic 2021-04-13 23:09:54 +02:00
ZacSharp
a4f06a9e1e Update javadoc as well 2021-04-10 23:56:30 +02:00
scorbett123
cbc5fc8d08 switch from forge mods to just other mods. 2021-04-08 18:36:46 +01:00
millennIumAMbiguity
0a27c0b6e4 Added missing information to USAGE.md
Added missing information about the `farm` command.
2021-04-07 18:12:47 +02:00
ZacSharp
f348a20035 invert disableAutoTool to autoTool 2021-04-04 03:34:10 +02:00
ZacSharp
bdb98b487f fix typo 2021-04-04 03:17:35 +02:00
Leijurv
2cb6402189 Update README.md 2021-04-03 16:56:26 -07:00
Leijurv
861bb7a00a v1.2.15 2021-04-03 16:50:01 -07:00
Leijurv
43d5458a25 fix weird behavior where allowBreak false broke #goto 2021-04-03 16:41:45 -07:00
Leijurv
fe491e4a7d Merge pull request #1809 from Moondarker/master
Added "install" target for instant maven-ready releases
2021-04-03 13:40:56 -07:00
wagyourtail
9d1b979318 fix replaymod crash 2021-03-28 21:32:48 -07:00
Leijurv
c1794dd0ca reduce useless links 2021-03-25 10:41:16 -10:00
Leijurv
8f7d8b1cba Merge pull request #2611 from Flurrrr/master
Center badges and other stuff
2021-03-25 09:29:08 -10:00
flurr
8ebb8a04fa Center badges and other stuff
-center the badges
-re-arrange them to be more organized
-update the Aristois/Impact badges to the correct versions and fix broken link
2021-03-25 11:51:18 -07:00
Leijurv
ef6435a02a whatever i don't care 2021-03-23 22:44:20 -10:00
Leijurv
5cbe0a8230 Update README.md 2021-03-23 22:44:03 -10:00
Leijurv
dcef6b556c Update README.md 2021-03-23 22:42:39 -10:00
Leijurv
c07a636db2 Update README.md 2021-03-23 22:41:59 -10:00
Leijurv
a6be95fe33 Merge pull request #2606 from scorbett123/patch-1
fix typo
2021-03-23 10:19:11 -10:00
scorbett123
14149aa6b1 fix typo 2021-03-23 19:35:11 +00:00
Leijurv
ae901219fb Merge pull request #2526 from ZacSharp/buildSkipBlocks
Settings to alter block treatment while builing
2021-03-23 08:09:44 -10:00
Leijurv
6d9600d132 Update README.md 2021-03-21 13:59:00 -07:00
Leijurv
ccc55562cd Update README.md 2021-03-21 13:52:27 -07:00
ZacSharp
67d9ae881f don't allocate tons of empty lists 2021-03-09 12:31:02 +01:00
ZacSharp
61e0525ee8 Don't copy block state properties every time 2021-03-09 12:26:47 +01:00
ZacSharp
363519db02 treat all airs as air 2021-03-09 11:53:43 +01:00
Leijurv
373ad3efdd soul fire 2021-02-24 13:16:03 -08:00
Leijurv
4bc179bd2a Merge pull request #2462 from scorbett123/ModifiedImprovement
Improve #modified command to include original setting value.
2021-02-19 20:14:35 -08:00
Leijurv
76debda76e Merge pull request #1978 from ZacSharp/master
 Add improved ETA and a command to access it
2021-02-19 20:13:47 -08:00
Leijurv
b4eabe19cb Merge pull request #2482 from ZacSharp/schematicCacheClearing
Clear caches of schematics when moving them
2021-02-19 16:06:28 -08:00
ZacSharp
971b75860f Call reset() on static schematics as well 2021-02-19 23:57:33 +01:00
ZacSharp
5a926bf169 formatting 2021-02-19 23:52:18 +01:00
Leijurv
d34f37c563 Merge pull request #2476 from biscuut/patch-1
Fixed incorrect block pos world coordinates
2021-02-19 10:54:47 -08:00
Leijurv
6035a01019 Merge pull request #2481 from ZacSharp/buildRepeatCrash
Don't crash by buildRepeating too often
2021-02-19 10:49:06 -08:00
ZacSharp
c880f71dc8 Clear caches of schematics when moving them 2021-02-17 01:59:23 +01:00
ZacSharp
13422ef7ce lag > crash 2021-02-17 01:19:16 +01:00
Biscuit
84e2efd42c Fixed incorrect block pos world coordinates
Fix block pos being incorrect when converting chunk coordinates to world coordinates because of order of operations.
2021-02-15 14:21:03 -05:00
ZacSharp
113d26937d remove unused imports 2021-02-11 01:08:33 +01:00
ZacSharp
34606415d7 Don't mark skipped blocks as invalid just because they are far away 2021-02-10 23:45:12 +01:00
scorbett123
6b9c1f0a22 Improve #modified command to include original setting value.
Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2021-02-10 16:00:44 +00:00
ZacSharp
132cc0e131 make range initialization more readable 2021-02-10 10:25:17 +01:00
ZacSharp
5926369a56 formatting and comments 2021-02-10 10:15:14 +01:00
ZacSharp
ff068d374f Don't box doubles 2021-02-10 00:29:45 +01:00
Leijurv
4132d6ff61 Merge pull request #2138 from scorbett123/swordSaver
add useSwordToMine setting.
2021-02-08 16:54:37 -08:00
scorbett123
1f10199e64 Change use sword to mine to default to true.
Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2021-02-08 08:34:31 +00:00
Leijurv
e97704b37f Merge pull request #2139 from scorbett123/notifyOnDeath
notify users that their death position has been saved.
2021-02-07 14:32:43 -08:00
scorbett123
4ae81a3b0b Merge branch 'master' into swordSaver 2021-02-07 12:19:18 +00:00
Moondarker
f4ec9a8ec1 Merge pull request #2 from cabaletta/master
Fetching latest updates
2021-02-07 06:39:00 +03:00
Leijurv
711037b619 rearrange for consistency 2021-02-06 13:36:24 -08:00
Leijurv
b32c9f1724 Merge pull request #2107 from scorbett123/toolsSaver
add itemSaver setting.
2021-02-06 13:33:01 -08:00
Leijurv
be132c531e Update SETUP.md 2021-02-05 22:53:44 -08:00
Leijurv
fb8826caf4 Update README.md 2021-02-05 22:42:03 -08:00
Leijurv
adff60b118 Update README.md 2021-02-05 22:41:52 -08:00
Leijurv
a48ae2a9a8 v1.6.3 2021-02-05 22:17:20 -08:00
Leijurv
a9b956c12d empty 2021-02-05 21:01:02 -08:00
Leijurv
476b724471 1.16.5 2021-02-05 20:47:46 -08:00
Leijurv
8f863bf19b empty 2021-02-05 20:08:46 -08:00
Leijurv
98da144691 Merge branch '1.15.2' into 1.16.4 2021-02-02 17:09:56 -08:00
Leijurv
7320c3fd7e Merge branch '1.14.4' into 1.15.2 2021-02-02 17:09:31 -08:00
Leijurv
c37cdf78e4 Merge branch '1.13.2' into 1.14.4 2021-02-02 17:09:18 -08:00
Leijurv
6a1f716dc8 Merge branch 'master' into 1.13.2 2021-02-02 17:09:06 -08:00
Leijurv
a9d90786ff Merge pull request #2413 from wagyourtail/sodium-fix-mcpmappings
compatibility for SodiumChunkManager
2021-02-02 17:07:38 -08:00
wagyourtail
484c606dc1 Update MixinSodiumChunkProvider.java 2021-02-02 17:56:00 -07:00
Leijurv
331a7f3842 Merge pull request #2407 from DifferentPerson/master
Fix SpongePowered Maven repo URL
2021-02-02 16:06:48 -08:00
wagyourtail
637c182114 sodium fix 2021-02-01 16:14:27 -07:00
DifferentPerson
25de16e051 Fix SpongePowered Maven repo URL
SpongePowered recently changed their Maven repo URL, so this is the right one
2021-01-31 15:55:52 -08:00
Leijurv
a732e766f4 crucial performance optimization 2021-01-30 17:22:19 -08:00
Leijurv
2377694a6b Merge branch '1.15.2' into 1.16.4 2021-01-29 21:28:21 -08:00
Leijurv
1b3799d4d7 reorder dist to alphabetical 2021-01-29 21:28:11 -08:00
Leijurv
81fadde388 Merge branch '1.15.2' into 1.16.4 2021-01-29 21:21:07 -08:00
Leijurv
a61eabd60c Merge branch '1.14.4' into 1.15.2 2021-01-29 21:14:10 -08:00
Leijurv
bb75e68b0a Merge branch '1.13.2' into 1.14.4 2021-01-29 21:13:33 -08:00
Leijurv
e9b9977674 Merge branch 'master' into 1.13.2 2021-01-29 21:13:12 -08:00
Leijurv
91854f97ad fully remove remnants of xvfb 2021-01-29 21:12:44 -08:00
Leijurv
825bad47ef add fabric build step 2021-01-29 21:06:37 -08:00
Leijurv
78acd2f945 reformatter 2021-01-29 21:02:57 -08:00
Leijurv
1183196e0d Merge pull request #2401 from wagyourtail/1.15.2-fabrictest
fabric support 1.15
2021-01-29 21:01:08 -08:00
Leijurv
e4947ec071 fake merge of 1.15.2 into 1.16.4 due to reformatting conflicts 2021-01-29 20:31:13 -08:00
Leijurv
5262f68215 a long overdue reformat of every file 2021-01-29 20:30:51 -08:00
Leijurv
4b45cc6f0b fake merge of 1.13.2 into 1.15.2 due to reformatting conflicts 2021-01-29 20:30:00 -08:00
Leijurv
a3da25ca27 a long overdue reformat of every file 2021-01-29 20:29:41 -08:00
Leijurv
eae6e4d804 fake merge of 1.13.2 into 1.14.4 due to reformatting conflicts 2021-01-29 20:28:32 -08:00
Leijurv
37cd50d435 a long overdue reformat of every file 2021-01-29 20:28:11 -08:00
Leijurv
3f65d46e12 fake merge of master into 1.13.2 due to reformatting conflicts 2021-01-29 20:26:22 -08:00
Leijurv
15fd313757 a long overdue reformat of every file 2021-01-29 20:26:06 -08:00
Leijurv
835fb3471f a long overdue reformat of every file 2021-01-29 20:17:53 -08:00
Leijurv
ca870af20e Merge branch '1.15.2' into 1.16.4 2021-01-29 20:13:56 -08:00
Leijurv
c98c54c985 Merge branch '1.14.4' into 1.15.2 2021-01-29 19:57:36 -08:00
Leijurv
4c9689fe19 Merge branch '1.13.2' into 1.14.4 2021-01-29 19:49:11 -08:00
Leijurv
f41c873852 Merge branch 'master' into 1.13.2 2021-01-29 19:31:16 -08:00
Leijurv
eb8a673165 Merge branch 'master' into 1.13.2 2021-01-29 19:30:56 -08:00
Leijurv
a9f497981f Merge pull request #2080 from millennIumAMbiguity/master
Added range argument to farm
2021-01-29 17:41:08 -08:00
Leijurv
74dd88d123 Merge pull request #2359 from stragulus/build-with-forge-instructions
Add instructions to build with forge for minecraft 1.15+
2021-01-29 17:37:43 -08:00
ZacSharp
fd61207709 Fix heuristic(no args) returning wrong values 2021-01-28 01:40:33 +01:00
wagyourtail
9a7b07befc move mappings folder to better location and have it autocreate 2021-01-27 09:20:10 -07:00
Leijurv
b94494d386 Merge pull request #2357 from ZacSharp/builderMaterialLogging
Log blocks the builder can't place (missing or obstructed by flowing liquid) when failing
2021-01-26 23:28:45 -08:00
Leijurv
974b19fcc7 Merge pull request #2378 from ZacSharp/patch-1
Correct usage for mining a specific amount
2021-01-26 23:24:07 -08:00
ZacSharp
364b7b5438 Correct usage for mining a specific amount
Found and fixed by @CesiumCs
2021-01-21 15:39:37 +01:00
wagyourtail
2c3f352d0d figure out how to revert "fix refmap location to be fabric-compliant"
I did some reading
2021-01-20 18:11:51 -07:00
wagyourtail
7fbe9c062e unique version names 2021-01-19 23:37:01 -07:00
wagyourtail
c1d7683896 fix version # 2021-01-19 23:14:37 -07:00
wagyourtail
b493c2ce89 remove debug, add ignore 2021-01-19 23:11:42 -07:00
wagyourtail
82436f30e1 cleanup 2021-01-19 23:11:08 -07:00
wagyourtail
f549e0e2d4 on the fly volderyarn mapping generation 2021-01-19 23:03:57 -07:00
wagyourtail
5494c43290 fabric task like forge 2021-01-19 23:03:40 -07:00
wagyourtail
f5d5457100 fix refmap location to be fabric-compliant 2021-01-19 23:03:35 -07:00
wagyourtail
d6cbb58e7e fabric with volder-mappings, soo close to working 2021-01-19 23:03:03 -07:00
ZacSharp
8c1a9f460d Simple blockstate preservation for buildSubstitutes 2021-01-18 12:06:50 +01:00
ZacSharp
f6d4a315c7 Remove debug log 2021-01-18 11:58:42 +01:00
Bram Avontuur
0222c47113 Typo fix 2021-01-17 11:40:52 -05:00
ZacSharp
fc1a2a6112 Add buildSubstitutes setting to builder 2021-01-17 02:45:40 +01:00
ZacSharp
13547781d2 add buildValidSubstitutes setting to builder 2021-01-17 00:53:50 +01:00
ZacSharp
d375d1abc9 Add setting parser for mappings 2021-01-17 00:16:34 +01:00
Bram Avontuur
33d007eea5 Add instructions to build with forge for minecraft 1.15+ 2021-01-16 11:34:12 -05:00
ZacSharp
5e4f31f39e proper place/break costs for skipped blocks 2021-01-16 02:05:59 +01:00
ZacSharp
79e0f4ba23 Log blocks it can't place 2021-01-15 12:52:38 +01:00
ZacSharp
dba186347c remove likely useless code breaking buildSkipBlocks 2021-01-13 22:45:59 +01:00
ZacSharp
7988274d61 add buildSkipBlocks setting 2021-01-12 23:59:11 +01:00
Leijurv
72cf9392b1 Update README.md 2020-12-24 21:34:02 -08:00
Leijurv
b6265036d4 Update README.md 2020-12-24 21:33:29 -08:00
Leijurv
dc70d810c9 Update README.md 2020-12-24 21:33:11 -08:00
Leijurv
dbb0f599fc v1.6.2 2020-12-16 13:32:11 -10:00
Brady
dcc0b82210 Update to 1.16.4 2020-12-16 16:42:35 -06:00
Leijurv
16cfcb36a3 Update USAGE.md 2020-11-29 20:04:44 -08:00
Leijurv
6bec994a57 Merge pull request #2185 from unrootexe/master
Update rootNET's supported version
2020-11-19 23:56:45 -08:00
unrootexe
a99206b6c2 Update rootNET's supported version
rootNET supports the latest version of Baritone, this change reflects that
2020-11-16 17:18:32 +00:00
Leijurv
c491d67925 add setting to just skip layers that the builder fails to construct 2020-11-11 17:53:26 -08:00
Sam Corbett
b9eeab06a1 change useSwordToMine to default to false.
Signed-off-by: Sam Corbett <sam@corbettchocolates.com>
2020-11-02 07:47:36 +00:00
millennIumAMbiguity
853b5ca771 Moved throw up into the default: 2020-11-02 01:44:12 +01:00
millennIumAMbiguity
f4706fff18 Simplified and optimised code 2020-11-02 01:25:25 +01:00
millennIumAMbiguity
7218a46211 Added defaults and javadocs 2020-11-02 00:33:31 +01:00
scorbett123
c0f7d5ab44 fix error made while copying and pasting.
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-11-01 17:30:53 +00:00
scorbett123
60f81fb89d notify users that their death position has been saved.
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-11-01 17:18:31 +00:00
scorbett123
49bc96dc7e add useSwordToMine setting.
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-11-01 16:12:38 +00:00
Leijurv
320a5d64a3 well i guess technically there could be an ore at bedrock level lmao 2020-10-30 22:39:30 -07:00
Leijurv
b16a8ecf21 Merge pull request #2079 from scorbett123/limitedMineDistance
add a minimum Y level during mining.
2020-10-30 22:35:26 -07:00
Leijurv
73265ef944 Merge pull request #2100 from GameCenterJerry/master
added jdk 8 instructions for macOS in SETUP.md
2020-10-30 22:28:57 -07:00
Leijurv
3bbc141e9a Merge pull request #2132 from ZacSharp/noForgeMod
don't make non-forge jars valid mods (fixes #2124)
2020-10-30 22:28:03 -07:00
ZacSharp
9ca95e8e14 don't make non-forge jars valid mods (fixes #2124) 2020-10-31 03:21:59 +01:00
Sam Corbett
9922382581 don't fall back onto the first slot if it has a low durability item in the slot.
Signed-off-by: Sam Corbett <sam@corbettchocolates.com>
2020-10-28 08:44:40 +00:00
scorbett123
4aa52d2f2e add itemSaver setting.
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-10-24 18:03:29 +01:00
Leijurv
6d51e10090 Merge pull request #1971 from krzys-h/fix-entity-follow-forge
Fix "#entity follow <name>" under Forge
2020-10-23 18:54:11 -07:00
GameCenterJerry
14b75973b0 Update SETUP.md 2020-10-22 15:02:17 +11:00
GameCenterJerry
0bfd0bca0c Update SETUP.md 2020-10-22 13:47:50 +11:00
GameCenterJerry
cafb810a1f Update SETUP.md 2020-10-22 13:28:18 +11:00
GameCenterJerry
07704b3ec7 Update SETUP.md 2020-10-22 13:14:53 +11:00
GameCenterJerry
7032efcc05 added jdk 8 instructions for macOS
added necessary commands and download links
2020-10-22 13:09:56 +11:00
millennIumAMbiguity
65a5677b33 Added the feature to only farm within range of a waypoint. 2020-10-22 00:36:19 +02:00
millennIumAMbiguity
5d3522ca0a Added range argument to farm 2020-10-16 23:32:53 +02:00
Sam Corbett
bfb530e02b add a minimum Y level.
Signed-off-by: Sam Corbett <sam@corbettchocolates.com>
2020-10-16 17:02:02 +01:00
ZacSharp
9393192036 Slight change to heuristic(no args) 2020-10-16 01:30:04 +02:00
ZacSharp
3cdbc4cb83 👌formatting in of comments 2020-10-15 21:48:17 +02:00
ZacSharp
0c7741120a 👌formatting 2020-10-15 00:05:54 +02:00
ZacSharp
e529438c7e Don't use Abs on Sqrt 2020-10-14 21:14:17 +02:00
Leijurv
5a5d11922f Merge pull request #1995 from scorbett123/exposedOres
add mineOnlyExposedOres setting
2020-10-14 12:01:49 -07:00
scorbett123
39cfebeb34 fix formatting
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-10-14 20:00:49 +01:00
Leijurv
950f47ccae Merge pull request #1958 from CDAGaming/feature/toasts
 Added Toast API Support
2020-10-14 11:18:09 -07:00
CDAGaming
d2c625e1c9 Apply Review Comments 2020-10-14 13:14:23 -05:00
Leijurv
3f207b7041 Merge pull request #2076 from CDAGaming/feature/rendering-compat-fix
🐛 Fix a Rendering Conflict with some other Mods
2020-10-14 11:09:00 -07:00
Leijurv
8deb9e5a35 Merge pull request #1959 from CDAGaming/feature/top-command
 Added a top/surface command
2020-10-14 11:02:07 -07:00
Leijurv
5eeb33a6f5 Merge pull request #1845 from mariusdkm/master
Fixing crash after clicking into the air using the #click command
2020-10-14 10:59:34 -07:00
CDAGaming
918f009e8a 🐛 Fix a Rendering Conflict with some other Mods
In testing within Fabritone, it was found that these two lines (Which were previously used for an unknown optifine workaround) are no longer needed, and had no known side effects as of writing.

This can be backported as needed, but details are unknown how far this can go down

Future me PS: This PR is a superseed of my last one, erased during repo refactors, so now it lives on master branch. Testing recommended and can be up-ported/down-ported as you wish.
2020-10-12 12:52:05 -05:00
CDAGaming
d6665f1cd5 Added Toast API Support
This adds in a logAsToast and toastTimer option, and is a minified form of Indrit's initial implementation previously used from fabritone
2020-10-12 12:46:01 -05:00
CDAGaming
af29ed7146 Added a top/surface command
Superseeds PR #594
2020-10-12 12:44:12 -05:00
Leijurv
8ddc795158 Merge pull request #2020 from ZacSharp/wpgoto
make `#wp goto` behave like `#wp goal` and `#path`
2020-09-29 16:55:50 -07:00
ZacSharp
8a572516fc Update description of WaypointsCommand 2020-09-23 22:54:41 +02:00
ZacSharp
aebfbba20e Also override heuristic(no args) when overriding isInGoal() 2020-09-20 22:39:48 +02:00
ZacSharp
85cc86346c Actually use Y and Z bounds for Y and Z 2020-09-20 22:20:24 +02:00
ZacSharp
b20e095683 add heuristic(no args) to GoalNear and GoalRunAway
not really a good solution but better than nothing
2020-09-20 00:29:31 +02:00
ZacSharp
b4d7f05165 🐛 fix two NPEs in estimatedTickToGoal
apparently `ctx.playerFeet()` and `startPosition` can be `null` before pathing the first time
2020-09-19 21:46:07 +02:00
ZacSharp
46a12754e9 🐛Reset ETA and return 0 if we are already there
not doing this caused a continuously increasing ETA when standing inside a `GoalNear` from `FollowProcess`
2020-09-19 00:30:25 +02:00
ZacSharp
411b2a0acc 🔨move ETA reset to it's own function 2020-09-18 23:58:06 +02:00
ZacSharp
508dacac63 directly start pathing after #home
just like servers directly teleport you after `/home` without waiting for something like `/teleport`
2020-09-18 22:41:33 +02:00
ZacSharp
13ca691f5d make #wp goto behave like #goto
It now is a combined `#wp goal` and `#path` just like `#goto` is `#goal` and `#path`
2020-09-16 20:19:55 +02:00
Leijurv
7e4d2c9b28 Update README.md 2020-09-15 12:43:34 -07:00
Brady
500c34c330 Merge pull request #2015 from babbaj/fix-troll-code
Don't call onLostControl on processes that haven't been fully constructed
2020-09-13 17:46:23 -05:00
Babbaj
234fd3f75e don't use getter 2020-09-13 18:45:50 -04:00
Babbaj
32ef30686b Don't call onLostControl on processes that haven't been fully constructed 2020-09-13 18:21:22 -04:00
Leijurv
175df6ce7a Update USAGE.md 2020-09-11 21:54:20 -07:00
Leijurv
96b874c099 Update README.md 2020-09-11 21:52:43 -07:00
Sam Corbett
612510550f fix javadoc.
Signed-off-by: Sam Corbett <sam@corbettchocolates.com>
2020-09-08 19:00:41 +01:00
Sam Corbett
80e4852f90 Merge https://github.com/cabaletta/baritone into exposedOres 2020-09-08 17:48:45 +01:00
Sam Corbett
071243b99a move is transparent to movement helper and circle maker 2020-09-08 17:47:46 +01:00
Sam Corbett
547db3a6b4 make the ability to turn it off.
Signed-off-by: Sam Corbett <sam@corbettchocolates.com>
2020-09-08 17:47:45 +01:00
scorbett123
063f698bd2 need to remove diagonals, however this does most of what you suggest.
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-09-08 17:47:45 +01:00
scorbett123
bcbfca100f add mineOnlyExposedOres setting
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-09-08 17:47:45 +01:00
Leijurv
8206b1673c Merge pull request #1988 from scorbett123/patch1
fix typo in java-doc x2
2020-09-07 13:18:52 -07:00
ZacSharp
7255ccbdaa add heuristic(no args) to GoalComposite
GoalNear and GoalRunAway are still missing it
2020-09-06 16:42:05 +02:00
ZacSharp
45dc8b949d add a method to get the heuristic at the goal
this alows the ETA to work with goals not ending with a heuristic of 0

GoalComposite, GoalRunAway and GoalNear are still missing
2020-09-05 22:32:38 +02:00
ZacSharp
10e3a5afc4 negative ETAs are actually impossible now 2020-09-05 22:13:05 +02:00
ZacSharp
303aa79ffb Update ETA formula, assuming heuritic at goal is 0 2020-09-04 23:56:01 +02:00
ZacSharp
35f3be9296 get rid of negative ETAs the lazy way 2020-09-02 22:59:13 +02:00
scorbett123
d7088c8eea fix typo in java-doc x2
Signed-off-by: scorbett123 <sam@corbettchocolates.com>
2020-08-31 18:48:46 +01:00
ZacSharp
695954bdb0 no eta after 0 ticks or with division by 0 2020-08-28 23:37:23 +02:00
ZacSharp
d29b3ee893 Fix copy/paste mistake in ETACommand.getLongDesc() 2020-08-28 01:19:06 +02:00
ZacSharp
d9cecb35cb rename Eta to ETA 2020-08-28 00:56:18 +02:00
ZacSharp
71dd6c6333 👌formatting 2020-08-27 01:16:17 +02:00
ZacSharp
56f13d314a Add eta command 2020-08-26 23:53:02 +02:00
ZacSharp
b628d67961 Add ETA for full path 2020-08-26 23:52:44 +02:00
Leijurv
bf723deced Merge pull request #1964 from ZacSharp/master
Fix MovementDiagonal being safeToCancel while cornering over air 2.0
2020-08-24 16:20:01 -07:00
ZacSharp
9636e69a6b slightly better condition 2020-08-24 23:06:19 +02:00
krzys-h
ed91e2aa7b Fix "#entity follow <name>" under Forge
One of the Forge patches removes EntityList.REGISTRY and provides
the getClass method as a replacement.

The fix is based on a similar one I found in WorldDownloader

Closes #1376 (and duplicates: #1777 and #1815)
2020-08-24 22:24:18 +02:00
ZacSharp
3c691bb498 But now it's working 2020-08-20 23:33:47 +02:00
ZacSharp
ea35a3478f Codacity again for the same and syntax
dab
2020-08-20 23:16:59 +02:00
ZacSharp
b7d1ba1fa5 Make Codacity happy 2020-08-20 23:11:55 +02:00
ZacSharp
5f686c1c12 improve isSafeToCancel in MovementDiagonal even more
It did not return true early enough for backfill while cornering over air
2020-08-20 22:55:42 +02:00
Leijurv
4eea8308d7 Merge pull request #1956 from RealIndrit/patch-1
🔥 Get yeeted unused code
2020-08-18 11:14:25 -07:00
kuthy
7f9704592e Made catch function wide 2020-08-18 15:40:12 +02:00
RealIndrit
523f13c430 🔥 Get yeeted unused code
Removed an unused function that can't be used anyways, because RayTraceUtils cant detect entity hit...
2020-08-18 12:36:10 +02:00
kuthy
0055a059f7 Formated Code 2020-07-03 16:52:03 +02:00
kuthy
8262909063 Fixing crash after clicking into the air 2020-07-03 15:36:44 +02:00
Moondarker
8fe05c9119 fixup! Allow multi-artifact building for Jitpack and local Maven repos 2020-06-20 23:16:20 +03:00
Moondarker
e8e6a9bc5c Allow multi-artifact building for Jitpack and local Maven repos 2020-06-20 23:11:16 +03:00
236 changed files with 3838 additions and 2980 deletions

View File

@@ -11,7 +11,7 @@ Operating system:
Java version:
Minecraft version:
Baritone version:
Forge mods (if used):
Other mods (if used):
## Exception, error or logs
Please find your `latest.log` or `debug.log` in this folder and attach it to the issue

45
.github/workflows/gradle_build.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
# 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@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build (fabric) with Gradle
run: ./gradlew build -Pbaritone.fabric_build
- name: Build (forge) with Gradle
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: dist/
- name: Archive mapping.txt
uses: actions/upload-artifact@v2
with:
name: Mappings
path: build/tmp/proguard/mapping.txt

26
.github/workflows/run_tests.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Tests
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Executing tests
run: ./gradlew test

9
.gitignore vendored
View File

@@ -4,6 +4,7 @@
run/
autotest/
dist/
volderyarn/
# Gradle
build/
@@ -20,6 +21,14 @@ classes/
*.iws
/logs/
# Eclipse Files
.classpath
.project
.settings/
baritone_Client.launch
# Copyright Files
!/.idea/copyright/Baritone.xml
!/.idea/copyright/profiles_settings.xml
.vscode/launch.json

View File

@@ -1,29 +0,0 @@
language: java
sudo: required
services:
- docker
install:
- travis_retry docker build -t cabaletta/baritone .
script:
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
#- docker run --name baritone cabaletta/baritone /bin/sh -c "/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
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

View File

@@ -1,24 +1,17 @@
FROM debian:stretch
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive
RUN apt update -y
RUN apt install \
openjdk-8-jdk \
openjdk-17-jdk \
--assume-yes
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
COPY . /code
WORKDIR /code
# this .deb is specially patched to support lwjgl
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
RUN ./gradlew build
RUN ./gradlew build -Pbaritone.forge_build
RUN ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
RUN ./gradlew build -Pbaritone.fabric_build

View File

@@ -1,47 +1,69 @@
# Baritone
[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/)
[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/)
<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>
[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/)
[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/)
[![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cabaletta/baritone&amp;utm_campaign=Badge_Grade)
[![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/)
[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/)
[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed)
[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/)
![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg)
![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code)
[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/)
[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/)
[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3-brightgreen.svg)](https://impactclient.net/)
[![KAMI Blue integration](https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green)](https://github.com/kami-blue/client)
[![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-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red)](https://futureclient.net/)
[![RusherHack integration](https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green)](https://rusherhack.org/)
[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/)
[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/)
<p align="center">
<img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.13.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.14.4-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.15.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.18.1-brightgreen.svg" alt="Minecraft"/>
</p>
A Minecraft pathfinder bot.
<p align="center">
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
<a href="https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cabaletta/baritone&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400" alt="Codacy Badge"/></a>
<a href="https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat" alt="Code of Conduct"/></a>
<a href="https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle"><img src="https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle" alt="Known Vulnerabilities"/></a>
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="Contributions welcome"/></a>
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/github/issues/cabaletta/baritone.svg" alt="Issues"/></a>
<a href="https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed/cabaletta/baritone.svg" alt="GitHub issues-closed"/></a>
<a href="https://github.com/cabaletta/baritone/pulls/"><img src="https://img.shields.io/github/issues-pr/cabaletta/baritone.svg" alt="Pull Requests"/></a>
<a href="https://github.com/cabaletta/baritone/graphs/contributors/"><img src="https://img.shields.io/github/contributors/cabaletta/baritone.svg" alt="GitHub contributors"/></a>
<a href="https://github.com/cabaletta/baritone/commit/"><img src="https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg" alt="GitHub commits"/></a>
<img src="https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg" alt="Code size"/>
<img src="https://img.shields.io/github/repo-size/cabaletta/baritone.svg" alt="GitHub repo size"/>
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code" alt="Lines of Code"/>
</p>
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.
<p align="center">
<a href="https://impactclient.net/"><img src="https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3%20/%20v1.6.3-brightgreen.svg" alt="Impact integration"/></a>
<a href="https://github.com/kami-blue/client"><img src="https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green" alt="KAMI Blue integration"/></a>
<a href="https://github.com/fr1kin/ForgeHax/"><img src="https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg" alt="ForgeHax integration"/></a>
<a href="https://aristois.net/"><img src="https://img.shields.io/badge/Aristois%20add--on%20integration-v1.6.3-green.svg" alt="Aristois add-on integration"/></a>
<a href="https://rootnet.dev/"><img src="https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg" alt="rootNET integration"/></a>
<a href="https://futureclient.net/"><img src="https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red" alt="Future integration"/></a>
<a href="https://rusherhack.org/"><img src="https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green" alt="RusherHack integration"/></a>
</p>
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.14/baritone-api-forge-1.2.14.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
<p align="center">
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
</p>
A Minecraft pathfinder bot.
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar.
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**.
If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 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).
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.

View File

@@ -2,7 +2,7 @@
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version
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.
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
@@ -11,9 +11,9 @@ These releases are not always completely up to date with latest features, and ar
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL)
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) 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`.
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`.
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).
@@ -32,11 +32,6 @@ If another one of your Forge mods has a Baritone integration, you want `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.
## More Info
To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal.
You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`.
## Build it yourself
- Clone or download Baritone
@@ -49,6 +44,27 @@ 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.
To check which java you are using do
`java -version` in a command prompt or terminal.
If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
Open JDK 8 download: https://openjdk.java.net/install/
#### macOS guide
In order to get JDK 8, Try running the following command:
`% /usr/libexec/java_home -V`
If it doesn't work try this guide: https://stackoverflow.com/questions/46513639/how-to-downgrade-java-from-9-to-8-on-a-macos-eclipse-is-not-running-with-java-9
If you see something like
`% 1.8.0_VERSION, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_VERSION.jdk/Contents/Home`
in the list then you've got JDK 8 installed.
In order to get JDK 8 running in the **current terminal window** you will have to run this command:
`% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)`
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
Setting up the Environment:
```
@@ -62,6 +78,12 @@ 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:
```

View File

@@ -24,6 +24,8 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
# Commands
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
**All** of these commands may need a prefix before them, as above ^.
`help`
@@ -38,14 +40,14 @@ Some common examples:
- `goal clear` to clear the goal
- `cancel` or `stop` to stop everything
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine 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.
- `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).
- `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type.
- `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)
- `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
- `schematica` to build the schematic that is currently open in schematica
- `tunnel` to dig and make a tunnel, 1x2. It will only deviate from the straight line if necessary such as to avoid lava. For a dumber tunnel that is really just cleararea, you can `tunnel 3 2 100`, to clear an area 3 high, 2 wide, and 100 deep.
- `farm` to automatically harvest, replant, or bone meal crops
- `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.
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.

View File

@@ -15,45 +15,25 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
group 'baritone'
version '1.6.1'
buildscript {
repositories {
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
jcenter()
}
dependencies {
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
}
plugins {
id 'java'
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
id 'maven-publish'
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
import net.minecraftforge.gradle.userdev.tasks.GenerateSRG
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
import org.apache.tools.ant.taskdefs.condition.Os
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
options.encoding = "UTF-8" // allow emoji in comments :^)
}
@@ -72,109 +52,67 @@ sourceSets {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
schematica_api {
compileClasspath += main.compileClasspath
}
main {
compileClasspath += schematica_api.output
}
}
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.api.allSource
}
minecraft {
mappings channel: 'snapshot', version: '20200813-1.16.1'
if (getProject().hasProperty("baritone.forge_build")) {
reobfMappings 'searge'
} else {
reobfMappings 'notch'
loom {
if (compileType.equals("FORGE")) {
forge {
mixinConfig 'mixins.baritone.json'
}
}
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
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"
}
source = sourceSets.launch
}
}
}
repositories {
mavenCentral()
maven {
name = 'spongepowered-repo'
url = 'http://repo.spongepowered.org/maven/'
}
repositories {
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
name = "ldtteam"
url = "https://maven.parchmentmc.net/"
}
mavenCentral()
}
dependencies {
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.2'
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
if (compileType.equals("FORGE")) {
forge "net.minecraftforge:forge:${project.forge_version}"
}
mappings loom.layered() {
officialMojangMappings()
//technically optional, but really helpful in dev:
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
}
minecraft "com.mojang:minecraft:${project.minecraft_version}"
if (!compileType.equals("FORGE")) {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
}
// 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'
exclude module: 'asm-debug-all'
}
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'
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.12'
}
mixin {
defaultObfuscationEnv searge
add sourceSets.launch, 'mixins.baritone.refmap.json'
}
javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true
@@ -183,11 +121,44 @@ javadoc {
classpath += sourceSets.api.compileClasspath
}
// 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 = 16
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
jar {
from sourceSets.launch.output, sourceSets.api.output
if (!getProject().hasProperty("baritone.forge_build")) {
exclude "**/BaritoneForgeModXD.class"
exclude "**/mods.toml"
}
preserveFileTimestamps = false
reproducibleFileOrder = true
if (getProject().hasProperty("baritone.fabric_build")) {
filesMatching("fabric.mod.json") {
expand "version": version
}
} else {
exclude("fabric.mod.json")
}
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
@@ -199,43 +170,21 @@ jar {
}
}
// skidded from ProguardTask
File getClientJar() {
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 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())
if (compileType.equals("OFFICIAL")) {
remapJar {
toM.set "official"
}
}
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 proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
extract 'proguard-7.2.0-beta2/lib/proguard.jar'
compType compileType
}
task createDist(type: CreateDistTask, dependsOn: proguard)
build.finalizedBy(createDist)
build.finalizedBy(createDist)

View File

@@ -20,6 +20,6 @@ repositories {
}
dependencies {
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
}

View File

@@ -41,13 +41,16 @@ class BaritoneGradleTask extends DefaultTask {
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
PROGUARD_EXPORT_PATH = "proguard_out.jar",
ARTIFACT_STANDARD = "%s-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
ARTIFACT_API = "%s-api-%s.jar",
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar";
ARTIFACT_STANDARD = "%s-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
ARTIFACT_API = "%s-api-%s.jar",
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
ARTIFACT_FORGE_API = "%s-api-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 final Path
@@ -65,6 +68,10 @@ class BaritoneGradleTask extends DefaultTask {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
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));
@@ -92,7 +99,7 @@ class BaritoneGradleTask extends DefaultTask {
}
protected Path getRelativeFile(String file) {
return Paths.get(new File(file).getAbsolutePath());
return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath());
}
protected Path getTemporaryFile(String file) {

View File

@@ -19,7 +19,7 @@ package baritone.gradle.task;
import org.gradle.api.tasks.TaskAction;
import javax.xml.bind.DatatypeConverter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest;
@@ -77,10 +77,13 @@ public class CreateDistTask extends BaritoneGradleTask {
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))
);
}
@@ -90,10 +93,22 @@ public class CreateDistTask extends BaritoneGradleTask {
if (SHA1_DIGEST == null) {
SHA1_DIGEST = MessageDigest.getInstance("SHA-1");
}
return DatatypeConverter.printHexBinary(SHA1_DIGEST.digest(Files.readAllBytes(path))).toLowerCase();
return bytesToHex(SHA1_DIGEST.digest(Files.readAllBytes(path))).toLowerCase();
} catch (Exception e) {
// haha no thanks
throw new IllegalStateException(e);
}
}
private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
public static String bytesToHex(byte[] bytes) {
byte[] hexChars = new byte[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars, StandardCharsets.UTF_8);
}
}

View File

@@ -20,21 +20,12 @@ package baritone.gradle.task;
import baritone.gradle.util.Determinizer;
import org.apache.commons.io.IOUtils;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.JavaVersion;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.internal.file.IdentityFileResolver;
import org.gradle.api.internal.plugins.DefaultConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.Pair;
import org.gradle.internal.jvm.Jvm;
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
import org.gradle.process.internal.DefaultExecActionFactory;
import java.io.*;
import java.net.URL;
@@ -57,13 +48,33 @@ public class ProguardTask extends BaritoneGradleTask {
@Input
private String url;
public String getUrl() {
return url;
}
@Input
private String extract;
public String getExtract() {
return extract;
}
@Input
private String compType;
public String getCompType() {
return compType;
}
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
@TaskAction
protected void exec() throws Exception {
super.verifyArtifacts();
copyMcJar();
// "Haha brady why don't you make separate tasks"
processArtifact();
downloadProguard();
@@ -74,6 +85,32 @@ public class ProguardTask extends BaritoneGradleTask {
cleanup();
}
private boolean isMcJar(File f) {
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-mapped");
}
private void copyMcJar() throws IOException {
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter(this::isMcJar)
.map(f -> {
switch (compType) {
case "OFFICIAL":
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
case "FABRIC":
return new File(f.getParentFile(), "minecraft-intermediary.jar");
case "FORGE":
return new File(f.getParentFile(), "minecraft-srg.jar");
}
return null;
})
.findFirst()
.get();
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
}
private void processArtifact() throws Exception {
if (Files.exists(this.artifactUnoptimizedPath)) {
Files.delete(this.artifactUnoptimizedPath);
@@ -182,15 +219,16 @@ public class ProguardTask extends BaritoneGradleTask {
}
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");
//TODO: fix for j16
// 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;
}
@@ -202,27 +240,19 @@ public class ProguardTask extends BaritoneGradleTask {
template.add(0, "-injars " + this.artifactPath.toString());
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
template.add(2, "-libraryjars '" + out + "'");
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
{
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);
// remove MCP mapped jar, and nashorn
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
if (getProject().hasProperty("baritone.forge_build")) {
libraries = dependencies
.map(f -> f.toString().endsWith("client.jar") ? getSrgMcJar() : f);
} else {
libraries = dependencies;
}
libraries = dependencies
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
}
libraries.forEach(f -> {
template.add(2, "-libraryjars '" + f + "'");
@@ -272,6 +302,10 @@ public class ProguardTask extends BaritoneGradleTask {
this.extract = extract;
}
public void setCompType(String compType) {
this.compType = compType;
}
private void runProguard(Path config) throws Exception {
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
if (Files.exists(this.proguardOut)) {

13
gradle.properties Normal file
View File

@@ -0,0 +1,13 @@
org.gradle.jvmargs=-Xmx2048M
mod_version=1.8.3
maven_group=baritone
archives_base_name=baritone
minecraft_version=1.18.2
forge_version=1.18.2-40.0.0
fabric_version=0.13.1
# # un comment for forge debugging default (as opposed to fabric)
# baritone.forge_build=true
# loom.platform=forge

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Tue Jul 31 21:56:56 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

53
gradlew vendored
View File

@@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View File

@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View File

@@ -337,3 +337,5 @@
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
-printmapping mapping.txt

Binary file not shown.

View File

@@ -15,5 +15,26 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
rootProject.name = 'baritone'
pluginManagement {
repositories {
maven { url "https://maven.architectury.dev/" }
maven {
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'forge'
url = 'https://files.minecraftforge.net/maven'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
maven {
url = 'https://libraries.minecraft.net/'
}
mavenCentral()
}
}

View File

@@ -20,13 +20,13 @@ package baritone.api;
import baritone.api.behavior.ILookBehavior;
import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IWorldProvider;
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.listener.IEventBus;
import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.*;
import baritone.api.selection.ISelectionManager;
import baritone.api.utils.IInputOverrideHandler;
import baritone.api.utils.IPlayerContext;
import baritone.api.command.manager.ICommandManager;
/**
* @author Brady

View File

@@ -20,11 +20,10 @@ package baritone.api;
import baritone.api.cache.IWorldScanner;
import baritone.api.command.ICommand;
import baritone.api.command.ICommandSystem;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import baritone.api.schematic.ISchematicSystem;
import java.util.List;
import java.util.Objects;
import net.minecraft.client.player.LocalPlayer;
/**
* Provides the present {@link IBaritone} instances, as well as non-baritone instance related APIs.
@@ -47,19 +46,19 @@ public interface IBaritoneProvider {
* returned by {@link #getPrimaryBaritone()}.
*
* @return All active {@link IBaritone} instances.
* @see #getBaritoneForPlayer(ClientPlayerEntity)
* @see #getBaritoneForPlayer(LocalPlayer)
*/
List<IBaritone> getAllBaritones();
/**
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}. This will likely be
* Provides the {@link IBaritone} instance for a given {@link LocalPlayer}. This will likely be
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
* {@code bot-system} is merged into {@code master}.
*
* @param player The player
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
default IBaritone getBaritoneForPlayer(LocalPlayer player) {
for (IBaritone baritone : getAllBaritones()) {
if (Objects.equals(player, baritone.getPlayerContext().player())) {
return baritone;

View File

@@ -17,22 +17,26 @@
package baritone.api;
import baritone.api.utils.NotificationHelper;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.TypeUtils;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.*;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.BiConsumer;
/**
* Baritone's settings. Settings apply to all Baritone instances.
@@ -64,15 +68,15 @@ public final class Settings {
/**
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
* <p>
* Specifically, path calculation will still assume that an auto tool wil run at execution time, even though
* Specifically, path calculation will still assume that an auto tool will run at execution time, even though
* Baritone itself will not do that.
*/
public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);
/**
* If this setting is on, no auto tool will occur at all, not at calculation time nor execution time
* Automatically select the best available tool
*/
public final Setting<Boolean> disableAutoTool = new Setting<>(false);
public final Setting<Boolean> autoTool = new Setting<>(true);
/**
* It doesn't actually take twenty ticks to place a block, this cost is so high
@@ -187,6 +191,13 @@ public final class Settings {
/**
* Blocks that Baritone is not allowed to break
*/
public final Setting<List<Block>> blocksToDisallowBreaking = new Setting<>(new ArrayList<>(
// Leave Empty by Default
));
/**
* blocks that baritone shouldn't break, but can if it needs to.
*/
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
Blocks.CRAFTING_TABLE,
Blocks.FURNACE,
@@ -194,6 +205,11 @@ public final class Settings {
Blocks.TRAPPED_CHEST
)));
/**
* this multiplies the break speed, if set above 1 it's "encourage breaking" instead
*/
public final Setting<Double> avoidBreakingMultiplier = new Setting<>(.1);
/**
* A list of blocks to be treated as if they're air.
* <p>
@@ -203,6 +219,29 @@ 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
*/
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
*/
public final Setting<Map<Block, List<Block>>> buildSubstitutes = new Setting<>(new HashMap<>());
/**
* A list of blocks to become air
* <p>
@@ -217,6 +256,11 @@ public final class Settings {
*/
public final Setting<Boolean> buildIgnoreExisting = new Setting<>(false);
/**
* If this is true, the builder will ignore directionality of certain blocks like glazed terracotta.
*/
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
/**
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
* <p>
@@ -519,18 +563,23 @@ public final class Settings {
*/
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
/**
* Remember the contents of containers (chests, echests, furnaces)
* <p>
* Really buggy since the packet stuff is multithreaded badly thanks to brady
*/
public final Setting<Boolean> containerMemory = new Setting<>(false);
/**
* Fill in blocks behind you
*/
public final Setting<Boolean> backfill = new Setting<>(false);
/**
* Shows popup message in the upper right corner, similarly to when you make an advancement
*/
public final Setting<Boolean> logAsToast = new Setting<>(false);
/**
* The time of how long the message in the pop-up will display
* <p>
* If below 1000L (1sec), it's better to disable this
*/
public final Setting<Long> toastTimer = new Setting<>(5000L);
/**
* Print all the debug messages to chat
*/
@@ -562,6 +611,12 @@ public final class Settings {
*/
public final Setting<Boolean> renderGoal = new Setting<>(true);
/**
* Render the goal as a sick animated thingy instead of just a box
* (also controls animation of GoalXZ if {@link #renderGoalXZBeacon} is enabled)
*/
public final Setting<Boolean> renderGoalAnimated = new Setting<>(true);
/**
* Render selection boxes
*/
@@ -631,7 +686,7 @@ public final class Settings {
/**
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not.
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this search to the whole "vein"; MineProcess does not.
* This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break)
* Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them.
*/
@@ -686,6 +741,16 @@ public final class Settings {
*/
public final Setting<Boolean> censorRanCommands = new Setting<>(false);
/**
* Stop using tools just before they are going to break.
*/
public final Setting<Boolean> itemSaver = new Setting<>(false);
/**
* Durability to leave on the tool when using itemSaver
*/
public final Setting<Integer> itemSaverThreshold = new Setting<>(10);
/**
* Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk
* touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
@@ -729,7 +794,25 @@ public final class Settings {
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
/**
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
* Sets the minimum y level whilst mining - set to 0 to turn off.
* if world has negative y values, subtract the min world height to get the value to put here
*/
public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
/**
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
*/
public final Setting<Boolean> allowOnlyExposedOres = new Setting<>(false);
/**
* When allowOnlyExposedOres is enabled this is the distance around to search.
* <p>
* It is recommended to keep this value low, as it dramatically increases calculation times.
*/
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.
*/
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
@@ -781,22 +864,44 @@ public final class Settings {
*/
public final Setting<Boolean> layerOrder = new Setting<>(false);
/**
* How high should the individual layers be?
*/
public final Setting<Integer> layerHeight = new Setting<>(1);
/**
* Start building the schematic at a specific layer.
* Can help on larger builds when schematic wants to break things its already built
*/
public final Setting<Integer> startAtLayer = new Setting<>(0);
/**
* If a layer is unable to be constructed, just skip it.
*/
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
*/
public final Setting<Vector3i> buildRepeat = new Setting<>(new Vector3i(0, 0, 0));
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
/**
* How many times to buildrepeat. -1 for infinite.
*/
public final Setting<Integer> buildRepeatCount = new Setting<>(-1);
/**
* Don't notify schematics that they are moved.
* e.g. replacing will replace the same spots for every repetition
* Mainly for backward compatibility.
*/
public final Setting<Boolean> buildRepeatSneaky = new Setting<>(true);
/**
* Allow standing above a block while mining it, in BuilderProcess
* <p>
@@ -905,6 +1010,7 @@ public final class Settings {
* Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit"
* where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player
* couldn't. If you don't want it to look like you're X-Raying, turn this on
* This will always explore, regardless of exploreForBlocks
*/
public final Setting<Boolean> legitMine = new Setting<>(false);
@@ -989,7 +1095,21 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
public final Setting<Consumer<Component>> logger = new Setting<>(Minecraft.getInstance().gui.getChat()::addMessage);
/**
* The function that is called when Baritone will send a desktop notification. This function can be added to
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
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};
*/
public final Setting<BiConsumer<Component, Component>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
/**
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors
@@ -1086,6 +1206,11 @@ public final class Settings {
*/
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);
/**
* Use sword to mine.
*/
public final Setting<Boolean> useSwordToMine = new Setting<>(true);
/**
* Desktop notifications
*/

View File

@@ -58,6 +58,15 @@ public interface IPathingBehavior extends IBehavior {
return Optional.of(current.getPath().ticksRemainingFrom(start));
}
/**
* Returns the estimated remaining ticks to the current goal.
* Given that the return type is an optional, {@link Optional#empty()}
* will be returned in the case that there is no current goal.
*
* @return The estimated remaining ticks to the current goal.
*/
Optional<Double> estimatedTicksToGoal();
/**
* @return The current pathing goal
*/

View File

@@ -17,8 +17,8 @@
package baritone.api.cache;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
/**
* @author Brady

View File

@@ -17,10 +17,9 @@
package baritone.api.cache;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk;
import java.util.ArrayList;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.chunk.LevelChunk;
/**
* @author Brady
@@ -44,7 +43,7 @@ public interface ICachedWorld {
*
* @param chunk The chunk to pack and store
*/
void queueForPacking(Chunk chunk);
void queueForPacking(LevelChunk chunk);
/**
* Returns whether or not the block at the specified X and Z coordinates

View File

@@ -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.cache;
import net.minecraft.util.math.BlockPos;
import java.util.Map;
/**
* @author Brady
* @since 9/23/2018
*/
public interface IContainerMemory {
/**
* Gets a remembered inventory by its block position.
*
* @param pos The position of the container block
* @return The remembered inventory
*/
IRememberedInventory getInventoryByPos(BlockPos pos);
/**
* Gets the map of all block positions to their remembered inventories.
*
* @return Map of block positions to their respective remembered inventories
*/
Map<BlockPos, IRememberedInventory> getRememberedInventories();
}

View File

@@ -1,39 +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.cache;
import net.minecraft.item.ItemStack;
import java.util.List;
/**
* @author Brady
* @since 9/23/2018
*/
public interface IRememberedInventory {
/**
* @return The contents of this inventory
*/
List<ItemStack> getContents();
/**
* @return The number of slots in this inventory
*/
int getSize();
}

View File

@@ -37,9 +37,4 @@ public interface IWorldData {
*/
IWaypointCollection getWaypoints();
/**
* @return The {@link IContainerMemory} instance
* @see IContainerMemory
*/
IContainerMemory getContainerMemory();
}

View File

@@ -19,11 +19,10 @@ package baritone.api.cache;
import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
/**
* @author Brady
@@ -88,7 +87,7 @@ public interface IWorldScanner {
* Queues the chunks in a square formation around the specified player, using the specified
* range, which represents 1/2 the square's dimensions, where the player is in the center.
*
* @param ctx The player, describing the origin
* @param ctx The player, describing the origin
* @param range The range to repack
* @return The amount of chunks successfully queued for repacking
*/

View File

@@ -34,9 +34,8 @@ import java.util.stream.Stream;
* So basically, you should use it because it provides a small amount of boilerplate,
* but you're not forced to use it.
*
* @see ICommand
*
* @author LoganDark
* @see ICommand
*/
public abstract class Command implements ICommand {

View File

@@ -46,8 +46,8 @@ public interface IArgParserManager {
/**
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
*
* @param type The type to try and parse the argument into.
* @param arg The argument to parse.
* @param type The type to try and parse the argument into.
* @param arg The argument to parse.
* @return An instance of the specified class.
* @throws CommandInvalidTypeException If the parsing failed
*/

View File

@@ -18,8 +18,6 @@
package baritone.api.command.argument;
import baritone.api.command.ICommand;
import baritone.api.command.exception.CommandTooManyArgumentsException;
import baritone.api.utils.Helper;
import baritone.api.command.argparser.IArgParser;
import baritone.api.command.datatypes.IDatatype;
import baritone.api.command.datatypes.IDatatypeFor;
@@ -27,11 +25,12 @@ import baritone.api.command.datatypes.IDatatypePost;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
import net.minecraft.util.Direction;
import baritone.api.command.exception.CommandTooManyArgumentsException;
import baritone.api.utils.Helper;
import java.util.Deque;
import java.util.LinkedList;
import java.util.stream.Stream;
import net.minecraft.core.Direction;
/**
* The {@link IArgConsumer} is how {@link ICommand}s read the arguments passed to them. This class has many benefits:
@@ -223,7 +222,7 @@ public interface IArgConsumer {
* @param type The type to peek as
* @param index The index to peek
* @return An instance of the specified type
* @throws CommandInvalidTypeException If the parsing failed
* @throws CommandInvalidTypeException If the parsing failed
* @see IArgParser
* @see #peekAs(Class)
* @see #peekAsOrDefault(Class, Object, int)
@@ -240,7 +239,7 @@ public interface IArgConsumer {
*
* @param type The type to peek as
* @return An instance of the specified type
* @throws CommandInvalidTypeException If the parsing failed
* @throws CommandInvalidTypeException If the parsing failed
* @see IArgParser
* @see #peekAs(Class, int)
* @see #peekAsOrDefault(Class, Object)
@@ -458,7 +457,7 @@ public interface IArgConsumer {
*
* @param type The type to peek as
* @return An instance of the specified type
* @throws CommandInvalidTypeException If the parsing failed
* @throws CommandInvalidTypeException If the parsing failed
* @see IArgParser
* @see #get()
* @see #getAsOrDefault(Class, Object)

View File

@@ -19,7 +19,7 @@ package baritone.api.command.argument;
import baritone.api.command.argparser.IArgParser;
import baritone.api.command.exception.CommandInvalidTypeException;
import net.minecraft.util.Direction;
import net.minecraft.core.Direction;
/**
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
@@ -87,7 +87,7 @@ public interface ICommandArgument {
*
* @param type The class to parse this argument into
* @return An instance of the specified type
* @throws CommandInvalidTypeException If the parsing failed
* @throws CommandInvalidTypeException If the parsing failed
*/
<T, S> T getAs(Class<T> type, Class<S> stateType, S state) throws CommandInvalidTypeException;

View File

@@ -19,11 +19,10 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
public enum BlockById implements IDatatypeFor<Block> {
INSTANCE;
@@ -32,7 +31,7 @@ public enum BlockById implements IDatatypeFor<Block> {
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
Block block;
if ((block = Registry.BLOCK.func_241873_b(id).orElse(null)) == null) {
if ((block = Registry.BLOCK.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id");
}
return block;

View File

@@ -19,11 +19,10 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
public enum EntityClassById implements IDatatypeFor<EntityType> {
INSTANCE;
@@ -32,7 +31,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
EntityType entity;
if ((entity = Registry.ENTITY_TYPE.func_241873_b(id).orElse(null)) == null) {
if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");
}
return entity;

View File

@@ -17,8 +17,8 @@
package baritone.api.command.datatypes;
import baritone.api.utils.BlockOptionalMeta;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.BlockOptionalMeta;
import java.util.stream.Stream;

View File

@@ -17,12 +17,11 @@
package baritone.api.command.datatypes;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.command.exception.CommandException;
import net.minecraft.util.Direction;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.Locale;
import java.util.stream.Stream;
import net.minecraft.core.Direction;
public enum ForDirection implements IDatatypeFor<Direction> {
INSTANCE;
@@ -36,7 +35,7 @@ public enum ForDirection implements IDatatypeFor<Direction> {
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(Stream.of(Direction.values())
.map(Direction::getName2).map(String::toLowerCase))
.map(Direction::getName).map(String::toLowerCase))
.filterPrefix(ctx.getConsumer().getString())
.stream();
}

View File

@@ -20,8 +20,8 @@ package baritone.api.command.datatypes;
import baritone.api.IBaritone;
import baritone.api.cache.IWaypoint;
import baritone.api.cache.IWaypointCollection;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.Comparator;
import java.util.stream.Stream;

View File

@@ -24,9 +24,8 @@ import baritone.api.command.argument.IArgConsumer;
* Provides an {@link IDatatype} with contextual information so
* that it can perform the desired operation on the target level.
*
* @see IDatatype
*
* @author Brady
* @see IDatatype
* @since 9/26/2019
*/
public interface IDatatypeContext {

View File

@@ -34,11 +34,10 @@ public interface IDatatypeFor<T> extends IDatatype {
* if the expected input does not conform to a parseable value. As far as a {@link CommandException} being
* thrown is concerned, see the note below for specifics.
*
* @see IDatatypeContext
*
* @param ctx The context
* @return The parsed data-type
* @throws CommandException If there was an issue parsing using another type or arguments could not be polled.
* @see IDatatypeContext
*/
T get(IDatatypeContext ctx) throws CommandException;
}

View File

@@ -20,21 +20,20 @@ package baritone.api.command.datatypes;
import baritone.api.IBaritone;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import java.util.List;
import java.util.stream.Stream;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
/**
* An {@link IDatatype} used to resolve nearby players, those within
* render distance of the target {@link IBaritone} instance.
*/
public enum NearbyPlayer implements IDatatypeFor<PlayerEntity> {
public enum NearbyPlayer implements IDatatypeFor<Player> {
INSTANCE;
@Override
public PlayerEntity get(IDatatypeContext ctx) throws CommandException {
public Player get(IDatatypeContext ctx) throws CommandException {
final String username = ctx.getConsumer().getString();
return getPlayers(ctx).stream()
.filter(s -> s.getName().getString().equalsIgnoreCase(username))
@@ -44,13 +43,13 @@ public enum NearbyPlayer implements IDatatypeFor<PlayerEntity> {
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(getPlayers(ctx).stream().map(PlayerEntity::getName).map(ITextComponent::getString))
.append(getPlayers(ctx).stream().map(Player::getName).map(Component::getString))
.filterPrefix(ctx.getConsumer().getString())
.sortAlphabetically()
.stream();
}
private static List<? extends PlayerEntity> getPlayers(IDatatypeContext ctx) {
return ctx.getBaritone().getPlayerContext().world().getPlayers();
private static List<? extends Player> getPlayers(IDatatypeContext ctx) {
return ctx.getBaritone().getPlayerContext().world().players();
}
}

View File

@@ -18,8 +18,8 @@
package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.BetterBlockPos;
import java.util.stream.Stream;

View File

@@ -94,7 +94,7 @@ public enum RelativeFile implements IDatatypePost<File, File> {
}
public static File gameDir() {
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
File gameDir = HELPER.mc.gameDirectory.getAbsoluteFile();
if (gameDir.getName().equals(".")) {
return gameDir.getParentFile();
}

View File

@@ -18,16 +18,13 @@
package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.exception.CommandException;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
public enum RelativeGoal implements IDatatypePost<Goal, BetterBlockPos> {

View File

@@ -18,12 +18,11 @@
package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.exception.CommandException;
import net.minecraft.util.math.MathHelper;
import java.util.stream.Stream;
import net.minecraft.util.Mth;
public enum RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPos> {
INSTANCE;
@@ -36,9 +35,9 @@ public enum RelativeGoalBlock implements IDatatypePost<GoalBlock, BetterBlockPos
final IArgConsumer consumer = ctx.getConsumer();
return new GoalBlock(
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y)),
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y)),
Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
);
}

View File

@@ -18,12 +18,11 @@
package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.exception.CommandException;
import net.minecraft.util.math.MathHelper;
import java.util.stream.Stream;
import net.minecraft.util.Mth;
public enum RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
INSTANCE;
@@ -36,8 +35,8 @@ public enum RelativeGoalXZ implements IDatatypePost<GoalXZ, BetterBlockPos> {
final IArgConsumer consumer = ctx.getConsumer();
return new GoalXZ(
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)),
Mth.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z))
);
}

View File

@@ -18,12 +18,11 @@
package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.utils.BetterBlockPos;
import baritone.api.command.exception.CommandException;
import net.minecraft.util.math.MathHelper;
import java.util.stream.Stream;
import net.minecraft.util.Mth;
public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> {
INSTANCE;
@@ -35,7 +34,7 @@ public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockP
}
return new GoalYLevel(
MathHelper.floor(ctx.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y))
Mth.floor(ctx.getConsumer().getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y))
);
}

View File

@@ -19,9 +19,8 @@ package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.command.argument.ICommandArgument;
import net.minecraft.util.text.TextFormatting;
import java.util.List;
import net.minecraft.ChatFormatting;
import static baritone.api.utils.Helper.HELPER;
@@ -38,8 +37,8 @@ public class CommandUnhandledException extends RuntimeException implements IComm
@Override
public void handle(ICommand command, List<ICommandArgument> args) {
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);
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
ChatFormatting.RED);
this.printStackTrace();
}

View File

@@ -19,9 +19,8 @@ package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.command.argument.ICommandArgument;
import net.minecraft.util.text.TextFormatting;
import java.util.List;
import net.minecraft.ChatFormatting;
import static baritone.api.utils.Helper.HELPER;
@@ -38,8 +37,8 @@ import static baritone.api.utils.Helper.HELPER;
public interface ICommandException {
/**
* @see Exception#getMessage()
* @return The exception details
* @see Exception#getMessage()
*/
String getMessage();
@@ -50,6 +49,6 @@ public interface ICommandException {
* @param args The arguments the command was called with.
*/
default void handle(ICommand command, List<ICommandArgument> args) {
HELPER.logDirect(this.getMessage(), TextFormatting.RED);
HELPER.logDirect(this.getMessage(), ChatFormatting.RED);
}
}

View File

@@ -17,20 +17,19 @@
package baritone.api.command.helpers;
import baritone.api.utils.Helper;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.command.argument.IArgConsumer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import baritone.api.utils.Helper;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
public class Paginator<E> implements Helper {
@@ -64,59 +63,59 @@ public class Paginator<E> implements Helper {
return this;
}
public void display(Function<E, ITextComponent> transform, String commandPrefix) {
public void display(Function<E, Component> transform, String commandPrefix) {
int offset = (page - 1) * pageSize;
for (int i = offset; i < offset + pageSize; i++) {
if (i < entries.size()) {
logDirect(transform.apply(entries.get(i)));
} else {
logDirect("--", TextFormatting.DARK_GRAY);
logDirect("--", ChatFormatting.DARK_GRAY);
}
}
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
TextComponent prevPageComponent = new StringTextComponent("<<");
BaseComponent prevPageComponent = new TextComponent("<<");
if (hasPrevPage) {
prevPageComponent.setStyle(prevPageComponent.getStyle()
.setClickEvent(new ClickEvent(
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format("%s %d", commandPrefix, page - 1)
))
.setHoverEvent(new HoverEvent(
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new StringTextComponent("Click to view previous page")
new TextComponent("Click to view previous page")
)));
} else {
prevPageComponent.setStyle(prevPageComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY));
prevPageComponent.setStyle(prevPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
}
TextComponent nextPageComponent = new StringTextComponent(">>");
BaseComponent nextPageComponent = new TextComponent(">>");
if (hasNextPage) {
nextPageComponent.setStyle(nextPageComponent.getStyle()
.setClickEvent(new ClickEvent(
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format("%s %d", commandPrefix, page + 1)
))
.setHoverEvent(new HoverEvent(
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new StringTextComponent("Click to view next page")
new TextComponent("Click to view next page")
)));
} else {
nextPageComponent.setStyle(nextPageComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY));
nextPageComponent.setStyle(nextPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
}
TextComponent pagerComponent = new StringTextComponent("");
pagerComponent.setStyle(pagerComponent.getStyle().setFormatting(TextFormatting.GRAY));
BaseComponent pagerComponent = new TextComponent("");
pagerComponent.setStyle(pagerComponent.getStyle().withColor(ChatFormatting.GRAY));
pagerComponent.append(prevPageComponent);
pagerComponent.appendString(" | ");
pagerComponent.append(" | ");
pagerComponent.append(nextPageComponent);
pagerComponent.appendString(String.format(" %d/%d", page, getMaxPage()));
pagerComponent.append(String.format(" %d/%d", page, getMaxPage()));
logDirect(pagerComponent);
}
public void display(Function<E, ITextComponent> transform) {
public void display(Function<E, Component> transform) {
display(transform, null);
}
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, Component> transform, String commandPrefix) throws CommandException {
int page = 1;
consumer.requireMax(1);
if (consumer.hasAny()) {
@@ -139,47 +138,47 @@ public class Paginator<E> implements Helper {
pagi.display(transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, Component> transform, String commandPrefix) throws CommandException {
paginate(consumer, new Paginator<>(elems), pre, transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, Component> transform, String commandPrefix) throws CommandException {
paginate(consumer, Arrays.asList(elems), pre, transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, Component> transform, String commandPrefix) throws CommandException {
paginate(consumer, pagi, null, transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, Component> transform, String commandPrefix) throws CommandException {
paginate(consumer, new Paginator<>(elems), null, transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, ITextComponent> transform, String commandPrefix) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, Component> transform, String commandPrefix) throws CommandException {
paginate(consumer, Arrays.asList(elems), null, transform, commandPrefix);
}
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, Component> transform) throws CommandException {
paginate(consumer, pagi, pre, transform, null);
}
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Runnable pre, Function<T, Component> transform) throws CommandException {
paginate(consumer, new Paginator<>(elems), pre, transform, null);
}
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, T[] elems, Runnable pre, Function<T, Component> transform) throws CommandException {
paginate(consumer, Arrays.asList(elems), pre, transform, null);
}
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Function<T, Component> transform) throws CommandException {
paginate(consumer, pagi, null, transform, null);
}
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, List<T> elems, Function<T, Component> transform) throws CommandException {
paginate(consumer, new Paginator<>(elems), null, transform, null);
}
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, ITextComponent> transform) throws CommandException {
public static <T> void paginate(IArgConsumer consumer, T[] elems, Function<T, Component> transform) throws CommandException {
paginate(consumer, Arrays.asList(elems), null, transform, null);
}
}

View File

@@ -19,18 +19,17 @@ package baritone.api.command.helpers;
import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.manager.ICommandManager;
import net.minecraft.util.ResourceLocation;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.resources.ResourceLocation;
/**
* The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper
@@ -236,7 +235,6 @@ public class TabCompleteHelper {
* Appends every command in the specified {@link ICommandManager} to this {@link TabCompleteHelper}
*
* @param manager A command manager
*
* @return This {@link TabCompleteHelper}
*/
public TabCompleteHelper addCommands(ICommandManager manager) {
@@ -254,8 +252,8 @@ public class TabCompleteHelper {
public TabCompleteHelper addSettings() {
return append(
BaritoneAPI.getSettings().allSettings.stream()
.filter(s -> !SettingsUtil.javaOnlySetting(s))
.map(Settings.Setting::getName)
.filter(s -> !s.equalsIgnoreCase("logger"))
.sorted(String.CASE_INSENSITIVE_ORDER)
);
}

View File

@@ -17,7 +17,7 @@
package baritone.api.event.events;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* Called when the local player interacts with a block, can be either {@link Type#START_BREAK} or {@link Type#USE}.

View File

@@ -18,8 +18,8 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.IPacket;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.Packet;
/**
* @author Brady
@@ -27,19 +27,19 @@ import net.minecraft.network.IPacket;
*/
public final class PacketEvent {
private final NetworkManager networkManager;
private final Connection networkManager;
private final EventState state;
private final IPacket<?> packet;
private final Packet<?> packet;
public PacketEvent(NetworkManager networkManager, EventState state, IPacket<?> packet) {
public PacketEvent(Connection networkManager, EventState state, Packet<?> packet) {
this.networkManager = networkManager;
this.state = state;
this.packet = packet;
}
public final NetworkManager getNetworkManager() {
public final Connection getNetworkManager() {
return this.networkManager;
}
@@ -47,12 +47,12 @@ public final class PacketEvent {
return this.state;
}
public final IPacket<?> getPacket() {
public final Packet<?> getPacket() {
return this.packet;
}
@SuppressWarnings("unchecked")
public final <T extends IPacket<?>> T cast() {
public final <T extends Packet<?>> T cast() {
return (T) this.packet;
}
}

View File

@@ -17,8 +17,8 @@
package baritone.api.event.events;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.util.math.vector.Matrix4f;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
/**
* @author Brady
@@ -32,9 +32,9 @@ public final class RenderEvent {
private final float partialTicks;
private final Matrix4f projectionMatrix;
private final MatrixStack modelViewStack;
private final PoseStack modelViewStack;
public RenderEvent(float partialTicks, MatrixStack modelViewStack, Matrix4f projectionMatrix) {
public RenderEvent(float partialTicks, PoseStack modelViewStack, Matrix4f projectionMatrix) {
this.partialTicks = partialTicks;
this.modelViewStack = modelViewStack;
this.projectionMatrix = projectionMatrix;
@@ -47,7 +47,7 @@ public final class RenderEvent {
return this.partialTicks;
}
public MatrixStack getModelViewStack() {
public PoseStack getModelViewStack() {
return this.modelViewStack;
}

View File

@@ -17,9 +17,9 @@
package baritone.api.event.events;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
/**
* @author Brady
@@ -70,7 +70,7 @@ public final class RotationMoveEvent {
/**
* Called when the player's motion is updated.
*
* @see Entity#moveRelative(float, Vector3d)
* @see Entity#moveRelative(float, Vec3)
*/
MOTION_UPDATE,

View File

@@ -18,7 +18,6 @@
package baritone.api.event.events;
import baritone.api.event.events.type.Cancellable;
import baritone.api.event.events.type.Overrideable;
/**
* @author LoganDark

View File

@@ -18,7 +18,7 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.multiplayer.ClientLevel;
/**
* @author Brady
@@ -29,14 +29,14 @@ public final class WorldEvent {
/**
* The new world that is being loaded. {@code null} if being unloaded.
*/
private final ClientWorld world;
private final ClientLevel world;
/**
* The state of the event
*/
private final EventState state;
public WorldEvent(ClientWorld world, EventState state) {
public WorldEvent(ClientLevel world, EventState state) {
this.world = world;
this.state = state;
}
@@ -44,7 +44,7 @@ public final class WorldEvent {
/**
* @return The new world that is being loaded. {@code null} if being unloaded.
*/
public final ClientWorld getWorld() {
public final ClientLevel getWorld() {
return this.world;
}

View File

@@ -19,12 +19,12 @@ package baritone.api.event.listener;
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.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.network.IPacket;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.client.gui.screens.DeathScreen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.Packet;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
/**
* @author Brady
@@ -36,7 +36,7 @@ public interface IGameEventListener {
* Run once per game tick before screen input is handled.
*
* @param event The event
* @see Minecraft#runTick()
* @see Minecraft#tick()
*/
void onTick(TickEvent event);
@@ -44,7 +44,7 @@ public interface IGameEventListener {
* Run once per game tick from before and after the player rotation is sent to the server.
*
* @param event The event
* @see ClientPlayerEntity#tick()
* @see LocalPlayer#tick()
*/
void onPlayerUpdate(PlayerUpdateEvent event);
@@ -52,7 +52,7 @@ public interface IGameEventListener {
* Runs whenever the client player sends a message to the server.
*
* @param event The event
* @see ClientPlayerEntity#sendChatMessage(String)
* @see LocalPlayer#chat(String)
*/
void onSendChatMessage(ChatEvent event);
@@ -81,7 +81,7 @@ public interface IGameEventListener {
* Runs before and after whenever a new world is loaded
*
* @param event The event
* @see Minecraft#loadWorld(ClientWorld)
* @see Minecraft#setLevel(ClientLevel)
*/
void onWorldEvent(WorldEvent event);
@@ -89,7 +89,7 @@ public interface IGameEventListener {
* Runs before a outbound packet is sent
*
* @param event The event
* @see IPacket
* @see Packet
*/
void onSendPacket(PacketEvent event);
@@ -97,7 +97,7 @@ public interface IGameEventListener {
* Runs before an inbound packet is processed
*
* @param event The event
* @see IPacket
* @see Packet
*/
void onReceivePacket(PacketEvent event);
@@ -106,15 +106,15 @@ public interface IGameEventListener {
* and before and after the player jumps.
*
* @param event The event
* @see Entity#moveRelative(float, Vector3d)
* @see Entity#moveRelative(float, Vec3)
*/
void onPlayerRotationMove(RotationMoveEvent event);
/**
* Called whenever the sprint keybind state is checked in {@link ClientPlayerEntity#livingTick}
* Called whenever the sprint keybind state is checked in {@link LocalPlayer#aiStep}
*
* @param event The event
* @see ClientPlayerEntity#livingTick()
* @see LocalPlayer#aiStep()
*/
void onPlayerSprintState(SprintStateEvent event);

View File

@@ -17,7 +17,7 @@
package baritone.api.pathing.goals;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* An abstract Goal for pathing, can be anything from a specific block to just a Y coordinate.
@@ -54,4 +54,18 @@ public interface Goal {
default double heuristic(BlockPos pos) {
return heuristic(pos.getX(), pos.getY(), pos.getZ());
}
/**
* Returns the heuristic at the goal.
* i.e. {@code heuristic() == heuristic(x,y,z)}
* when {@code isInGoal(x,y,z) == true}
* This is needed by {@code PathingBehavior#estimatedTicksToGoal} because
* some Goals actually do not have a heuristic of 0 when that condition is met
*
* @return The estimate number of ticks to satisfy the goal when the goal
* is already satisfied
*/
default double heuristic() {
return 0;
}
}

View File

@@ -19,7 +19,7 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* A specific BlockPos goal
@@ -87,9 +87,9 @@ public class GoalBlock implements Goal, IGoalRenderPos {
public static double calculate(double xDiff, int yDiff, double zDiff) {
double heuristic = 0;
// if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be
// therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate
heuristic += GoalYLevel.calculate(yDiff, 0);
// if yDiff is 1 that means that currentY-goalY==1 which means that we're 1 block above where we should be
// therefore going from 0,yDiff,0 to a GoalYLevel of 0 is accurate
heuristic += GoalYLevel.calculate(0, yDiff);
//use the pythagorean and manhattan mixture from GoalXZ
heuristic += GoalXZ.calculate(xDiff, zDiff);

View File

@@ -57,6 +57,16 @@ public class GoalComposite implements Goal {
return min;
}
@Override
public double heuristic() {
double min = Double.MAX_VALUE;
for (Goal g : goals) {
// just take the highest value that is guaranteed to be inside the goal
min = Math.min(min, g.heuristic());
}
return min;
}
@Override
public String toString() {
return "GoalComposite" + Arrays.toString(goals);

View File

@@ -19,7 +19,7 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**

View File

@@ -45,6 +45,11 @@ public class GoalInverted implements Goal {
return -origin.heuristic(x, y, z);
}
@Override
public double heuristic() {
return Double.NEGATIVE_INFINITY;
}
@Override
public String toString() {
return String.format("GoalInverted{%s}", origin.toString());

View File

@@ -19,7 +19,9 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import net.minecraft.core.BlockPos;
public class GoalNear implements Goal, IGoalRenderPos {
@@ -51,6 +53,34 @@ public class GoalNear implements Goal, IGoalRenderPos {
return GoalBlock.calculate(xDiff, yDiff, zDiff);
}
@Override
public double heuristic() {// TODO less hacky solution
int range = (int) Math.ceil(Math.sqrt(rangeSq));
DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978
double minOutside = Double.POSITIVE_INFINITY;
for (int dx = -range; dx <= range; dx++) {
for (int dy = -range; dy <= range; dy++) {
for (int dz = -range; dz <= range; dz++) {
double h = heuristic(x + dx, y + dy, z + dz);
if (h < minOutside && isInGoal(x + dx, y + dy, z + dz)) {
maybeAlwaysInside.add(h);
} else {
minOutside = Math.min(minOutside, h);
}
}
}
}
double maxInside = Double.NEGATIVE_INFINITY;
DoubleIterator it = maybeAlwaysInside.iterator();
while (it.hasNext()) {
double inside = it.nextDouble();
if (inside < minOutside) {
maxInside = Math.max(maxInside, inside);
}
}
return maxInside;
}
@Override
public BlockPos getGoalPos() {
return new BlockPos(x, y, z);

View File

@@ -18,9 +18,10 @@
package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.math.BlockPos;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import java.util.Arrays;
import net.minecraft.core.BlockPos;
/**
* Useful for automated combat (retreating specifically)
@@ -31,7 +32,7 @@ public class GoalRunAway implements Goal {
private final BlockPos[] from;
private final double distanceSq;
private final int distanceSq;
private final Integer maintainY;
@@ -44,7 +45,7 @@ public class GoalRunAway implements Goal {
throw new IllegalArgumentException();
}
this.from = from;
this.distanceSq = distance * distance;
this.distanceSq = (int) (distance * distance);
this.maintainY = maintainY;
}
@@ -56,7 +57,7 @@ public class GoalRunAway implements Goal {
for (BlockPos p : from) {
int diffX = x - p.getX();
int diffZ = z - p.getZ();
double distSq = diffX * diffX + diffZ * diffZ;
int distSq = diffX * diffX + diffZ * diffZ;
if (distSq < distanceSq) {
return false;
}
@@ -65,7 +66,7 @@ public class GoalRunAway implements Goal {
}
@Override
public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock
public double heuristic(int x, int y, int z) {// mostly copied from GoalBlock
double min = Double.MAX_VALUE;
for (BlockPos p : from) {
double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z);
@@ -80,6 +81,48 @@ public class GoalRunAway implements Goal {
return min;
}
@Override
public double heuristic() {// TODO less hacky solution
int distance = (int) Math.ceil(Math.sqrt(distanceSq));
int minX = Integer.MAX_VALUE;
int minY = Integer.MAX_VALUE;
int minZ = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int maxY = Integer.MIN_VALUE;
int maxZ = Integer.MIN_VALUE;
for (BlockPos p : from) {
minX = Math.min(minX, p.getX() - distance);
minY = Math.min(minY, p.getY() - distance);
minZ = Math.min(minZ, p.getZ() - distance);
maxX = Math.max(minX, p.getX() + distance);
maxY = Math.max(minY, p.getY() + distance);
maxZ = Math.max(minZ, p.getZ() + distance);
}
DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978
double minOutside = Double.POSITIVE_INFINITY;
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
double h = heuristic(x, y, z);
if (h < minOutside && isInGoal(x, y, z)) {
maybeAlwaysInside.add(h);
} else {
minOutside = Math.min(minOutside, h);
}
}
}
}
double maxInside = Double.NEGATIVE_INFINITY;
DoubleIterator it = maybeAlwaysInside.iterator();
while (it.hasNext()) {
double inside = it.nextDouble();
if (inside < minOutside) {
maxInside = Math.max(maxInside, inside);
}
}
return maxInside;
}
@Override
public String toString() {
if (maintainY != null) {

View File

@@ -18,8 +18,8 @@
package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
/**
* Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
@@ -36,8 +36,8 @@ public class GoalStrictDirection implements Goal {
x = origin.getX();
y = origin.getY();
z = origin.getZ();
dx = direction.getXOffset();
dz = direction.getZOffset();
dx = direction.getStepX();
dz = direction.getStepZ();
if (dx == 0 && dz == 0) {
throw new IllegalArgumentException(direction + "");
}
@@ -64,6 +64,11 @@ public class GoalStrictDirection implements Goal {
return heuristic;
}
@Override
public double heuristic() {
return Double.NEGATIVE_INFINITY;
}
@Override
public String toString() {
return String.format(

View File

@@ -19,7 +19,7 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* Useful if the goal is just to mine a block. This goal will be satisfied if the specified

View File

@@ -20,8 +20,8 @@ package baritone.api.pathing.goals;
import baritone.api.BaritoneAPI;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
/**
* Useful for long-range goals that don't have a specific Y level.
@@ -94,11 +94,11 @@ public class GoalXZ implements Goal {
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune
}
public static GoalXZ fromDirection(Vector3d origin, float yaw, double distance) {
public static GoalXZ fromDirection(Vec3 origin, float yaw, double distance) {
float theta = (float) Math.toRadians(yaw);
double x = origin.x - MathHelper.sin(theta) * distance;
double z = origin.z + MathHelper.cos(theta) * distance;
return new GoalXZ(MathHelper.floor(x), MathHelper.floor(z));
double x = origin.x - Mth.sin(theta) * distance;
double z = origin.z + Mth.cos(theta) * distance;
return new GoalXZ(Mth.floor(x), Mth.floor(z));
}
public int getX() {

View File

@@ -18,7 +18,7 @@
package baritone.api.pathing.movement;
import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* @author Brady

View File

@@ -75,7 +75,7 @@ public interface IBaritoneProcess {
* to start eating this tick. {@code PauseForAutoEatProcess} should only actually right click once onTick is called with
* {@code isSafeToCancel} true though.
*
* @return Whethor or not if this control is temporary
* @return Whether or not if this control is temporary
*/
boolean isTemporary();

View File

@@ -18,11 +18,10 @@
package baritone.api.process;
import baritone.api.schematic.ISchematic;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.BlockState;
import java.io.File;
import java.util.List;
@@ -39,7 +38,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
* @param schematic The object representation of the schematic
* @param origin The origin position of the schematic being built
*/
void build(String name, ISchematic schematic, Vector3i origin);
void build(String name, ISchematic schematic, Vec3i origin);
/**
* Requests a build for the specified schematic, labeled as specified, with the specified origin.
@@ -49,10 +48,10 @@ public interface IBuilderProcess extends IBaritoneProcess {
* @param origin The origin position of the schematic being built
* @return Whether or not the schematic was able to load from file
*/
boolean build(String name, File schematic, Vector3i origin);
boolean build(String name, File schematic, Vec3i origin);
default boolean build(String schematicFile, BlockPos origin) {
File file = new File(new File(Minecraft.getInstance().gameDir, "schematics"), schematicFile);
File file = new File(new File(Minecraft.getInstance().gameDirectory, "schematics"), schematicFile);
return build(schematicFile, file, origin);
}

View File

@@ -17,7 +17,29 @@
package baritone.api.process;
import net.minecraft.core.BlockPos;
public interface IFarmProcess extends IBaritoneProcess {
void farm();
/**
* Begin to search for crops to farm with in specified aria
* from specified location.
*
* @param range The distance from center to farm from
* @param pos The center position to base the range from
*/
void farm(int range, BlockPos pos);
/**
* Begin to search for nearby crops to farm.
*/
default void farm() {farm(0, null);}
/**
* Begin to search for crops to farm with in specified aria
* from the position the command was executed.
*
* @param range The distance to search for crops to farm
*/
default void farm(int range) {farm(range, null);}
}

View File

@@ -17,10 +17,9 @@
package baritone.api.process;
import net.minecraft.entity.Entity;
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.world.entity.Entity;
/**
* @author Brady

View File

@@ -18,7 +18,7 @@
package baritone.api.process;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
/**
* but it rescans the world every once in a while so it doesn't get fooled by its cache

View File

@@ -19,9 +19,8 @@ package baritone.api.process;
import baritone.api.utils.BlockOptionalMeta;
import baritone.api.utils.BlockOptionalMetaLookup;
import net.minecraft.block.Block;
import java.util.stream.Stream;
import net.minecraft.world.level.block.Block;
/**
* @author Brady

View File

@@ -17,10 +17,9 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.level.block.state.BlockState;
public class CompositeSchematic extends AbstractSchematic {
@@ -71,4 +70,11 @@ public class CompositeSchematic extends AbstractSchematic {
}
return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
}
@Override
public void reset() {
for (CompositeSchematicEntry entry : schematicArr) {
entry.schematic.reset();
}
}
}

View File

@@ -18,10 +18,9 @@
package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import java.util.List;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
public class FillSchematic extends AbstractSchematic {
@@ -44,8 +43,6 @@ public class FillSchematic extends AbstractSchematic {
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
if (bom.matches(current)) {
return current;
} else if (current.getBlock() != Blocks.AIR) {
return Blocks.AIR.getDefaultState();
}
for (BlockState placeable : approxPlaceable) {
if (bom.matches(placeable)) {

View File

@@ -17,10 +17,9 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import java.util.List;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
/**
* Basic representation of a schematic. Provides the dimensions and the desired state for a given position relative to
@@ -73,6 +72,11 @@ public interface ISchematic {
*/
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
*/

View File

@@ -17,15 +17,14 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
/**
* A static schematic is capable of providing the desired state at a given position without
* additional context. Schematics of this type are expected to have non-varying contents.
*
* @see #getDirect(int, int, int)
*
* @author Brady
* @see #getDirect(int, int, int)
* @since 12/24/2019
*/
public interface IStaticSchematic extends ISchematic {

View File

@@ -17,9 +17,8 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import java.util.List;
import net.minecraft.world.level.block.state.BlockState;
public abstract class MaskSchematic extends AbstractSchematic {

View File

@@ -18,7 +18,7 @@
package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMetaLookup;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
public class ReplaceSchematic extends MaskSchematic {
@@ -31,6 +31,18 @@ public class ReplaceSchematic extends MaskSchematic {
this.cache = new Boolean[widthX()][heightY()][lengthZ()];
}
@Override
public void reset() {
// it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()]
for (int x = 0; x < cache.length; x++) {
for (int y = 0; y < cache[0].length; y++) {
for (int z = 0; z < cache[0][0].length; z++) {
cache[x][y][z] = null;
}
}
}
}
@Override
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
if (cache[x][y][z] == null) {

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
public class ShellSchematic extends MaskSchematic {

View File

@@ -0,0 +1,90 @@
/*
* 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.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
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<BlockState, Map<Block, BlockState>> 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, BlockState currentState) {
return schematic.inSchematic(x, y, z, currentState);
}
@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
BlockState 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 AirBlock)) {// 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 AirBlock) {
return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.defaultBlockState(); // can always "place" air
}
for (BlockState placeable : approxPlaceable) {
if (substitute.equals(placeable.getBlock())) {
return withBlock(desired, placeable.getBlock());
}
}
}
return substitutes.get(0).defaultBlockState();
}
private BlockState withBlock(BlockState state, Block block) {
if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) {
return blockStateCache.get(state).get(block);
}
Collection<Property<?>> properties = state.getProperties();
BlockState newState = block.defaultBlockState();
for (Property<?> 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,BlockState>()).put(block, newState);
return newState;
}
private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
return toState.setValue(prop, fromState.getValue(prop));
}
}

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
public class WallsSchematic extends MaskSchematic {

View File

@@ -18,9 +18,9 @@
package baritone.api.selection;
import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.world.phys.AABB;
/**
* A selection is an immutable object representing the current selection. The selection is commonly used for certain
@@ -51,12 +51,12 @@ public interface ISelection {
/**
* @return The size of this ISelection.
*/
Vector3i size();
Vec3i size();
/**
* @return An {@link AxisAlignedBB} encompassing all blocks in this selection.
* @return An {@link AABB} encompassing all blocks in this selection.
*/
AxisAlignedBB aabb();
AABB aabb();
/**
* Returns a new {@link ISelection} expanded in the specified direction by the specified number of blocks.

View File

@@ -18,7 +18,7 @@
package baritone.api.selection;
import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.Direction;
import net.minecraft.core.Direction;
/**
* The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving

View File

@@ -17,12 +17,11 @@
package baritone.api.utils;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3i;
import javax.annotation.Nonnull;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
/**
* A better BlockPos that has fewer hash collisions (and slightly more performant offsets)
@@ -49,7 +48,7 @@ public final class BetterBlockPos extends BlockPos {
}
public BetterBlockPos(double x, double y, double z) {
this(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
this(Mth.floor(x), Mth.floor(y), Mth.floor(z));
}
public BetterBlockPos(BlockPos pos) {
@@ -116,7 +115,7 @@ public final class BetterBlockPos extends BlockPos {
}
@Override
public BetterBlockPos up() {
public BetterBlockPos above() {
// this is unimaginably faster than blockpos.up
// that literally calls
// this.up(1)
@@ -130,35 +129,35 @@ public final class BetterBlockPos extends BlockPos {
}
@Override
public BetterBlockPos up(int amt) {
public BetterBlockPos above(int amt) {
// see comment in up()
return amt == 0 ? this : new BetterBlockPos(x, y + amt, z);
}
@Override
public BetterBlockPos down() {
public BetterBlockPos below() {
// see comment in up()
return new BetterBlockPos(x, y - 1, z);
}
@Override
public BetterBlockPos down(int amt) {
public BetterBlockPos below(int amt) {
// see comment in up()
return amt == 0 ? this : new BetterBlockPos(x, y - amt, z);
}
@Override
public BetterBlockPos offset(Direction dir) {
Vector3i vec = dir.getDirectionVec();
public BetterBlockPos relative(Direction dir) {
Vec3i vec = dir.getNormal();
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
}
@Override
public BetterBlockPos offset(Direction dir, int dist) {
public BetterBlockPos relative(Direction dir, int dist) {
if (dist == 0) {
return this;
}
Vector3i vec = dir.getDirectionVec();
Vec3i vec = dir.getNormal();
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
}

View File

@@ -20,17 +20,27 @@ package baritone.api.utils;
import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableSet;
import io.netty.util.concurrent.ThreadPerTaskExecutor;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.*;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@@ -45,8 +55,8 @@ public final class BlockOptionalMeta {
private final ImmutableSet<Integer> stateHashes;
private final ImmutableSet<Integer> stackHashes;
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
private static LootTableManager manager;
private static LootPredicateManager predicate = new LootPredicateManager();
private static LootTables manager;
private static PredicateManager predicate = new PredicateManager();
private static Map<Block, List<Item>> drops = new HashMap<>();
public BlockOptionalMeta(@Nonnull Block block) {
@@ -72,7 +82,7 @@ public final class BlockOptionalMeta {
}
private static Set<BlockState> getStates(@Nonnull Block block) {
return new HashSet<>(block.getStateContainer().getValidStates());
return new HashSet<>(block.getStateDefinition().getPossibleStates());
}
private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
@@ -113,7 +123,7 @@ public final class BlockOptionalMeta {
//noinspection ConstantConditions
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
hash -= stack.getDamage();
hash -= stack.getDamageValue();
return stackHashes.contains(hash);
}
@@ -131,16 +141,16 @@ public final class BlockOptionalMeta {
return null;
}
public static LootTableManager getManager() {
public static LootTables getManager() {
if (manager == null) {
ResourcePackList rpl = new ResourcePackList(ResourcePackInfo::new, new ServerPackFinder());
rpl.reloadPacksFromFinders();
IResourcePack thePack = rpl.getAllPacks().iterator().next().getResourcePack();
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
manager = new LootTableManager(predicate);
resourceManager.addReloadListener(manager);
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
rpl.reload();
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
manager = new LootTables(predicate);
resourceManager.registerReloadListener(manager);
try {
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get();
} catch (Exception exception) {
throw new RuntimeException(exception);
}
@@ -148,28 +158,28 @@ public final class BlockOptionalMeta {
return manager;
}
public static LootPredicateManager getPredicateManager() {
public static PredicateManager getPredicateManager() {
return predicate;
}
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
ResourceLocation lootTableLocation = block.getLootTable();
if (lootTableLocation == LootTables.EMPTY) {
if (lootTableLocation == BuiltInLootTables.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.field_237457_g_, Vector3d.copy(BlockPos.NULL_VECTOR))
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
.withParameter(LootParameters.BLOCK_STATE, block.getDefaultState())
.build(LootParameterSets.BLOCK),
stack -> items.add(stack.getItem())
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder((ServerLevel) null)
.withRandom(new Random())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK),
stack -> items.add(stack.getItem())
);
return items;
}

View File

@@ -17,13 +17,12 @@
package baritone.api.utils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class BlockOptionalMetaLookup {

View File

@@ -17,12 +17,11 @@
package baritone.api.utils;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
public class BlockUtils {
@@ -57,7 +56,7 @@ public class BlockUtils {
if (resourceCache.containsKey(name)) {
return null; // cached as null
}
block = Registry.BLOCK.func_241873_b(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
block = Registry.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block);
resourceCache = copy;

View File

@@ -18,12 +18,12 @@
package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import java.util.Arrays;
import java.util.Calendar;
import java.util.stream.Stream;
@@ -47,23 +47,94 @@ public interface Helper {
*/
Minecraft mc = Minecraft.getInstance();
static ITextComponent getPrefix() {
static Component getPrefix() {
// Inner text component
final Calendar now = Calendar.getInstance();
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
TextComponent baritone = new StringTextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.setStyle(baritone.getStyle().setFormatting(TextFormatting.LIGHT_PURPLE));
BaseComponent baritone = new TextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
// Outer brackets
TextComponent prefix = new StringTextComponent("");
prefix.setStyle(baritone.getStyle().setFormatting(TextFormatting.DARK_PURPLE));
prefix.appendString("[");
BaseComponent prefix = new TextComponent("");
prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
prefix.append("[");
prefix.append(baritone);
prefix.appendString("]");
prefix.append("]");
return prefix;
}
/**
* Send a message to display as a toast popup
*
* @param title The title to display in the popup
* @param message The message to display in the popup
*/
default void logToast(Component title, Component message) {
mc.execute(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message));
}
/**
* Send a message to display as a toast popup
*
* @param title The title to display in the popup
* @param message The message to display in the popup
*/
default void logToast(String title, String message) {
logToast(new TextComponent(title), new TextComponent(message));
}
/**
* Send a message to display as a toast popup
*
* @param message The message to display in the popup
*/
default void logToast(String message) {
logToast(Helper.getPrefix(), new TextComponent(message));
}
/**
* Send a message as a desktop notification
*
* @param message The message to display in the notification
*/
default void logNotification(String message) {
logNotification(message, false);
}
/**
* Send a message as a desktop notification
*
* @param message The message to display in the notification
* @param error Whether to log as an error
*/
default void logNotification(String message, boolean error) {
if (BaritoneAPI.getSettings().desktopNotifications.value) {
logNotificationDirect(message, error);
}
}
/**
* Send a message as a desktop notification regardless of desktopNotifications
* (should only be used for critically important messages)
*
* @param message The message to display in the notification
*/
default void logNotificationDirect(String message) {
logNotificationDirect(message, false);
}
/**
* Send a message as a desktop notification regardless of desktopNotifications
* (should only be used for critically important messages)
*
* @param message The message to display in the notification
* @param error Whether to log as an error
*/
default void logNotificationDirect(String message, boolean error) {
mc.execute(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error));
}
/**
* Send a message to chat only if chatDebug is on
*
@@ -75,7 +146,27 @@ public interface Helper {
//System.out.println(message);
return;
}
logDirect(message);
// We won't log debug chat into toasts
// Because only a madman would want that extreme spam -_-
logDirect(message, false);
}
/**
* Send components to chat with the [Baritone] prefix
*
* @param logAsToast Whether to log as a toast notification
* @param components The components to send
*/
default void logDirect(boolean logAsToast, Component... components) {
BaseComponent component = new TextComponent("");
component.append(getPrefix());
component.append(new TextComponent(" "));
Arrays.asList(components).forEach(component::append);
if (logAsToast) {
logToast(getPrefix(), component);
} else {
mc.execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
}
}
/**
@@ -83,12 +174,24 @@ public interface Helper {
*
* @param components The components to send
*/
default void logDirect(ITextComponent... components) {
TextComponent component = new StringTextComponent("");
component.append(getPrefix());
component.append(new StringTextComponent(" "));
Arrays.asList(components).forEach(component::append);
mc.execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
default void logDirect(Component... components) {
logDirect(BaritoneAPI.getSettings().logAsToast.value, components);
}
/**
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a
* direct response to a chat command)
*
* @param message The message to display in chat
* @param color The color to print that message in
* @param logAsToast Whether to log as a toast notification
*/
default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
Stream.of(message.split("\n")).forEach(line -> {
BaseComponent component = new TextComponent(line.replace("\t", " "));
component.setStyle(component.getStyle().withColor(color));
logDirect(logAsToast, component);
});
}
/**
@@ -98,12 +201,19 @@ public interface Helper {
* @param message The message to display in chat
* @param color The color to print that message in
*/
default void logDirect(String message, TextFormatting color) {
Stream.of(message.split("\n")).forEach(line -> {
TextComponent component = new StringTextComponent(line.replace("\t", " "));
component.setStyle(component.getStyle().setFormatting(color));
logDirect(component);
});
default void logDirect(String message, ChatFormatting color) {
logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value);
}
/**
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a
* direct response to a chat command)
*
* @param message The message to display in chat
* @param logAsToast Whether to log as a toast notification
*/
default void logDirect(String message, boolean logAsToast) {
logDirect(message, ChatFormatting.GRAY, logAsToast);
}
/**
@@ -113,6 +223,6 @@ public interface Helper {
* @param message The message to display in chat
*/
default void logDirect(String message) {
logDirect(message, TextFormatting.GRAY);
logDirect(message, BaritoneAPI.getSettings().logAsToast.value);
}
}

View File

@@ -18,17 +18,18 @@
package baritone.api.utils;
import baritone.api.cache.IWorldData;
import net.minecraft.block.SlabBlock;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.*;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
/**
* @author Brady
@@ -36,14 +37,14 @@ import java.util.stream.StreamSupport;
*/
public interface IPlayerContext {
ClientPlayerEntity player();
LocalPlayer player();
IPlayerController playerController();
World world();
Level world();
default Iterable<Entity> entities() {
return ((ClientWorld) world()).getAllEntities();
return ((ClientLevel) world()).entitiesForRendering();
}
default Stream<Entity> entitiesStream() {
@@ -53,11 +54,11 @@ public interface IPlayerContext {
IWorldData worldData();
RayTraceResult objectMouseOver();
HitResult objectMouseOver();
default BetterBlockPos playerFeet() {
// TODO find a better way to deal with soul sand!!!!!
BetterBlockPos feet = new BetterBlockPos(player().getPositionVec().x, player().getPositionVec().y + 0.1251, player().getPositionVec().z);
BetterBlockPos feet = new BetterBlockPos(player().position().x, player().position().y + 0.1251, player().position().z);
// sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException
// that causes the game to immediately crash
@@ -69,23 +70,23 @@ public interface IPlayerContext {
// if there is an exception, the only overhead is Java generating the exception object... so we can ignore it
try {
if (world().getBlockState(feet).getBlock() instanceof SlabBlock) {
return feet.up();
return feet.above();
}
} catch (NullPointerException ignored) {}
return feet;
}
default Vector3d playerFeetAsVec() {
return new Vector3d(player().getPositionVec().x, player().getPositionVec().y, player().getPositionVec().z);
default Vec3 playerFeetAsVec() {
return new Vec3(player().position().x, player().position().y, player().position().z);
}
default Vector3d playerHead() {
return new Vector3d(player().getPositionVec().x, player().getPositionVec().y + player().getEyeHeight(), player().getPositionVec().z);
default Vec3 playerHead() {
return new Vec3(player().position().x, player().position().y + player().getEyeHeight(), player().position().z);
}
default Rotation playerRotations() {
return new Rotation(player().rotationYaw, player().rotationPitch);
return new Rotation(player().getYRot(), player().getXRot());
}
static double eyeHeight(boolean ifSneaking) {
@@ -98,9 +99,9 @@ public interface IPlayerContext {
* @return The position of the highlighted block
*/
default Optional<BlockPos> getSelectedBlock() {
RayTraceResult result = objectMouseOver();
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
return Optional.of(((BlockRayTraceResult) result).getPos());
HitResult result = objectMouseOver();
if (result != null && result.getType() == HitResult.Type.BLOCK) {
return Optional.of(((BlockHitResult) result).getBlockPos());
}
return Optional.empty();
}
@@ -108,17 +109,4 @@ public interface IPlayerContext {
default boolean isLookingAt(BlockPos pos) {
return getSelectedBlock().equals(Optional.of(pos));
}
/**
* Returns the entity that the crosshair is currently placed over. Updated once per tick.
*
* @return The entity
*/
default Optional<Entity> getSelectedEntity() {
RayTraceResult result = objectMouseOver();
if (result != null && result.getType() == RayTraceResult.Type.ENTITY) {
return Optional.of(((EntityRayTraceResult) result).getEntity());
}
return Optional.empty();
}
}

View File

@@ -17,18 +17,17 @@
package baritone.api.utils;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import baritone.api.BaritoneAPI;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
/**
* @author Brady
@@ -44,13 +43,13 @@ public interface IPlayerController {
void resetBlockRemoving();
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player);
void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player);
GameType getGameType();
ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, Hand hand, BlockRayTraceResult result);
InteractionResult processRightClickBlock(LocalPlayer player, Level world, InteractionHand hand, BlockHitResult result);
ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand);
InteractionResult processRightClick(LocalPlayer player, Level world, InteractionHand hand);
boolean clickBlock(BlockPos loc, Direction face);

View File

@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils;
package baritone.api.utils;
import org.apache.commons.lang3.SystemUtils;

View File

@@ -17,10 +17,10 @@
package baritone.api.utils;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
/**
* @author Brady
@@ -40,27 +40,27 @@ public final class RayTraceUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The calculated raytrace result
*/
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
public static HitResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
return rayTraceTowards(entity, rotation, blockReachDistance, false);
}
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) {
Vector3d start;
public static HitResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) {
Vec3 start;
if (wouldSneak) {
start = inferSneakingEyePosition(entity);
} else {
start = entity.getEyePosition(1.0F); // do whatever is correct
}
Vector3d direction = RotationUtils.calcVector3dFromRotation(rotation);
Vector3d end = start.add(
Vec3 direction = RotationUtils.calcVector3dFromRotation(rotation);
Vec3 end = start.add(
direction.x * blockReachDistance,
direction.y * blockReachDistance,
direction.z * blockReachDistance
);
return entity.world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
return entity.level.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
}
public static Vector3d inferSneakingEyePosition(Entity entity) {
return new Vector3d(entity.getPosX(), entity.getPosY() + IPlayerContext.eyeHeight(true), entity.getPosZ());
public static Vec3 inferSneakingEyePosition(Entity entity) {
return new Vec3(entity.getX(), entity.getY() + IPlayerContext.eyeHeight(true), entity.getZ());
}
}

View File

@@ -19,17 +19,19 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import net.minecraft.block.BlockState;
import net.minecraft.block.FireBlock;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.*;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d;
import java.util.Optional;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
/**
* @author Brady
@@ -50,13 +52,13 @@ public final class RotationUtils {
/**
* Offsets from the root block position to the center of each side.
*/
private static final Vector3d[] BLOCK_SIDE_MULTIPLIERS = new Vector3d[]{
new Vector3d(0.5, 0, 0.5), // Down
new Vector3d(0.5, 1, 0.5), // Up
new Vector3d(0.5, 0.5, 0), // North
new Vector3d(0.5, 0.5, 1), // South
new Vector3d(0, 0.5, 0.5), // West
new Vector3d(1, 0.5, 0.5) // East
private static final Vec3[] BLOCK_SIDE_MULTIPLIERS = new Vec3[]{
new Vec3(0.5, 0, 0.5), // Down
new Vec3(0.5, 1, 0.5), // Up
new Vec3(0.5, 0.5, 0), // North
new Vec3(0.5, 0.5, 1), // South
new Vec3(0, 0.5, 0.5), // West
new Vec3(1, 0.5, 0.5) // East
};
private RotationUtils() {}
@@ -69,7 +71,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination
*/
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
return calcRotationFromVec3d(new Vector3d(orig.getX(), orig.getY(), orig.getZ()), new Vector3d(dest.getX(), dest.getY(), dest.getZ()));
return calcRotationFromVec3d(new Vec3(orig.getX(), orig.getY(), orig.getZ()), new Vec3(dest.getX(), dest.getY(), dest.getZ()));
}
/**
@@ -98,7 +100,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination
* @see #wrapAnglesToRelative(Rotation, Rotation)
*/
public static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest, Rotation current) {
public static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest, Rotation current) {
return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest));
}
@@ -109,11 +111,11 @@ public final class RotationUtils {
* @param dest The destination position
* @return The rotation from the origin to the destination
*/
private static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest) {
private static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest) {
double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z};
double yaw = MathHelper.atan2(delta[0], -delta[2]);
double yaw = Mth.atan2(delta[0], -delta[2]);
double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
double pitch = MathHelper.atan2(delta[1], dist);
double pitch = Mth.atan2(delta[1], dist);
return new Rotation(
(float) (yaw * RAD_TO_DEG),
(float) (pitch * RAD_TO_DEG)
@@ -126,19 +128,19 @@ public final class RotationUtils {
* @param rotation The input rotation
* @return Look vector for the rotation
*/
public static Vector3d calcVector3dFromRotation(Rotation rotation) {
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vector3d((double) (f1 * f2), (double) f3, (double) (f * f2));
public static Vec3 calcVector3dFromRotation(Rotation rotation) {
float f = Mth.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f1 = Mth.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f2 = -Mth.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float f3 = Mth.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vec3((double) (f1 * f2), (double) f3, (double) (f * f2));
}
/**
* @param ctx Context for the viewing entity
* @param pos The target block position
* @return The optional rotation
* @see #reachable(ClientPlayerEntity, BlockPos, double)
* @see #reachable(LocalPlayer, BlockPos, double)
*/
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
@@ -160,11 +162,11 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance) {
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false);
}
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
if (baritone.getPlayerContext().isLookingAt(pos)) {
/*
@@ -177,11 +179,11 @@ 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
*/
Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F);
Rotation hypothetical = new Rotation(entity.getYRot(), entity.getXRot() + 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)) {
HitResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
if (result != null && result.getType() == HitResult.Type.BLOCK && ((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
}
} else {
@@ -194,16 +196,16 @@ public final class RotationUtils {
return possibleRotation;
}
BlockState state = entity.world.getBlockState(pos);
VoxelShape shape = state.getShape(entity.world, pos);
BlockState state = entity.level.getBlockState(pos);
VoxelShape shape = state.getShape(entity.level, pos);
if (shape.isEmpty()) {
shape = VoxelShapes.fullCube();
shape = Shapes.block();
}
for (Vector3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
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 Vector3d(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
for (Vec3 sideOffset : BLOCK_SIDE_MULTIPLIERS) {
double xDiff = shape.min(Direction.Axis.X) * sideOffset.x + shape.max(Direction.Axis.X) * (1 - sideOffset.x);
double yDiff = shape.min(Direction.Axis.Y) * sideOffset.y + shape.max(Direction.Axis.Y) * (1 - sideOffset.y);
double zDiff = shape.min(Direction.Axis.Z) * sideOffset.z + shape.max(Direction.Axis.Z) * (1 - sideOffset.z);
possibleRotation = reachableOffset(entity, pos, new Vec3(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
if (possibleRotation.isPresent()) {
return possibleRotation;
}
@@ -222,16 +224,16 @@ 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, Vector3d offsetPos, double blockReachDistance, boolean wouldSneak) {
Vector3d 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);
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.getYRot(), entity.getXRot()));
HitResult 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)) {
if (result != null && result.getType() == HitResult.Type.BLOCK) {
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.world.getBlockState(pos).getBlock() instanceof FireBlock && ((BlockRayTraceResult) result).getPos().equals(pos.down())) {
if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation);
}
}
@@ -248,6 +250,6 @@ public final class RotationUtils {
* @return The optional rotation
*/
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
}
}

View File

@@ -19,14 +19,13 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -38,6 +37,7 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -49,8 +49,9 @@ import java.util.stream.Stream;
public class SettingsUtil {
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDir.toPath().resolve("baritone").resolve("settings.txt");
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDirectory.toPath().resolve("baritone").resolve("settings.txt");
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space
private static final String[] JAVA_ONLY_SETTINGS = {"logger", "notifier", "toaster"};
private static boolean isComment(String line) {
@@ -113,7 +114,7 @@ public class SettingsUtil {
System.out.println("NULL SETTING?" + setting.getName());
continue;
}
if (setting.getName().equals("logger")) {
if (javaOnlySetting(setting)) {
continue; // NO
}
if (setting.value == setting.defaultValue) {
@@ -167,13 +168,28 @@ public class SettingsUtil {
}
public static String settingToString(Settings.Setting setting) throws IllegalStateException {
if (setting.getName().equals("logger")) {
return "logger";
if (javaOnlySetting(setting)) {
return setting.getName();
}
return setting.getName() + " " + settingValueToString(setting);
}
/**
* This should always be the same as whether the setting can be parsed from or serialized to a string
*
* @param the setting
* @return true if the setting can not be set or read by the user
*/
public static boolean javaOnlySetting(Settings.Setting setting) {
for (String name : JAVA_ONLY_SETTINGS) { // no JAVA_ONLY_SETTINGS.contains(...) because that would be case sensitive
if (setting.getName().equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
Settings.Setting setting = settings.byLowerName.get(settingName);
if (setting == null) {
@@ -225,8 +241,8 @@ public class SettingsUtil {
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
),
VEC3I(
Vector3i.class,
str -> new Vector3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
Vec3i.class,
str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ()
),
BLOCK(
@@ -236,7 +252,7 @@ public class SettingsUtil {
),
ITEM(
Item.class,
str -> Registry.ITEM.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
str -> Registry.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> Registry.ITEM.getKey(item).toString()
),
LIST() {
@@ -263,6 +279,36 @@ public class SettingsUtil {
public boolean accepts(Type type) {
return List.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
}
},
MAPPING() {
@Override
public Object parse(ParserContext context, String raw) {
Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType);
return Stream.of(raw.split(",(?=[^,]*->)"))
.map(s -> s.split("->"))
.collect(Collectors.toMap(s -> keyParser.parse(context, s[0]), s -> valueParser.parse(context, s[1])));
}
@Override
public String toString(ParserContext context, Object value) {
Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType);
return ((Map<?,?>) value).entrySet().stream()
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
.collect(Collectors.joining(","));
}
@Override
public boolean accepts(Type type) {
return Map.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
}
};
private final Class<?> cla$$;

Some files were not shown because too many files have changed in this diff Show More