Compare commits

...

632 Commits
v1.9.2 ... 1.21

Author SHA1 Message Date
leijurv
ec57888ce1 Merge pull request #4451 from ZacSharp/1.21-update
Merge 1.20.5 into 1.21
2024-08-22 10:58:20 -07:00
ZacSharp
8867fb7010 Merge branch '1.20.5' into 1.21 2024-08-02 00:45:15 +02:00
leijurv
acdcbf5146 Merge pull request #4439 from ZacSharp/1.20.5-update
Merge 1.19.4 into 1.20.5
2024-07-28 00:39:51 -07:00
ZacSharp
6b2fd5acee Merge branch '1.19.4' into 1.20.5 2024-07-21 13:02:03 +02:00
leijurv
8786148fef Merge pull request #4394 from rfresh2/1.21
1.21
2024-07-20 11:52:24 -07:00
leijurv
edb433ea6e Merge pull request #4432 from ZacSharp/pr/1.19.4/build/fixClassloaderExclusion
Move `BaritoneTweaker` to its own package
2024-07-20 11:50:23 -07:00
leijurv
a02704e097 Merge pull request #4430 from ZacSharp/pr/1.19.4/farm/addBamboo
Add bamboo to `FarmProcess` targets
2024-07-20 11:50:12 -07:00
rfresh2
e66fdea500 update supported litematic version 2024-07-19 13:37:16 -07:00
ZacSharp
1947459acf Move tweak class to its own package
Launchwrapper automatically adds a classloader exclusion for every package containing a tweak class, forcing the whole package to load through the parent class loader.
2024-07-14 13:47:52 +02:00
ZacSharp
52aa609ac7 Add bamboo to FarmProcess targets 2024-07-14 10:37:31 +02:00
rfresh2
74f46cd6eb 1.21 2024-06-20 01:03:15 -07:00
leijurv
1704d56274 Merge pull request #4396 from wagyourtail/1.20/1.20.5-(neo)forge
fix neoforge and forge for 1.20.5+
2024-06-19 18:20:49 -07:00
leijurv
92bc067633 Merge pull request #4395 from wagyourtail/1.19/proguard-cleanup
clean up proguard task
2024-06-19 18:20:08 -07:00
leijurv
64639b377f Merge pull request #4385 from ZacSharp/pr/1.19.4/farm/unhardcodeScanLimit
Unhardcode farm scan limit
2024-06-19 18:18:29 -07:00
Wagyourtail
81f7375591 fix mixin eating my try-catch 2024-06-17 00:26:34 -05:00
Wagyourtail
74d82f2339 fix neoforge and forge for 1.20.5+ 2024-06-17 00:11:11 -05:00
Wagyourtail
42c62a0559 clean up proguard task 2024-06-16 23:46:27 -05:00
ZacSharp
b25a6305ce Don't bother testing reachability for far away blocks
This is a massive performance improvement for big farms.
2024-06-09 18:14:41 +02:00
ZacSharp
98e90e72f7 Make farm scan limit configurable 2024-06-09 18:14:41 +02:00
ZacSharp
10851ddf14 Only create scan list when needed 2024-06-09 18:14:40 +02:00
ZacSharp
402079d7db Fail if there is no target position 2024-06-09 18:14:35 +02:00
leijurv
b184141db2 Merge pull request #4374 from ZacSharp/pr/1.19.4/guiclick/removeLogspam
Remove logspam from `GuiClick`
2024-06-07 00:45:33 -07:00
leijurv
42c6abbf72 Merge pull request #4347 from wagyourtail/1.20/1.20.5
1.20.5/6
2024-06-07 00:45:20 -07:00
William Gray
8bb19797e1 Update neoforge/src/main/resources/META-INF/neoforge.mods.toml
Co-authored-by: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
2024-05-27 05:13:47 -06:00
ZacSharp
f9a8aa0c2b Remove logspam 2024-05-26 03:19:35 +02:00
Wagyourtail
6b274b3f1e just work already 2024-05-07 13:25:34 -05:00
Wagyourtail
f02c3115d1 update proguard 2024-05-07 13:19:12 -05:00
Wagyourtail
ee9ca6dd49 fix gradle version not supporting 21 2024-05-07 13:10:54 -05:00
Wagyourtail
8a5e3f7009 fix unfixable conflicts 2024-05-07 13:07:02 -05:00
Wagyourtail
b29878d0f2 fix neoforge version 2024-05-07 13:04:28 -05:00
Wagyourtail
19c8194eae re-enable lexforge 2024-05-07 13:02:58 -05:00
Wagyourtail
d8381c71fd rebuild loot tables 2024-05-07 13:00:32 -05:00
Wagyourtail
4b76fa995c java 21 2024-04-28 09:59:04 -05:00
Wagyourtail
088056b3d0 port to 1.20.5 2024-04-28 08:32:18 -05:00
leijurv
0c09441154 Merge pull request #4324 from ZacSharp/pr/1.19.4/setting/fixRecursiveParserType
Fix recursive setting parsers
2024-04-24 12:50:21 -07:00
leijurv
69d3bc0c2e Merge pull request #4320 from rfresh2/instabreak-fix
don't apply block break delay to insta-breaks
2024-04-24 12:50:06 -07:00
leijurv
1018db797e Merge pull request #4315 from ZacSharp/1.20.4-update
Merge 1.19.4 into 1.20.4
2024-04-24 12:49:27 -07:00
leijurv
b31e0a87cb Merge pull request #4333 from ZacSharp/pr/1.19.4/misc/toolset/fixHardnessCrash
Fix NPE in break time calculation
2024-04-24 12:49:15 -07:00
ZacSharp
4572b75db7 Fix NPE in break time calculation 2024-04-10 14:03:48 +02:00
rfresh2
15fdbb2312 revert API renaming 2024-04-07 20:30:16 -07:00
ZacSharp
848b7c6de0 Fix recursive parsers
Does not affect existing parsers since all nested parameterized setting types
are `Map<String, List<String>>` so there is no difference between the first
parameter of the inner type and the first parameter of the outer type
2024-04-02 21:32:01 +02:00
rfresh2
2b96a2e463 don't apply block break delay to insta-breaks 2024-04-01 15:21:24 -07:00
ZacSharp
354b26b1da Merge branch '1.19.4' into 1.20.4 2024-03-29 03:30:39 +01:00
leijurv
62b2f81ba1 Merge pull request #4314 from ZacSharp/pr/1.19.4/builder/fixBuildSkipBlocksNPE
Fix NPE
2024-03-28 19:25:58 -07:00
ZacSharp
5826931eea Fix NPE 2024-03-29 03:17:00 +01:00
leijurv
a8119366a1 Merge pull request #4292 from rfresh2/place-delay-patch
align rightClickSpeed setting with actual delay
2024-03-28 16:53:33 -07:00
leijurv
b0575fbe0c Merge pull request #4291 from rfresh2/block-break-delay
Block break delay setting
2024-03-28 16:53:13 -07:00
leijurv
866cf34f50 Merge pull request #4303 from ZacSharp/pr/1.19.4/builder/placeIncorrectBlockPenaltyMultiplier
Add a `placeIncorrectBlockPenaltyMultiplier` setting
2024-03-28 16:52:31 -07:00
leijurv
23908ad14f Merge pull request #4289 from ZacSharp/pr/1.19.4/ci/updateWorkflows
Update workflows
2024-03-28 16:51:43 -07:00
leijurv
6d06713610 Merge pull request #4280 from ZacSharp/1.20.4-update
Merge 1.19.4 into 1.20.4
2024-03-28 16:51:28 -07:00
rfresh2
18d3c4c2bd align rightClickSpeed setting with actual delay 2024-03-10 21:05:30 -07:00
rfresh2
faece77e8c align setting value with actual tick delay between breaks 2024-03-10 16:49:59 -07:00
rfresh2
413c11a23e block break delay setting 2024-03-09 15:26:18 -08:00
ZacSharp
4c9253fa5e Add placeIncorrectBlockPenaltyMultiplier builder setting 2024-03-08 17:49:51 +01:00
ZacSharp
d86a34a527 Fix too low bound and log spam 2024-03-08 17:49:45 +01:00
ZacSharp
92aba1b78e Update workflows 2024-03-06 02:26:58 +01:00
ZacSharp
28ba97c3de Move up and fix access modifiers 2024-02-22 14:16:52 +01:00
ZacSharp
24c23e28ec Reduce recursion limit and fix visibility 2024-02-20 21:35:59 +01:00
ZacSharp
2a2842361b Consistently use helper method
and make a safe cast unnecessary
2024-02-20 21:33:53 +01:00
ZacSharp
632e05c4c2 Make buildSkipBlocks use a wrapper schematic 2024-02-20 21:32:55 +01:00
ZacSharp
980d68536c Merge branch '1.19.4' into 1.20.4 2024-02-20 15:24:50 +01:00
leijurv
4144344acd Merge pull request #4251 from wagyourtail/1.19/fix/feather-crash
Fix feather crashing by catching error
2024-01-23 14:40:28 -08:00
leijurv
e962c39506 Merge pull request #4248 from ZacSharp/pr/1.19.4/mine/unhardcodeMaxOreLocations
Unhardcode `ORE_LOCATIONS_COUNT`
2024-01-23 14:40:02 -08:00
leijurv
48f309ac05 Merge pull request #4247 from ZacSharp/pr/1.19.4/elytra/removeUnsafeCast
Remove unsafe generic cast
2024-01-23 14:39:44 -08:00
leijurv
0688a57a38 Merge pull request #4252 from wagyourtail/1.19/fix/build-fail
fix 1.19 build failing
2024-01-23 11:04:14 -08:00
Wagyourtail
078b3909b3 fix build failing, by making nether pathfinder version consistent 2024-01-23 08:18:58 -07:00
Wagyourtail
d51b23bd1e Fix feather crashing by catching error 2024-01-22 10:39:12 -07:00
ZacSharp
9378f7e8a0 Unhardcode ORE_LOCATIONS_COUNT 2024-01-21 01:32:30 +01:00
ZacSharp
e7e434a95b Remove unsafe generic cast 2024-01-20 23:35:54 +01:00
leijurv
be1203fabb Merge pull request #4244 from wagyourtail/1.19/fix/null-elytra
fix 🪨🧠 preventing null elytra process from working
2024-01-20 08:50:31 -08:00
Wagyourtail
340d2a1d54 fix 🪨🧠 preventing null elytra process from working 2024-01-20 07:53:11 -07:00
leijurv
f84b749ff4 Update README.md 2024-01-06 12:21:52 -08:00
Leijurv
8a0f3018bf v1.10.2 2024-01-06 11:28:46 -08:00
leijurv
3e7eb87a36 Merge pull request #4214 from wagyourtail/1.20/1.20.4
1.20.4
2024-01-06 09:26:22 -10:00
Wagyourtail
c146440cb2 mark 1.20.3 as supported 2023-12-17 03:36:23 -07:00
Wagyourtail
4b6652b4cf 1.20.4 2023-12-07 14:18:39 -07:00
Wagyourtail
21feeb664e fix missing function 2023-11-23 19:31:55 -07:00
Wagyourtail
3dbcf0102a fix forge version 2023-11-23 19:14:10 -07:00
Wagyourtail
c1b555c289 bump parchment 2023-11-23 19:11:39 -07:00
Wagyourtail
dce35e339f Merge remote-tracking branch 'origin/1.19.4' into 1.20.2 2023-11-23 19:06:07 -07:00
leijurv
f147519a5c Merge pull request #4195 from ZacSharp/pr/1.19.4/worldscanner/fixSingleValuePalette
Fix scanning chunks using a SingleValuePalette
2023-11-17 17:50:53 -08:00
ZacSharp
19accb0d90 Fix scanning in chunks using a SingleValuePalette 2023-11-16 23:52:12 +01:00
leijurv
44bcd4251d Merge pull request #4114 from wagyourtail/just-unimined-update
bump unimined
2023-11-14 14:48:14 -08:00
William Gray
5795baab1a Merge branch '1.19.4' into just-unimined-update 2023-11-14 07:12:23 -07:00
leijurv
e183dcba17 Merge pull request #4137 from babbaj/1.19.4
silence elytra chat spam
2023-10-31 11:27:25 -07:00
leijurv
a945cfaa3c Merge pull request #4172 from ZacSharp/1.20.2-update
Merge 1.19.4 into 1.20.2
2023-10-31 11:26:58 -07:00
leijurv
ea964a976c Merge pull request #4168 from ZacSharp/pr/build/1.19.4/improvedVersionDetection
Improve version detection
2023-10-31 11:26:10 -07:00
leijurv
1409c92e69 Merge pull request #4153 from xiaodown/xiaodown/add_git_to_dockerfile_apt
Adds git to the Dockerfile apt install (Windows build functionality)
2023-10-31 11:25:08 -07:00
leijurv
a0914192d0 Merge pull request #4158 from ZacSharp/pr/1.19.4/builder/restoreBuildIgnoreExisting
Restore `buildIgnoreExisting`
2023-10-31 11:23:44 -07:00
leijurv
e19fd1161d Merge pull request #4157 from ZacSharp/pr/1.19.4/worldscanner/handleDuplicatePaletteEntries
Handle duplicate palette entries
2023-10-31 11:23:26 -07:00
ZacSharp
3a3b012199 Merge branch '1.19.4' into 1.20.2 2023-10-29 02:08:57 +01:00
ZacSharp
9accb2bfb0 Don't crash the build if git is not available 2023-10-26 21:19:26 +02:00
ZacSharp
20d62c68bf Slightly better version strings 2023-10-26 21:19:26 +02:00
ZacSharp
0ca81b14bf Restore buildIgnoreExisting 2023-10-18 16:39:26 +02:00
ZacSharp
1dd2a334d6 Handle duplicate palette entries 2023-10-18 12:45:31 +02:00
Xiaodown
3332ec9e1f Adds git to the Dockerfile apt install
I saw in setup.md "(if you have docker on Windows, I'd be grateful if
you could let me know if it works there too)".  So I went to build
it on Windows.

I use Windows Subsystem for Linux, which is (mostly) Ubuntu but not
really (there's no init).  But Docker Desktop has an integration for
WSL2.

For me, gradle wouldn't build the image without forcing git to install
in the container.  I'll attach screenshots to the pull request.  It just
looks like whatever ubuntu:focal my docker system grabbed doesn't have
git installed by default.

Anyway, this fixes it, and shouldn't screw anything even if git is
installed by default.  I tested it on my M1 Mac pro and it still works
fine.
2023-10-11 19:25:51 -07:00
leijurv
30f27d43e7 Merge pull request #4145 from wagyourtail/1.19.4
actually fix mine under 0 height
2023-10-06 01:40:09 -07:00
Wagyourtail
74457db125 actually fix mine under 0 height 2023-10-04 19:24:09 -06:00
leijurv
91588caf7d oh my GOD 2023-09-28 20:42:08 -07:00
leijurv
9bf890a7b6 Merge pull request #4136 from rfresh2/1.20.2
1.20.2
2023-09-27 22:23:00 -07:00
leijurv
e1e620a0d9 Merge pull request #4138 from rfresh2/fix-forge-1-20-1-crash
Fix forge 1.20.1 crash
2023-09-27 22:19:09 -07:00
rfresh2
f5d15927de 1.20.2 2023-09-24 15:44:15 -07:00
rfresh2
7902517663 fix forge mixin crash 2023-09-24 15:44:15 -07:00
rfresh2
4db988dbef fix forge mixin crash 2023-09-24 15:34:59 -07:00
Babbaj
9ad273a46c silence elytra chat spam 2023-09-23 17:03:47 -04:00
leijurv
81932069d9 remove footgun 2023-09-13 21:25:59 -07:00
Wagyourtail
a1ac87f80d bump unimined 2023-08-23 19:47:07 -06:00
Leijurv
97067b9078 Merge branch '1.19.4' into 1.20.1 2023-08-22 13:29:08 -07:00
Leijurv
2cd5c6b0af delete master stuff 2023-08-22 13:28:45 -07:00
Leijurv
920c3aa280 Merge branch 'master' into 1.19.4 2023-08-22 13:28:24 -07:00
Leijurv
f2679bea29 hopefully actually fix backtracking 2023-08-22 13:28:11 -07:00
leijurv
e8bcd0535d Merge pull request #4108 from babbaj/1.19.4
recover from flying into lava (and fix ignoreLava)
2023-08-21 20:44:02 -07:00
Leijurv
3b30b06313 Merge branch '1.19.4' into 1.20.1 2023-08-20 13:37:07 -07:00
Leijurv
e492e5f830 bump nether pathfinder 2023-08-20 13:36:45 -07:00
Leijurv
5a4500177d Merge branch '1.19.4' into 1.20.1 2023-08-20 11:54:08 -07:00
Leijurv
c4f33b72c2 check chunk load in sepples 2023-08-20 11:54:02 -07:00
Babbaj
5f5567f283 recover from flying into lava (and fix ignoreLava) 2023-08-19 15:33:12 -04:00
leijurv
301ad40350 link to latest 2023-08-18 19:36:12 -07:00
leijurv
aee36e4d85 deprecate 1.12.2 2023-08-18 19:35:30 -07:00
leijurv
e063475ebd list 1.20 2023-08-18 19:22:40 -07:00
leijurv
58d6b80f4f baritone elytra selling 2023-08-18 19:21:50 -07:00
Leijurv
fa28a56e84 Merge branch '1.19.4' into 1.20.1 2023-08-18 18:20:38 -07:00
Leijurv
c18fa512ef 1.19 defaults 2023-08-18 17:53:44 -07:00
Leijurv
3bdd0a81a5 rm debug 2023-08-18 17:49:37 -07:00
Leijurv
7668952ca8 Merge branch '1.19.4' into 1.20.1 2023-08-18 16:37:43 -07:00
Leijurv
b351ceef71 Merge branch 'master' into 1.19.4 2023-08-18 16:37:38 -07:00
Leijurv
4efa2b1272 fix backtracking bad behavior when render distance is tiny 2023-08-18 15:02:13 -07:00
Leijurv
c2308c650a mapping 2023-08-18 14:35:02 -07:00
Leijurv
b16590d504 Merge branch '1.20.1' of github.com:cabaletta/baritone into 1.20.1 2023-08-18 13:38:43 -07:00
Leijurv
51843f7074 Merge branch '1.19.4' into 1.20.1 2023-08-18 13:37:20 -07:00
Leijurv
7969988099 yay fixing the build was actually easy 2023-08-18 13:09:28 -07:00
Brady
fc474cfb49 bradyfix 2023-08-18 14:14:34 -05:00
Leijurv
bfc813a802 mostly works 2023-08-17 20:03:44 -07:00
Leijurv
fd8ca8576b Merge branch 'master' into 1.19.4 2023-08-17 17:36:22 -07:00
leijurv
75b8554a11 bump readme 2023-08-17 17:14:33 -07:00
leijurv
d9cb2d91a0 v1.2.19 2023-08-17 16:57:11 -07:00
leijurv
d4b95110f5 fml 2023-08-17 16:56:22 -07:00
leijurv
8a2a20a1b3 1.16 and 1.18 deprecated 2023-08-17 14:40:26 -07:00
leijurv
7daf1022c0 Merge pull request #4100 from babbaj/fix-proguard-lol
proguard: get java from gradle runtime before JAVA_HOME
2023-08-15 21:33:42 -07:00
Babbaj
60d6791f0c proguard: get java from gradle runtime before JAVA_HOME 2023-08-16 00:27:23 -04:00
Leijurv
ca4385da7a update readme 2023-08-14 22:34:38 -07:00
Leijurv
661b16af7e v1.2.18 2023-08-14 22:20:42 -07:00
leijurv
f36072c8d3 Merge pull request #4099 from babbaj/elytra
make raytracer collide with unknown chunks
2023-08-14 22:16:27 -07:00
Babbaj
b1be4f29ad make raytracer collide with unknown chunks 2023-08-15 01:14:53 -04:00
leijurv
050e3a570d bedrock is much lower now, although worth considering if deepslate needs similar special treatment 2023-08-14 21:56:41 -07:00
Leijurv
7b911aa0a7 clean up elytra given 2b2t status 2023-08-14 20:51:39 -07:00
Brady
9ecb416bf3 Merge branch 'elytra' 2023-08-14 14:38:44 -05:00
Leijurv
f35e55ef66 unused 2023-08-14 12:34:24 -07:00
leijurv
b0929991b1 typo 2023-08-14 01:40:47 -07:00
leijurv
bd263e1bf8 message for 2b players just in case the update actually happens 2023-08-14 01:40:15 -07:00
Leijurv
535eccfc24 no longer applies 2023-08-13 22:46:51 -07:00
Leijurv
81e004380f thanks lamp! i love lamp! 2023-08-13 22:42:51 -07:00
Leijurv
d67a3d8bbc much better safety 2023-08-13 22:37:47 -07:00
Leijurv
36534eeb2d vastly more helpful 2023-08-13 22:13:33 -07:00
Leijurv
4e3a7abac9 recompute on change 2023-08-13 19:29:19 -07:00
leijurv
f331124895 Merge pull request #4096 from babbaj/elytra
add setting that makes unknown chunks air
2023-08-13 19:08:12 -07:00
Babbaj
15a38c4871 add setting that makes unknown chunks air 2023-08-13 21:58:07 -04:00
leijurv
070523511a Merge pull request #4092 from wagyourtail/master-1
fix badges
2023-08-07 14:43:35 -07:00
William Gray
0edcf65044 fix badges 2023-08-07 21:33:42 +00:00
Brady Hahn
139fd03470 Update lines of code badge to match style 2023-08-02 17:07:03 -05:00
leijurv
3215824a9e Merge pull request #4085 from TheAlan404/patch-1
Add badge count badge
2023-08-02 15:04:24 -07:00
Dennis
f5bd737ee9 add badge count badge 2023-08-02 21:19:35 +03:00
Leijurv
70640246b6 fix infinite memory usage / crash 2023-08-01 14:11:25 -07:00
Leijurv
8c1ccd6c19 reduce dumb behavior 2023-08-01 11:45:53 -07:00
Leijurv
7813a9caba looks better 2023-08-01 11:30:30 -07:00
Brady Hahn
231d3a376b Merge pull request #4084 from babbaj/elytra
more intuitive smooth look/free look settings
2023-08-01 00:19:08 -05:00
Babbaj
3791569519 refactor so that Target.Mode is not a lie
fine

yes honey
2023-08-01 01:12:38 -04:00
Babbaj
7aa3eda3f6 fix nudgeToLevel with smoothLook 2023-07-31 19:13:53 -04:00
Babbaj
0ca173f5dc separate smooth look setting for elytra 2023-07-31 19:13:53 -04:00
Babbaj
c0a1e6540f simplify smoothLook into one setting and separate smoothLook from freeLook 2023-07-31 19:13:52 -04:00
Leijurv
46f38f2ce7 orderly shutdown 2023-07-31 15:06:25 -07:00
Leijurv
64a881f990 elytra warning 2023-07-31 01:36:01 -07:00
Leijurv
541b710ea7 too aggressive 2023-07-31 00:27:50 -07:00
Leijurv
cc8afe95c5 setting for nether fortress 2023-07-31 00:18:43 -07:00
Leijurv
83feddf6be recalc if all points out of view 2023-07-31 00:12:15 -07:00
Leijurv
7662810405 add back unsegmenting 2023-07-31 00:12:01 -07:00
Leijurv
d921d2e367 live a little 2023-07-30 23:33:49 -07:00
Leijurv
9630224e78 whatever 2023-07-30 23:26:46 -07:00
Leijurv
134bfb2a16 fix two cases where it could get stuck indefinitely 2023-07-30 23:24:04 -07:00
Leijurv
36df7b17f8 destroy async 2023-07-30 22:56:33 -07:00
Leijurv
7e9cf2e1e9 ok its based now 2023-07-30 22:47:39 -07:00
leijurv
54511f13d9 Merge pull request #4081 from babbaj/elytra
increase air bubble radius, append destination to path when landing
2023-07-30 22:30:07 -07:00
Babbaj
27e45b816d increase air bubble radius, append destination to path when landing 2023-07-30 19:45:25 -04:00
Brady
3a6e5541fb Don't deploy elytra while PathingBehavior is active 2023-07-30 17:48:53 -05:00
Leijurv
a83d275622 forgot 2023-07-30 15:47:43 -07:00
Leijurv
d6adb52718 tweaks 2023-07-30 15:46:18 -07:00
leijurv
976f3439eb Merge pull request #4077 from babbaj/elytra
safer elytra landing
2023-07-30 14:23:33 -07:00
leijurv
2821a2a0a7 Merge pull request #4078 from ZacSharp/1.20.1-update
Merge 1.19.4 into 1.20.1
2023-07-30 14:22:57 -07:00
Babbaj
2e2c0ecc0b use MutableBlockPos 2023-07-29 11:52:37 -04:00
Babbaj
31d1656c48 safer landing 2023-07-29 00:22:52 -04:00
Brady
4b5a094f30 Render fields can be private now 2023-07-28 01:41:03 -05:00
Brady
6b611cf4c7 Move more state into SolverContext 2023-07-28 01:30:54 -05:00
Brady
90f2b39fba Remove glPushAttrib/glPopAttrib usage 2023-07-26 19:52:25 -05:00
leijurv
2164857408 Merge pull request #4070 from babbaj/elytra
fixes for comments in elytra pr
2023-07-26 13:13:03 -07:00
ZacSharp
e0308dee49 Merge branch '1.19.4' into 1.20.1 2023-07-25 01:35:55 +02:00
Babbaj
601a781983 improve control flow (fixes behavior.onTick() being called twice) 2023-07-24 08:21:46 -04:00
Babbaj
f14bb282f0 add null check to resetState 2023-07-24 04:41:19 -04:00
Babbaj
1e0dce8f41 127 instead of 128 2023-07-24 03:30:38 -04:00
Babbaj
45400a9685 fix concurrency concerns 2023-07-24 03:30:06 -04:00
leijurv
6ffe31b59e Merge pull request #4068 from babbaj/elytra
add dimension checks to elytra
2023-07-23 17:47:46 -07:00
Babbaj
293b556b56 add dimension checks 2023-07-23 20:46:12 -04:00
leijurv
dbf38efd83 Merge pull request #4067 from babbaj/elytra
elytra command improvements
2023-07-23 12:11:37 -07:00
Babbaj
e63aad7825 elytra command improvements 2023-07-23 15:09:56 -04:00
Leijurv
212ef4d4cc waste fireworks smiling_imp 2023-07-23 11:44:29 -07:00
leijurv
31e082b8dc Merge pull request #4066 from babbaj/elytra
safe landing improvements
2023-07-23 11:29:40 -07:00
Babbaj
75e8035551 safe landing improvements 2023-07-23 14:26:31 -04:00
Leijurv
f7f0521093 not legacy 2023-07-22 23:29:07 -07:00
leijurv
684fda2d1b Merge pull request #4063 from babbaj/elytra
make elytra play nice with CustomGoalProcess
2023-07-22 23:12:07 -07:00
leijurv
886091df50 Merge branch 'elytra' into elytra 2023-07-22 23:08:45 -07:00
Leijurv
9707dd7ce8 redo checkedpositions given y descending iteration order 2023-07-22 23:02:29 -07:00
Babbaj
b81d712a33 higher priority is good enough lol 2023-07-23 01:57:27 -04:00
leijurv
3ffacbf375 Merge pull request #4064 from babbaj/safe-landing
find safe landing spot for elytra
2023-07-22 22:48:00 -07:00
Babbaj
eec85b20be fix bias in comparator 2023-07-23 01:45:39 -04:00
Babbaj
c0ead0147a use priority queue to bias upwards 2023-07-23 01:38:07 -04:00
leijurv
bafd41837e Merge pull request #4062 from ZacSharp/1.19.4-update
Merge 1.18.2 into 1.19.4
2023-07-22 22:15:46 -07:00
Babbaj
9bfa2025d5 memoize isSafeLandingSPot 2023-07-23 01:14:19 -04:00
Babbaj
bf63ffbc1d cringe fence hater 😭 2023-07-23 01:01:59 -04:00
Babbaj
985148b49a check for specific blocks to land on and anything non air is lava 2023-07-23 01:00:23 -04:00
Babbaj
9e78443595 resolve comment 2023-07-23 00:53:26 -04:00
Babbaj
58723a33ca hate cherry pick now 2023-07-23 00:05:11 -04:00
Babbaj
c9aa1658b2 improvements/fixes 2023-07-23 00:03:31 -04:00
Babbaj
7f9e50bbe2 initial safe landing impl 2023-07-23 00:02:46 -04:00
Babbaj
664375a678 make elytra play nice with CustomGoalProcess 2023-07-22 01:55:12 -04:00
Brady
097e30850f Move WalkOffCalculationContext into ElytraProcess 2023-07-18 23:35:09 -05:00
Brady Hahn
a63cbab013 Merge pull request #4060 from babbaj/elytra
refactor elytra into process
2023-07-18 23:23:25 -05:00
ZacSharp
37f1c30ad0 Merge branch '1.19.2' into 1.19.4 2023-07-19 04:32:08 +02:00
ZacSharp
217dca5363 Merge branch '1.18.2' into 1.19.2 2023-07-19 04:13:47 +02:00
ZacSharp
15e97268ed Fake merge branch '1.19.2' into 1.19.4 2023-07-19 04:09:37 +02:00
Brady Hahn
29301e8a39 Merge pull request #4059 from cabaletta/pr/render/vulkanCompatibility
VulkanMod Compatibility
2023-07-18 20:07:38 -05:00
Brady
dfa838a6f9 Replace Mth.fastInvSqrt with 1.0 / Math.sqrt 2023-07-18 19:19:08 -05:00
Brady
218de1cb98 Requested changes 2023-07-18 16:48:00 -05:00
Brady
6a9694b03a Manually specify some normals, fix GoalXZ rendering 2023-07-18 15:24:21 -05:00
Babbaj
0239a2cad4 notificationOnPathComplete and disconnectOnArrival 2023-07-18 15:36:29 -04:00
Babbaj
38553b3324 behavior can't be null in onTick 2023-07-18 14:52:09 -04:00
Babbaj
ba78c48a75 shutdown solverExecutor 2023-07-18 13:36:55 -04:00
Babbaj
f4996137a3 minor code improvements 2023-07-18 13:36:55 -04:00
Babbaj
ccd80dfc8f that isn't necessary 2023-07-18 13:36:55 -04:00
Babbaj
ff1b3e7c5f simplify management of elytra state 2023-07-18 13:36:55 -04:00
Babbaj
2f0497756b simplify icky code 2023-07-18 13:36:54 -04:00
Babbaj
afe9359d3e don't call onTick if we are pawsed 2023-07-18 13:36:54 -04:00
Babbaj
4b5d629df6 fix off by one error (causing the last point to be stuck in terrain) 2023-07-18 13:36:54 -04:00
Babbaj
dbc0a46b10 call elytra event handlers from ElytraProcess 2023-07-18 13:36:54 -04:00
Babbaj
9a6241af8a refactor elytra into being just a process 2023-07-18 13:36:53 -04:00
Brady
1b82bd1f33 pitch smooth look and setting for ticks 2023-07-17 17:58:08 -05:00
Brady
bf9cb76604 VulkanMod compatibility + use LINES instead of DEBUG_LINES 2023-07-17 16:34:01 -05:00
Brady Hahn
90cfd82810 Merge pull request #4056 from babbaj/elytra
consistent elytra setting naming
2023-07-16 20:30:35 -05:00
Brady
108dbdae5d partially appease codacy 2023-07-16 20:29:30 -05:00
Brady
32a4c4644e Move cull code 2023-07-16 20:21:40 -05:00
Leijurv
edc92753cf Revert "shrimple"
This reverts commit 0e567f2f90.
2023-07-16 18:17:53 -07:00
Leijurv
0e567f2f90 shrimple 2023-07-16 18:17:15 -07:00
Babbaj
41e8c69db9 consistent elytra setting naming 2023-07-16 18:58:42 -04:00
Brady Hahn
a83d1901f2 Merge pull request #4055 from babbaj/elytra
cull far away chunks from the cache
2023-07-16 17:00:42 -05:00
Babbaj
f3bb5a0cb2 make sure BlockStateOctreeInterface doesn't use freed chunk pointers 2023-07-16 13:53:02 -04:00
Babbaj
76d3a13f58 cull far away chunks from the cache 2023-07-16 01:19:51 -04:00
Brady Hahn
6f99f891dc Merge pull request #4054 from babbaj/elytra
simple way to land at the goal
2023-07-15 22:24:42 -05:00
Brady Hahn
e579bf980d Update NetherPath.java 2023-07-15 22:23:59 -05:00
Brady Hahn
716b3ae0d2 Update ElytraBehavior.java
i love github web editor
2023-07-15 22:23:35 -05:00
Babbaj
b468b8eb95 landing procedure 2023-07-15 22:17:21 -04:00
leijurv
b647c0fca0 Merge pull request #4050 from ZacSharp/1.18.2-update
Merge 1.16.5 into 1.18.2
2023-07-13 22:14:32 -07:00
Brady
1d109d4b9f crucial performance optimization 2023-07-13 14:47:19 -05:00
Brady
29bf046aa8 BlockStateOctreeInterface 2023-07-13 14:28:51 -05:00
Brady Hahn
4399b7c2fb Merge pull request #4053 from babbaj/elytra
auto swap elytra
2023-07-13 13:37:30 -05:00
Babbaj
d35571923f appease brady 2023-07-13 14:35:33 -04:00
Babbaj
461f56c4d6 countdown instead of count up 2023-07-13 14:21:15 -04:00
Babbaj
0b5d5b8176 use ticksBetweenInventoryMoves 2023-07-12 22:54:04 -04:00
Babbaj
42771686c6 auto swap elytra 2023-07-12 16:42:14 -04:00
ZacSharp
448e454cc8 Merge branch '1.17.1' into 1.18.2 2023-07-12 18:56:17 +02:00
Brady
8f5105c454 trolled pt2 2023-07-11 22:50:35 -05:00
Brady
7c696b7055 trolled 2023-07-11 22:49:51 -05:00
Brady
349c951b55 Better handling of unsupported systems 2023-07-11 22:47:09 -05:00
Leijurv
5dc403e643 crucial performance optimization 2023-07-10 00:12:10 -07:00
Brady Hahn
a8e1b16dee Merge pull request #4048 from babbaj/elytra
don't send the whole chunk for small changes
2023-07-09 22:31:42 -07:00
Babbaj
dc53a95bef don't send the whole chunk for small changes 2023-07-10 00:45:12 -04:00
Brady
eec4edea05 Remove old pack method 2023-07-09 20:00:35 -07:00
Brady Hahn
70249e5fa7 Merge pull request #4047 from babbaj/elytra
optimize uploading chunk data
2023-07-09 19:58:59 -07:00
Babbaj
96a64b454e optimize uploading chunk data 2023-07-09 22:29:31 -04:00
Brady
7a935fb2ea Fix simulation not respecting ignoreLava 2023-07-09 09:12:21 -07:00
Brady
c0cdfb7781 Add commands for pathfinder reset and chunk repack 2023-07-07 19:44:59 -07:00
Brady
487b3a759a mostRecentGoal, fixes immediate goal clear 2023-07-07 18:35:02 -07:00
Brady
fe67489419 Combine VALIDATE_PATH and LOCATE_JUMP states 2023-07-07 14:38:11 -07:00
Brady
308b9bbfea Apply minimum fall height to regular falls too 2023-07-07 13:26:43 -07:00
Brady
bfb4ffcafc Reset context on world load/unload 2023-07-07 11:19:18 -07:00
Brady
537100a5e5 Nether seed setting and automatic context reset 2023-07-07 10:44:56 -07:00
Brady
b6bf4427ef Use soft references for nether chunk packing queue 2023-07-07 00:30:07 -07:00
Brady
8de239f468 Use soft references for chunks queued for packing 2023-07-06 23:15:35 -07:00
Brady
ecfd664f30 Fix isSafeToCancel() return value 2023-07-06 20:11:50 -07:00
Brady
c4ac23837f Set safeToCancel to false while flying 2023-07-06 19:31:37 -07:00
Brady
aeeb001205 Fix some codacy issues 2023-07-06 19:02:13 -07:00
Brady
2552eb8dca Add setting documentation 2023-07-06 18:57:51 -07:00
ZacSharp
cbf0d79c9c Merge branch '1.16.5' into 1.17.1 2023-07-06 13:30:25 +02:00
leijurv
8ceb89d021 Merge pull request #4028 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2023-07-05 11:47:27 -07:00
ZacSharp
8e58dd9e64 Merge branch '1.15.2' into 1.16.5 2023-07-04 16:48:41 +02:00
ZacSharp
45abbb7fa1 Merge branch '1.14.4' into 1.15.2 2023-07-04 16:48:36 +02:00
ZacSharp
1d983d5fdc Merge branch '1.13.2' into 1.14.4 2023-07-04 16:48:31 +02:00
ZacSharp
be54b8ee5b Merge branch 'master' into 1.13.2 2023-07-04 16:47:58 +02:00
Brady
4c0c263d11 trolling 2023-07-03 13:28:53 -05:00
Brady
c8259d3e90 ZOOM 2023-07-03 13:27:23 -05:00
Brady
d892ef54f0 Merge branch 'master' into elytra 2023-07-02 20:04:04 -05:00
Brady
6654476da4 Make blockFreeLook depend on freeLook 2023-07-02 19:59:26 -05:00
Brady
fc209599af Update nether-pathfinder to 0.21 2023-07-02 01:03:34 -05:00
Brady
dee7df1534 I HATE OLD MIXIN!!!!
awesome buggy 0.7.11 hates referencing shadows in mixin superclasses wooooooo
2023-07-01 19:38:38 -05:00
Brady
ccd737d0a1 Actually fix Forge by reverting Mixin change completely 2023-07-01 18:38:13 -05:00
Brady
14b5a0cec3 Fix Forge support 2023-07-01 17:28:23 -05:00
Brady
2f7dc2397e Better start position selection and validation 2023-07-01 01:32:03 -05:00
Brady
3498082f2b Better state switch and start path halfway down fall 2023-06-30 20:53:42 -05:00
Brady
83066fc57c Find jump off spot using INSANE custom CalculationContext 2023-06-30 20:42:03 -05:00
Brady
d32f1b2a16 Add hit pos raytrace method to context 2023-06-30 20:38:45 -05:00
Leijurv
8211ae4af5 memory leaks are joever 2023-06-29 21:59:31 -07:00
Brady
4590ba3ff8 Use separate executor for solver 2023-06-29 23:35:12 -05:00
Brady
b4578931d3 Reduce passing around of ignoreLava 2023-06-29 22:59:15 -05:00
Brady
b8ede0a652 Remove unnecessary IPlayerContext argument 2023-06-29 22:54:55 -05:00
Brady
3eb7610f89 Block lookup optimization 2023-06-29 20:45:59 -05:00
Brady
5a48f4119e Reduce number of raytraces when validating simulation 2023-06-29 19:15:06 -05:00
Brady
974b86aac1 Bump nether-pathfinder to 0.20 2023-06-29 18:50:29 -05:00
Brady
f30cb916bd Remove addressed TODO 2023-06-29 14:53:55 -05:00
Brady
494ebfa10d More accurate isActive return value 2023-06-29 14:53:12 -05:00
Brady
222f53b105 Use Arrays.fill 2023-06-29 14:46:42 -05:00
Brady
12898df2f1 Reduce main thread recalculations after using a firework 2023-06-29 14:46:04 -05:00
Brady
fbb66a0586 Tweaks 2023-06-29 14:14:49 -05:00
Brady
48462da473 Disable interp on relaxation 0 2023-06-28 21:47:37 -05:00
Brady
4b689bd946 Fix Supplier meme 2023-06-28 17:55:47 -05:00
Brady
5126ec9c36 interp double 2023-06-28 17:49:33 -05:00
Brady
d640ebb02d Reliability improvements 2023-06-28 17:47:01 -05:00
Brady
0bb6f1b094 Invalidate pendingSolution 2023-06-28 01:05:22 -05:00
Brady
bb39fea415 Considerations 2023-06-28 01:04:08 -05:00
Brady
7a61ab8137 We need event priorities. 2023-06-28 00:58:51 -05:00
Brady
7861860187 Clarify 2023-06-28 00:48:28 -05:00
Brady
70166f385d That should be in the other tick method 2023-06-28 00:47:20 -05:00
Brady
03ee30bca9 Call elytra tick() from the process 2023-06-28 00:46:14 -05:00
Brady
c48de32860 PitchResult 2023-06-27 16:31:08 -05:00
Brady
3b31387092 Render simulation line from player pos 2023-06-27 13:02:01 -05:00
Brady
ff12832a21 whoops 2023-06-27 12:30:41 -05:00
Brady
4ccaf681c5 Somewhat functional elytraAutoJump, but mostly scuffed 2023-06-27 02:54:53 -05:00
Brady
02fc62f1c4 Stop simulation when goal reached 2023-06-26 18:37:06 -05:00
Brady
04a5a1a620 Replace bool firework with ticksBoosted in solvePitch 2023-06-26 16:58:29 -05:00
Brady
3e94cac567 clarity 2023-06-26 16:25:21 -05:00
Brady
452b2c278b Fix renderElytraSimulation 2023-06-26 16:21:15 -05:00
Brady
db0bfbe722 Move elytra simulation into new method 2023-06-26 16:12:56 -05:00
Brady
f0148a625e Move steps into solvePitch 2023-06-26 16:04:05 -05:00
Brady
0b5a310f18 Move firework boost calculation into solvePitch 2023-06-26 15:35:40 -05:00
Brady
c18715b8d7 Reset minimumBoostTicks to 0 earlier 2023-06-26 14:00:38 -05:00
Brady
d244a39040 Make MixinEntityLivingBase extend MixinEntity 2023-06-26 13:57:24 -05:00
Brady
0981114b78 Create FireworkBoost class for additional boost context
Also initialize `boostedEntity` in `EntityFireworkRocket` if `null` since it's lazily initialized in `onUpdate()`
2023-06-26 13:55:18 -05:00
Brady
9bd0856445 lol 2023-06-25 15:32:02 -07:00
Brady
9d1addd114 Add smoothLook setting 2023-06-25 15:28:06 -07:00
Brady
1902e6c1f3 Reset minimumBoostTicks to 0 when not boosted 2023-06-24 22:37:21 -07:00
Brady
a1a3d93dc1 Add renderElytraSimulation setting 2023-06-24 22:27:38 -07:00
Brady
32b7c82650 Add renderHitboxRaytraces setting 2023-06-24 22:11:08 -07:00
Brady
615266ed96 Replace manual calculation with util method 2023-06-24 21:57:00 -07:00
Brady
15f4253b3d Clamp pitch to normal range 2023-06-24 21:48:44 -07:00
Brady
2ccd464a49 Utilize aim processor API for correct elytra simulation 2023-06-24 21:44:08 -07:00
Brady
f2374edd8b Merge branch 'master' into elytra
# Conflicts:
#	src/launch/java/baritone/launch/mixins/MixinMinecraft.java
#	src/main/java/baritone/Baritone.java
#	src/main/java/baritone/behavior/LookBehavior.java
2023-06-23 23:31:43 -07:00
leijurv
24b0bd2edf Merge pull request #4019 from ZacSharp/pr/misc/rotation/fixMouseStuck
Fix getting stuck due to impossible rotations
2023-06-23 21:59:34 -07:00
Brady
f56e0569a2 Add minimumBoostTicks 2023-06-23 16:30:10 -07:00
Brady
c10903be69 Remove firstFireworks from InventoryBehavior 2023-06-23 16:17:59 -07:00
ZacSharp
e3a1ac85cc Fix waiting for impossible rotations 2023-06-23 04:22:35 +02:00
leijurv
1ea071de09 Merge pull request #4015 from cabaletta/pr/deterministicLookTarget
API for rotations produced by LookBehavior
2023-06-22 19:21:02 -07:00
Brady
c9a18caf49 Register LookBehavior first
Since there's no event priority system, this is necessary to ensure anything else listening to the PRE `TickEvent` can accurately simulate rotations.
2023-06-22 20:38:00 -05:00
Brady
bfae100cb9 Create ITickableAimProcessor 2023-06-22 20:35:22 -05:00
Brady
878a32228a Add avoidance setting 2023-06-22 18:22:40 -05:00
Brady
bce2c74a8e NO MORE CONCUSSIONS! 2023-06-22 18:07:11 -05:00
Brady
90434b3178 A bit more flexibility 2023-06-22 12:54:30 -05:00
Brady
9cf5538058 Improve stepper collision detection 2023-06-22 12:50:06 -05:00
Brady
f4a99253f4 Prevent head bonks 2023-06-22 12:08:30 -05:00
Brady
b366b1b1d1 Fix other null checks 2023-06-22 11:40:45 -05:00
Brady Hahn
a90e720956 Merge pull request #4017 from babbaj/elytra
simplify null check
2023-06-22 11:40:08 -05:00
Babbaj
535fd17a42 simplify null check 2023-06-22 08:30:25 -04:00
Brady
47dc0f9b94 Add missing exception null check to async completed callback 2023-06-21 21:30:04 -05:00
Brady
4776fa1876 Don't update playerNear on an empty path 2023-06-21 21:19:12 -05:00
leijurv
944405e4df Merge pull request #4014 from jdbool/1.19.2
Add useMessageTag setting
2023-06-21 18:55:06 -07:00
leijurv
0dd38ca65a Merge pull request #4012 from ZacSharp/pr/commands/usableTabCompletion
Fix tab completion with brigadier
2023-06-21 18:54:20 -07:00
leijurv
b0ebbf4dfb Merge pull request #4007 from ZacSharp/pr/schematics/mask/fixBinaryOperatorMaskOOB
Don't call `partOfMask` out of bounds in `BinaryOperatorMask`
2023-06-21 18:53:58 -07:00
leijurv
9d12a4ba3d Merge pull request #4008 from ZacSharp/pr/pathing/goals/implHashCode
Implement `hashCode` for goals
2023-06-21 18:53:36 -07:00
leijurv
6dc953631b Merge pull request #4006 from ZacSharp/pr/blockOptionalMeta/tabCompleteProperties
Tab completion improvements
2023-06-21 18:53:06 -07:00
Mike
7ef4307ab7 Clean up useMessageTag 2023-06-21 18:25:24 -07:00
Brady
0aff31b768 Perfect elytra simulation 2023-06-21 18:59:44 -05:00
Brady
0682e63707 Apply processor to RotationMoveEvent 2023-06-21 17:39:04 -05:00
Brady
7e426bd2e8 AimProcessor API 2023-06-21 17:35:47 -05:00
Mike
a5ca664a6a Add useMessageTag setting 2023-06-21 15:14:54 -07:00
Brady
367ce5fa17 cherry pick Allow freeLook when using elytra 2023-06-21 14:55:40 -05:00
Brady
877fd25608 Distinguish unexpected exceptions in path calc 2023-06-21 00:52:43 -05:00
Brady
cfd9a69052 Revert how PathManager tick works 2023-06-21 00:21:37 -05:00
Brady
d42bfcfa53 Fix NPE 2023-06-20 23:15:45 -05:00
Brady
defa6399e2 Tweak hitbox constraints 2023-06-20 23:01:07 -05:00
Brady
699e8bdea6 troll concurrency fix for rn 2023-06-20 22:36:27 -05:00
Brady
2eb912835a Restore interp values 2023-06-20 21:28:30 -05:00
Brady
bd7a57f7aa We do a little trolling 2023-06-20 21:27:54 -05:00
Brady
e76f79214e Replace pathAt with NetherPath 2023-06-20 21:07:21 -05:00
Brady
141a48a15e Some refactoring, more precise goingTo 2023-06-20 20:30:10 -05:00
Brady
fa158c6e67 Remove unnecessary conversions to Vec3d 2023-06-20 20:18:56 -05:00
Brady
7a12ef530c Cancel solver on behavior cancel 2023-06-20 20:11:34 -05:00
Brady
1d092a7165 Compute angles on another thread between ticks 2023-06-20 20:09:53 -05:00
Brady
57a17e907e Add missing CallbackInfo 2023-06-20 17:30:38 -05:00
Brady
2a82f6048a Implement POST TickEvent with new onPostTick callback 2023-06-20 17:18:30 -05:00
Brady
4076263afa Un-scuff PRE TickEvent injector 2023-06-20 17:00:42 -05:00
Brady
e3c8283158 Move solver into separate method 2023-06-20 15:15:02 -05:00
Brady
0aad3470d9 Differ between no pitch solution and no solution at all 2023-06-20 15:05:59 -05:00
Brady Hahn
553c85f0f6 Merge pull request #4011 from babbaj/elytra
fix 0.5 offset in elytra path rendering
2023-06-20 14:49:00 -05:00
Babbaj
c057081f07 fix 0.5 offset in elytra path rendering 2023-06-20 15:48:12 -04:00
Brady
7d22a71507 Only count unchanged ticks when using elytra 2023-06-20 13:50:26 -05:00
Brady
0ecabdd047 Update nether-pathfinder to 0.18 2023-06-20 13:43:42 -05:00
Brady
6c6b44ee65 Recalculate path if stuck 2023-06-20 13:43:14 -05:00
Brady
14ff90ccf1 remaining ticks mojang incident 2023-06-19 23:12:46 -05:00
Brady
5d7655fbdf Fix silly 0x integer wraparound trolle 2023-06-19 22:52:27 -05:00
Brady
ee0a6c2523 Use new single trace isVisible api 2023-06-19 21:45:52 -05:00
Brady
753b1cf1c3 Interpolate path positions
- Update `nether-pathfinder` to 0.17
- Utilize new batched visibility raytracing to efficiently trace bounding box paths
2023-06-19 21:38:08 -05:00
0x22
cd1c07deef added elytraFireworkSetbackUseDelay setting. 2023-06-19 22:22:57 -04:00
ZacSharp
41d730fb04 Forgot to include target pos 2023-06-20 03:20:44 +02:00
ZacSharp
30278a1c52 Implement hashCode for goals 2023-06-20 02:44:29 +02:00
ZacSharp
d87d1ab9b5 Don't call partOfMask out of bounds 2023-06-20 02:00:08 +02:00
ZacSharp
31c9072970 Forgot to git add 2023-06-20 01:36:09 +02:00
ZacSharp
f7a20a3acf Don't swallow random exceptions, don't bother with CommandExceptions 2023-06-20 01:32:18 +02:00
Brady Hahn
9d05043fa0 Merge pull request #4005 from babbaj/elytra
use legacy raytrace with ignore liquid to get out of lava
2023-06-19 18:04:14 -05:00
Babbaj
5f709eef9c use world raytrace 2023-06-19 18:26:00 -04:00
ZacSharp
b111fd2f3e Don't construct malformed ResourceLocations
Later mc versions throw an exception when you construct a malformed `ResourceLocation`.
2023-06-20 00:02:56 +02:00
ZacSharp
84777c2437 Don't complete more than what's supported 2023-06-20 00:01:33 +02:00
ZacSharp
13742df877 Complete the last argument, not the first one 2023-06-20 00:00:52 +02:00
Babbaj
e57a84ded4 use legacy raytrace with ignore liquid to get out of lava 2023-06-19 17:58:06 -04:00
ZacSharp
f55f7f19b4 Tab complete the datatype which will be parsed 2023-06-19 23:50:42 +02:00
ZacSharp
e43200865c Move this to the right place 2023-06-19 23:48:07 +02:00
ZacSharp
1de2d55965 Tab complete block properties 2023-06-19 23:05:46 +02:00
Brady
959b4cddbd Remove unneeded while (true) 2023-06-19 15:29:30 -05:00
Brady
82156250df Update nether-pathfinder to 0.16 2023-06-19 15:20:04 -05:00
Brady
90f401a067 Remove legacy raytracing methods 2023-06-19 15:19:32 -05:00
Brady
c6a6624045 Reorder fields 2023-06-19 15:16:11 -05:00
Brady
7d17ace15d Reset recalculating flag on clear 2023-06-19 15:15:29 -05:00
Brady
8d3b0c8f07 Always enforce sinceFirework 2023-06-19 14:10:41 -05:00
0x22
6741dff12b replaced (PI / 180) constants, RotationUtils calcVec3dFromRotation->calcLookDirectionFromRotation and named local variables. 2023-06-19 14:17:54 -04:00
Brady
9e10faa4c5 Elytra inventory modifications
- Use `throwaway` to switch items
- Remove inventory settings
- Prioritizes boost fireworks, but works without
- Avoids explosion fireworks
2023-06-19 12:32:25 -05:00
Brady Hahn
579e6d6e4c Merge pull request #4003 from rycbar0/elytra
prevent <player> went off with a bang
2023-06-19 12:12:15 -05:00
rycbar0
a32ac59ec1 prevent <player> went off with a bang 2023-06-19 12:44:32 +02:00
Leijurv
2b259d6dee cuter debug 2023-06-18 23:09:43 -07:00
Brady
67efb7a5b6 Add experimentalRaytrace setting for native raytrace
Update `nether-pathfinder` to 0.15
2023-06-19 00:34:22 -05:00
Brady
1da7ab2c22 Fix raytracer rendering 2023-06-18 23:58:20 -05:00
Brady
1257a0128c Remove unnecessary Baritone casts 2023-06-18 21:46:56 -05:00
Brady
0886f176b3 Make elytra API changes 2023-06-18 21:46:03 -05:00
Brady
7a8f8e8d47 fix noob error from resolving merge conflicts 2023-06-18 21:42:04 -05:00
Brady Hahn
7046927394 Merge pull request #3996 from rfresh2/elytra
firework inv management + pause/resume
2023-06-18 21:41:11 -05:00
Brady Hahn
d2b1398cea Merge branch 'elytra' into elytra 2023-06-18 21:39:09 -05:00
Leijurv
6c8f2698d6 cherry pick remainWithExistingLookDirection from fork 2023-06-18 19:31:51 -07:00
Brady
9808f62fe4 Send chunks to nether-pathfinder on BlockUpdateEvent 2023-06-18 21:25:00 -05:00
Brady
1837b66bb5 Add BlockChangeEvent
Moves the cache repack on block change functionality into `GameEventHandler`
2023-06-18 21:24:13 -05:00
Leijurv
efae476bc0 solved 2023-06-18 18:16:13 -07:00
Leijurv
a236031435 fix raytracer 2023-06-18 18:09:45 -07:00
Leijurv
812be14375 debug 2023-06-18 18:06:32 -07:00
Brady
1dbfc9abe3 optimize block lookups and move goingTo to local 2023-06-18 19:57:29 -05:00
leijurv
411c43d90e Merge pull request #3992 from ZacSharp/pr/blockOptionalMeta/useStackHashesInBlockOptionalMetaLookup
Actually use stack hashes
2023-06-18 17:25:53 -07:00
leijurv
bac5fd7438 Merge pull request #3999 from ZacSharp/pr/setting/tabCompleteSetingsLoadPath
Tab complete the file argument for `#settings load`
2023-06-18 17:25:27 -07:00
Brady Hahn
4df31a3fbb Merge pull request #4000 from ZacSharp/pr/selection/fixHorizontalCylinders
Fix `CylinderMask` with horizontal alignment
2023-06-18 19:02:07 -05:00
rfresh2
8dc32ae03c firework inv management + pause/resume 2023-06-18 13:34:55 -07:00
ZacSharp
5fd915ab8a Tab complete the file argument for #settings load 2023-06-18 22:27:57 +02:00
Brady
68901695ca Add experimental takeoff feature 2023-06-18 13:23:41 -05:00
ZacSharp
6aeb73b5bd Fix CylinderMask with horizontal alignment 2023-06-18 19:18:46 +02:00
0x22
aec683d80f fast raytrace 2023-06-18 12:21:01 -04:00
Brady
d4e6a84ec9 Remove usage of realms Pair class 2023-06-18 10:57:13 -05:00
Brady
d66b8f1dd8 Extract currentSpeed into variable 2023-06-18 00:13:55 -05:00
Brady
688bbb83c8 Rename wasteFireworks to conserveFireworks and invert 2023-06-18 00:11:40 -05:00
Brady
da31a643b3 unscuff 2023-06-17 23:56:08 -05:00
Babbaj
76c5c1155f Fix ElytraCommand throwing exception for invalid goals 2023-06-18 00:51:07 -04:00
Leijurv
94027d17f2 gaming 2023-06-17 20:12:05 -07:00
Leijurv
fef7ba4701 tweaks 2023-06-17 20:03:30 -07:00
Brady
fcf8cd35d2 Handle exception to ensure recalculating is reset 2023-06-17 19:58:19 -05:00
Brady
91609f4ebf Use player bounding box in isClear 2023-06-17 19:36:29 -05:00
Brady
64a5ceabd8 Fix the regular pathfinder issue 2023-06-17 15:35:26 -05:00
Brady
4c2984a9a0 Consistent path prefix for methods 2023-06-17 14:21:32 -05:00
Brady
d1a6de06e2 😼 PathManager 2023-06-17 14:15:57 -05:00
Brady
0290b344dc Cancel before shutting down executor 2023-06-17 02:33:43 -05:00
Brady
395706edc9 move context wrapper to new class 2023-06-17 02:02:26 -05:00
Brady
a67889ab42 refactoring 2023-06-17 01:55:07 -05:00
Brady
97e91ed680 one var 2023-06-17 01:42:49 -05:00
Brady
424f27c798 remove debug msg 2023-06-17 01:41:17 -05:00
Brady
c5475498ca so cute 2023-06-17 01:39:21 -05:00
Leijurv
157e4db7c5 fireworks hack 2023-06-16 22:39:50 -07:00
Leijurv
1f303e69b0 cut at render distance 2023-06-16 22:21:52 -07:00
Leijurv
dc53c79393 gaming 2023-06-16 21:35:56 -07:00
Brady
37167746b5 Merge remote-tracking branch 'origin/master' into elytra 2023-06-16 22:52:24 -05:00
Brady
a046708867 Merge remote-tracking branch 'origin/elytra-buildScriptOverhaul' into elytra 2023-06-16 22:41:14 -05:00
Brady
f798ff26f6 fixed seed 2023-06-16 22:31:53 -05:00
leijurv
a665605a5a Merge pull request #3991 from ZacSharp/pr/guiclick/fixSelectionPreview
Fix `GuiClick` not rendering the outline of the selection being made
2023-06-16 20:29:25 -07:00
Brady
071e6164fe Fix nether-pathfinder on Windows 2023-06-16 21:55:08 -05:00
0x22
b72bbfce5e make all json deterministic 2023-06-16 22:36:58 -04:00
0x22
cb7c2d7171 1.12.2 build script overhaul.
- Updated to ForgeGradle 4.0, MixinGradle 0.7 and Gradle 6.9.4
- Added a hack to run the game on arm64 on Mac OS X natively.
2023-06-16 22:04:16 -04:00
Brady
800cb2e747 Replace sublist troll in PathRenderer with visiblePath 2023-06-16 20:53:53 -05:00
Brady
5b39eb5041 clean up 2023-06-16 20:38:29 -05:00
Brady
53a0069704 Remove Java pathfinder in preparation for insertChunkData 2023-06-16 19:54:37 -05:00
Brady
8c12416348 Use new nether-pathfinder API
Doesn't stitch segments, just partially functional
2023-06-16 18:59:57 -05:00
ZacSharp
e00e0032b4 Actually use stack hashes 2023-06-17 01:40:19 +02:00
ZacSharp
f1bf1e8663 Use IRenderer setup methods 2023-06-17 00:36:35 +02:00
ZacSharp
ef4cdfd646 Fix render bug caused by color bug fix 2023-06-16 19:22:37 +02:00
Leijurv
e01093eb9a build with pathfinder 2023-06-15 20:59:15 -07:00
Brady
a9e9cd978d cancel lol 2023-06-15 22:59:01 -05:00
Brady
fe8ec19b6d Fix renderRaytraces crash 2023-06-15 22:07:44 -05:00
leijurv
0e87f350b3 Merge pull request #3990 from cabaletta/elytra-freelook
Merge `elytra-freelook` into `elytra`
2023-06-15 20:00:45 -07:00
leijurv
c86643874d Merge pull request #3936 from ZacSharp/pr/builder/fixPlaceableComparison
Fix considering states unplaceable regardless of buildIgnoreProperties
2023-06-15 19:36:25 -07:00
Leijurv
8df6778641 sort of integrated nether pathfinder 2023-06-15 00:32:26 -07:00
Brady
26a2945696 remove comment 2023-06-14 19:13:07 -05:00
leijurv
04b09fbfbd Merge pull request #3985 from cabaletta/pr/deprecateHelperMc
Deprecate `Helper.mc`
2023-06-14 16:20:38 -07:00
Brady
f14caa3778 Fix cringe shift by injector 2023-06-14 17:32:47 -05:00
Brady
06d11c1874 Revert file path 2023-06-14 16:59:03 -05:00
Brady
91bf7d726b Un-scuff and add setting 2023-06-14 16:32:56 -05:00
Brady
bde0c620ad Allow freeLook when using elytra 2023-06-14 16:11:11 -05:00
Brady
9672bd2c6d Fix compile 2023-06-14 16:08:34 -05:00
Brady
7b6f9b3eb6 Merge remote-tracking branch 'origin/master' into elytra 2023-06-14 15:48:16 -05:00
Brady
ea9245ad26 missed that 😩 2023-06-14 14:23:24 -05:00
Brady
8534e1ba55 💚 appease codacy 2023-06-14 14:04:34 -05:00
Brady
ae66004b80 Custom registration of Baritone instances from Minecraft 2023-06-14 13:52:27 -05:00
Brady
5b39c0dd96 Remove getMinecraft() from BlockStateInterface 2023-06-14 12:18:50 -05:00
Brady
2db2d8be59 Steal BaritoneList from bot-system 2023-06-14 02:00:10 -05:00
Brady
75d47bb110 Fix all usages of Helper.mc 2023-06-14 01:53:29 -05:00
leijurv
3662b3fdf1 nope 2023-06-13 21:33:12 -07:00
leijurv
b03d31e990 will github let me do this 2023-06-13 21:32:57 -07:00
leijurv
54f0a3c14c marginally better 2023-06-13 21:32:21 -07:00
leijurv
6a80b0d4ff forgot github markdown is stupid 2023-06-13 21:31:49 -07:00
leijurv
5e724c1e3a making these clickable was a mistake 2023-06-13 21:31:10 -07:00
leijurv
88e604426c 1.20.1 2023-06-13 21:30:31 -07:00
Leijurv
7487b90d50 v1.10.1 2023-06-13 21:21:45 -07:00
Brady
dd7b492b0c registerBehavior is called explicitly now 2023-06-13 23:21:20 -05:00
Brady
c7f4e366e2 Remove mc references from WorldProvider
Also refactored a bit, should be a lot easier to merge upwards to new game versions
2023-06-13 23:07:26 -05:00
leijurv
09554ab39d Merge pull request #3943 from wagyourtail/1.20/1.20
1.20
2023-06-13 20:53:05 -07:00
Brady
382f82b0e0 Move Minecraft to IPlayerContext 2023-06-13 21:17:42 -05:00
Brady
ab3d9e9c47 I LOVE final 2023-06-13 21:13:34 -05:00
Wagyourtail
2ae7bc6a64 bump unimined to latest stable 2023-06-13 19:42:16 -06:00
Wagyourtail
6979bd6971 support both 2023-06-13 19:42:08 -06:00
Wagyourtail
b2bd025896 1.20.1 2023-06-13 19:32:55 -06:00
Brady
714ebb2c2d Deprecate Helper.mc and begin to replace usages 2023-06-13 18:24:31 -05:00
leijurv
1b254a4811 Merge pull request #3979 from cabaletta/pr/feature/blockFreeLook
Allow free looking when breaking and placing blocks
2023-06-13 10:32:18 -07:00
Leijurv
92509f07e9 normal raytracer skips flowing lava (aka lavafalls) which is no good 2023-06-12 22:00:23 -07:00
Leijurv
44cd5dcd41 go around glowstone and nether fortresses 2023-06-12 21:43:10 -07:00
Brady
76fe0d14d3 Simplify some player context references 2023-06-12 21:13:10 -05:00
Brady
2022d33d03 Fix incorrect references to player and world 2023-06-12 21:12:49 -05:00
Brady
c8b8deb3d6 Ensure angle delta is producible with mouse movement 2023-06-12 21:04:30 -05:00
Brady
4885d49d20 Reorganize code 2023-06-12 20:00:03 -05:00
Brady
13fc58933d Don't bother returning serverRotations if no free look 2023-06-12 19:03:03 -05:00
Brady
c217a34f13 🐛 fix batch render color bug by backporting 1.17+ render code 2023-06-12 17:06:11 -05:00
leijurv
15182cb151 Merge pull request #3984 from cabaletta/pr/bugfix/censorCoordinatesRecalc
Fix `censorCoordinates` recalc bug
2023-06-12 14:57:02 -07:00
Brady
8a65a1cfc5 🐛 fix incorrect comparison operator 2023-06-12 16:52:20 -05:00
Brady
5bdd5b0c0d 👌 appease leijurv 2023-06-12 16:50:02 -05:00
leijurv
298256197b Merge pull request #3983 from John200410/1.18.2
Add proper level height to GoalXZ rendering (1.18+)
2023-06-12 14:26:05 -07:00
Brady
7da802a238 Fix censorCoordinates recalc bug
Adds `equals` and `toString` implementations where needed
Replaces `toString` equality check with actual `equals` check in `forceRevalidate`
2023-06-12 16:21:05 -05:00
John200410
de80527702 Add proper level height to GoalXZ rendering 2023-06-12 17:16:07 -04:00
leijurv
e334aae608 Merge pull request #3974 from cabaletta/pr/sel-shape-masks
Add sphere and cylinder build commands to sel
2023-06-12 12:57:01 -07:00
leijurv
c48a9d98b4 Merge pull request #3982 from cabaletta/pr/batchRender
Batch Rendering
2023-06-12 12:56:05 -07:00
Brady
ed34ae73c0 Fix Mode.NONE target invalidation 2023-06-12 13:46:10 -05:00
Brady
c8a0ae9e10 Do nudgeToLevel and randomLooking when using freeLook 2023-06-12 13:44:08 -05:00
Brady
67a085c95f Batch together GL_LINES draw calls 2023-06-12 13:16:37 -05:00
Brady
1d5ee079b4 Read serverRotation from packet and invalidate on world load 2023-06-12 12:11:50 -05:00
Leijurv
410cfcf21a typo, fix crash at end of path 2023-06-11 22:40:35 -07:00
Leijurv
4148b98187 typo 2023-06-11 22:22:49 -07:00
Leijurv
b9054cdfc9 use more fireworks 2023-06-11 22:22:01 -07:00
Leijurv
35a996e2b0 firework more often 2023-06-11 20:59:28 -07:00
Brady
bb36ebfc0c Use IPlayerContext for all RotationUtils methods
Deprecates all old overloads
2023-06-11 20:09:37 -05:00
Brady
a7d15d1e32 Consistent naming and comments for clarification 2023-06-11 18:43:48 -05:00
Brady
4317dca024 Determine target mode (client/server) in updateTarget 2023-06-11 18:35:34 -05:00
Wagyourtail
666a890088 fix frog 2023-06-11 16:46:15 -06:00
Leijurv
c48c2aa45c allow even more desperate motion 2023-06-11 13:57:21 -07:00
Brady
77ca36c794 Use playerRotations in reachableOffset 2023-06-11 15:49:04 -05:00
Leijurv
a602863426 better elytra 2023-06-11 12:49:31 -07:00
Brady
a09e63d6aa appease codacy 2023-06-11 13:14:52 -05:00
Brady
fbe28e397e Make setting disabled by default 2023-06-11 12:38:13 -05:00
Brady
364ae87ef8 Add blockFreeLook setting 2023-06-11 12:36:53 -05:00
Brady
ffd00080f2 Mask binary operators 2023-06-11 11:27:51 -05:00
Brady
94d757104b Clean ups 2023-06-11 11:24:31 -05:00
Leijurv
705a5a0712 elytra prototype mvp 2023-06-11 00:33:35 -07:00
Brady
9729e63d98 Create and utilize new Mask type
Added factory method to `MaskSchematic` for creation using a `Mask`
Sort-of mocks the schematic structure, without the block states ofc
2023-06-09 17:25:29 -05:00
Wagyourtail
b389b573e5 add frog 2023-06-09 08:27:38 -06:00
Brady
f232bbdb15 Clean up formatting 2023-06-08 16:36:32 -05:00
Brady
26574b4a9b Add optional axis parameter for #sel cyl 2023-06-08 16:32:33 -05:00
Brady
a1b1ef88cf Use a Supplier to mimic a switch expression 2023-06-08 15:46:32 -05:00
Brady
b6c52cd8e1 Cache mask in a boolean[][][] 2023-06-08 11:52:13 -05:00
Wagyourtail
eb28298983 confirm release version works 2023-06-07 17:03:21 -06:00
Brady
34abbfb5da appease codacy 2023-06-07 17:38:26 -05:00
Brady
0d14bde583 Working sphere/cylinder build commands for #sel 2023-06-07 16:31:52 -05:00
leijurv
4b0a8eb166 Merge pull request #3966 from cabaletta/pr/setting-metadata
Setting Field Metadata
2023-06-04 16:59:14 -07:00
Brady
80ec9023ce Replace JAVA_ONLY_SETTINGS array with @JavaOnly annotation 2023-06-04 12:31:34 -05:00
Wagyourtail
336b2c2798 pre.7 2023-05-31 07:54:16 -04:00
leijurv
5dd10b6e81 Merge pull request #3946 from ZacSharp/pr/farm/addCocoa
Make cocoa farmable
2023-05-23 17:31:06 -07:00
leijurv
415fa048ba Merge pull request #3924 from ZacSharp/pr/blockOptionalMetaProperties
Extend BlockOptionalMeta parsing to parse block properties
2023-05-23 15:57:10 -07:00
leijurv
a1661e94b5 Merge pull request #3923 from ZacSharp/pr/mine/maxYLevelWhileMining
 Add maxYLevelWhileMining setting
2023-05-23 15:56:11 -07:00
Wagyourtail
63d0064d69 pre.2 2023-05-18 22:37:07 -06:00
Wagyourtail
43eb4e3581 prepare for 1.20 2023-05-10 16:17:40 -06:00
ZacSharp
c45a714b77 Fix considering states unplaceable even if buildIgnoreProperties allows it 2023-05-08 03:51:38 +02:00
ZacSharp
271c2ff636 Extend BlockOptionalMeta parsing to parse block properties 2023-04-24 23:49:23 +02:00
ZacSharp
e4cd35ac33 Add maxYLevelWhileMining setting 2023-04-24 23:11:55 +02:00
ZacSharp
e8a4a9fdac Make cocoa farmable 2023-04-24 16:23:38 +02:00
Leijurv
7bb311687b v1.9.3 2023-04-13 14:03:51 -07:00
leijurv
5f2eadbfa6 download links for 1.19.2 2023-04-11 20:36:29 -07:00
Leijurv
6eeeeb3a1b v1.9.4 2023-04-11 19:50:51 -07:00
leijurv
35ab687d5e 1.9.3 download links 2023-04-11 16:00:22 -07:00
leijurv
3ff2bd4f17 Merge pull request #3908 from wagyourtail/patch-3
Update Setup.md
2023-04-11 14:47:59 -07:00
Wagyourtail
f334b3b765 update setup.md 2023-04-10 18:40:48 -07:00
leijurv
e3c6b312ef Merge pull request #3900 from wagyourtail/1.19.2
remove 1.19.3 method in blockOptionalMeta
2023-04-02 17:57:27 -07:00
Wagyourtail
acce20c573 remove 1.19.3 method in blockOptionalMeta 2023-04-02 17:01:57 -07:00
Leijurv
e4d725d9aa Revert "loottables broke & #click not working"
This reverts commit 3e082b21d5.
2023-04-02 15:24:50 -07:00
Leijurv
0cf89e0b2a Revert "fix items and #click"
This reverts commit 4168401aa1.
2023-04-02 15:20:26 -07:00
leijurv
ff1732011e vid is outdated and doesn't get to the point fast enough, so let's move it lower down 2023-03-20 22:07:51 -07:00
leijurv
c5721fb7e3 Merge pull request #3878 from wagyourtail/1.12/fix-wp-c
make wp c not throw npe on invalid tag name
2023-03-14 18:40:41 -07:00
leijurv
3200d976d7 1.19.4 2023-03-14 18:35:15 -07:00
Wagyourtail
6698505dd8 make wp c not throw npe on invalid tag name 2023-03-13 15:31:18 -07:00
Leijurv
790a4f6769 command to load settings from a specific file 2023-03-01 00:25:49 -08:00
leijurv
c9d7a5bea6 kami blue to lambda 2023-02-28 23:56:34 -08:00
Leijurv
f1ead19b6e option to only move inventory when stationary 2023-02-28 23:44:33 -08:00
ZacSharp
9efc512253 Make tab completion usable
Now behaves almost identical to vanilla tab completion
2023-02-19 19:27:39 +01:00
Leijurv
174bdd2307 overhaul readme 2023-02-18 16:42:05 -08:00
Leijurv
24e047c12e v1.8.4 2023-02-18 15:41:19 -08:00
Leijurv
6e5fec576f v1.7.3 2023-02-18 15:38:40 -08:00
Leijurv
1e7e504650 v1.6.4 2023-02-18 15:37:37 -08:00
Leijurv
814c17522a changed it back to the old way by manually renaming the release files 2023-02-18 15:20:50 -08:00
Leijurv
b622adf300 ugh why was this changed since 1.18 2023-02-18 15:13:15 -08:00
Leijurv
c1b58f8a01 link 1.19 2023-02-18 15:12:17 -08:00
leijurv
c1a9621dfa Merge pull request #3768 from wagyourtail/1.12/fasterworldscanner
replace the world scanner with a 500x faster one
2023-01-28 10:18:59 -08:00
Wagyourtail
6de266a106 remove extra method call 2023-01-28 01:39:58 -07:00
Wagyourtail
334d9c119b remove the allocation of an intlist per section 2023-01-28 00:44:54 -07:00
leijurv
1a2c30b4e3 Merge pull request #3803 from Entropy5/master
Litematica x BuildOnlySelection support
2023-01-27 23:34:35 -08:00
Entropy5
413cc1469f zac suggestion (number 2), test ongoing 2023-01-27 14:23:08 +01:00
Wagyourtail
7404414e7a less impure 2023-01-20 23:43:00 -07:00
Entropy5
49b1f3528b Merge remote-tracking branch 'origin/master' 2023-01-17 06:33:09 +01:00
Entropy5
26cceede15 litematica support for buildonlyselection, mostly rycbars 2023-01-17 06:33:01 +01:00
Wagyourtail
b71c9e776a oops didn't mean to commit that 2022-12-28 01:09:46 -07:00
Wagyourtail
746faf6df6 faster section reorder 2022-12-28 01:05:17 -07:00
Wagyourtail
a367031fe2 Revert "sacrifice a bit of speed for better block ordering"
This reverts commit e55db05f20.
2022-12-28 00:03:58 -07:00
Wagyourtail
853dadd906 Merge remote-tracking branch 'origin/master' into 1.12/fasterworldscanner 2022-12-27 23:58:13 -07:00
Wagyourtail
e55db05f20 sacrifice a bit of speed for better block ordering 2022-12-27 23:30:35 -07:00
Wagyourtail
98a748afb3 fix stream limit. immutable's in BOML 2022-12-27 22:42:38 -07:00
William Gray
c04eb066cb Update src/main/java/baritone/cache/FasterWorldScanner.java
Co-authored-by: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
2022-12-28 01:06:10 +00:00
Wagyourtail
6260c6d3d7 apply suggestions 2022-12-24 12:11:26 -07:00
Wagyourtail
ce1fb49252 spiral always pick closest chunk first now 2022-12-24 11:52:48 -07:00
Wagyourtail
ecdec87e7a fix using wrong functions in scan 2022-12-24 11:43:54 -07:00
Wagyourtail
96f432d2d5 add comment 2022-12-23 17:26:46 -07:00
Wagyourtail
0ae59755e3 make limit not happen if it shouldn't 2022-12-23 17:25:23 -07:00
Wagyourtail
12b596e536 fix spiral 2022-12-23 17:10:37 -07:00
Wagyourtail
0b6088cd2d fix getting the block from the pallete, and change the chunk scan order to spiral out 2022-12-23 16:58:10 -07:00
Wagyourtail
1736f2ffc7 replace the world scanner with a 500x faster one 2022-12-23 16:34:49 -07:00
181 changed files with 7966 additions and 1595 deletions

View File

@@ -13,14 +13,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: gradle
@@ -28,16 +28,16 @@ jobs:
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)"
run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)"
- name: Archive Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: dist/
- name: Archive mapping.txt
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Mappings
path: mapping/

View File

@@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Grant execute permission for gradlew

8
.gitignore vendored
View File

@@ -37,4 +37,10 @@ baritone_Client.launch
.vscode/launch.json
.architectury-transformer
mapping
mapping
libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
libs/java-objc-bridge-1.1.jar
mapping

View File

@@ -6,6 +6,7 @@ RUN apt update -y
RUN apt install \
openjdk-17-jdk \
git \
--assume-yes
COPY . /code

View File

@@ -4,13 +4,16 @@
</p>
<p align="center">
<a href="https://github.com/cabaletta/baritone/tree/master"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.13.2"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.14.4"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.15.2"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.16.5"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.17.1"><img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.18.2"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.16.5-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.17.1-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.18.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.4-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.20.1-brightgreen.svg" alt="Minecraft"/></a>
</p>
<p align="center">
@@ -28,12 +31,13 @@
<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"/>
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code&style=flat" alt="Lines of Code"/>
<img src="https://img.shields.io/badge/Badges-36-blue.svg" alt="yes"/>
</p>
<p align="center">
<a href="https://impactclient.net/"><img src="https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3%20/%20v1.6.3-brightgreen.svg" alt="Impact integration"/></a>
<a href="https://github.com/kami-blue/client"><img src="https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green" alt="KAMI Blue integration"/></a>
<a href="https://github.com/lambda-client/lambda"><img src="https://img.shields.io/badge/Lambda%20integration-v1.2.17-brightgreen.svg" alt="Lambda integration"/></a>
<a href="https://github.com/fr1kin/ForgeHax/"><img src="https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg" alt="ForgeHax integration"/></a>
<a href="https://aristois.net/"><img src="https://img.shields.io/badge/Aristois%20add--on%20integration-v1.6.3-green.svg" alt="Aristois add-on integration"/></a>
<a href="https://rootnet.dev/"><img src="https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg" alt="rootNET integration"/></a>
@@ -42,27 +46,36 @@
</p>
<p align="center">
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
</p>
A Minecraft pathfinder bot.
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
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.
**Quick download links:**
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
| Forge | Fabric |
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.19/baritone-api-forge-1.2.19.jar) | |
| [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-forge-1.6.5.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-fabric-1.6.5.jar) |
| [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) |
| [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.6/baritone-api-forge-1.8.6.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.6/baritone-api-fabric-1.8.6.jar) |
| [1.19.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-forge-1.9.4.jar) | [1.19.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-fabric-1.9.4.jar) |
| [1.19.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-forge-1.9.1.jar) | [1.19.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-fabric-1.9.1.jar) |
| [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) |
| [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) |
| [1.20.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-forge-1.10.2.jar) | [1.20.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-fabric-1.10.2.jar) |
| [1.20.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-forge-1.10.2.jar) | [1.20.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-fabric-1.10.2.jar) |
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.17/baritone-api-forge-1.2.17.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). It supports 1.19.4 and 1.20.1, Forge or Fabric. If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ).
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)**.
**How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa). Also try `#elytra` for Elytra flying in the Nether using fireworks.
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) 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.2/baritone-api-fabric-1.7.2.jar)**.
If you need Forge or Fabric 1.18.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.3) and get the `api-forge` or `api-fabric` jar. **For 1.18.2 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-fabric-1.8.3.jar)**. **For 1.18.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-forge-1.8.3.jar)**.
For other versions of Minecraft or more complicated situations or for development, see [Installation & setup](SETUP.md). Also consider just installing [Impact](https://impactclient.net/), which comes with Baritone and is easier to install than wrangling with version JSONs and zips. For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#6313 on Baritone which I recommend.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).

View File

@@ -43,13 +43,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone
## Command Line
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16 for 1.17.1, and JDK 17 for 1.18.1.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16+ for 1.17.1, and JDK 17+ for 1.18.1.
To check which java you are using do
`java -version` in a command prompt or terminal.
If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
Open JDK download: https://openjdk.java.net/install/
Download java: https://adoptium.net/
#### macOS guide
In order to get JDK 8, Try running the following command:
`% /usr/libexec/java_home -V`
@@ -66,68 +66,13 @@ In order to get JDK 8 running in the **current terminal window** you will have t
To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc
Setting up the Environment:
### Building Baritone
```
$ gradlew setupDecompWorkspace
$ gradlew --refresh-dependencies
```
These tasks depend on the minecraft version, but are (for the most part) standard for building mods.
Building Baritone:
```
$ gradlew build
```
For minecraft 1.15.2+, run the following instead to include the Forge jars:
```
$ gradlew build -Pbaritone.forge_build
```
Do this instead for Fabric jars:
```
$ gradlew build -Pbaritone.fabric_build
```
Running Baritone:
```
$ gradlew runClient
```
For information on how to build baritone, see [Building Baritone](#building-baritone)
for more details, see [the build ci action](/.github/workflows/gradle_build.yml)
## IntelliJ
- Open the project in IntelliJ as a Gradle project
![Image](https://i.imgur.com/jw7Q6vY.png)
- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns`
![Image](https://i.imgur.com/QEfVvWP.png)
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
![Image](https://i.imgur.com/3V7EdWr.png)
- Select the "Minecraft Client" launch config
![Image](https://i.imgur.com/1qz2QGV.png)
- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config
![Image](https://i.imgur.com/s4ly0ZF.png)
- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`.
![Image](https://i.imgur.com/hrLhG9u.png)
## IntelliJ
- Navigate to the gradle tasks on the right tab as follows
![Image](https://i.imgur.com/PE6r9iN.png)
- Double click on **build** to run it
- depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working

View File

@@ -21,17 +21,29 @@ allprojects {
apply plugin: "maven-publish"
archivesBaseName = rootProject.archives_base_name
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
def vers = ""
try {
vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim()
} catch (Exception e) {
println "Version detection failed: " + e
}
if (!vers.startsWith("v")) {
println "git doesn't appear to be installed!"
println "using version number: " + rootProject.mod_version
version = rootProject.mod_version
} else {
version = vers.substring(1)
println "Detected version " + version
}
group = rootProject.maven_group
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = targetCompatibility = JavaVersion.toVersion(project.java_version)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(sourceCompatibility.majorVersion.toInteger()))
}
}
repositories {
maven {
@@ -59,33 +71,48 @@ allprojects {
}
}
mavenCentral()
maven {
name = 'babbaj-repo'
url = 'https://babbaj.github.io/maven/'
}
}
dependencies {
minecraft "net.minecraft:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings "net.fabricmc:intermediary:${rootProject.minecraft_version}:v2"
mappings "net.minecraft:minecraft:${rootProject.minecraft_version}:client-mappings"
mappings "org.parchmentmc.data:parchment-1.19.2:2022.11.27@zip"
implementation "org.spongepowered:mixin:0.8.5"
implementation "org.ow2.asm:asm:9.3"
compileOnly "org.spongepowered:mixin:0.8"
compileOnly "org.ow2.asm:asm:9.7"
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
//launchImplementation('dev.babbaj:nether-pathfinder:1.3.0')
implementation "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
}
unimined.minecraft(sourceSets.main, true) {
version rootProject.minecraft_version
mappings {
intermediary()
mojmap()
parchment("1.20.6", "2024.05.01")
devFallbackNamespace "official"
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
def targetVersion = 17
def targetVersion = project.java_version.toInteger()
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
minecraft {
unimined.minecraft {
runs.off = true
defaultRemapJar = false
}
archivesBaseName = archivesBaseName + "-common"
@@ -125,15 +152,10 @@ jar {
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
}
remapJar {
targetNamespace = "named"
fallbackTargetNamespace = "intermediary"
}
javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true
options.encoding "UTF-8" // allow emoji in comments :^)
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
}
}

View File

@@ -29,12 +29,16 @@ repositories {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'NeoForgedMaven'
url = 'https://maven.neoforged.net/'
}
mavenCentral()
}
dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '0.3.4'
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.2.9'
}

View File

@@ -36,8 +36,8 @@ import java.nio.file.Paths;
class BaritoneGradleTask extends DefaultTask {
protected static final String
PROGUARD_ZIP = "proguard.zip",
PROGUARD_JAR = "proguard.jar",
PROGUARD_ZIP = "proguard-%s.zip",
PROGUARD_JAR = "proguard-%s.jar",
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
PROGUARD_CONFIG_DEST = "template.pro",
PROGUARD_API_CONFIG = "api.pro",

View File

@@ -18,31 +18,31 @@
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.tasks.Input;
import org.gradle.api.tasks.SourceSetContainer;
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.jvm.Jvm;
import xyz.wagyourtail.unimined.api.Constants;
import xyz.wagyourtail.unimined.api.minecraft.EnvType;
import xyz.wagyourtail.unimined.api.minecraft.MinecraftProvider;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.jvm.toolchain.JavaToolchainService;
import xyz.wagyourtail.unimined.api.UniminedExtension;
import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
/**
* @author Brady
* @since 10/11/2018
@@ -50,18 +50,13 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
public class ProguardTask extends BaritoneGradleTask {
@Input
private String url;
private String proguardVersion;
public String getUrl() {
return url;
public String getProguardVersion() {
return proguardVersion;
}
@Input
private String extract;
public String getExtract() {
return extract;
}
private List<String> requiredLibraries;
@TaskAction
protected void exec() throws Exception {
@@ -69,23 +64,26 @@ public class ProguardTask extends BaritoneGradleTask {
super.verifyArtifacts();
// "Haha brady why don't you make separate tasks"
processArtifact();
downloadProguard();
extractProguard();
generateConfigs();
processArtifact();
proguardApi();
proguardStandalone();
cleanup();
}
MinecraftProvider<?, ?> provider = this.getProject().getExtensions().getByType(MinecraftProvider.class);
UniminedExtension ext = getProject().getExtensions().getByType(UniminedExtension.class);
SourceSetContainer sourceSets = getProject().getExtensions().getByType(SourceSetContainer.class);
private File getMcJar() {
return provider.getMinecraftWithMapping(EnvType.COMBINED, provider.getMcPatcher().getProdNamespace(), provider.getMcPatcher().getProdFallbackNamespace()).toFile();
MinecraftConfig mcc = ext.getMinecrafts().get(sourceSets.getByName("main"));
return mcc.getMinecraft(mcc.getMcPatcher().getProdNamespace(), mcc.getMcPatcher().getProdNamespace()).toFile();
}
private boolean isMcJar(File f) {
return this.getProject().getConfigurations().getByName(Constants.MINECRAFT_COMBINED_PROVIDER).getFiles().contains(f);
MinecraftConfig mcc = ext.getMinecrafts().get(sourceSets.getByName("main"));
return mcc.isMinecraftJar(f.toPath());
}
private void processArtifact() throws Exception {
@@ -93,124 +91,41 @@ public class ProguardTask extends BaritoneGradleTask {
Files.delete(this.artifactUnoptimizedPath);
}
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), List.of(), false);
}
private void downloadProguard() throws Exception {
Path proguardZip = getTemporaryFile(PROGUARD_ZIP);
Path proguardZip = getTemporaryFile(String.format(PROGUARD_ZIP, proguardVersion));
if (!Files.exists(proguardZip)) {
write(new URL(this.url).openStream(), proguardZip);
write(new URL(String.format("https://github.com/Guardsquare/proguard/releases/download/v%s/proguard-%s.zip", proguardVersion, proguardVersion)).openStream(), proguardZip);
}
}
private void extractProguard() throws Exception {
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
Path proguardJar = getTemporaryFile(String.format(PROGUARD_JAR, proguardVersion));
if (!Files.exists(proguardJar)) {
ZipFile zipFile = new ZipFile(getTemporaryFile(PROGUARD_ZIP).toFile());
ZipEntry zipJarEntry = zipFile.getEntry(this.extract);
ZipFile zipFile = new ZipFile(getTemporaryFile(String.format(PROGUARD_ZIP, proguardVersion)).toFile());
ZipEntry zipJarEntry = zipFile.getEntry(String.format("proguard-%s/lib/proguard.jar", proguardVersion));
write(zipFile.getInputStream(zipJarEntry), proguardJar);
zipFile.close();
}
}
private String getJavaBinPathForProguard() throws Exception {
String path;
try {
path = findJavaPathByGradleConfig();
if (path != null) return path;
}
catch (Exception ex) {
System.err.println("Unable to find java by javaCompile options");
ex.printStackTrace();
private JavaLauncher getJavaLauncherForProguard() {
var toolchains = getProject().getExtensions().getByType(JavaToolchainService.class);
var toolchain = toolchains.launcherFor((spec) -> {
spec.getLanguageVersion().set(JavaLanguageVersion.of(getProject().findProperty("java_version").toString()));
}).getOrNull();
if (toolchain == null) {
throw new IllegalStateException("Java toolchain not found");
}
try {
path = findJavaByJavaHome();
if (path != null) return path;
}
catch(Exception ex) {
System.err.println("Unable to find java by JAVA_HOME");
ex.printStackTrace();
}
path = findJavaByGradleCurrentRuntime();
if (path != null) return path;
throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," +
" JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)");
}
private String findJavaByGradleCurrentRuntime() {
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
if (this.validateJavaVersion(path)) {
System.out.println("Using Gradle's runtime Java for ProGuard");
return path;
}
return null;
}
private String findJavaByJavaHome() {
final String javaHomeEnv = System.getenv("JAVA_HOME");
if (javaHomeEnv != null) {
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
if (this.validateJavaVersion(path)) {
System.out.println("Detected Java path by JAVA_HOME");
return path;
}
}
return null;
}
private String findJavaPathByGradleConfig() {
final TaskCollection<JavaCompile> javaCompiles = super.getProject().getTasks().withType(JavaCompile.class);
final JavaCompile compileTask = javaCompiles.iterator().next();
final ForkOptions forkOptions = compileTask.getOptions().getForkOptions();
if (forkOptions != null) {
String javacPath = forkOptions.getExecutable();
if (javacPath != null) {
File javacFile = new File(javacPath);
if (javacFile.exists()) {
File[] maybeJava = javacFile.getParentFile().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.equals("java");
}
});
if (maybeJava != null && maybeJava.length > 0) {
String path = maybeJava[0].getAbsolutePath();
if (this.validateJavaVersion(path)) {
System.out.println("Detected Java path by forkOptions");
return path;
}
}
}
}
}
return null;
}
private boolean validateJavaVersion(String java) {
//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;
return toolchain;
}
private void generateConfigs() throws Exception {
Files.copy(getRootRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
Files.copy(getRootRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), StandardCopyOption.REPLACE_EXISTING);
// Setup the template that will be used to derive the API and Standalone configs
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
@@ -233,11 +148,11 @@ public class ProguardTask extends BaritoneGradleTask {
{
// Discover all of the libraries that we will need to acquire from gradle
final Stream<File> dependencies = acquireDependencies()
// remove MCP mapped jar, and nashorn
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
// remove MCP mapped jar, and nashorn
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
libraries = dependencies
.map(f -> isMcJar(f) ? mcJar : f);
.map(f -> isMcJar(f) ? mcJar : f);
}
libraries.forEach(f -> {
template.add(2, "-libraryjars '" + f + "'");
@@ -250,29 +165,48 @@ public class ProguardTask extends BaritoneGradleTask {
api.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("api.txt")));
// API config doesn't require any changes from the changes that we made to the template
Files.write(getTemporaryFile(compType+PROGUARD_API_CONFIG), api);
Files.write(getTemporaryFile(compType + PROGUARD_API_CONFIG), api);
// For the Standalone config, don't keep the API package
List<String> standalone = new ArrayList<>(template);
standalone.removeIf(s -> s.contains("# this is the keep api"));
standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("standalone.txt")));
Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone);
Files.write(getTemporaryFile(compType + PROGUARD_STANDALONE_CONFIG), standalone);
}
private Stream<File> acquireDependencies() {
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
.stream()
.filter(File::isFile);
.stream()
.filter(File::isFile);
}
private void proguardApi() throws Exception {
runProguard(getTemporaryFile(compType+PROGUARD_API_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
runProguard(getTemporaryFile(compType + PROGUARD_API_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), List.of(), false);
}
private void proguardStandalone() throws Exception {
runProguard(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
runProguard(getTemporaryFile(compType + PROGUARD_STANDALONE_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), List.of(), false);
}
private static final class Pair<A, B> {
public final A a;
public final B b;
private Pair(final A a, final B b) {
this.a = a;
this.b = b;
}
@Override
public String toString() {
return "Pair{" +
"a=" + this.a +
", " +
"b=" + this.b +
'}';
}
}
private void cleanup() {
@@ -281,51 +215,25 @@ public class ProguardTask extends BaritoneGradleTask {
} catch (IOException ignored) {}
}
public void setUrl(String url) {
this.url = url;
public void setProguardVersion(String url) {
this.proguardVersion = url;
}
public void setExtract(String extract) {
this.extract = extract;
}
private void runProguard(Path config) throws Exception {
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
if (Files.exists(this.proguardOut)) {
Files.delete(this.proguardOut);
}
// Make paths relative to work directory; fixes spaces in path to config, @"" doesn't work
Path workingDirectory = getTemporaryFile("");
Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR));
config = workingDirectory.relativize(config);
// Honestly, if you still have spaces in your path at this point, you're SOL.
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
.directory(workingDirectory.toFile()) // Set the working directory to the temporary folder]
.start();
getProject().javaexec(spec -> {
spec.workingDir(workingDirectory.toFile());
spec.args("@" + workingDirectory.relativize(config));
spec.classpath(getTemporaryFile(String.format(PROGUARD_JAR, proguardVersion)));
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
this.printOutputLog(p.getInputStream(), System.out);
this.printOutputLog(p.getErrorStream(), System.err);
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
int exitCode = p.waitFor();
if (exitCode != 0) {
throw new IllegalStateException("Proguard exited with code " + exitCode);
}
spec.executable(getJavaLauncherForProguard().getExecutablePath().getAsFile());
}).assertNormalExitValue().rethrowFailure();
}
private void printOutputLog(InputStream stream, PrintStream outerr) {
new Thread(() -> {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
String line;
while ((line = reader.readLine()) != null) {
outerr.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
}

View File

@@ -39,10 +39,11 @@ import java.util.stream.Collectors;
*/
public class Determinizer {
public static void determinize(String inputPath, String outputPath) throws IOException {
public static void determinize(String inputPath, String outputPath, List<File> toInclude, boolean doForgeReplacementOfMetaInf) throws IOException {
System.out.println("Running Determinizer");
System.out.println(" Input path: " + inputPath);
System.out.println(" Output path: " + outputPath);
System.out.println(" Shade: " + toInclude);
try (
JarFile jarFile = new JarFile(new File(inputPath));
@@ -64,14 +65,35 @@ public class Determinizer {
clone.setTime(42069);
jos.putNextEntry(clone);
if (entry.getName().endsWith(".refmap.json")) {
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
jos.write(writeSorted(object).getBytes());
JsonElement json = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry)));
jos.write(writeSorted(json).getBytes());
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && doForgeReplacementOfMetaInf) { // only replace for forge jar
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
copy(jarFile.getInputStream(entry), cancer);
String manifest = new String(cancer.toByteArray());
if (!manifest.contains("baritone.launch.tweaker.BaritoneTweaker")) {
throw new IllegalStateException("unable to replace");
}
manifest = manifest.replace("baritone.launch.tweaker.BaritoneTweaker", "org.spongepowered.asm.launch.MixinTweaker");
jos.write(manifest.getBytes());
} else {
copy(jarFile.getInputStream(entry), jos);
}
}
for (File file : toInclude) {
try (JarFile mixin = new JarFile(file)) {
for (JarEntry entry : mixin.stream().sorted(Comparator.comparing(JarEntry::getName)).collect(Collectors.toList())) {
if (entry.getName().startsWith("META-INF") && !entry.getName().startsWith("META-INF/services")) {
continue;
}
jos.putNextEntry(entry);
copy(mixin.getInputStream(entry), jos);
}
}
}
jos.finish();
}
System.out.println("Done with determinizer");
}
private static void copy(InputStream is, OutputStream os) throws IOException {
@@ -82,7 +104,7 @@ public class Determinizer {
}
}
private static String writeSorted(JsonObject in) throws IOException {
private static String writeSorted(JsonElement in) throws IOException {
StringWriter writer = new StringWriter();
JsonWriter jw = new JsonWriter(writer);
ORDERED_JSON_WRITER.write(jw, in);

View File

@@ -19,13 +19,15 @@ import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"
id "com.github.johnrengelman.shadow" version "8.0.0"
}
archivesBaseName = archivesBaseName + "-fabric"
minecraft {
fabric()
unimined.minecraft {
fabric {
loader project.fabric_version
}
}
configurations {
@@ -36,8 +38,6 @@ configurations {
}
dependencies {
fabric "net.fabricmc:fabric-loader:${project.fabric_version}"
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
@@ -45,6 +45,7 @@ dependencies {
common sourceSet.output
shadowCommon sourceSet.output
}
include "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
processResources {
@@ -57,17 +58,17 @@ processResources {
shadowJar {
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
archiveClassifier.set null
}
jar {
classifier "dev"
archiveClassifier.set "dev"
}
components.java {
@@ -77,8 +78,7 @@ components.java {
}
task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar'
proguardVersion "7.4.2"
compType "fabric"
}
@@ -100,4 +100,4 @@ publishing {
repositories {
// Add repositories to publish to here.
}
}
}

View File

@@ -1,4 +1,3 @@
{
"schemaVersion": 1,
"id": "baritone",
@@ -25,7 +24,7 @@
],
"depends": {
"fabricloader": ">=0.11.0",
"minecraft": "1.19.4"
"fabricloader": ">=0.14.22",
"minecraft": "1.21"
}
}

View File

@@ -19,15 +19,15 @@ import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"
id "com.github.johnrengelman.shadow" version "8.0.0"
}
archivesBaseName = archivesBaseName + "-forge"
minecraft {
forge {
devFallbackNamespace = "intermediary"
mixinConfig = ["mixins.baritone.json"]
unimined.minecraft {
minecraftForge {
loader project.forge_version
mixinConfig ["mixins.baritone.json"]
}
}
@@ -45,8 +45,6 @@ configurations {
}
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
@@ -54,6 +52,7 @@ dependencies {
common sourceSet.output
shadowCommon sourceSet.output
}
shadowCommon "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
processResources {
@@ -66,17 +65,17 @@ processResources {
shadowJar {
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
archiveClassifier.set null
}
jar {
classifier "dev"
archiveClassifier.set "dev"
manifest {
attributes(
@@ -96,8 +95,7 @@ components.java {
}
task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar'
proguardVersion "7.4.2"
compType "forge"
}

View File

@@ -6,7 +6,7 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[33,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[48,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="https://raw.githubusercontent.com/cabaletta/baritone/1.16.2/LICENSE"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.19.3]"
versionRange="[1.21]"
ordering="NONE"
side="BOTH"
side="BOTH"

View File

@@ -1,9 +1,19 @@
org.gradle.jvmargs=-Xmx4G
mod_version=1.9.2
available_loaders=fabric,forge,neoforge,tweaker
mod_version=1.11.0
maven_group=baritone
archives_base_name=baritone
minecraft_version=1.19.4
forge_version=1.19.3-44.0.1
fabric_version=0.14.11
java_version=21
minecraft_version=1.21
forge_version=51.0.16
neoforge_version=20-beta
fabric_version=0.15.11
nether_pathfinder_version=1.4.1

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )

130
neoforge/build.gradle Normal file
View File

@@ -0,0 +1,130 @@
/*
* 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/>.
*/
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
plugins {
id "com.github.johnrengelman.shadow" version "8.0.0"
}
archivesBaseName = archivesBaseName + "-neoforge"
unimined.minecraft {
neoForged {
loader project.neoforge_version
mixinConfig ["mixins.baritone.json"]
}
minecraftRemapper.config {
// neoforge adds 1 conflict, where 2 interfaces have a method with the same name on yarn/mojmap,
// but the method has different names in the intermediary mappings.
// this is a conflict because they have a class that extends both interfaces.
// this shouldn't be a problem as long as named mappings don't make the name of those 2 methods different.
ignoreConflicts(true)
}
}
//loom {
// forge {
// mixinConfig 'mixins.baritone.json'
// }
//}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
}
dependencies {
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
if (sourceSet == rootProject.sourceSets.schematica_api) continue
common sourceSet.output
shadowCommon sourceSet.output
}
shadowCommon "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version
}
}
shadowJar {
configurations = [project.configurations.shadowCommon]
archiveClassifier.set "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}
jar {
archiveClassifier.set "dev"
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone',
'Implementation-Version': version,
)
}
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
task proguard(type: ProguardTask) {
proguardVersion "7.4.2"
compType "neoforge"
}
task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "neoforge"
}
build.finalizedBy(createDist)
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

View File

@@ -0,0 +1,18 @@
#
# 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/>.
#
loom.platform=forge

View File

@@ -0,0 +1,25 @@
/*
* 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.launch;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.Mod;
@Mod(value = "baritoe", dist = Dist.CLIENT)
public class BaritoneForgeModXD {
}

View File

@@ -0,0 +1,40 @@
# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[1,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="https://raw.githubusercontent.com/cabaletta/baritone/1.16.2/LICENSE"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="baritoe" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${version}" #mandatory
# A display name for the mod
displayName="Baritone" #mandatory
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://github.com/cabaletta/baritone" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
credits="Hat Gamers" #optional
# A text field displayed in the mod UI
authors="leijurv, Brady" #optional
# The description text for the mod (multi line!) (#mandatory)
description='''
A Minecraft pathfinder bot.
'''
[[dependencies.baritoe]]
modId="minecraft"
type="required"
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.21]"
ordering="NONE"
side="BOTH"

View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "null",
"pack_format": 8
}
}

View File

@@ -19,6 +19,8 @@
-dontwarn module-info
# we dont have forge
-dontwarn baritone.launch.BaritoneForgeModXD
# progard doesn't like signature polymorphism
-dontwarn java.lang.invoke.MethodHandle
# please do not change the comment below
-keep class baritone.api.** { *; } # this is the keep api

View File

@@ -42,10 +42,6 @@ pluginManagement {
rootProject.name = 'baritone'
include("tweaker")
if (System.getProperty("Baritone.enabled_platforms") == null) {
// System.setProperty("Baritone.enabled_platforms", "fabric,forge")
System.setProperty("Baritone.enabled_platforms", "fabric")
}
for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) {
for (platform in available_loaders.split(",")) {
include(platform)
}

View File

@@ -32,7 +32,7 @@ public final class BaritoneAPI {
static {
settings = new Settings();
SettingsUtil.readAndApply(settings);
SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME);
try {
provider = (IBaritoneProvider) Class.forName("baritone.BaritoneProvider").newInstance();

View File

@@ -88,6 +88,12 @@ public interface IBaritone {
*/
IGetToBlockProcess getGetToBlockProcess();
/**
* @return The {@link IElytraProcess} instance
* @see IElytraProcess
*/
IElytraProcess getElytraProcess();
/**
* @return The {@link IWorldProvider} instance
* @see IWorldProvider

View File

@@ -21,9 +21,12 @@ import baritone.api.cache.IWorldScanner;
import baritone.api.command.ICommand;
import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
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.
@@ -51,15 +54,13 @@ public interface IBaritoneProvider {
List<IBaritone> getAllBaritones();
/**
* 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}.
* Provides the {@link IBaritone} instance for a given {@link LocalPlayer}.
*
* @param player The player
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForPlayer(LocalPlayer player) {
for (IBaritone baritone : getAllBaritones()) {
for (IBaritone baritone : this.getAllBaritones()) {
if (Objects.equals(player, baritone.getPlayerContext().player())) {
return baritone;
}
@@ -67,6 +68,55 @@ public interface IBaritoneProvider {
return null;
}
/**
* Provides the {@link IBaritone} instance for a given {@link Minecraft}.
*
* @param minecraft The minecraft
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForMinecraft(Minecraft minecraft) {
for (IBaritone baritone : this.getAllBaritones()) {
if (Objects.equals(minecraft, baritone.getPlayerContext().minecraft())) {
return baritone;
}
}
return null;
}
/**
* Provides the {@link IBaritone} instance for the player with the specified connection.
*
* @param connection The connection
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForConnection(ClientPacketListener connection) {
for (IBaritone baritone : this.getAllBaritones()) {
final LocalPlayer player = baritone.getPlayerContext().player();
if (player != null && player.connection == connection) {
return baritone;
}
}
return null;
}
/**
* Creates and registers a new {@link IBaritone} instance using the specified {@link Minecraft}. The existing
* instance is returned if already registered.
*
* @param minecraft The minecraft
* @return The {@link IBaritone} instance
*/
IBaritone createBaritone(Minecraft minecraft);
/**
* Destroys and removes the specified {@link IBaritone} instance. If the specified instance is the
* {@link #getPrimaryBaritone() primary baritone}, this operation has no effect and will return {@code false}.
*
* @param baritone The baritone instance to remove
* @return Whether the baritone instance was removed
*/
boolean destroyBaritone(IBaritone baritone);
/**
* Returns the {@link IWorldScanner} instance. This is not a type returned by
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.

View File

@@ -17,22 +17,32 @@
package baritone.api;
import baritone.api.utils.Helper;
import baritone.api.utils.NotificationHelper;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.TypeUtils;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.client.GuiMessageTag;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -42,6 +52,7 @@ import java.util.function.Consumer;
* @author leijurv
*/
public final class Settings {
private static final Logger LOGGER = LoggerFactory.getLogger("Baritone");
/**
* Allow Baritone to break blocks
@@ -68,6 +79,16 @@ public final class Settings {
*/
public final Setting<Boolean> allowInventory = new Setting<>(false);
/**
* Wait this many ticks between InventoryBehavior moving inventory items
*/
public final Setting<Integer> ticksBetweenInventoryMoves = new Setting<>(1);
/**
* Come to a halt before doing any inventory moves. Intended for anticheat such as 2b2t
*/
public final Setting<Boolean> inventoryMoveOnlyIfStationary = new Setting<>(false);
/**
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
* <p>
@@ -364,6 +385,12 @@ public final class Settings {
*/
public final Setting<Float> blockReachDistance = new Setting<>(4.5f);
/**
* How many ticks between breaking a block and starting to break the next block. Default in game is 6 ticks.
* Values under 1 will be clamped. The delay only applies to non-instant (1-tick) breaks.
*/
public final Setting<Integer> blockBreakSpeed = new Setting<>(6);
/**
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
*/
@@ -609,6 +636,13 @@ public final class Settings {
*/
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
/**
* The chunk packer queue can never grow to larger than this, if it does, the oldest chunks are discarded
* <p>
* The newest chunks are kept, so that if you're moving in a straight line quickly then stop, your immediate render distance is still included
*/
public final Setting<Integer> chunkPackerQueueMaxSize = new Setting<>(2000);
/**
* Fill in blocks behind you
*/
@@ -710,6 +744,37 @@ public final class Settings {
*/
public final Setting<Boolean> freeLook = new Setting<>(true);
/**
* Break and place blocks without having to force the client-sided rotations. Requires {@link #freeLook}.
*/
public final Setting<Boolean> blockFreeLook = new Setting<>(false);
/**
* Automatically elytra fly without having to force the client-sided rotations.
*/
public final Setting<Boolean> elytraFreeLook = new Setting<>(true);
/**
* Forces the client-sided yaw rotation to an average of the last {@link #smoothLookTicks} of server-sided rotations.
*/
public final Setting<Boolean> smoothLook = new Setting<>(false);
/**
* Same as {@link #smoothLook} but for elytra flying.
*/
public final Setting<Boolean> elytraSmoothLook = new Setting<>(false);
/**
* The number of ticks to average across for {@link #smoothLook};
*/
public final Setting<Integer> smoothLookTicks = new Setting<>(5);
/**
* When true, the player will remain with its existing look direction as often as possible.
* Although, in some cases this can get it stuck, hence this setting to disable that behavior.
*/
public final Setting<Boolean> remainWithExistingLookDirection = new Setting<>(true);
/**
* Will cause some minor behavioral differences to ensure that Baritone works on anticheats.
* <p>
@@ -772,6 +837,11 @@ public final class Settings {
*/
public final Setting<Boolean> shortBaritonePrefix = new Setting<>(false);
/**
* Use a modern message tag instead of a prefix when logging to chat
*/
public final Setting<Boolean> useMessageTag = new Setting<>(false);
/**
* Echo commands to chat when they are run
*/
@@ -839,12 +909,24 @@ public final class Settings {
*/
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
/**
* Mine will not scan for or remember more than this many target locations.
* Note that the number of locations retrieved from cache is additionaly
* limited by {@link #maxCachedWorldScanCount}.
*/
public final Setting<Integer> mineMaxOreLocationsCount = new Setting<>(64);
/**
* 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);
/**
* Sets the maximum y level to mine ores at.
*/
public final Setting<Integer> maxYLevelWhileMining = new Setting<>(2031);
/**
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
*/
@@ -891,6 +973,11 @@ public final class Settings {
*/
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
/**
* Farming will scan for at most this many blocks.
*/
public final Setting<Integer> farmMaxScanSize = new Setting<>(256);
/**
* When the cache scan gives less blocks than the maximum threshold (but still above zero), scan the main world too.
* <p>
@@ -982,6 +1069,11 @@ public final class Settings {
*/
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
/**
* Multiply the cost of placing a block that's incorrect in the builder's schematic by this coefficient
*/
public final Setting<Double> placeIncorrectBlockPenaltyMultiplier = new Setting<>(2d);
/**
* When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
*/
@@ -1141,13 +1233,22 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
@JavaOnly
public final Setting<Consumer<Component>> logger = new Setting<>((msg) -> {
try {
final GuiMessageTag tag = useMessageTag.value ? Helper.MESSAGE_TAG : null;
Minecraft.getInstance().gui.getChat().addMessage(msg, null, tag);
} catch (Throwable t) {
LOGGER.warn("Failed to log message to chat: " + msg.getString(), t);
}
});
/**
* The function that is called when Baritone will send a desktop notification. This function can be added to
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
@JavaOnly
public final Setting<BiConsumer<String, Boolean>> notifier = new Setting<>(NotificationHelper::notify);
/**
@@ -1155,6 +1256,7 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
@JavaOnly
public final Setting<BiConsumer<Component, Component>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
/**
@@ -1287,6 +1389,120 @@ public final class Settings {
*/
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
/**
* The number of ticks of elytra movement to simulate while firework boost is not active. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraSimulationTicks = new Setting<>(20);
/**
* The maximum allowed deviation in pitch from a direct line-of-sight to the flight target. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraPitchRange = new Setting<>(25);
/**
* The minimum speed that the player can drop to (in blocks/tick) before a firework is automatically deployed.
*/
public final Setting<Double> elytraFireworkSpeed = new Setting<>(1.2);
/**
* The delay after the player's position is set-back by the server that a firework may be automatically deployed.
* Value is in ticks.
*/
public final Setting<Integer> elytraFireworkSetbackUseDelay = new Setting<>(15);
/**
* The minimum padding value that is added to the player's hitbox when considering which point to fly to on the
* path. High values can result in points not being considered which are otherwise safe to fly to. Low values can
* result in flight paths which are extremely tight, and there's the possibility of crashing due to getting too low
* to the ground.
*/
public final Setting<Double> elytraMinimumAvoidance = new Setting<>(0.2);
/**
* If enabled, avoids using fireworks when descending along the flight path.
*/
public final Setting<Boolean> elytraConserveFireworks = new Setting<>(false);
/**
* Renders the raytraces that are performed by the elytra fly calculation.
*/
public final Setting<Boolean> elytraRenderRaytraces = new Setting<>(false);
/**
* Renders the raytraces that are used in the hitbox part of the elytra fly calculation.
* Requires {@link #elytraRenderRaytraces}.
*/
public final Setting<Boolean> elytraRenderHitboxRaytraces = new Setting<>(false);
/**
* Renders the best elytra flight path that was simulated each tick.
*/
public final Setting<Boolean> elytraRenderSimulation = new Setting<>(true);
/**
* Automatically path to and jump off of ledges to initiate elytra flight when grounded.
*/
public final Setting<Boolean> elytraAutoJump = new Setting<>(false);
/**
* The seed used to generate chunks for long distance elytra path-finding in the nether.
* Defaults to 2b2t's nether seed.
*/
public final Setting<Long> elytraNetherSeed = new Setting<>(146008555100680L);
/**
* Whether nether-pathfinder should generate terrain based on {@link #elytraNetherSeed}.
* If false all chunks that haven't been loaded are assumed to be air.
*/
public final Setting<Boolean> elytraPredictTerrain = new Setting<>(false);
/**
* Automatically swap the current elytra with a new one when the durability gets too low
*/
public final Setting<Boolean> elytraAutoSwap = new Setting<>(true);
/**
* The minimum durability an elytra can have before being swapped
*/
public final Setting<Integer> elytraMinimumDurability = new Setting<>(5);
/**
* The minimum fireworks before landing early for safety
*/
public final Setting<Integer> elytraMinFireworksBeforeLanding = new Setting<>(5);
/**
* Automatically land when elytra is almost out of durability, or almost out of fireworks
*/
public final Setting<Boolean> elytraAllowEmergencyLand = new Setting<>(true);
/**
* Time between culling far away chunks from the nether pathfinder chunk cache
*/
public final Setting<Long> elytraTimeBetweenCacheCullSecs = new Setting<>(TimeUnit.MINUTES.toSeconds(3));
/**
* Maximum distance chunks can be before being culled from the nether pathfinder chunk cache
*/
public final Setting<Integer> elytraCacheCullDistance = new Setting<>(5000);
/**
* Should elytra consider nether brick a valid landing block
*/
public final Setting<Boolean> elytraAllowLandOnNetherFortress = new Setting<>(false);
/**
* Has the user read and understood the elytra terms and conditions
*/
public final Setting<Boolean> elytraTermsAccepted = new Setting<>(false);
/**
* Verbose chat logging in elytra mode
*/
public final Setting<Boolean> elytraChatSpam = new Setting<>(false);
/**
* A map of lowercase setting field names to their respective setting
*/
@@ -1304,6 +1520,7 @@ public final class Settings {
public T value;
public final T defaultValue;
private String name;
private boolean javaOnly;
@SuppressWarnings("unchecked")
private Setting(T value) {
@@ -1312,6 +1529,7 @@ public final class Settings {
}
this.value = value;
this.defaultValue = value;
this.javaOnly = false;
}
/**
@@ -1348,8 +1566,25 @@ public final class Settings {
public final Type getType() {
return settingTypes.get(this);
}
/**
* This should always be the same as whether the setting can be parsed from or serialized to a string; in other
* words, the only way to modify it is by writing to {@link #value} programatically.
*
* @return {@code true} if the setting can not be set or read by the user
*/
public boolean isJavaOnly() {
return javaOnly;
}
}
/**
* Marks a {@link Setting} field as being {@link Setting#isJavaOnly() Java-only}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
private @interface JavaOnly {}
// here be dragons
Settings() {
@@ -1365,6 +1600,7 @@ public final class Settings {
Setting<?> setting = (Setting<?>) field.get(this);
String name = field.getName();
setting.name = name;
setting.javaOnly = field.isAnnotationPresent(JavaOnly.class);
name = name.toLowerCase();
if (tmpByName.containsKey(name)) {
throw new IllegalStateException("Duplicate setting name");

View File

@@ -17,6 +17,8 @@
package baritone.api.behavior;
import baritone.api.Settings;
import baritone.api.behavior.look.IAimProcessor;
import baritone.api.utils.Rotation;
/**
@@ -26,14 +28,23 @@ import baritone.api.utils.Rotation;
public interface ILookBehavior extends IBehavior {
/**
* Updates the current {@link ILookBehavior} target to target
* the specified rotations on the next tick. If force is {@code true},
* then freeLook will be overriden and angles will be set regardless.
* If any sort of block interaction is required, force should be {@code true},
* otherwise, it should be {@code false};
* Updates the current {@link ILookBehavior} target to target the specified rotations on the next tick. If any sort
* of block interaction is required, {@code blockInteract} should be {@code true}. It is not guaranteed that the
* rotations set by the caller will be the exact rotations expressed by the client (This is due to settings like
* {@link Settings#randomLooking}). If the rotations produced by this behavior are required, then the
* {@link #getAimProcessor() aim processor} should be used.
*
* @param rotation The target rotations
* @param force Whether or not to "force" the rotations
* @param rotation The target rotations
* @param blockInteract Whether the target rotations are needed for a block interaction
*/
void updateTarget(Rotation rotation, boolean force);
void updateTarget(Rotation rotation, boolean blockInteract);
/**
* The aim processor instance for this {@link ILookBehavior}, which is responsible for applying additional,
* deterministic transformations to the target rotation set by {@link #updateTarget}.
*
* @return The aim processor
* @see IAimProcessor#fork
*/
IAimProcessor getAimProcessor();
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.behavior.look;
import baritone.api.utils.Rotation;
/**
* @author Brady
*/
public interface IAimProcessor {
/**
* Returns the actual rotation that will be used when the desired rotation is requested. The returned rotation
* always reflects what would happen in the upcoming tick. In other words, it is a pure function, and no internal
* state changes. If simulation of the rotation states beyond the next tick is required, then a
* {@link IAimProcessor#fork fork} should be created.
*
* @param desired The desired rotation to set
* @return The actual rotation
*/
Rotation peekRotation(Rotation desired);
/**
* Returns a copy of this {@link IAimProcessor} which has its own internal state and is manually tickable.
*
* @return The forked processor
* @see ITickableAimProcessor
*/
ITickableAimProcessor fork();
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.behavior.look;
import baritone.api.utils.Rotation;
/**
* @author Brady
*/
public interface ITickableAimProcessor extends IAimProcessor {
/**
* Advances the internal state of this aim processor by a single tick.
*/
void tick();
/**
* Calls {@link #tick()} the specified number of times.
*
* @param ticks The number of calls
*/
void advance(int ticks);
/**
* Returns the actual rotation as provided by {@link #peekRotation(Rotation)}, and then automatically advances the
* internal state by one {@link #tick() tick}.
*
* @param rotation The desired rotation to set
* @return The actual rotation
*/
Rotation nextRotation(Rotation rotation);
}

View File

@@ -17,6 +17,8 @@
package baritone.api.cache;
import java.util.function.Consumer;
/**
* @author Brady
* @since 9/24/2018
@@ -29,4 +31,11 @@ public interface IWorldProvider {
* @return The current world data
*/
IWorldData getCurrentWorld();
default void ifWorldLoaded(Consumer<IWorldData> callback) {
final IWorldData currentWorld = this.getCurrentWorld();
if (currentWorld != null) {
callback.accept(currentWorld);
}
}
}

View File

@@ -23,14 +23,20 @@ import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import java.util.regex.Pattern;
import java.util.stream.Stream;
public enum BlockById implements IDatatypeFor<Block> {
INSTANCE;
/**
* Matches (domain:)?name? where domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ respectively.
*/
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?[a-z0-9/_.-]*");
@Override
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Block block;
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id");
@@ -40,13 +46,19 @@ public enum BlockById implements IDatatypeFor<Block> {
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
String arg = ctx.getConsumer().getString();
if (!PATTERN.matcher(arg).matches()) {
return Stream.empty();
}
return new TabCompleteHelper()
.append(
BuiltInRegistries.BLOCK.keySet()
.stream()
.map(Object::toString)
)
.filterPrefixNamespaced(ctx.getConsumer().getString())
.filterPrefixNamespaced(arg)
.sortAlphabetically()
.stream();
}

View File

@@ -30,7 +30,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
@Override
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
EntityType entity;
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");

View File

@@ -0,0 +1,43 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.Direction;
import java.util.Locale;
import java.util.stream.Stream;
public enum ForAxis implements IDatatypeFor<Direction.Axis> {
INSTANCE;
@Override
public Direction.Axis get(IDatatypeContext ctx) throws CommandException {
return Direction.Axis.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
}
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(Stream.of(Direction.Axis.values())
.map(Direction.Axis::getName).map(String::toLowerCase))
.filterPrefix(ctx.getConsumer().getString())
.stream();
}
}

View File

@@ -18,20 +18,137 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.Property;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
INSTANCE;
/**
* Matches (domain:)?name([(property=value)*])? but the input can be truncated at any position.
* domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ because that's what mc 1.13+ accepts.
* property and value use the same format as domain.
*/
// Good luck reading this.
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?(?:[a-z0-9/_.-]+(?:\\[(?:(?:[a-z0-9_.-]+=[a-z0-9_.-]+,)*(?:[a-z0-9_.-]+(?:=(?:[a-z0-9_.-]+(?:\\])?)?)?)?|\\])?)?)?");
@Override
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
return new BlockOptionalMeta(ctx.getConsumer().getString());
}
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) {
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
String arg = ctx.getConsumer().peekString();
if (!PATTERN.matcher(arg).matches()) {
// Invalid format; we can't complete this.
ctx.getConsumer().getString();
return Stream.empty();
}
if (arg.endsWith("]")) {
// We are already done.
ctx.getConsumer().getString();
return Stream.empty();
}
if (!arg.contains("[")) {
// no properties so we are completing the block id
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
}
ctx.getConsumer().getString();
// destructuring assignment? Please?
String blockId, properties;
{
String[] parts = splitLast(arg, '[');
blockId = parts[0];
properties = parts[1];
}
Block block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId)).orElse(null);
if (block == null) {
// This block doesn't exist so there's no properties to complete.
return Stream.empty();
}
String leadingProperties, lastProperty;
{
String[] parts = splitLast(properties, ',');
leadingProperties = parts[0];
lastProperty = parts[1];
}
if (!lastProperty.contains("=")) {
// The last property-value pair doesn't have a value yet so we are completing its name
Set<String> usedProps = Stream.of(leadingProperties.split(","))
.map(pair -> pair.split("=")[0])
.collect(Collectors.toSet());
String prefix = arg.substring(0, arg.length() - lastProperty.length());
return new TabCompleteHelper()
.append(
block.getStateDefinition()
.getProperties()
.stream()
.map(Property::getName)
)
.filter(prop -> !usedProps.contains(prop))
.filterPrefix(lastProperty)
.sortAlphabetically()
.map(prop -> prefix + prop)
.stream();
}
String lastName, lastValue;
{
String[] parts = splitLast(lastProperty, '=');
lastName = parts[0];
lastValue = parts[1];
}
// We are completing the value of a property
String prefix = arg.substring(0, arg.length() - lastValue.length());
Property<?> property = block.getStateDefinition().getProperty(lastName);
if (property == null) {
// The property does not exist so there's no values to complete
return Stream.empty();
}
return new TabCompleteHelper()
.append(getValues(property))
.filterPrefix(lastValue)
.sortAlphabetically()
.map(val -> prefix + val)
.stream();
}
/**
* Always returns exactly two strings.
* If the separator is not found the FIRST returned string is empty.
*/
private static String[] splitLast(String string, char chr) {
int idx = string.lastIndexOf(chr);
if (idx == -1) {
return new String[]{"", string};
}
return new String[]{string.substring(0, idx), string.substring(idx + 1)};
}
// this shouldn't need to be a separate method?
private static <T extends Comparable<T>> Stream<String> getValues(Property<T> property) {
return property.getPossibleValues().stream().map(property::getName);
}
}

View File

@@ -19,6 +19,8 @@ package baritone.api.command.datatypes;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.utils.Helper;
import net.minecraft.client.Minecraft;
import java.io.File;
import java.io.IOException;
@@ -30,8 +32,6 @@ import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;
import static baritone.api.utils.Helper.HELPER;
public enum RelativeFile implements IDatatypePost<File, File> {
INSTANCE;
@@ -93,8 +93,13 @@ public enum RelativeFile implements IDatatypePost<File, File> {
.filter(s -> !s.contains(" "));
}
@Deprecated
public static File gameDir() {
File gameDir = HELPER.mc.gameDirectory.getAbsoluteFile();
return gameDir(Helper.mc);
}
public static File gameDir(Minecraft mc) {
File gameDir = mc.gameDirectory.getAbsoluteFile();
if (gameDir.getName().equals(".")) {
return gameDir.getParentFile();
}

View File

@@ -19,8 +19,8 @@ package baritone.api.command.exception;
import baritone.api.command.ICommand;
import baritone.api.command.argument.ICommandArgument;
import java.util.List;
import net.minecraft.ChatFormatting;
import static baritone.api.utils.Helper.HELPER;
@@ -36,10 +36,6 @@ 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",
ChatFormatting.RED);
this.printStackTrace();
HELPER.logUnhandledException(this);
}
}

View File

@@ -212,7 +212,7 @@ public class TabCompleteHelper {
* @return This {@link TabCompleteHelper}
*/
public TabCompleteHelper filterPrefixNamespaced(String prefix) {
return filterPrefix(new ResourceLocation(prefix).toString());
return filterPrefix(ResourceLocation.parse(prefix).toString());
}
/**
@@ -252,7 +252,7 @@ public class TabCompleteHelper {
public TabCompleteHelper addSettings() {
return append(
BaritoneAPI.getSettings().allSettings.stream()
.filter(s -> !SettingsUtil.javaOnlySetting(s))
.filter(s -> !s.isJavaOnly())
.map(Settings.Setting::getName)
.sorted(String.CASE_INSENSITIVE_ORDER)
);

View File

@@ -0,0 +1,47 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.event.events;
import baritone.api.utils.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.state.BlockState;
import java.util.List;
/**
* @author Brady
*/
public final class BlockChangeEvent {
private final ChunkPos chunk;
private final List<Pair<BlockPos, BlockState>> blocks;
public BlockChangeEvent(ChunkPos pos, List<Pair<BlockPos, BlockState>> blocks) {
this.chunk = pos;
this.blocks = blocks;
}
public ChunkPos getChunkPos() {
return this.chunk;
}
public List<Pair<BlockPos, BlockState>> getBlocks() {
return this.blocks;
}
}

View File

@@ -57,31 +57,38 @@ public final class ChunkEvent {
/**
* @return The state of the event
*/
public final EventState getState() {
public EventState getState() {
return this.state;
}
/**
* @return The type of chunk event that occurred;
*/
public final Type getType() {
public Type getType() {
return this.type;
}
/**
* @return The Chunk X position.
*/
public final int getX() {
public int getX() {
return this.x;
}
/**
* @return The Chunk Z position.
*/
public final int getZ() {
public int getZ() {
return this.z;
}
/**
* @return {@code true} if the event was fired after a chunk population
*/
public boolean isPostPopulate() {
return this.state == EventState.POST && this.type.isPopulate();
}
public enum Type {
/**
@@ -106,6 +113,10 @@ public final class ChunkEvent {
* <p>
* And it's a partial chunk
*/
POPULATE_PARTIAL
POPULATE_PARTIAL;
public final boolean isPopulate() {
return this == POPULATE_FULL || this == POPULATE_PARTIAL;
}
}
}

View File

@@ -17,6 +17,7 @@
package baritone.api.event.events;
import baritone.api.utils.Rotation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
@@ -32,14 +33,27 @@ public final class RotationMoveEvent {
*/
private final Type type;
private final Rotation original;
/**
* The yaw rotation
*/
private float yaw;
public RotationMoveEvent(Type type, float yaw) {
/**
* The pitch rotation
*/
private float pitch;
public RotationMoveEvent(Type type, float yaw, float pitch) {
this.type = type;
this.original = new Rotation(yaw, pitch);
this.yaw = yaw;
this.pitch = pitch;
}
public Rotation getOriginal() {
return this.original;
}
/**
@@ -47,21 +61,37 @@ public final class RotationMoveEvent {
*
* @param yaw Yaw rotation
*/
public final void setYaw(float yaw) {
public void setYaw(float yaw) {
this.yaw = yaw;
}
/**
* @return The yaw rotation
*/
public final float getYaw() {
public float getYaw() {
return this.yaw;
}
/**
* Set the pitch movement rotation
*
* @param pitch Pitch rotation
*/
public void setPitch(float pitch) {
this.pitch = pitch;
}
/**
* @return The pitch rotation
*/
public float getPitch() {
return pitch;
}
/**
* @return The type of the event
*/
public final Type getType() {
public Type getType() {
return this.type;
}

View File

@@ -18,9 +18,18 @@
package baritone.api.event.events;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.Minecraft;
import java.util.function.BiFunction;
/**
* Called on and after each game tick of the primary {@link Minecraft} instance and dispatched to all Baritone
* instances.
* <p>
* When {@link #state} is {@link EventState#PRE}, the event is being called just prior to when the current in-game
* screen is ticked. When {@link #state} is {@link EventState#POST}, the event is being called at the very end
* of the {@link Minecraft#runTick()} method.
*/
public final class TickEvent {
private static int overallTickCount;

View File

@@ -33,6 +33,9 @@ public interface AbstractGameEventListener extends IGameEventListener {
@Override
default void onTick(TickEvent event) {}
@Override
default void onPostTick(TickEvent event) {}
@Override
default void onPlayerUpdate(PlayerUpdateEvent event) {}
@@ -45,6 +48,9 @@ public interface AbstractGameEventListener extends IGameEventListener {
@Override
default void onChunkEvent(ChunkEvent event) {}
@Override
default void onBlockChange(BlockChangeEvent event) {}
@Override
default void onRenderPass(RenderEvent event) {}

View File

@@ -40,6 +40,14 @@ public interface IGameEventListener {
*/
void onTick(TickEvent event);
/**
* Run once per game tick after the tick is completed
*
* @param event The event
* @see Minecraft#runTick()
*/
void onPostTick(TickEvent event);
/**
* Run once per game tick from before and after the player rotation is sent to the server.
*
@@ -70,6 +78,13 @@ public interface IGameEventListener {
*/
void onChunkEvent(ChunkEvent event);
/**
* Runs after a single or multi block change packet is received and processed.
*
* @param event The event
*/
void onBlockChange(BlockChangeEvent event);
/**
* Runs once per world render pass.
*

View File

@@ -42,6 +42,16 @@ public class GoalAxis implements Goal {
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
}
@Override
public boolean equals(Object o) {
return o.getClass() == GoalAxis.class;
}
@Override
public int hashCode() {
return 201385781;
}
@Override
public String toString() {
return "GoalAxis";

View File

@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.core.BlockPos;
@@ -66,6 +67,26 @@ public class GoalBlock implements Goal, IGoalRenderPos {
return calculate(xDiff, yDiff, zDiff);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalBlock goal = (GoalBlock) o;
return x == goal.x
&& y == goal.y
&& z == goal.z;
}
@Override
public int hashCode() {
return (int) BetterBlockPos.longHash(x, y, z) * 905165533;
}
@Override
public String toString() {
return String.format(

View File

@@ -67,6 +67,24 @@ public class GoalComposite implements Goal {
return min;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalComposite goal = (GoalComposite) o;
return Arrays.equals(goals, goal.goals);
}
@Override
public int hashCode() {
return Arrays.hashCode(goals);
}
@Override
public String toString() {
return "GoalComposite" + Arrays.toString(goals);

View File

@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.core.BlockPos;
@@ -60,6 +61,26 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalGetToBlock goal = (GoalGetToBlock) o;
return x == goal.x
&& y == goal.y
&& z == goal.z;
}
@Override
public int hashCode() {
return (int) BetterBlockPos.longHash(x, y, z) * -49639096;
}
@Override
public String toString() {
return String.format(

View File

@@ -17,6 +17,8 @@
package baritone.api.pathing.goals;
import java.util.Objects;
/**
* Invert any goal.
* <p>
@@ -50,6 +52,24 @@ public class GoalInverted implements Goal {
return Double.NEGATIVE_INFINITY;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalInverted goal = (GoalInverted) o;
return Objects.equals(origin, goal.origin);
}
@Override
public int hashCode() {
return origin.hashCode() * 495796690;
}
@Override
public String toString() {
return String.format("GoalInverted{%s}", origin.toString());

View File

@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
@@ -86,6 +87,27 @@ public class GoalNear implements Goal, IGoalRenderPos {
return new BlockPos(x, y, z);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalNear goal = (GoalNear) o;
return x == goal.x
&& y == goal.y
&& z == goal.z
&& rangeSq == goal.rangeSq;
}
@Override
public int hashCode() {
return (int) BetterBlockPos.longHash(x, y, z) + rangeSq;
}
@Override
public String toString() {
return String.format(

View File

@@ -23,6 +23,7 @@ import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.core.BlockPos;
import java.util.Arrays;
import java.util.Objects;
/**
* Useful for automated combat (retreating specifically)
@@ -124,6 +125,29 @@ public class GoalRunAway implements Goal {
return maxInside;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalRunAway goal = (GoalRunAway) o;
return distanceSq == goal.distanceSq
&& Arrays.equals(from, goal.from)
&& Objects.equals(maintainY, goal.maintainY);
}
@Override
public int hashCode() {
int hash = Arrays.hashCode(from);
hash = hash * 1196803141 + distanceSq;
hash = hash * -2053788840 + maintainY;
return hash;
}
@Override
public String toString() {
if (maintainY != null) {

View File

@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -69,6 +70,31 @@ public class GoalStrictDirection implements Goal {
return Double.NEGATIVE_INFINITY;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalStrictDirection goal = (GoalStrictDirection) o;
return x == goal.x
&& y == goal.y
&& z == goal.z
&& dx == goal.dx
&& dz == goal.dz;
}
@Override
public int hashCode() {
int hash = (int) BetterBlockPos.longHash(x, y, z);
hash = hash * 630627507 + dx;
hash = hash * -283028380 + dz;
return hash;
}
@Override
public String toString() {
return String.format(

View File

@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.core.BlockPos;
@@ -72,6 +73,26 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
return new BlockPos(x, y, z);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalTwoBlocks goal = (GoalTwoBlocks) o;
return x == goal.x
&& y == goal.y
&& z == goal.z;
}
@Override
public int hashCode() {
return (int) BetterBlockPos.longHash(x, y, z) * 516508351;
}
@Override
public String toString() {
return String.format(

View File

@@ -64,6 +64,27 @@ public class GoalXZ implements Goal {
return calculate(xDiff, zDiff);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalXZ goal = (GoalXZ) o;
return x == goal.x && z == goal.z;
}
@Override
public int hashCode() {
int hash = 1791873246;
hash = hash * 222601791 + x;
hash = hash * -1331679453 + z;
return hash;
}
@Override
public String toString() {
return String.format(

View File

@@ -58,6 +58,24 @@ public class GoalYLevel implements Goal, ActionCosts {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalYLevel goal = (GoalYLevel) o;
return level == goal.level;
}
@Override
public int hashCode() {
return level * 1271009915;
}
@Override
public String toString() {
return String.format(

View File

@@ -50,6 +50,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
*/
boolean build(String name, File schematic, Vec3i origin);
@Deprecated
default boolean build(String schematicFile, BlockPos origin) {
File file = new File(new File(Minecraft.getInstance().gameDirectory, "schematics"), schematicFile);
return build(schematicFile, file, origin);

View File

@@ -38,6 +38,11 @@ public interface ICustomGoalProcess extends IBaritoneProcess {
*/
Goal getGoal();
/**
* @return The most recent set goal, which doesn't invalidate upon {@link #onLostControl()}
*/
Goal mostRecentGoal();
/**
* Sets the goal and begins the path execution.
*

View File

@@ -0,0 +1,50 @@
/*
* 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.process;
import baritone.api.pathing.goals.Goal;
import net.minecraft.core.BlockPos;
public interface IElytraProcess extends IBaritoneProcess {
void repackChunks();
/**
* @return Where it is currently flying to, null if not active
*/
BlockPos currentDestination();
void pathTo(BlockPos destination);
void pathTo(Goal destination);
/**
* Resets the state of the process but will maintain the same destination and will try to keep flying
*/
void resetState();
/**
* @return {@code true} if the native library loaded and elytra is actually usable
*/
boolean isLoaded();
/*
* FOR INTERNAL USE ONLY. MAY BE REMOVED AT ANY TIME.
*/
boolean isSafeToCancel();
}

View File

@@ -56,5 +56,10 @@ public enum PathingCommandType {
/**
* Go and ask the next process what to do
*/
DEFER
DEFER,
/**
* Sets the goal and calculates a path, but pauses instead of immediately starting the path.
*/
SET_GOAL_AND_PAUSE
}

View File

@@ -17,9 +17,11 @@
package baritone.api.schematic;
import java.util.List;
import baritone.api.schematic.mask.Mask;
import net.minecraft.world.level.block.state.BlockState;
import java.util.List;
public abstract class MaskSchematic extends AbstractSchematic {
private final ISchematic schematic;
@@ -40,4 +42,14 @@ public abstract class MaskSchematic extends AbstractSchematic {
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return schematic.desiredState(x, y, z, current, approxPlaceable);
}
public static MaskSchematic create(ISchematic schematic, Mask function) {
return new MaskSchematic(schematic) {
@Override
protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
return function.partOfMask(x, y, z, currentState);
}
};
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
/**
* @author Brady
*/
public abstract class AbstractMask implements Mask {
private final int widthX;
private final int heightY;
private final int lengthZ;
public AbstractMask(int widthX, int heightY, int lengthZ) {
this.widthX = widthX;
this.heightY = heightY;
this.lengthZ = lengthZ;
}
@Override
public int widthX() {
return this.widthX;
}
@Override
public int heightY() {
return this.heightY;
}
@Override
public int lengthZ() {
return this.lengthZ;
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.world.level.block.state.BlockState;
/**
* @author Brady
*/
public interface Mask {
/**
* @param x The relative x position of the block
* @param y The relative y position of the block
* @param z The relative z position of the block
* @param currentState The current state of that block in the world, may be {@code null}
* @return Whether the given position is included in this mask
*/
boolean partOfMask(int x, int y, int z, BlockState currentState);
int widthX();
int heightY();
int lengthZ();
default Mask not() {
return new NotMask(this);
}
default Mask union(Mask other) {
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.OR);
}
default Mask intersection(Mask other) {
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.AND);
}
default Mask xor(Mask other) {
return new BinaryOperatorMask(this, other, BooleanBinaryOperators.XOR);
}
}

View File

@@ -0,0 +1,44 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
/**
* @author Brady
*/
final class PreComputedMask extends AbstractMask implements StaticMask {
private final boolean[][][] mask;
public PreComputedMask(StaticMask mask) {
super(mask.widthX(), mask.heightY(), mask.lengthZ());
this.mask = new boolean[this.heightY()][this.lengthZ()][this.widthX()];
for (int y = 0; y < this.heightY(); y++) {
for (int z = 0; z < this.lengthZ(); z++) {
for (int x = 0; x < this.widthX(); x++) {
this.mask[y][z][x] = mask.partOfMask(x, y, z);
}
}
}
}
@Override
public boolean partOfMask(int x, int y, int z) {
return this.mask[y][z][x];
}
}

View File

@@ -0,0 +1,82 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.world.level.block.state.BlockState;
/**
* A mask that is context-free. In other words, it doesn't require the current block state to determine if a relative
* position is a part of the mask.
*
* @author Brady
*/
public interface StaticMask extends Mask {
/**
* Determines if a given relative coordinate is included in this mask, without the need for the current block state.
*
* @param x The relative x position of the block
* @param y The relative y position of the block
* @param z The relative z position of the block
* @return Whether the given position is included in this mask
*/
boolean partOfMask(int x, int y, int z);
/**
* Implements the parent {@link Mask#partOfMask partOfMask function} by calling the static function
* provided in this functional interface without needing the {@link BlockState} argument. This {@code default}
* implementation should <b><u>NOT</u></b> be overriden.
*
* @param x The relative x position of the block
* @param y The relative y position of the block
* @param z The relative z position of the block
* @param currentState The current state of that block in the world, may be {@code null}
* @return Whether the given position is included in this mask
*/
@Override
default boolean partOfMask(int x, int y, int z, BlockState currentState) {
return this.partOfMask(x, y, z);
}
@Override
default StaticMask not() {
return new NotMask.Static(this);
}
default StaticMask union(StaticMask other) {
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.OR);
}
default StaticMask intersection(StaticMask other) {
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.AND);
}
default StaticMask xor(StaticMask other) {
return new BinaryOperatorMask.Static(this, other, BooleanBinaryOperators.XOR);
}
/**
* Returns a pre-computed mask using {@code this} function, with the specified size parameters.
*/
default StaticMask compute() {
return new PreComputedMask(this);
}
}

View File

@@ -0,0 +1,79 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.operator;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask;
import baritone.api.utils.BooleanBinaryOperator;
import net.minecraft.world.level.block.state.BlockState;
/**
* @author Brady
*/
public final class BinaryOperatorMask extends AbstractMask {
private final Mask a;
private final Mask b;
private final BooleanBinaryOperator operator;
public BinaryOperatorMask(Mask a, Mask b, BooleanBinaryOperator operator) {
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
this.a = a;
this.b = b;
this.operator = operator;
}
@Override
public boolean partOfMask(int x, int y, int z, BlockState currentState) {
return this.operator.applyAsBoolean(
partOfMask(a, x, y, z, currentState),
partOfMask(b, x, y, z, currentState)
);
}
private static boolean partOfMask(Mask mask, int x, int y, int z, BlockState currentState) {
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z, currentState);
}
public static final class Static extends AbstractMask implements StaticMask {
private final StaticMask a;
private final StaticMask b;
private final BooleanBinaryOperator operator;
public Static(StaticMask a, StaticMask b, BooleanBinaryOperator operator) {
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
this.a = a;
this.b = b;
this.operator = operator;
}
@Override
public boolean partOfMask(int x, int y, int z) {
return this.operator.applyAsBoolean(
partOfMask(a, x, y, z),
partOfMask(b, x, y, z)
);
}
private static boolean partOfMask(StaticMask mask, int x, int y, int z) {
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z);
}
}
}

View File

@@ -0,0 +1,56 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.operator;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask;
import net.minecraft.world.level.block.state.BlockState;
/**
* @author Brady
*/
public final class NotMask extends AbstractMask {
private final Mask source;
public NotMask(Mask source) {
super(source.widthX(), source.heightY(), source.lengthZ());
this.source = source;
}
@Override
public boolean partOfMask(int x, int y, int z, BlockState currentState) {
return !this.source.partOfMask(x, y, z, currentState);
}
public static final class Static extends AbstractMask implements StaticMask {
private final StaticMask source;
public Static(StaticMask source) {
super(source.widthX(), source.heightY(), source.lengthZ());
this.source = source;
}
@Override
public boolean partOfMask(int x, int y, int z) {
return !this.source.partOfMask(x, y, z);
}
}
}

View File

@@ -0,0 +1,69 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.shape;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.StaticMask;
import net.minecraft.core.Direction;
/**
* @author Brady
*/
public final class CylinderMask extends AbstractMask implements StaticMask {
private final double centerA;
private final double centerB;
private final double radiusSqA;
private final double radiusSqB;
private final boolean filled;
private final Direction.Axis alignment;
public CylinderMask(int widthX, int heightY, int lengthZ, boolean filled, Direction.Axis alignment) {
super(widthX, heightY, lengthZ);
this.centerA = this.getA(widthX, heightY, alignment) / 2.0;
this.centerB = this.getB(heightY, lengthZ, alignment) / 2.0;
this.radiusSqA = (this.centerA - 1) * (this.centerA - 1);
this.radiusSqB = (this.centerB - 1) * (this.centerB - 1);
this.filled = filled;
this.alignment = alignment;
}
@Override
public boolean partOfMask(int x, int y, int z) {
double da = Math.abs((this.getA(x, y, this.alignment) + 0.5) - this.centerA);
double db = Math.abs((this.getB(y, z, this.alignment) + 0.5) - this.centerB);
if (this.outside(da, db)) {
return false;
}
return this.filled
|| this.outside(da + 1, db)
|| this.outside(da, db + 1);
}
private boolean outside(double da, double db) {
return da * da / this.radiusSqA + db * db / this.radiusSqB > 1;
}
private static int getA(int x, int y, Direction.Axis alignment) {
return alignment == Direction.Axis.X ? y : x;
}
private static int getB(int y, int z, Direction.Axis alignment) {
return alignment == Direction.Axis.Z ? y : z;
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.shape;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.StaticMask;
/**
* @author Brady
*/
public final class SphereMask extends AbstractMask implements StaticMask {
private final double centerX;
private final double centerY;
private final double centerZ;
private final double radiusSqX;
private final double radiusSqY;
private final double radiusSqZ;
private final boolean filled;
public SphereMask(int widthX, int heightY, int lengthZ, boolean filled) {
super(widthX, heightY, lengthZ);
this.centerX = widthX / 2.0;
this.centerY = heightY / 2.0;
this.centerZ = lengthZ / 2.0;
this.radiusSqX = this.centerX * this.centerX;
this.radiusSqY = this.centerY * this.centerY;
this.radiusSqZ = this.centerZ * this.centerZ;
this.filled = filled;
}
@Override
public boolean partOfMask(int x, int y, int z) {
double dx = Math.abs((x + 0.5) - this.centerX);
double dy = Math.abs((y + 0.5) - this.centerY);
double dz = Math.abs((z + 0.5) - this.centerZ);
if (this.outside(dx, dy, dz)) {
return false;
}
return this.filled
|| this.outside(dx + 1, dy, dz)
|| this.outside(dx, dy + 1, dz)
|| this.outside(dx, dy, dz + 1);
}
private boolean outside(double dx, double dy, double dz) {
return dx * dx / this.radiusSqX + dy * dy / this.radiusSqY + dz * dz / this.radiusSqZ > 1;
}
}

View File

@@ -34,6 +34,15 @@ import net.minecraft.util.Mth;
*/
public final class BetterBlockPos extends BlockPos {
private static final int NUM_X_BITS = 26;
private static final int NUM_Z_BITS = NUM_X_BITS;
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
private static final int Y_SHIFT = NUM_Z_BITS;
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0);
public final int x;
@@ -201,6 +210,20 @@ public final class BetterBlockPos extends BlockPos {
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
}
public double distanceSq(final BetterBlockPos to) {
double dx = (double) this.x - to.x;
double dy = (double) this.y - to.y;
double dz = (double) this.z - to.z;
return dx * dx + dy * dy + dz * dz;
}
public double distanceTo(final BetterBlockPos to) {
double dx = (double) this.x - to.x;
double dy = (double) this.y - to.y;
double dz = (double) this.z - to.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
@Override
@Nonnull
public String toString() {
@@ -211,4 +234,15 @@ public final class BetterBlockPos extends BlockPos {
SettingsUtil.maybeCensor(z)
);
}
public static long serializeToLong(final int x, final int y, final int z) {
return ((long) x & X_MASK) << X_SHIFT | ((long) y & Y_MASK) << Y_SHIFT | ((long) z & Z_MASK);
}
public static BetterBlockPos deserializeFromLong(final long serialized) {
final int x = (int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
final int y = (int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
final int z = (int) (serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
return new BetterBlockPos(x, y, z);
}
}

View File

@@ -18,85 +18,132 @@
package baritone.api.utils;
import baritone.api.utils.accessor.IItemStack;
import baritone.api.utils.accessor.ILootTable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.netty.util.concurrent.ThreadPerTaskExecutor;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.commands.Commands;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.ReloadableServerRegistries;
import net.minecraft.server.ReloadableServerResources;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.packs.*;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.CloseableResourceManager;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Unit;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.RandomSequences;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.CustomSpawner;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.WorldDataConfiguration;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.ServerLevelData;
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.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
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 sun.misc.Unsafe;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public final class BlockOptionalMeta {
// id or id[] or id[properties] where id and properties are any text with at least one character
private static final Pattern PATTERN = Pattern.compile("^(?<id>.+?)(?:\\[(?<properties>.+?)?\\])?$");
private final Block block;
private final String propertiesDescription; // exists so toString() can return something more useful than a list of all blockstates
private final Set<BlockState> blockstates;
private final ImmutableSet<Integer> stateHashes;
private final ImmutableSet<Integer> stackHashes;
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
private static LootTables lootTables;
private static PredicateManager predicate = new PredicateManager();
private static Map<Block, List<Item>> drops = new HashMap<>();
public BlockOptionalMeta(@Nonnull Block block) {
this.block = block;
this.blockstates = getStates(block);
this.propertiesDescription = "{}";
this.blockstates = getStates(block, Collections.emptyMap());
this.stateHashes = getStateHashes(blockstates);
this.stackHashes = getStackHashes(blockstates);
}
public BlockOptionalMeta(@Nonnull String selector) {
Matcher matcher = pattern.matcher(selector);
Matcher matcher = PATTERN.matcher(selector);
if (!matcher.find()) {
throw new IllegalArgumentException("invalid block selector");
}
MatchResult matchResult = matcher.toMatchResult();
block = BlockUtils.stringToBlockRequired(matcher.group("id"));
block = BlockUtils.stringToBlockRequired(matchResult.group(1));
blockstates = getStates(block);
String props = matcher.group("properties");
Map<Property<?>, ?> properties = props == null || props.equals("") ? Collections.emptyMap() : parseProperties(block, props);
propertiesDescription = props == null ? "{}" : "{" + props.replace("=", ":") + "}";
blockstates = getStates(block, properties);
stateHashes = getStateHashes(blockstates);
stackHashes = getStackHashes(blockstates);
}
private static Set<BlockState> getStates(@Nonnull Block block) {
return new HashSet<>(block.getStateDefinition().getPossibleStates());
private static <C extends Comparable<C>, P extends Property<C>> P castToIProperty(Object value) {
//noinspection unchecked
return (P) value;
}
private static Map<Property<?>, ?> parseProperties(Block block, String raw) {
ImmutableMap.Builder<Property<?>, Object> builder = ImmutableMap.builder();
for (String pair : raw.split(",")) {
String[] parts = pair.split("=");
if (parts.length != 2) {
throw new IllegalArgumentException(String.format("\"%s\" is not a valid property-value pair", pair));
}
String rawKey = parts[0];
String rawValue = parts[1];
Property<?> key = block.getStateDefinition().getProperty(rawKey);
Comparable<?> value = castToIProperty(key).getValue(rawValue)
.orElseThrow(() -> new IllegalArgumentException(String.format(
"\"%s\" is not a valid value for %s on %s",
rawValue, key, block
)));
builder.put(key, value);
}
return builder.build();
}
private static Set<BlockState> getStates(@Nonnull Block block, @Nonnull Map<Property<?>, ?> properties) {
return block.getStateDefinition().getPossibleStates().stream()
.filter(blockstate -> properties.entrySet().stream().allMatch(entry ->
blockstate.getValue(entry.getKey()) == entry.getValue()
))
.collect(Collectors.toSet());
}
private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
@@ -144,7 +191,7 @@ public final class BlockOptionalMeta {
@Override
public String toString() {
return String.format("BlockOptionalMeta{block=%s}", block);
return String.format("BlockOptionalMeta{block=%s,properties=%s}", block, propertiesDescription);
}
public BlockState getAnyBlockState() {
@@ -155,6 +202,14 @@ public final class BlockOptionalMeta {
return null;
}
public Set<BlockState> getAllBlockStates() {
return blockstates;
}
public Set<Integer> stackHashes() {
return stackHashes;
}
private static Method getVanillaServerPack;
private static VanillaPackResources getVanillaServerPack() {
@@ -172,44 +227,21 @@ public final class BlockOptionalMeta {
return null;
}
public static LootTables getManager() {
if (lootTables == null) {
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
lootTables = new LootTables(predicate);
resourceManager.registerReloadListener(lootTables);
try {
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
return lootTables;
}
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 == BuiltInLootTables.EMPTY) {
ResourceLocation lootTableLocation = block.getLootTable().location();
if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) {
return Collections.emptyList();
} else {
List<Item> items = new ArrayList<>();
try {
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder(ServerLevelStub.fastCreate())
.withRandom(RandomSource.create())
.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())
);
ServerLevel lv2 = ServerLevelStub.fastCreate();
LootParams.Builder lv5 = new LootParams.Builder(lv2)
.withParameter(LootContextParams.ORIGIN, Vec3.ZERO)
.withParameter(LootContextParams.BLOCK_STATE, b.defaultBlockState())
.withParameter(LootContextParams.TOOL, new ItemStack(Items.NETHERITE_PICKAXE, 1));
getDrops(block, lv5).stream().map(ItemStack::getItem).forEach(items::add);
} catch (Exception e) {
e.printStackTrace();
}
@@ -218,11 +250,25 @@ public final class BlockOptionalMeta {
});
}
private static class ServerLevelStub extends ServerLevel {
private static List<ItemStack> getDrops(Block state, LootParams.Builder params) {
ResourceKey<LootTable> lv = state.getLootTable();
if (lv == BuiltInLootTables.EMPTY) {
return Collections.emptyList();
} else {
LootParams lv2 = params.withParameter(LootContextParams.BLOCK_STATE, state.defaultBlockState()).create(LootContextParamSets.BLOCK);
ServerLevelStub lv3 = (ServerLevelStub) lv2.getLevel();
LootTable lv4 = lv3.holder().getLootTable(lv);
return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null));
}
}
public static class ServerLevelStub extends ServerLevel {
private static Minecraft client = Minecraft.getInstance();
private static Unsafe unsafe = getUnsafe();
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10) {
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10);
private static CompletableFuture<RegistryAccess> registryAccess = load();
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10, @Nullable RandomSequences $$11) {
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11);
}
@Override
@@ -239,6 +285,15 @@ public final class BlockOptionalMeta {
}
}
@Override
public RegistryAccess registryAccess() {
return registryAccess.join();
}
public ReloadableServerRegistries.Holder holder() {
return new ReloadableServerRegistries.Holder(registryAccess().freeze());
}
public static Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
@@ -249,5 +304,42 @@ public final class BlockOptionalMeta {
}
}
public static CompletableFuture<RegistryAccess> load() {
PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository();
CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected());
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = loadAndReplaceLayer(
closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES
);
return ReloadableServerResources.loadResources(
closeableResourceManager,
layeredRegistryAccess,
WorldDataConfiguration.DEFAULT.enabledFeatures(),
Commands.CommandSelection.INTEGRATED,
2,
Runnable::run,
Minecraft.getInstance()
).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get());
}
private static LayeredRegistryAccess<RegistryLayer> loadAndReplaceLayer(
ResourceManager resourceManager,
LayeredRegistryAccess<RegistryLayer> registryAccess,
RegistryLayer registryLayer,
List<RegistryDataLoader.RegistryData<?>> registryData
) {
RegistryAccess.Frozen frozen = loadLayer(resourceManager, registryAccess, registryLayer, registryData);
return registryAccess.replaceFrom(registryLayer, frozen);
}
private static RegistryAccess.Frozen loadLayer(
ResourceManager resourceManager,
LayeredRegistryAccess<RegistryLayer> registryAccess,
RegistryLayer registryLayer,
List<RegistryDataLoader.RegistryData<?>> registryData
) {
RegistryAccess.Frozen frozen = registryAccess.getAccessForLoading(registryLayer);
return RegistryDataLoader.load(resourceManager, frozen, registryData);
}
}
}

View File

@@ -17,67 +17,70 @@
package baritone.api.utils;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableSet;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class BlockOptionalMetaLookup {
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
public class BlockOptionalMetaLookup {
private final ImmutableSet<Block> blockSet;
private final ImmutableSet<BlockState> blockStateSet;
private final ImmutableSet<Integer> stackHashes;
private final BlockOptionalMeta[] boms;
public BlockOptionalMetaLookup(BlockOptionalMeta... boms) {
this.boms = boms;
Set<Block> blocks = new HashSet<>();
Set<BlockState> blockStates = new HashSet<>();
Set<Integer> stacks = new HashSet<>();
for (BlockOptionalMeta bom : boms) {
blocks.add(bom.getBlock());
blockStates.addAll(bom.getAllBlockStates());
stacks.addAll(bom.stackHashes());
}
this.blockSet = ImmutableSet.copyOf(blocks);
this.blockStateSet = ImmutableSet.copyOf(blockStates);
this.stackHashes = ImmutableSet.copyOf(stacks);
}
public BlockOptionalMetaLookup(Block... blocks) {
this.boms = Stream.of(blocks)
this(Stream.of(blocks)
.map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new);
.toArray(BlockOptionalMeta[]::new));
}
public BlockOptionalMetaLookup(List<Block> blocks) {
this.boms = blocks.stream()
this(blocks.stream()
.map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new);
.toArray(BlockOptionalMeta[]::new));
}
public BlockOptionalMetaLookup(String... blocks) {
this.boms = Stream.of(blocks)
this(Stream.of(blocks)
.map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new);
.toArray(BlockOptionalMeta[]::new));
}
public boolean has(Block block) {
for (BlockOptionalMeta bom : boms) {
if (bom.getBlock() == block) {
return true;
}
}
return false;
return blockSet.contains(block);
}
public boolean has(BlockState state) {
for (BlockOptionalMeta bom : boms) {
if (bom.matches(state)) {
return true;
}
}
return false;
return blockStateSet.contains(state);
}
public boolean has(ItemStack stack) {
for (BlockOptionalMeta bom : boms) {
if (bom.matches(stack)) {
return true;
}
}
return false;
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
hash -= stack.getDamageValue();
return stackHashes.contains(hash);
}
public List<BlockOptionalMeta> blocks() {

View File

@@ -0,0 +1,27 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
/**
* @author Brady
*/
@FunctionalInterface
public interface BooleanBinaryOperator {
boolean applyAsBoolean(boolean a, boolean b);
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
/**
* @author Brady
*/
public enum BooleanBinaryOperators implements BooleanBinaryOperator {
OR((a, b) -> a || b),
AND((a, b) -> a && b),
XOR((a, b) -> a ^ b);
private final BooleanBinaryOperator op;
BooleanBinaryOperators(BooleanBinaryOperator op) {
this.op = op;
}
@Override
public boolean applyAsBoolean(boolean a, boolean b) {
return this.op.applyAsBoolean(a, b);
}
}

View File

@@ -18,13 +18,13 @@
package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.utils.gui.BaritoneToast;
import baritone.api.Settings;
import net.minecraft.ChatFormatting;
import net.minecraft.client.GuiMessageTag;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import java.awt.*;
import java.util.Arrays;
import java.util.Calendar;
import java.util.stream.Stream;
@@ -44,10 +44,17 @@ public interface Helper {
Helper HELPER = new Helper() {};
/**
* Instance of the game
* The main game instance returned by {@link Minecraft#getInstance()}.
* Deprecated since {@link IPlayerContext#minecraft()} should be used instead (In the majority of cases).
*/
@Deprecated
Minecraft mc = Minecraft.getInstance();
/**
* The tag to assign to chat messages when {@link Settings#useMessageTag} is {@code true}.
*/
GuiMessageTag MESSAGE_TAG = new GuiMessageTag(0xFF55FF, null, Component.literal("Baritone message."), "Baritone");
static Component getPrefix() {
// Inner text component
final Calendar now = Calendar.getInstance();
@@ -72,7 +79,7 @@ public interface Helper {
* @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));
Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message));
}
/**
@@ -133,7 +140,7 @@ public interface Helper {
* @param error Whether to log as an error
*/
default void logNotificationDirect(String message, boolean error) {
mc.execute(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error));
Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error));
}
/**
@@ -160,13 +167,15 @@ public interface Helper {
*/
default void logDirect(boolean logAsToast, Component... components) {
MutableComponent component = Component.literal("");
component.append(getPrefix());
component.append(Component.literal(" "));
if (!logAsToast && !BaritoneAPI.getSettings().useMessageTag.value) {
component.append(getPrefix());
component.append(Component.literal(" "));
}
Arrays.asList(components).forEach(component::append);
if (logAsToast) {
logToast(getPrefix(), component);
} else {
mc.execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
}
}
@@ -226,4 +235,11 @@ public interface Helper {
default void logDirect(String message) {
logDirect(message, BaritoneAPI.getSettings().logAsToast.value);
}
default void logUnhandledException(final Throwable exception) {
HELPER.logDirect("An unhandled exception occurred. " +
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
ChatFormatting.RED);
exception.printStackTrace();
}
}

View File

@@ -18,9 +18,7 @@
package baritone.api.utils;
import baritone.api.cache.IWorldData;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
@@ -31,12 +29,18 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* @author Brady
* @since 11/12/2018
*/
public interface IPlayerContext {
Minecraft minecraft();
LocalPlayer player();
IPlayerController playerController();
@@ -85,6 +89,12 @@ public interface IPlayerContext {
return new Vec3(player().position().x, player().position().y + player().getEyeHeight(), player().position().z);
}
default Vec3 playerMotion() {
return player().getDeltaMovement();
}
BetterBlockPos viewerPos();
default Rotation playerRotations() {
return new Rotation(player().getYRot(), player().getXRot());
}

View File

@@ -0,0 +1,59 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
import java.util.Objects;
/**
* @author Brady
*/
public final class Pair<A, B> {
private final A a;
private final B b;
public Pair(A a, B b) {
this.a = a;
this.b = b;
}
public A first() {
return this.a;
}
public B second() {
return this.b;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || o.getClass() != Pair.class) {
return false;
}
Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(this.a, pair.a) && Objects.equals(this.b, pair.b);
}
@Override
public int hashCode() {
return 31 * Objects.hashCode(this.a) + Objects.hashCode(this.b);
}
}

View File

@@ -51,13 +51,14 @@ public final class RayTraceUtils {
} else {
start = entity.getEyePosition(1.0F); // do whatever is correct
}
Vec3 direction = RotationUtils.calcVector3dFromRotation(rotation);
Vec3 direction = RotationUtils.calcLookDirectionFromRotation(rotation);
Vec3 end = start.add(
direction.x * blockReachDistance,
direction.y * blockReachDistance,
direction.z * blockReachDistance
);
return entity.level.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
return entity.level().clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
}
public static Vec3 inferSneakingEyePosition(Entity entity) {

View File

@@ -26,12 +26,12 @@ public class Rotation {
/**
* The yaw angle of this Rotation
*/
private float yaw;
private final float yaw;
/**
* The pitch angle of this Rotation
*/
private float pitch;
private final float pitch;
public Rotation(float yaw, float pitch) {
this.yaw = yaw;
@@ -113,6 +113,10 @@ public class Rotation {
);
}
public Rotation withPitch(float pitch) {
return new Rotation(this.yaw, pitch);
}
/**
* Is really close to
*

View File

@@ -19,7 +19,6 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import java.util.Optional;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -33,6 +32,8 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.Optional;
/**
* @author Brady
* @since 9/25/2018
@@ -43,11 +44,13 @@ public final class RotationUtils {
* Constant that a degree value is multiplied by to get the equivalent radian value
*/
public static final double DEG_TO_RAD = Math.PI / 180.0;
public static final float DEG_TO_RAD_F = (float) DEG_TO_RAD;
/**
* Constant that a radian value is multiplied by to get the equivalent degree value
*/
public static final double RAD_TO_DEG = 180.0 / Math.PI;
public static final float RAD_TO_DEG_F = (float) RAD_TO_DEG;
/**
* Offsets from the root block position to the center of each side.
@@ -128,26 +131,31 @@ public final class RotationUtils {
* @param rotation The input rotation
* @return Look vector for the rotation
*/
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));
public static Vec3 calcLookDirectionFromRotation(Rotation rotation) {
float flatZ = Mth.cos((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI);
float flatX = Mth.sin((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI);
float pitchBase = -Mth.cos(-rotation.getPitch() * DEG_TO_RAD_F);
float pitchHeight = Mth.sin(-rotation.getPitch() * DEG_TO_RAD_F);
return new Vec3(flatX * pitchBase, pitchHeight, flatZ * pitchBase);
}
@Deprecated
public static Vec3 calcVec3dFromRotation(Rotation rotation) {
return calcLookDirectionFromRotation(rotation);
}
/**
* @param ctx Context for the viewing entity
* @param pos The target block position
* @return The optional rotation
* @see #reachable(LocalPlayer, BlockPos, double)
* @see #reachable(IPlayerContext, BlockPos, double)
*/
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
return reachable(ctx, pos, false);
}
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, boolean wouldSneak) {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance(), wouldSneak);
return reachable(ctx, pos, ctx.playerController().getBlockReachDistance(), wouldSneak);
}
/**
@@ -157,18 +165,17 @@ public final class RotationUtils {
* side that is reachable. The return type will be {@link Optional#empty()} if the entity is
* unable to reach any of the sides of the block.
*
* @param entity The viewing entity
* @param ctx Context for the viewing entity
* @param pos The target block position
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false);
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, double blockReachDistance) {
return reachable(ctx, pos, blockReachDistance, false);
}
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
if (baritone.getPlayerContext().isLookingAt(pos)) {
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
if (BaritoneAPI.getSettings().remainWithExistingLookDirection.value && ctx.isLookingAt(pos)) {
/*
* why add 0.0001?
* to indicate that we actually have a desired pitch
@@ -179,10 +186,10 @@ 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.getYRot(), entity.getXRot() + 0.0001F);
Rotation hypothetical = ctx.playerRotations().add(new Rotation(0, 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
HitResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), 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
}
@@ -190,14 +197,14 @@ public final class RotationUtils {
return Optional.of(hypothetical);
}
}
Optional<Rotation> possibleRotation = reachableCenter(entity, pos, blockReachDistance, wouldSneak);
Optional<Rotation> possibleRotation = reachableCenter(ctx, pos, blockReachDistance, wouldSneak);
//System.out.println("center: " + possibleRotation);
if (possibleRotation.isPresent()) {
return possibleRotation;
}
BlockState state = entity.level.getBlockState(pos);
VoxelShape shape = state.getShape(entity.level, pos);
BlockState state = ctx.world().getBlockState(pos);
VoxelShape shape = state.getShape(ctx.world(), pos);
if (shape.isEmpty()) {
shape = Shapes.block();
}
@@ -205,7 +212,7 @@ public final class RotationUtils {
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);
possibleRotation = reachableOffset(ctx, pos, new Vec3(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
if (possibleRotation.isPresent()) {
return possibleRotation;
}
@@ -218,22 +225,23 @@ public final class RotationUtils {
* the given offsetted position. The return type will be {@link Optional#empty()} if
* the entity is unable to reach the block with the offset applied.
*
* @param entity The viewing entity
* @param ctx Context for the viewing entity
* @param pos The target block position
* @param offsetPos The position of the block with the offset applied.
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
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);
public static Optional<Rotation> reachableOffset(IPlayerContext ctx, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(ctx.player()) : ctx.player().getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, ctx.playerRotations());
Rotation actualRotation = BaritoneAPI.getProvider().getBaritoneForPlayer(ctx.player()).getLookBehavior().getAimProcessor().peekRotation(rotation);
HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), actualRotation, blockReachDistance, wouldSneak);
//System.out.println(result);
if (result != null && result.getType() == HitResult.Type.BLOCK) {
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
if (ctx.world().getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation);
}
}
@@ -244,12 +252,46 @@ public final class RotationUtils {
* Determines if the specified entity is able to reach the specified block where it is
* looking at the direct center of it's hitbox.
*
* @param entity The viewing entity
* @param ctx Context for the viewing entity
* @param pos The target block position
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachableCenter(IPlayerContext ctx, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(ctx, pos, VecUtils.calculateBlockCenter(ctx.world(), pos), blockReachDistance, wouldSneak);
}
@Deprecated
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false);
}
@Deprecated
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
IPlayerContext ctx = baritone.getPlayerContext();
return reachable(ctx, pos, blockReachDistance, wouldSneak);
}
@Deprecated
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() == HitResult.Type.BLOCK) {
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.level().getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation);
}
}
return Optional.empty();
}
@Deprecated
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level(), pos), blockReachDistance, wouldSneak);
}
}

View File

@@ -47,12 +47,10 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SettingsUtil {
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDirectory.toPath().resolve("baritone").resolve("settings.txt");
public static final String SETTINGS_DEFAULT_NAME = "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) {
@@ -71,12 +69,12 @@ public class SettingsUtil {
}
}
public static void readAndApply(Settings settings) {
public static void readAndApply(Settings settings, String settingsName) {
try {
forEachLine(SETTINGS_PATH, line -> {
forEachLine(settingsByName(settingsName), line -> {
Matcher matcher = SETTING_PATTERN.matcher(line);
if (!matcher.matches()) {
System.out.println("Invalid syntax in setting file: " + line);
Helper.HELPER.logDirect("Invalid syntax in setting file: " + line);
return;
}
@@ -85,29 +83,33 @@ public class SettingsUtil {
try {
parseAndApply(settings, settingName, settingValue);
} catch (Exception ex) {
System.out.println("Unable to parse line " + line);
Helper.HELPER.logDirect("Unable to parse line " + line);
ex.printStackTrace();
}
});
} catch (NoSuchFileException ignored) {
System.out.println("Baritone settings file not found, resetting.");
Helper.HELPER.logDirect("Baritone settings file not found, resetting.");
} catch (Exception ex) {
System.out.println("Exception while reading Baritone settings, some settings may be reset to default values!");
Helper.HELPER.logDirect("Exception while reading Baritone settings, some settings may be reset to default values!");
ex.printStackTrace();
}
}
public static synchronized void save(Settings settings) {
try (BufferedWriter out = Files.newBufferedWriter(SETTINGS_PATH)) {
try (BufferedWriter out = Files.newBufferedWriter(settingsByName(SETTINGS_DEFAULT_NAME))) {
for (Settings.Setting setting : modifiedSettings(settings)) {
out.write(settingToString(setting) + "\n");
}
} catch (Exception ex) {
System.out.println("Exception thrown while saving Baritone settings!");
Helper.HELPER.logDirect("Exception thrown while saving Baritone settings!");
ex.printStackTrace();
}
}
private static Path settingsByName(String name) {
return Minecraft.getInstance().gameDirectory.toPath().resolve("baritone").resolve(name);
}
public static List<Settings.Setting> modifiedSettings(Settings settings) {
List<Settings.Setting> modified = new ArrayList<>();
for (Settings.Setting setting : settings.allSettings) {
@@ -115,7 +117,7 @@ public class SettingsUtil {
System.out.println("NULL SETTING?" + setting.getName());
continue;
}
if (javaOnlySetting(setting)) {
if (setting.isJavaOnly()) {
continue; // NO
}
if (setting.value == setting.defaultValue) {
@@ -147,7 +149,7 @@ public class SettingsUtil {
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName());
}
return io.toString(new ParserContext(setting), value);
return io.toString(setting.getType(), value);
}
public static String settingValueToString(Settings.Setting setting) throws IllegalArgumentException {
@@ -169,7 +171,7 @@ public class SettingsUtil {
}
public static String settingToString(Settings.Setting setting) throws IllegalStateException {
if (javaOnlySetting(setting)) {
if (setting.isJavaOnly()) {
return setting.getName();
}
@@ -177,18 +179,14 @@ public class SettingsUtil {
}
/**
* This should always be the same as whether the setting can be parsed from or serialized to a string
* Deprecated. Use {@link Settings.Setting#isJavaOnly()} instead.
*
* @param setting The Setting
* @return true if the setting can not be set or read by the user
*/
@Deprecated
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;
return setting.isJavaOnly();
}
public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
@@ -198,7 +196,7 @@ public class SettingsUtil {
}
Class intendedType = setting.getValueClass();
ISettingParser ioMethod = Parser.getParser(setting.getType());
Object parsed = ioMethod.parse(new ParserContext(setting), settingValue);
Object parsed = ioMethod.parse(setting.getType(), settingValue);
if (!intendedType.isInstance(parsed)) {
throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass());
}
@@ -207,26 +205,13 @@ public class SettingsUtil {
private interface ISettingParser<T> {
T parse(ParserContext context, String raw);
T parse(Type type, String raw);
String toString(ParserContext context, T value);
String toString(Type type, T value);
boolean accepts(Type type);
}
private static class ParserContext {
private final Settings.Setting<?> setting;
private ParserContext(Settings.Setting<?> setting) {
this.setting = setting;
}
private Settings.Setting<?> getSetting() {
return this.setting;
}
}
private enum Parser implements ISettingParser {
DOUBLE(Double.class, Double::parseDouble),
@@ -253,26 +238,26 @@ public class SettingsUtil {
),
ITEM(
Item.class,
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {
@Override
public Object parse(ParserContext context, String raw) {
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Parser parser = Parser.getParser(type);
public Object parse(Type type, String raw) {
Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];
Parser parser = Parser.getParser(elementType);
return Stream.of(raw.split(","))
.map(s -> parser.parse(context, s))
.map(s -> parser.parse(elementType, s))
.collect(Collectors.toList());
}
@Override
public String toString(ParserContext context, Object value) {
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Parser parser = Parser.getParser(type);
public String toString(Type type, Object value) {
Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];
Parser parser = Parser.getParser(elementType);
return ((List<?>) value).stream()
.map(o -> parser.toString(context, o))
.map(o -> parser.toString(elementType, o))
.collect(Collectors.joining(","));
}
@@ -283,26 +268,26 @@ public class SettingsUtil {
},
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];
public Object parse(Type type, String raw) {
Type keyType = ((ParameterizedType) type).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) type).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])));
.collect(Collectors.toMap(s -> keyParser.parse(keyType, s[0]), s -> valueParser.parse(valueType, 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];
public String toString(Type type, Object value) {
Type keyType = ((ParameterizedType) type).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) type).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()))
.map(o -> keyParser.toString(keyType, o.getKey()) + "->" + valueParser.toString(valueType, o.getValue()))
.collect(Collectors.joining(","));
}
@@ -333,14 +318,14 @@ public class SettingsUtil {
}
@Override
public Object parse(ParserContext context, String raw) {
public Object parse(Type type, String raw) {
Object parsed = this.parser.apply(raw);
Objects.requireNonNull(parsed);
return parsed;
}
@Override
public String toString(ParserContext context, Object value) {
public String toString(Type type, Object value) {
return this.toString.apply(value);
}

View File

@@ -0,0 +1,28 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils.accessor;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
public interface ILootTable {
ObjectArrayList<ItemStack> invokeGetRandomItems(LootContext context);
}

View File

@@ -20,6 +20,7 @@ package baritone.api.utils.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.network.chat.Component;
@@ -38,7 +39,7 @@ public class BaritoneToast implements Toast {
this.totalShowTime = totalShowTime;
}
public Visibility render(PoseStack matrixStack, ToastComponent toastGui, long delta) {
public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) {
if (this.newDisplay) {
this.firstDrawTime = delta;
this.newDisplay = false;
@@ -46,15 +47,13 @@ public class BaritoneToast implements Toast {
//TODO: check
toastGui.getMinecraft().getTextureManager().bindForSetup(new ResourceLocation("textures/gui/toasts.png"));
//GlStateManager._color4f(1.0F, 1.0F, 1.0F, 255.0F);
toastGui.blit(matrixStack, 0, 0, 0, 32, 160, 32);
gui.blit(ResourceLocation.parse("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
if (this.subtitle == null) {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 12, -11534256);
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);
} else {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 7, -11534256);
toastGui.getMinecraft().font.draw(matrixStack, this.subtitle, 18, 18, -16777216);
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 7, -11534256);
gui.drawString(toastGui.getMinecraft().font, this.subtitle, 18, 18, -16777216);
}
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;

View File

@@ -20,29 +20,36 @@ package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.BlockChangeEvent;
import baritone.api.event.events.ChatEvent;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.type.EventState;
import baritone.api.utils.Pair;
import baritone.cache.CachedChunk;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.multiplayer.CommonListenerCookie;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.core.BlockPos;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.*;
import net.minecraft.world.level.ChunkPos;
import org.spongepowered.asm.mixin.Final;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
import java.util.List;
/**
* @author Brady
* @since 8/3/2018
*/
@Mixin(ClientPacketListener.class)
public class MixinClientPlayNetHandler {
public abstract class MixinClientPlayNetHandler extends ClientCommonPacketListenerImpl {
// unused lol
/*@Inject(
@@ -68,12 +75,14 @@ public class MixinClientPlayNetHandler {
}
}*/
@Shadow @Final private Minecraft minecraft;
protected MixinClientPlayNetHandler(final Minecraft arg, final Connection arg2, final CommonListenerCookie arg3) {
super(arg, arg2, arg3);
}
@Inject(
method = "sendChat(Ljava/lang/String;)V",
at = @At("HEAD"),
cancellable = true
method = "sendChat(Ljava/lang/String;)V",
at = @At("HEAD"),
cancellable = true
)
private void sendChatMessage(String string, CallbackInfo ci) {
ChatEvent event = new ChatEvent(string);
@@ -116,7 +125,7 @@ public class MixinClientPlayNetHandler {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z)
);
}
}
@@ -131,7 +140,7 @@ public class MixinClientPlayNetHandler {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z)
);
}
}
@@ -168,31 +177,22 @@ public class MixinClientPlayNetHandler {
at = @At("RETURN")
)
private void postHandleMultiBlockChange(ClientboundSectionBlocksUpdatePacket packetIn, CallbackInfo ci) {
if (!Baritone.settings().repackOnAnyBlockChange.value) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForConnection((ClientPacketListener) (Object) this);
if (baritone == null) {
return;
}
ChunkPos[] chunkPos = new ChunkPos[1];
packetIn.runUpdates((pos, state) -> {
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(state.getBlock())) {
chunkPos[0] = new ChunkPos(pos);
}
List<Pair<BlockPos, BlockState>> changes = new ArrayList<>();
packetIn.runUpdates((mutPos, state) -> {
changes.add(new Pair<>(mutPos.immutable(), state));
});
if (chunkPos[0] == null) {
if (changes.isEmpty()) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
ChunkEvent.Type.POPULATE_FULL,
chunkPos[0].x,
chunkPos[0].z
)
);
}
}
baritone.getGameEventHandler().onBlockChange(new BlockChangeEvent(
new ChunkPos(changes.get(0).first()),
changes
));
}
@Inject(
@@ -210,4 +210,71 @@ public class MixinClientPlayNetHandler {
}
}
}
/*
@Inject(
method = "handleChunkData",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/chunk/Chunk.read(Lnet/minecraft/network/PacketBuffer;IZ)V"
)
)
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForConnection((NetHandlerPlayClient) (Object) this);
if (baritone == null) {
return;
}
baritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.PRE,
packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
packetIn.getChunkX(),
packetIn.getChunkZ()
)
);
}
@Inject(
method = "handleChunkData",
at = @At("RETURN")
)
private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForConnection((NetHandlerPlayClient) (Object) this);
if (baritone == null) {
return;
}
baritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
packetIn.getChunkX(),
packetIn.getChunkZ()
)
);
}
@Inject(
method = "handleBlockChange",
at = @At("RETURN")
)
private void postHandleBlockChange(SPacketBlockChange packetIn, CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForConnection((NetHandlerPlayClient) (Object) this);
if (baritone == null) {
return;
}
final ChunkPos pos = new ChunkPos(packetIn.getBlockPosition().getX() >> 4, packetIn.getBlockPosition().getZ() >> 4);
final Pair<BlockPos, IBlockState> changed = new Pair<>(packetIn.getBlockPosition(), packetIn.getBlockState());
baritone.getGameEventHandler().onBlockChange(new BlockChangeEvent(pos, Collections.singletonList(changed)));
}
@Inject(
method = "handleMultiBlockChange",
at = @At("RETURN")
)
private void postHandleMultiBlockChange(SPacketMultiBlockChange packetIn, CallbackInfo ci) {
}
*/
}

View File

@@ -19,41 +19,43 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.ChatEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.type.EventState;
import baritone.behavior.LookBehavior;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Abilities;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
/**
* @author Brady
* @since 8/1/2018
*/
@Mixin(LocalPlayer.class)
public class MixinClientPlayerEntity {
@Unique
private static final MethodHandle MAY_FLY = baritone$resolveMayFly();
@Inject(
method = "tick",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/player/LocalPlayer.isPassenger()Z",
shift = At.Shift.BY,
by = -3
)
)
private void onPreUpdate(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (baritone != null) {
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
@Unique
private static MethodHandle baritone$resolveMayFly() {
try {
var lookup = MethodHandles.publicLookup();
return lookup.findVirtual(LocalPlayer.class, "mayFly", MethodType.methodType(boolean.class));
} catch (NoSuchMethodException e) {
return null;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@@ -61,15 +63,14 @@ public class MixinClientPlayerEntity {
method = "tick",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/player/LocalPlayer.sendPosition()V",
shift = At.Shift.BY,
by = 2
target = "net/minecraft/client/player/AbstractClientPlayer.tick()V",
shift = At.Shift.AFTER
)
)
private void onPostUpdate(CallbackInfo ci) {
private void onPreUpdate(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (baritone != null) {
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
}
}
@@ -80,6 +81,7 @@ public class MixinClientPlayerEntity {
target = "net/minecraft/world/entity/player/Abilities.mayfly:Z"
)
)
@Group(name = "mayFly", min = 1, max = 1)
private boolean isAllowFlying(Abilities capabilities) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (baritone == null) {
@@ -88,6 +90,22 @@ public class MixinClientPlayerEntity {
return !baritone.getPathingBehavior().isPathing() && capabilities.mayfly;
}
@Redirect(
method = "aiStep",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/player/LocalPlayer;mayFly()Z"
)
)
@Group(name = "mayFly", min = 1, max = 1)
private boolean onMayFlyNeoforge(LocalPlayer instance) throws Throwable {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (baritone == null) {
return (boolean) MAY_FLY.invokeExact(instance);
}
return !baritone.getPathingBehavior().isPathing() && (boolean) MAY_FLY.invokeExact(instance);
}
@Redirect(
method = "aiStep",
at = @At(
@@ -124,4 +142,19 @@ public class MixinClientPlayerEntity {
((LookBehavior) baritone.getLookBehavior()).pig();
}
}
@Redirect(
method = "aiStep",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/player/LocalPlayer;tryToStartFallFlying()Z"
)
)
private boolean tryToStartFallFlying(final LocalPlayer instance) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(instance);
if (baritone != null && baritone.getPathingBehavior().isPathing()) {
return false;
}
return instance.tryToStartFallFlying();
}
}

View File

@@ -19,9 +19,12 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.event.events.TabCompleteEvent;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.context.StringRange;
import com.mojang.brigadier.suggestion.Suggestion;
import com.mojang.brigadier.suggestion.Suggestions;
import net.minecraft.client.gui.components.CommandSuggestions;
import net.minecraft.client.gui.components.EditBox;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -33,8 +36,6 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.client.gui.components.CommandSuggestions;
import net.minecraft.client.gui.components.EditBox;
/**
* @author Brady
@@ -51,9 +52,18 @@ public class MixinCommandSuggestionHelper {
@Final
private List<String> commandUsage;
@Shadow
private ParseResults currentParse;
@Shadow
private CompletableFuture<Suggestions> pendingSuggestions;
@Shadow
private CommandSuggestions.SuggestionsList suggestions;
@Shadow
boolean keepSuggestions;
@Inject(
method = "updateCommandInfo",
at = @At("HEAD"),
@@ -74,27 +84,32 @@ public class MixinCommandSuggestionHelper {
if (event.completions != null) {
ci.cancel();
this.currentParse = null; // stop coloring
if (this.keepSuggestions) { // Supress suggestions update when cycling suggestions.
return;
}
this.input.setSuggestion(null); // clear old suggestions
this.suggestions = null;
// TODO: Support populating the command usage
this.commandUsage.clear();
if (event.completions.length == 0) {
this.pendingSuggestions = Suggestions.empty();
} else {
int offset = this.input.getValue().endsWith(" ")
? this.input.getCursorPosition()
: this.input.getValue().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
StringRange range = StringRange.between(prefix.lastIndexOf(" ") + 1, prefix.length()); // if there is no space this starts at 0
List<Suggestion> suggestionList = Stream.of(event.completions)
.map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s))
.map(s -> new Suggestion(range, s))
.collect(Collectors.toList());
Suggestions suggestions = new Suggestions(
StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)),
suggestionList);
Suggestions suggestions = new Suggestions(range, suggestionList);
this.pendingSuggestions = new CompletableFuture<>();
this.pendingSuggestions.complete(suggestions);
}
((CommandSuggestions) (Object) this).showSuggestions(true); // actually populate the suggestions list from the suggestions future
}
}
}

View File

@@ -23,6 +23,7 @@ import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -33,21 +34,25 @@ public class MixinEntity {
@Shadow
private float yRot;
float yawRestore;
@Shadow
private float xRot;
@Unique
private RotationMoveEvent motionUpdateRotationEvent;
@Inject(
method = "moveRelative",
at = @At("HEAD")
)
private void moveRelativeHead(CallbackInfo info) {
this.yawRestore = this.yRot;
// noinspection ConstantConditions
if (!LocalPlayer.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this) == null) {
return;
}
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.yRot);
this.motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.yRot, this.xRot);
BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
this.yRot = motionUpdateRotationEvent.getYaw();
this.yRot = this.motionUpdateRotationEvent.getYaw();
this.xRot = this.motionUpdateRotationEvent.getPitch();
}
@Inject(
@@ -55,6 +60,10 @@ public class MixinEntity {
at = @At("RETURN")
)
private void moveRelativeReturn(CallbackInfo info) {
this.yRot = this.yawRestore;
if (this.motionUpdateRotationEvent != null) {
this.yRot = this.motionUpdateRotationEvent.getOriginal().getYaw();
this.xRot = this.motionUpdateRotationEvent.getOriginal().getPitch();
this.motionUpdateRotationEvent = null;
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.launch.mixins;
import baritone.utils.accessor.IFireworkRocketEntity;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.OptionalInt;
@Mixin(FireworkRocketEntity.class)
public abstract class MixinFireworkRocketEntity extends Entity implements IFireworkRocketEntity {
@Shadow
@Final
private static EntityDataAccessor<OptionalInt> DATA_ATTACHED_TO_TARGET;
@Shadow
private LivingEntity attachedToEntity;
@Shadow
public abstract boolean isAttachedToEntity();
private MixinFireworkRocketEntity(Level level) {
super(EntityType.FIREWORK_ROCKET, level);
}
@Override
public LivingEntity getBoostedEntity() {
if (this.isAttachedToEntity() && this.attachedToEntity == null) { // isAttachedToEntity checks if the optional is present
final Entity entity = this.level().getEntity(this.entityData.get(DATA_ATTACHED_TO_TARGET).getAsInt());
if (entity instanceof LivingEntity) {
this.attachedToEntity = (LivingEntity) entity;
}
}
return this.attachedToEntity;
}
}

View File

@@ -25,13 +25,15 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static org.objectweb.asm.Opcodes.GETFIELD;
import java.util.Optional;
/**
* @author Brady
@@ -43,9 +45,13 @@ public abstract class MixinLivingEntity extends Entity {
/**
* Event called to override the movement direction when jumping
*/
@Unique
private RotationMoveEvent jumpRotationEvent;
public MixinLivingEntity(EntityType<?> entityTypeIn, Level worldIn) {
@Unique
private RotationMoveEvent elytraRotationEvent;
private MixinLivingEntity(EntityType<?> entityTypeIn, Level worldIn) {
super(entityTypeIn, worldIn);
}
@@ -54,14 +60,10 @@ public abstract class MixinLivingEntity extends Entity {
at = @At("HEAD")
)
private void preMoveRelative(CallbackInfo ci) {
// noinspection ConstantConditions
if (LocalPlayer.class.isInstance(this)) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (baritone != null) {
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.getYRot());
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
}
}
this.getBaritone().ifPresent(baritone -> {
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.getYRot(), this.getXRot());
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
});
}
@Redirect(
@@ -78,5 +80,45 @@ public abstract class MixinLivingEntity extends Entity {
return self.getYRot();
}
@Inject(
method = "travel",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.getLookAngle()Lnet/minecraft/world/phys/Vec3;"
)
)
private void onPreElytraMove(Vec3 direction, CallbackInfo ci) {
this.getBaritone().ifPresent(baritone -> {
this.elytraRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.getYRot(), this.getXRot());
baritone.getGameEventHandler().onPlayerRotationMove(this.elytraRotationEvent);
this.setYRot(this.elytraRotationEvent.getYaw());
this.setXRot(this.elytraRotationEvent.getPitch());
});
}
@Inject(
method = "travel",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V",
shift = At.Shift.AFTER
)
)
private void onPostElytraMove(Vec3 direction, CallbackInfo ci) {
if (this.elytraRotationEvent != null) {
this.setYRot(this.elytraRotationEvent.getOriginal().getYaw());
this.setXRot(this.elytraRotationEvent.getOriginal().getPitch());
this.elytraRotationEvent = null;
}
}
@Unique
private Optional<IBaritone> getBaritone() {
// noinspection ConstantConditions
if (LocalPlayer.class.isInstance(this)) {
return Optional.ofNullable(BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this));
} else {
return Optional.empty();
}
}
}

View File

@@ -1,74 +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.launch.mixins;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
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 org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(LootContext.Builder.class)
public class MixinLootContext {
@Redirect(
method = "create",
at = @At(
value = "INVOKE",
target = "net/minecraft/server/level/ServerLevel.getServer()Lnet/minecraft/server/MinecraftServer;"
)
)
private MinecraftServer getServer(ServerLevel world) {
if (world == null) {
return null;
}
return world.getServer();
}
@Redirect(
method = "create",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getLootTables()Lnet/minecraft/world/level/storage/loot/LootTables;"
)
)
private LootTables getLootTableManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getManager();
}
return server.getLootTables();
}
@Redirect(
method = "create",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getPredicateManager()Lnet/minecraft/world/level/storage/loot/PredicateManager;"
)
)
private PredicateManager getLootPredicateManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getPredicateManager();
}
return server.getPredicateManager();
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.launch.mixins;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ReloadableServerRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.storage.loot.LootContext;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(LootContext.Builder.class)
public abstract class MixinLootContextBuilder {
@Shadow public abstract ServerLevel getLevel();
@Redirect(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;reloadableRegistries()Lnet/minecraft/server/ReloadableServerRegistries$Holder;"))
private ReloadableServerRegistries.Holder create(MinecraftServer instance) {
if (instance != null) {
return instance.reloadableRegistries();
}
if (getLevel() instanceof BlockOptionalMeta.ServerLevelStub sls) {
return sls.holder();
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.launch.mixins;
import baritone.api.utils.accessor.ILootTable;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(LootTable.class)
public abstract class MixinLootTable implements ILootTable {
@Invoker
public abstract ObjectArrayList<ItemStack> invokeGetRandomItems(LootContext context);
}

View File

@@ -19,19 +19,23 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.event.events.WorldEvent;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ReceivingLevelScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BiFunction;
@@ -48,6 +52,9 @@ public class MixinMinecraft {
@Shadow
public ClientLevel level;
@Unique
private BiFunction<EventState, TickEvent.Type, TickEvent> tickProvider;
@Inject(
method = "<init>",
at = @At("RETURN")
@@ -56,37 +63,75 @@ public class MixinMinecraft {
BaritoneAPI.getProvider().getPrimaryBaritone();
}
@Inject(
method = "tick",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "net/minecraft/client/Minecraft.screen:Lnet/minecraft/client/gui/screens/Screen;",
ordinal = 0,
shift = At.Shift.BEFORE
),
slice = @Slice(
from = @At(
value = "FIELD",
opcode = Opcodes.PUTFIELD,
target = "net/minecraft/client/Minecraft.missTime:I"
)
)
)
private void runTick(CallbackInfo ci) {
this.tickProvider = TickEvent.createNextProvider();
for (IBaritone baritone : BaritoneAPI.getProvider().getAllBaritones()) {
TickEvent.Type type = baritone.getPlayerContext().player() != null && baritone.getPlayerContext().world() != null
? TickEvent.Type.IN
: TickEvent.Type.OUT;
baritone.getGameEventHandler().onTick(this.tickProvider.apply(EventState.PRE, type));
}
}
@Inject(
method = "tick",
at = @At("RETURN")
)
private void postRunTick(CallbackInfo ci) {
if (this.tickProvider == null) {
return;
}
for (IBaritone baritone : BaritoneAPI.getProvider().getAllBaritones()) {
TickEvent.Type type = baritone.getPlayerContext().player() != null && baritone.getPlayerContext().world() != null
? TickEvent.Type.IN
: TickEvent.Type.OUT;
baritone.getGameEventHandler().onPostTick(this.tickProvider.apply(EventState.POST, type));
}
this.tickProvider = null;
}
@Inject(
method = "tick",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;",
ordinal = 4,
shift = At.Shift.BY,
by = -3
value = "INVOKE",
target = "net/minecraft/client/multiplayer/ClientLevel.tickEntities()V",
shift = At.Shift.AFTER
)
)
private void runTick(CallbackInfo ci) {
final BiFunction<EventState, TickEvent.Type, TickEvent> tickProvider = TickEvent.createNextProvider();
for (IBaritone baritone : BaritoneAPI.getProvider().getAllBaritones()) {
TickEvent.Type type = baritone.getPlayerContext().player() != null && baritone.getPlayerContext().world() != null
? TickEvent.Type.IN
: TickEvent.Type.OUT;
baritone.getGameEventHandler().onTick(tickProvider.apply(EventState.PRE, type));
private void postUpdateEntities(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(this.player);
if (baritone != null) {
// Intentionally call this after all entities have been updated. That way, any modification to rotations
// can be recognized by other entity code. (Fireworks and Pigs, for example)
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
}
}
@Inject(
method = "setLevel",
at = @At("HEAD")
)
private void preLoadWorld(ClientLevel world, CallbackInfo ci) {
private void preLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) {
// If we're unloading the world but one doesn't exist, ignore it
if (this.level == null && world == null) {
return;
@@ -106,7 +151,7 @@ public class MixinMinecraft {
method = "setLevel",
at = @At("RETURN")
)
private void postLoadWorld(ClientLevel world, CallbackInfo ci) {
private void postLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) {
// still fire event for both null, as that means we've just finished exiting a world
// mc.world changing is only the primary baritone
@@ -123,12 +168,25 @@ public class MixinMinecraft {
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/gui/screens/Screen;passEvents:Z"
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;"
),
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;showDebugScreen()Z"
),
to = @At(
value = "CONSTANT",
args = "stringValue=Keybindings"
)
)
)
private boolean passEvents(Screen screen) {
private Screen passEvents(Minecraft instance) {
// allow user input is only the primary baritone
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) {
return null;
}
return instance.screen;
}
// TODO

View File

@@ -23,8 +23,6 @@ import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.type.EventState;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
@@ -54,7 +52,7 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("HEAD")
)
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}
@@ -70,7 +68,7 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("RETURN")
)
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}

View File

@@ -0,0 +1,34 @@
/*
* 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.launch.mixins;
import baritone.utils.accessor.IPalettedContainer.IData;
import net.minecraft.util.BitStorage;
import net.minecraft.world.level.chunk.Palette;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(targets = "net/minecraft/world/level/chunk/PalettedContainer$Data")
public abstract class MixinPalettedContainer$Data<T> implements IData<T> {
@Accessor
public abstract Palette<T> getPalette();
@Accessor
public abstract BitStorage getStorage();
}

View File

@@ -0,0 +1,100 @@
/*
* 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.launch.mixins;
import baritone.utils.accessor.IPalettedContainer;
import baritone.utils.accessor.IPalettedContainer.IData;
import net.minecraft.util.BitStorage;
import net.minecraft.world.level.chunk.Palette;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@Mixin(PalettedContainer.class)
public abstract class MixinPalettedContainer<T> implements IPalettedContainer<T> {
private static final MethodHandle DATA_GETTER;
// Mixin has no way of referring to the data field and we can't use inheritance
// tricks to determine its name, so we use this ugly workaround instead.
// Classloading is hell here and causes accessor mixins (@Mixin interfaces with
// only @Accessor and @Invoker methods) to break on use and proguard hates method
// handles and on top of that mojang decided that error messages during world
// load are not needed so if you want to debug this you'll probably need an extra
// mixin just to display the error and hard quit the game before follow up errors
// blow up your log file.
// Mumphrey, please add the shadow classes you promised 5 years ago.
static {
Field dataField = null;
for (Field field : PalettedContainer.class.getDeclaredFields()) {
Class<?> fieldType = field.getType();
if (IData.class.isAssignableFrom(fieldType)) {
if ((field.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) != 0 || field.isSynthetic()) {
continue;
}
if (dataField != null) {
throw new IllegalStateException("PalettedContainer has more than one Data field.");
}
dataField = field;
}
}
if (dataField == null) {
throw new IllegalStateException("PalettedContainer has no Data field.");
}
MethodHandle rawGetter;
try {
rawGetter = MethodHandles.lookup().unreflectGetter(dataField);
} catch (IllegalAccessException impossible) {
// we literally are the owning class, wtf?
throw new IllegalStateException("PalettedContainer may not access its own field?!", impossible);
}
MethodType getterType = MethodType.methodType(IData.class, PalettedContainer.class);
DATA_GETTER = MethodHandles.explicitCastArguments(rawGetter, getterType);
}
@Override
public Palette<T> getPalette() {
return data().getPalette();
}
@Override
public BitStorage getStorage() {
return data().getStorage();
}
@Unique
private IData<T> data() {
try {
// cast to Object first so the method handle doesn't hide the interface usage from proguard
return (IData<T>) (Object) DATA_GETTER.invoke((PalettedContainer<T>) (Object) this);
} catch (Throwable t) {
throw sneaky(t, RuntimeException.class);
}
}
@Unique
private static <T extends Throwable> T sneaky(Throwable t, Class<T> as) throws T {
throw (T) t;
}
}

View File

@@ -31,6 +31,10 @@ public abstract class MixinPlayerController implements IPlayerControllerMP {
@Override
public abstract void setIsHittingBlock(boolean isHittingBlock);
@Accessor("isDestroying")
@Override
public abstract boolean isHittingBlock();
@Accessor("destroyBlockPos")
@Override
public abstract BlockPos getCurrentBlock();
@@ -38,4 +42,8 @@ public abstract class MixinPlayerController implements IPlayerControllerMP {
@Invoker("ensureHasSentCarriedItem")
@Override
public abstract void callSyncCurrentPlayItem();
@Accessor("destroyDelay")
@Override
public abstract void setDestroyDelay(int destroyDelay);
}

View File

@@ -35,11 +35,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Screen.class)
public abstract class MixinScreen implements IGuiScreen {
@Override
@Invoker("openLink")
public abstract void openLinkInvoker(URI url);
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {

View File

@@ -22,6 +22,7 @@ import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
@@ -41,12 +42,13 @@ public class MixinWorldRenderer {
@Inject(
method = "renderLevel",
at = @At("RETURN"),
locals = LocalCapture.CAPTURE_FAILSOFT
at = @At("RETURN")
)
private void onStartHand(PoseStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, Camera activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn));
PoseStack poseStack = new PoseStack();
poseStack.mulPose(matrix4f);
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, matrix4f2));
}
}
}
}

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