Compare commits

..

193 Commits

Author SHA1 Message Date
leijurv
944405e4df Merge pull request #4014 from jdbool/1.19.2
Add useMessageTag setting
2023-06-21 18:55:06 -07:00
Mike
7ef4307ab7 Clean up useMessageTag 2023-06-21 18:25:24 -07:00
Mike
a5ca664a6a Add useMessageTag setting 2023-06-21 15:14:54 -07:00
Leijurv
6eeeeb3a1b v1.9.4 2023-04-11 19:50:51 -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
7a5c4f1f03 Merge pull request #3843 from wagyourtail/1.19/fix/1.19.3-fixdistnames
fix dist names to match previous versions
2023-02-18 16:08:45 -08:00
Wagyourtail
787644181a fix dist names to match previous versions 2023-02-18 16:59:39 -07:00
Leijurv
7b60943714 v1.9.1 2023-02-18 15:01:48 -08:00
leijurv
7879b6909a Merge pull request #3837 from ZacSharp/1.19.2-update
Merge 1.18.2 into 1.19.3
2023-02-18 15:00:01 -08:00
ZacSharp
9898e0da26 Merge branch '1.18.2' into 1.19.3 2023-02-12 23:50:54 +01:00
leijurv
5841bd4e36 Merge pull request #3825 from ZacSharp/1.18.2-update
Merge 1.17.1 into 1.18.2
2023-02-12 12:47:28 -08:00
ZacSharp
81e9865067 Merge branch '1.17.1' into 1.18.2 2023-02-04 01:05:31 +01:00
leijurv
f9d563b9e6 Merge pull request #3819 from ZacSharp/1.17.1-update
Merge 1.16.5 into 1.17.1
2023-02-03 14:58:02 -08:00
ZacSharp
3e3312f009 Use CarpetBlock rather than WoolCarpetBlock 2023-01-29 01:27:58 +01:00
ZacSharp
327fbc868e Merge branch '1.16.5' into 1.17.1 2023-01-29 01:25:17 +01:00
leijurv
7677ed8240 Merge pull request #3744 from wagyourtail/1.19/1.19.3
1.19/1.19.3
2023-01-13 11:08:57 -08:00
leijurv
7ad1a2dac7 Merge pull request #3774 from wagyourtail/patch-2
fix jitpack.yml so 1.19 builds there again
2023-01-01 23:38:51 -10:00
William Gray
fd55e455a1 Update jitpack.yml 2022-12-30 00:42:53 +00:00
William Gray
e7e25abc0b Update jitpack.yml 2022-12-30 00:39:29 +00:00
leijurv
4bc9884a95 Merge pull request #3731 from EvilCodeZ/1.19.1
Removed System.out.println.
2022-12-24 00:08:46 -08:00
Wagyourtail
0e35a3e62b fix #3756 by allowing to recompute worldData if null 2022-12-19 07:42:23 -07:00
Wagyourtail
1112feff5b cache 2022-12-12 13:24:43 -07:00
Wagyourtail
967dc6cbd6 bump unimined version 2022-12-12 13:23:36 -07:00
Wagyourtail
2ce60fbb79 fix tweaker build, don't include schematica api 2022-12-12 13:12:14 -07:00
Wagyourtail
35b7c48430 some people are getting a null worldData bug. add a debug line to see if its here 2022-12-12 12:54:06 -07:00
Wagyourtail
db842445f6 forge support 2022-12-08 12:31:12 -07:00
Wagyourtail
3a8d438d7c update to release 2022-12-07 22:58:20 -07:00
Wagyourtail
386caf5d1e add parchment back 2022-12-06 18:30:43 -07:00
Wagyourtail
f7f0c84407 fix proguard not seeing unsafe 2 2022-12-02 14:39:57 -07:00
Wagyourtail
75cd4600a0 fix proguard not seeing unsafe 2022-12-02 14:31:00 -07:00
Wagyourtail
e6642a2122 fix ci 2022-12-02 14:24:29 -07:00
Wagyourtail
e7252f5b3f remove the mixin from api 2022-12-02 14:23:16 -07:00
Wagyourtail
4168401aa1 fix items and #click 2022-12-02 14:09:47 -07:00
Wagyourtail
3e082b21d5 loottables broke & #click not working 2022-12-02 01:17:25 -07:00
Wagyourtail
85790c0b2f switch to unimined 2022-12-01 23:04:40 -07:00
EvilCodeZ
c20d40f8dd Removed System.out.println. 2022-11-18 19:39:39 +01:00
Leijurv
4fa43ce201 Merge pull request #3707 from ZacSharp/1.19.2-update
Merge 1.18.2 into 1.19.1
2022-11-07 01:39:51 -08:00
ZacSharp
f51f835b11 Merge branch '1.18.2' into 1.19.1 2022-11-01 00:11:26 +01:00
Leijurv
54f6851dd9 Merge pull request #3688 from ZacSharp/1.18.2-update
Merge 1.17.1 into 1.18.2
2022-10-31 12:25:18 -07:00
ZacSharp
98763271a4 Update litematic version check 2022-10-13 23:36:38 +02:00
ZacSharp
063842edc4 Merge branch '1.17.1' into 1.18.2 2022-10-12 18:17:34 +02:00
Leijurv
2453a4a4f1 Merge pull request #3458 from ZacSharp/1.17.1-update
Merge 1.16.5 into 1.17.1
2022-10-11 14:12:58 -07:00
ZacSharp
5a8adc5344 Merge branch '1.16.5' into 1.17.1 2022-10-06 20:43:01 +02:00
Leijurv
8b94ac8fca Merge pull request #3640 from scorbett123/fixWaterJump
Fix for infinite loop in water
2022-10-04 13:04:04 -07:00
scorbett123
8f514bd782 Cleaner fix for water jump issue 2022-10-03 21:22:07 +01:00
Leijurv
ec2941bede Merge pull request #3597 from wagyourtail/1.19/1.19.2
1.19.2
2022-10-03 12:29:07 -07:00
Leijurv
5b37b68363 Merge pull request #3592 from wagyourtail/1.19/1.19
fix click menus for baritone control
2022-10-03 12:22:10 -07:00
Leijurv
bf43fd1274 Merge pull request #3601 from scorbett123/patch-6
Update legitMineYLevel for 1.18 +
2022-09-24 14:59:57 -10:00
scorbett123
287addb9fd Fix for infinite loop in water 2022-08-30 18:46:58 +01:00
scorbett123
d1a0f1e3ca Update legitMineYLevel for 1.18 +
Update the legit mine default setting to work at the correct diamond level in 1.18+.
2022-08-08 15:20:41 +02:00
Wagyourtail
52d077de49 1.19.2 2022-08-07 14:47:18 -06:00
Wagyourtail
b1f35e93dc fix click menus for baritone control, closes #3587 2022-08-03 20:17:10 -06:00
Leijurv
076326dcc3 Merge pull request #3478 from wagyourtail/1.19/1.19
1.19/1.19
2022-08-01 12:48:03 -07:00
wagyourtail
b1b8288d05 Merge branch '1.19.1' into 1.19/1.19 2022-07-28 13:07:03 -06:00
Wagyourtail
df62427fee forge 2022-07-28 12:37:30 -06:00
Wagyourtail
61b9762a22 1.19.1 2022-07-27 19:59:44 -06:00
Wagyourtail
06be5f5372 1.19.1-rc2 2022-07-21 12:16:21 -06:00
Wagyourtail
fcd20b10f1 WORKING TWEAKER!!! 2022-06-11 11:54:30 +00:00
Leijurv
82f184c848 Merge pull request #3488 from ZacSharp/1.18.2-update
Merge 1.17.1 into 1.18.2
2022-06-08 19:03:00 -07:00
Wagyourtail
fd43dace70 rework this again and fix dist 2022-06-08 10:16:09 -06:00
Wagyourtail
a475f522ef artifact_standard needs project artifact name 2022-06-08 10:01:55 -06:00
Wagyourtail
e6cc9b1131 oops 2022-06-08 09:35:49 -06:00
Wagyourtail
347027a8e0 handle this differently (grab archive name from root project) 2022-06-08 09:26:47 -06:00
Wagyourtail
f204fbb08e froge support 2022-06-08 02:28:22 -06:00
Wagyourtail
606f9c55a8 1.19! 2022-06-07 12:07:12 -06:00
Wagyourtail
f2a11df616 prepare for release day 2022-06-07 05:13:56 -06:00
Wagyourtail
5773da36bd Merge remote-tracking branch 'zacsharp/1.17.1-update' into 1.19/1.19 2022-06-07 05:11:47 -06:00
Wagyourtail
86303ed495 Merge branch '1.12/beta-versioning' into 1.19/1.19 2022-06-07 04:52:05 -06:00
Wagyourtail
2b4da2a46c deep checkout so we actually get tag names in CI 2022-06-03 14:46:39 -06:00
Wagyourtail
f699be7973 so umm, it's not using right version number in CI... 2022-06-03 14:42:23 -06:00
Wagyourtail
ed381d6b33 fix CI not having access to git when run via gradle 2022-06-03 14:29:51 -06:00
Wagyourtail
1caa99fee3 oops 2022-06-03 14:26:27 -06:00
ZacSharp
4a042510d8 Merge branch '1.17.1' into 1.18.2 2022-06-03 22:26:24 +02:00
Wagyourtail
ffbe683e86 versioning with normal build 2022-06-03 14:24:17 -06:00
Wagyourtail
4dba5a4399 use git describe instead 2022-06-03 14:09:37 -06:00
Wagyourtail
8cfdcbdc9e rc.2 2022-06-03 13:47:09 -06:00
ZacSharp
59b3fe7c3a Merge branch '1.16.5' into 1.17.1 2022-06-03 19:05:47 +02:00
Wagyourtail
6e37221b3c rc.1 2022-06-02 13:37:51 -06:00
Wagyourtail
caa88c5b60 DONT on tags 2022-06-01 16:28:53 -06:00
Wagyourtail
1b3139c99a oops 2022-06-01 16:21:21 -06:00
Wagyourtail
3d95f0ad65 auto-increment version number as well 2022-06-01 16:16:41 -06:00
Wagyourtail
0df45a89be don't do the other stuff 2022-06-01 15:51:25 -06:00
Wagyourtail
b0266cd14b do beta versioning on gh action builds 2022-06-01 15:49:41 -06:00
Wagyourtail
9bf40dd60b pre.5 2022-06-01 15:17:45 -06:00
Wagyourtail
56b44496bf verify fabric/tweaker builds are valid 2022-05-31 03:03:43 -06:00
Wagyourtail
3df451677c use loom 11 to allow building 2022-05-31 02:42:17 -06:00
Wagyourtail
9e021d2875 1.19 2022-05-31 02:38:55 -06:00
Wagyourtail
db9ee98762 Merge remote-tracking branch 'wagyourtail/1.18.2/cached-chunk-oopsie' into rework-buildscript-117 2022-05-31 01:58:12 -06:00
Wagyourtail
d0d74b1591 freeze version numbers at known working 2022-04-16 04:02:45 -07:00
Wagyourtail
056107a356 fix checksums, this'll probably confuse someone.
I couldn't figure out how to fix it the other way...
2022-04-16 03:46:41 -07:00
Wagyourtail
93a16f356d cleanup. move tweaker classes 2022-04-16 03:22:53 -07:00
Wagyourtail
070083dc9b properly remap refmap for tweaker 2022-04-16 02:57:29 -07:00
Wagyourtail
af646bd313 yeet change I forgot to yeet 2 commits ago 2022-04-04 20:45:17 -07:00
Wagyourtail
c3c88c50d1 jitpack.yml 2022-04-04 20:11:15 -07:00
Wagyourtail
16f93ce769 explicitly include mixin "properly", mavenpublish should work now 2022-04-04 20:10:25 -07:00
Wagyourtail
3cee66229a proper mappings per proguard run 2022-04-04 19:15:21 -07:00
Wagyourtail
88c00f2fec java 17 is lts, so use java 17 2022-04-04 18:53:29 -07:00
Wagyourtail
394b4fd5b8 proguard builds now 2022-04-04 18:38:23 -07:00
Wagyourtail
48b34bfbb8 some jank to sourcesets to get dev launching 2022-04-04 18:11:03 -07:00
wagyourtail
4b2d1fe6b0 fix an oopsie in chunk caches with dynamic world height 2022-04-04 14:18:25 -07:00
Wagyourtail
01c75db38a rework buildscript (part 1) 2022-04-02 21:36:18 -07:00
Leijurv
f3c93855bb Merge pull request #3363 from stackmagic/build-fix-1.17
Build fix 1.17
2022-03-31 14:01:26 -07:00
Patrick Huber
599aa42cd8 Build: set rootProject.name again (already present up until 1.16 and went missing afterwards) 2022-03-26 18:59:13 +01:00
Patrick Huber
95afaf3eac Build: print more details on error 2022-03-26 18:49:06 +01:00
Leijurv
384dfb5f46 Merge pull request #3325 from wagyourtail/1.17.1
move death event to work with `doImmediateRespawn` gamerule
2022-03-15 19:07:11 -07:00
Wagyourtail
89bd2a4a07 move death event to work with doImmediateRespawn gamerule 2022-03-15 18:44:39 -07:00
Leijurv
477e3a706b Merge pull request #3308 from wagyourtail/1.17.1
fix `<parameter1> is null`
2022-03-08 17:01:51 -08:00
Wagyourtail
9ba8949a2e fix <parameter1> is null (and sneak in some other changes) 2022-03-08 17:28:56 -07:00
Wagyourtail
9b7d3af03d remove duplicate 2022-03-08 17:28:56 -07:00
Leijurv
8a0771e5f4 v1.8.3 2022-03-08 14:50:04 -08:00
Leijurv
9c6c977314 Merge pull request #3292 from wagyourtail/1.18.2
1.18.2
2022-03-08 14:47:42 -08:00
Wagyourtail
38c5388e00 forge updated (finally) 2022-03-01 16:36:09 -07:00
Wagyourtail
519a76a171 fix for 1.18.2 2022-02-28 15:29:37 -07:00
Leijurv
eefc98a68e Merge pull request #3269 from wagyourtail/1.17.1
fix amethyst bud stuck
2022-02-14 14:38:07 -08:00
Wagyourtail
d0dc8cf726 fix amethyst bud stuck 2022-02-14 15:35:34 -07:00
Leijurv
267961434c Merge pull request #3254 from wagyourtail/1.17.1
fix an array oob with dynamic worldheight
2022-02-08 10:46:01 -08:00
Leijurv
0bfe98d306 Merge pull request #3255 from wagyourtail/replaymod-newfix
replaymod replay crash fix 1.17+
2022-02-08 10:45:39 -08:00
Wagyourtail
bfa644e7a7 oops 2022-02-08 11:41:45 -07:00
Wagyourtail
0ef1558803 fix this in a "better" way 2022-02-08 02:09:29 -07:00
Wagyourtail
9dad1af960 move up null check to fix new data-driven caused crash with replaymod 2022-02-08 01:57:56 -07:00
Wagyourtail
407f4dbbae fix an array oob with dynamic worldheight 2022-02-08 01:36:32 -07:00
Leijurv
af240d38e0 Merge pull request #3242 from wagyourtail/1.17.1
fix getting stuck in powdered snow
2022-02-02 21:10:14 -08:00
Wagyourtail
a3dbec62dc fix getting stuck in powdered snow 2022-02-02 21:47:45 -07:00
Leijurv
b6cc15e9ab v1.8.2 2022-02-02 15:55:22 -08:00
Leijurv
fe26168a07 v1.7.2 2022-02-02 15:54:39 -08:00
Leijurv
ebb9dd1aaf Merge branch '1.17.1' into 1.18.1 2022-02-02 15:47:50 -08:00
Leijurv
d4c4441cb6 Merge pull request #3238 from wagyourtail/1.17.1
Merge master into 1.17
2022-02-02 15:47:20 -08:00
Wagyourtail
91bfab30e0 fix tabbing 2022-02-02 14:10:20 -07:00
Wagyourtail
a32811942e merge master in 2022-02-02 11:17:02 -07:00
Leijurv
e077995332 v1.8.1 2022-02-02 00:38:06 -08:00
Leijurv
71e17d6c29 v1.7.1 2022-02-02 00:35:37 -08:00
Leijurv
c9ebc0191d Merge branch '1.17.1' into 1.18.1 2022-02-02 00:30:29 -08:00
Leijurv
2f7f15da77 gitignore vscode file 2022-02-02 00:30:25 -08:00
Leijurv
fa3f5ae521 rm vscode stuff 2022-02-02 00:30:12 -08:00
Leijurv
db0ebeebee Merge branch '1.17.1' into 1.18.1 2022-02-02 00:29:26 -08:00
Leijurv
dc4913d98d oopsie 2 2022-02-02 00:29:15 -08:00
Leijurv
70dc2a3009 Merge branch '1.17.1' into 1.18.1 2022-02-02 00:25:13 -08:00
Leijurv
33943dc473 oopsie 2022-02-02 00:24:32 -08:00
Leijurv
21022f30b6 Merge commit 'd4ae351065889bfe37f5a51f123d5cd9a3e173e0' into 1.17.1 2022-02-02 00:20:23 -08:00
Leijurv
2b75241338 Merge branch '1.16.4' into 1.17.1 2022-02-02 00:17:09 -08:00
Leijurv
696ec6756d Merge pull request #3077 from wagyourtail/1.18
1.18 support
2022-02-02 00:00:05 -08:00
Leijurv
6e03e6859c Merge pull request #3194 from wagyourtail/1.17.1
fix dripleaf and azalea behavior
2022-02-01 23:57:54 -08:00
Wagyourtail
697c92ae77 Merge branch '1.17.1' into 1.18 2022-01-20 15:19:49 -07:00
Wagyourtail
e37d81d3fc fix runClient to actually have the right sourceSet by default 2022-01-20 15:19:35 -07:00
Wagyourtail
7f21362a2a fix dripleaf and azalea behavior
change so rebuilds
2022-01-10 16:58:17 -07:00
Wagyourtail
c4da682e84 Merge branch '1.17.1' into 1.18
change so rebuilds
2022-01-10 16:58:03 -07:00
Wagyourtail
33ee39dcce fix dripleaf and azalea behavior 2022-01-10 11:28:37 -07:00
Wagyourtail
587c2cc8e2 forge support 2021-12-02 11:13:56 -07:00
Wagyourtail
1c8899ceae 1.18 release
pre.5


pre.6


pre.7


rc.1


1.18 release
2021-11-30 14:06:03 -07:00
Wagyourtail
088009fe4a pre.3 2021-11-17 10:16:07 -07:00
Wagyourtail
90ac6f331e missed a spot 2021-11-16 16:47:37 -07:00
Wagyourtail
e80e4afa48 bump proguard version 2021-11-16 16:41:34 -07:00
Wagyourtail
b73295d180 bump to gradle 7.3, java 17 and 1.18-pre2 2021-11-16 16:30:37 -07:00
Wagyourtail
186a3cb6df shedainel says its fixed 2021-11-12 19:38:46 -07:00
Wagyourtail
b6fba56291 temp comment vanilla/forge 2021-11-12 19:38:46 -07:00
Wagyourtail
f52fee8254 revert this commit when shedaniel fixes arch-loom 2021-11-12 19:38:46 -07:00
Wagyourtail
f1061cfd31 fix baritone only ticking when screen open 2021-11-12 19:38:46 -07:00
Wagyourtail
9a9358bc78 WIP 2021-11-12 19:38:46 -07:00
Leijurv
749fd4fac3 Merge pull request #2850 from wagyourtail/1.17
1.17.X port, (uses changes from #2814)
2021-11-11 19:33:09 -08:00
Wagyourtail
43ecc906c7 cleanup 2021-10-28 08:03:37 -06:00
wagyourtail
64b647ea65 oops... .idea folder contains copyright in file stuff (I thought gradle did that) 2021-10-11 04:42:26 -06:00
wagyourtail
6ed3a88491 continue fix mine and a* for data driven world height 2021-10-09 15:29:02 -06:00
wagyourtail
bd5ffe8f31 put timeout back 2021-10-09 14:55:26 -06:00
wagyourtail
d22a52976b fix A* and scanner for data driven world height 2021-10-09 14:54:07 -06:00
wagyourtail
e055ef36d4 add parchment mappings 2021-10-09 14:16:57 -06:00
wagyourtail
5ec6b7b72e make chunk cache/scanning work with data driven worldheight 2021-10-09 14:16:49 -06:00
wagyourtail
de27fb2f68 fix mc jar detection for forge build with loom 0.10.x 2021-09-23 19:43:23 -06:00
wagyourtail
2e2e725eb3 fix proguard to have proper loom 0.10.x minecraft jar locations 2021-09-23 19:10:52 -06:00
wagyourtail
202618a32a add forge build script 2021-09-22 12:22:00 -06:00
wagyourtail
462dbce665 prep forge support 2021-09-22 12:14:43 -06:00
wagyourtail
0944e6255e add fabric build to git 2021-07-11 22:25:32 -06:00
wagyourtail
8be821746e update dockerfile to use java 16
debian doesn't provide it
2021-07-11 22:20:06 -06:00
wagyourtail
9c05133ac7 cherry pick (and update) pr #2801 2021-07-11 22:10:13 -06:00
wagyourtail
29f5eaa35f Amethyst Crystal and Pointed Dripstone 2021-07-11 14:28:23 -06:00
wagyourtail
c06fdec287 1.17.1 2021-07-07 15:43:48 -06:00
wagyourtail
c7d210bfd6 fix proguard maybe 2021-07-07 15:43:48 -06:00
wagyourtail
683e987b1d fix bad mapping breaking pathing on item entities. 2021-07-07 15:43:48 -06:00
wagyourtail
40c323f53d fix mis-mapping from manual mixin review and put this back 2021-07-07 15:43:48 -06:00
wagyourtail
2d2354730d fix movement, mixins and color, proguard 2021-07-07 15:43:48 -06:00
wagyourtail
a7b81940b3 fix j16 debug environment (may have to set cp to baritone.launch) 2021-07-07 15:43:48 -06:00
wagyourtail
8df87eb620 bump fabric loader to support j16 2021-07-07 15:43:48 -06:00
wagyourtail
41abda37c1 fix migration for 1.17. (also proguard broke with j16...) 2021-07-07 15:43:48 -06:00
wagyourtail
e6d8b268c7 migrate to mojmap 2021-07-07 15:43:48 -06:00
wagyourtail
f0130c7199 move to j16/gradle7 2021-07-07 15:43:48 -06:00
wagyourtail
de42109771 add check 2021-07-06 15:59:06 -06:00
wagyourtail
2e98eee7e0 fix dockerfile 2021-07-06 08:26:30 -06:00
wagyourtail
f6236bdc66 launchtweaker build shouldn't require forge 2021-07-06 08:25:30 -06:00
wagyourtail
d00249bbd6 checking again, this is fixed actually (somehow...). 2021-07-05 15:15:08 -06:00
wagyourtail
a49f4ee858 cleanup 2021-06-16 02:51:56 -06:00
wagyourtail
998b84ef87 switch to forgified-fabric-loom 2021-06-16 02:12:47 -06:00
245 changed files with 3515 additions and 5939 deletions

View File

@@ -14,23 +14,21 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build (fabric) with Gradle
run: ./gradlew build -Pbaritone.fabric_build
- name: Build (forge) with Gradle
run: ./gradlew build -Pbaritone.forge_build
run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)"
- name: Archive Artifacts
uses: actions/upload-artifact@v3
@@ -42,4 +40,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Mappings
path: build/tmp/proguard/mapping.txt
path: mapping/

View File

@@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
@@ -23,4 +23,4 @@ jobs:
- name: Executing tests
run: ./gradlew test

5
.gitignore vendored
View File

@@ -21,6 +21,9 @@ classes/
*.iws
/logs/
tweaker/logs/
common/logs/
# Eclipse Files
.classpath
.project
@@ -32,4 +35,6 @@ baritone_Client.launch
!/.idea/copyright/profiles_settings.xml
.vscode/launch.json
.architectury-transformer
mapping

View File

@@ -1,11 +1,11 @@
FROM debian:stretch
FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive
RUN apt update -y
RUN apt install \
openjdk-8-jdk \
openjdk-17-jdk \
--assume-yes
COPY . /code
@@ -13,5 +13,3 @@ COPY . /code
WORKDIR /code
RUN ./gradlew build
RUN ./gradlew build -Pbaritone.forge_build
RUN ./gradlew build -Pbaritone.fabric_build

130
README.md
View File

@@ -1 +1,129 @@
This branch of Baritone is deprecated. It will no longer recieve updates. Updates to older versions of Minecraft will not be merged into this branch, even if a newer branch is not deprecated (this branch will be skipped). Bug reports that only affect deprecated branches will not be addressed.
# Baritone
<p align="center">
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/downloads/cabaletta/baritone/total.svg" alt="GitHub All Releases"/></a>
</p>
<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>
</p>
<p align="center">
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
<a href="https://www.codacy.com/gh/cabaletta/baritone/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cabaletta/baritone&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/cadab857dab049438b6e28b3cfc5570e" alt="Codacy Badge"/></a>
<a href="https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat" alt="Code of Conduct"/></a>
<a href="https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle"><img src="https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle" alt="Known Vulnerabilities"/></a>
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="Contributions welcome"/></a>
<a href="https://github.com/cabaletta/baritone/issues/"><img src="https://img.shields.io/github/issues/cabaletta/baritone.svg" alt="Issues"/></a>
<a href="https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed/cabaletta/baritone.svg" alt="GitHub issues-closed"/></a>
<a href="https://github.com/cabaletta/baritone/pulls/"><img src="https://img.shields.io/github/issues-pr/cabaletta/baritone.svg" alt="Pull Requests"/></a>
<a href="https://github.com/cabaletta/baritone/graphs/contributors/"><img src="https://img.shields.io/github/contributors/cabaletta/baritone.svg" alt="GitHub contributors"/></a>
<a href="https://github.com/cabaletta/baritone/commit/"><img src="https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg" alt="GitHub commits"/></a>
<img src="https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg" alt="Code size"/>
<img src="https://img.shields.io/github/repo-size/cabaletta/baritone.svg" alt="GitHub repo size"/>
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code" alt="Lines of Code"/>
</p>
<p align="center">
<a href="https://impactclient.net/"><img src="https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3%20/%20v1.6.3-brightgreen.svg" alt="Impact integration"/></a>
<a href="https://github.com/kami-blue/client"><img src="https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green" alt="KAMI Blue integration"/></a>
<a href="https://github.com/fr1kin/ForgeHax/"><img src="https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg" alt="ForgeHax integration"/></a>
<a href="https://aristois.net/"><img src="https://img.shields.io/badge/Aristois%20add--on%20integration-v1.6.3-green.svg" alt="Aristois add-on integration"/></a>
<a href="https://rootnet.dev/"><img src="https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg" alt="rootNET integration"/></a>
<a href="https://futureclient.net/"><img src="https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red" alt="Future integration"/></a>
<a href="https://rusherhack.org/"><img src="https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green" alt="RusherHack integration"/></a>
</p>
<p align="center">
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
</p>
A Minecraft pathfinder bot.
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to
install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click
[here](https://github.com/cabaletta/baritone/releases/download/v1.2.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.
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.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)**.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
# Getting Started
Here are some links to help to get started:
- [Features](FEATURES.md)
- [Installation & setup](SETUP.md)
- [API Javadocs](https://baritone.leijurv.com/)
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
- [Usage (chat control)](USAGE.md)
## Stars over time
[![Stargazers over time](https://starchart.cc/cabaletta/baritone.svg)](https://starchart.cc/cabaletta/baritone)
# API
The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
jar.
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.
```java
BaritoneAPI.getSettings().allowSprint.value = true;
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
```
# FAQ
## Can I use Baritone as a library in my custom utility client?
That's what it's for, sure! (As long as usage complies with the LGPL 3.0 License)
## How is it so fast?
Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain)
### Additional Special Thanks To:
![YourKit-Logo](https://www.yourkit.com/images/yklogo.png)
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications.
YourKit is the creator of the [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/), and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
We thank them for granting Baritone an OSS license so that we can make our software the best it can be.
## Why is it called Baritone?
It's named for FitMC's deep sultry voice.

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.
Download java: https://adoptium.net/
Open JDK download: https://openjdk.java.net/install/
#### macOS guide
In order to get JDK 8, Try running the following command:
`% /usr/libexec/java_home -V`
@@ -66,13 +66,68 @@ In order to get JDK 8 running in the **current terminal window** you will have t
To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc
### Building Baritone
Setting up the Environment:
These tasks depend on the minecraft version, but are (for the most part) standard for building mods.
```
$ gradlew setupDecompWorkspace
$ gradlew --refresh-dependencies
```
for more details, see [the build ci action](/.github/workflows/gradle_build.yml)
Building Baritone:
```
$ gradlew build
```
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)
## 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)
- depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working
![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

View File

@@ -15,73 +15,89 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
group 'baritone'
version '1.6.5'
allprojects {
apply plugin: 'java'
apply plugin: "xyz.wagyourtail.unimined"
apply plugin: "maven-publish"
archivesBaseName = rootProject.archives_base_name
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
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)
}
group = rootProject.maven_group
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
buildscript {
repositories {
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'fabric-maven'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
name = "ldtteam"
url = "https://maven.parchmentmc.net/"
}
// for the newer version of launchwrapper
maven {
url = 'https://maven.fabricmc.net/'
}
maven {
url = 'https://libraries.minecraft.net/'
name = "multimc-maven"
url = "https://files.multimc.org/maven/"
metadataSources {
artifact()
}
}
mavenCentral()
jcenter()
}
dependencies {
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
classpath group: 'net.fabricmc', name: 'fabric-loom', version: '0.7-SNAPSHOT'
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"
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
import baritone.gradle.fabric.CreateVolderYarn
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'java'
apply plugin: 'maven'
def mcpVersion = [channel: 'snapshot', version: '20201028-1.16.3']
if (getProject().hasProperty("baritone.fabric_build")) {
CreateVolderYarn.genMappings("1.16.5", mcpVersion)
apply plugin: 'fabric-loom'
} else {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
}
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
options.encoding = "UTF-8" // allow emoji in comments :^)
minecraft {
runs.off = true
}
archivesBaseName = archivesBaseName + "-common"
sourceSets {
api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += api.output
runtimeClasspath += api.output
}
test {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
@@ -91,124 +107,26 @@ sourceSets {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
schematica_api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += schematica_api.output
}
}
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.api.allSource
}
if (getProject().hasProperty("baritone.fabric_build")) {
minecraft.refmapName = "mixins.baritone.refmap.json"
} else {
minecraft {
mappings mcpVersion
if (getProject().hasProperty("baritone.forge_build")) {
reobfMappings 'searge'
} else {
reobfMappings 'notch'
}
runs {
client {
workingDirectory project.file('run')
source sourceSets.launch
main 'baritone.launch.LaunchTesting'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', downloadAssets.output
environment 'nativesDirectory', extractNatives.output
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
if (Os.isFamily(Os.FAMILY_MAC)) {
jvmArgs "-XstartOnFirstThread"
}
}
autoTest {
workingDirectory project.file('autotest')
source sourceSets.launch
main 'baritone.launch.LaunchTesting'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', downloadAssets.output
environment 'nativesDirectory', extractNatives.output
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
environment 'BARITONE_AUTO_TEST', 'true'
if (Os.isFamily(Os.FAMILY_MAC)) {
jvmArgs "-XstartOnFirstThread"
}
}
}
}
mixin {
defaultObfuscationEnv searge
add sourceSets.launch, 'mixins.baritone.refmap.json'
}
}
repositories {
mavenCentral()
maven {
name = 'SpongePowered'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
runtimeClasspath += schematica_api.output
}
}
dependencies {
if (getProject().hasProperty("baritone.fabric_build")) {
minecraft "com.mojang:minecraft:1.16.5"
mappings fileTree(dir: "./build/volderyarn", include: "**.jar")
modImplementation "net.fabricmc:fabric-loader:0.9.1+build.205"
testImplementation 'junit:junit:4.13.2'
}
// this makes it compile with the forge tweak stuff
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
implementation('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
}
jar {
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'
} else {
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.5'
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
}
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
runtime launchCompile('org.spongepowered:mixin:0.8.3') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
}
testImplementation 'junit:junit:4.12'
remapJar {
target = "mojmap"
}
javadoc {
@@ -217,145 +135,4 @@ javadoc {
options.encoding "UTF-8" // allow emoji in comments :^)
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
}
if (getProject().hasProperty("baritone.fabric_build")) {
// skidded from fabric-example-mod (comments and all)
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
jar {
from sourceSets.launch.output, sourceSets.api.output
if (!getProject().hasProperty("baritone.forge_build")) {
exclude "**/BaritoneForgeModXD.class"
exclude "**/mods.toml"
}
preserveFileTimestamps = false
reproducibleFileOrder = true
if (getProject().hasProperty("baritone.fabric_build")) {
filesMatching("fabric.mod.json") {
expand "version": version
}
} else {
exclude("fabric.mod.json")
}
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone',
'Implementation-Version': version,
)
}
}
// skidded from ProguardTask
File getClientJar() {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter({ f -> f.toString().endsWith("client-extra.jar") })
.map({ f -> new File(f.getParentFile(), "client.jar") })
.findFirst()
.get()
}
File getClientJarFabric() {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter({ f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") })
.map({ f -> new File(f.getParentFile().getParentFile(), f.getName().toString().replace("mapped", "intermediary")) })
.findFirst()
.get()
}
if (getProject().hasProperty("baritone.fabric_build")) {
task copyMcJar(type: Copy) {
def mcJar = { getClientJarFabric() }
from mcJar
into 'build/createMcIntermediaryJar/'
rename { 'client.jar' }
}
task proguard(type: ProguardTask, dependsOn: copyMcJar) {
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
extract 'proguard6.0.3/lib/proguard.jar'
}
task createDist(type: CreateDistTask, dependsOn: proguard)
} else {
task copyMcJar(type: Copy) {
def mcJar = { getClientJar() }
from mcJar
into 'build/createMcSrgJar/'
rename { 'client-srg.jar' }
}
task createSrgMc(type: RenameJarInPlace) {
setInput(new File(copyMcJar.getOutputs().getFiles().getSingleFile(), "client-srg.jar"))
setClasspath(files({ getClientJar() }))
// fork
setMappingType(net.minecraftforge.gradle.common.util.MappingFile.Mapping.SEARGE)
setJarTask('trans alaska pipeline')
}
project.afterEvaluate {
createSrgMc.dependsOn(extractSrg, copyMcJar)
createSrgMc.setMappings(extractSrg.getOutput())
}
task proguard(type: ProguardTask, dependsOn: createSrgMc) { // TODO: dont need to create srg mc if doing notch build
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
extract 'proguard6.0.3/lib/proguard.jar'
}
task createDist(type: CreateDistTask, dependsOn: proguard)
}
build.finalizedBy(createDist)
install {
def jarApiName = String.format("%s-api-%s", rootProject.name, version.toString())
def jarApiForgeName = String.format("%s-api-forge-%s", rootProject.name, version.toString())
def jarSAName = String.format("%s-standalone-%s", rootProject.name, version.toString())
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
artifacts {
archives file("$buildDir/libs/"+jarApiName+".jar")
archives file("$buildDir/libs/"+jarApiForgeName+".jar")
archives file("$buildDir/libs/"+jarSAName+".jar")
archives file("$buildDir/libs/"+jarSAForgeName+".jar")
}
repositories.mavenInstaller {
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
}
}
install.dependsOn(build)
}

View File

@@ -16,10 +16,25 @@
*/
repositories {
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/releases'
}
maven {
name = 'ForgeMaven'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
}
dependencies {
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '0.4.9'
}

View File

@@ -1,259 +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.gradle.fabric;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/**
* @Author Wagyourtail
*/
public class CreateVolderYarn {
public static String VOLDERYARNFOLDER = "./build/volderyarn/";
public static String VOLDERYARN = "volderyarn-%s-%s-%s.jar";
public static void genMappings(String mcVersion, Map<String, String> mcpVersion) throws IOException {
//download yarn intermediary
URL intURL = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%s/intermediary-%s-v2.jar", mcVersion, mcVersion));
String intermediary = readZipContentFromURL(intURL, "mappings/mappings.tiny").get("mappings/mappings.tiny");
Map<String, ClassData> mappings = parseTinyMap(intermediary);
//download srg
URL srgURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_config/%s/mcp_config-%s.zip", mcVersion, mcVersion));
String tsrg = readZipContentFromURL(srgURL, "config/joined.tsrg").get("config/joined.tsrg");
MCPData mcpData = addTSRGData(mappings, tsrg);
//download mcp
URL mcpURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_%s/%s/mcp_%s-%s.zip", mcpVersion.get("channel"), mcpVersion.get("version"), mcpVersion.get("channel"), mcpVersion.get("version")));
Map<String, String> mcpfiles = readZipContentFromURL(mcpURL, "fields.csv", "methods.csv");
addMCPData(mcpData, mcpfiles.get("fields.csv"), mcpfiles.get("methods.csv"));
StringBuilder builder = new StringBuilder("tiny\t2\t0\tintermediary\tnamed");
for (ClassData clazz : mappings.values()) {
builder.append("\n").append(clazz.getIntToMCP());
}
File outputFolder = new File(VOLDERYARNFOLDER);
if (!outputFolder.exists() && !outputFolder.mkdirs())
throw new RuntimeException("Failed to create dir for volderyarn mappings.");
for (File f : outputFolder.listFiles()) {
if (!f.isDirectory()) f.delete();
}
File outputFile = new File(outputFolder, String.format(VOLDERYARN, mcVersion, mcpVersion.get("channel"), mcpVersion.get("version")));
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdir())
throw new FileNotFoundException("Failed to create folder for volderyarn!");
}
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outputFile))) {
output.putNextEntry(new ZipEntry("mappings/mappings.tiny"));
byte[] outData = builder.toString().getBytes(StandardCharsets.UTF_8);
output.write(outData, 0, outData.length);
}
}
private static Map<String, ClassData> parseTinyMap(String map) {
Map<String, ClassData> mappings = new LinkedHashMap<>();
ClassData clazzdata = null;
for (String line : map.split("\n")) {
String[] parts = line.trim().split("\t");
switch (parts[0]) {
case "c":
mappings.put(parts[1], clazzdata = new ClassData(mappings, parts[1], parts[2]));
break;
case "m":
assert clazzdata != null;
clazzdata.addMethod(parts[2], parts[1], parts[3]);
break;
case "f":
assert clazzdata != null;
clazzdata.addField(parts[2], parts[1], parts[3]);
break;
default:
}
}
return mappings;
}
private static MCPData addTSRGData(Map<String, ClassData> mappings, String tsrg) {
MCPData mcpData = new MCPData();
String[] classes = String.join("\t", tsrg.split("\n\t")).split("\n");
for (String c : classes) {
String[] lines = c.split("\t");
String[] classData = lines[0].split("\\s+");
ClassData clazz = mappings.get(classData[0]);
if (clazz == null) continue;
clazz.mcpName = classData[1];
for (int i = 1; i < lines.length; ++i) {
String[] lineData = lines[i].split("\\s+");
//method
if (lineData.length == 3) {
if (!mcpData.methods.containsKey(lineData[2])) mcpData.methods.put(lineData[2], new LinkedList<>());
MethodData d = clazz.methods.get(lineData[0] + lineData[1]);
if (d == null) continue;
d.mcpName = lineData[2];
mcpData.methods.get(lineData[2]).add(d);
//field
} else {
if (!mcpData.fields.containsKey(lineData[1])) mcpData.fields.put(lineData[1], new LinkedList<>());
FieldData d = clazz.fields.get(lineData[0]);
if (d == null) continue;
d.mcpName = lineData[1];
mcpData.fields.get(lineData[1]).add(d);
}
}
}
return mcpData;
}
private static void addMCPData(MCPData mcpData, String fields, String methods) {
for (String field : fields.split("\n")) {
String[] fieldData = field.split(",");
mcpData.fields.getOrDefault(fieldData[0].trim(), new LinkedList<>()).forEach(f -> f.mcpName = fieldData[1].trim());
}
for (String method : methods.split("\n")) {
String[] methodData = method.split(",");
mcpData.methods.getOrDefault(methodData[0].trim(), new LinkedList<>()).forEach(m -> m.mcpName = methodData[1].trim());
}
}
private static Map<String, String> readZipContentFromURL(URL remote, String... files) throws IOException {
try (ZipInputStream is = new ZipInputStream(new BufferedInputStream(remote.openStream(), 1024))) {
byte[] buff = new byte[1024];
ZipEntry entry;
Set<String> fileList = new HashSet<>(Arrays.asList(files));
Map<String, String> fileContents = new HashMap<>();
while ((entry = is.getNextEntry()) != null) {
if (fileList.contains(entry.getName())) {
StringBuilder builder = new StringBuilder();
int read;
while ((read = is.read(buff, 0, 1024)) > 0) {
builder.append(new String(buff, 0, read));
}
fileContents.put(entry.getName(), builder.toString());
}
}
return fileContents;
}
}
private static class ClassData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final Map<String, MethodData> methods = new LinkedHashMap<>();
final Map<String, FieldData> fields = new LinkedHashMap<>();
public ClassData(Map<String, ClassData> classMap, String obf, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.intermediary = intermediary;
}
public void addMethod(String obf, String obfSig, String intermediary) {
methods.put(obf + obfSig, new MethodData(classMap, obf, obfSig, intermediary));
}
public void addField(String obf, String obfSig, String intermediary) {
fields.put(obf, new FieldData(classMap, obf, obfSig, intermediary));
}
public String getIntToMCP() {
StringBuilder builder = new StringBuilder("c\t").append(intermediary).append("\t").append(mcpName);
for (MethodData method : methods.values()) {
builder.append("\n\tm\t").append(method.getIntermediarySig()).append("\t").append(method.intermediary).append("\t").append(method.mcpName);
}
for (FieldData field : fields.values()) {
builder.append("\n\tf\t").append(field.getIntermediarySig()).append("\t").append(field.intermediary).append("\t").append(field.mcpName);
}
return builder.toString();
}
}
private static class MethodData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final String obfSig;
public MethodData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.obfSig = obfSig;
this.intermediary = intermediary;
}
public String getIntermediarySig() {
int offset = 0;
Matcher m = Pattern.compile("L(.+?);").matcher(obfSig);
String intSig = obfSig;
while (m.find()) {
if (!classMap.containsKey(m.group(1))) continue;
String intName = classMap.get(m.group(1)).intermediary;
intSig = intSig.substring(0, m.start(1) + offset) + intName + intSig.substring(m.end(1) + offset);
offset += intName.length() - m.group(1).length();
}
return intSig;
}
}
private static class FieldData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final String obfSig;
public FieldData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.obfSig = obfSig;
this.intermediary = intermediary;
}
public String getIntermediarySig() {
Matcher m = Pattern.compile("(\\[*)L(.+?);").matcher(obfSig);
if (m.find()) {
if (!classMap.containsKey(m.group(2))) return obfSig;
return m.group(1) + "L" + classMap.get(m.group(2)).intermediary + ";";
} else {
return obfSig;
}
}
}
private static class MCPData {
final Map<String, List<MethodData>> methods = new HashMap<>();
final Map<String, List<FieldData>> fields = new HashMap<>();
}
}

View File

@@ -18,6 +18,9 @@
package baritone.gradle.task;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import java.io.File;
import java.io.IOException;
@@ -40,50 +43,56 @@ class BaritoneGradleTask extends DefaultTask {
PROGUARD_API_CONFIG = "api.pro",
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
PROGUARD_EXPORT_PATH = "proguard_out.jar",
PROGUARD_MAPPING_DIR = "mapping",
ARTIFACT_STANDARD = "%s-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
ARTIFACT_API = "%s-api-%s.jar",
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
protected String artifactName, artifactVersion;
protected final Path
protected Path
artifactPath,
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
proguardOut;
@Input
@Optional
protected String compType = null;
public String getCompType() {
return compType;
}
public void setCompType(String compType) {
this.compType = compType;
}
public BaritoneGradleTask() {
this.artifactName = getProject().getName();
this.artifactVersion = getProject().getVersion().toString();
this.artifactName = getProject().getRootProject().getProperties().get("archives_base_name").toString();
}
public void doFirst() {
if (compType != null) {
this.artifactVersion = compType + "-" + getProject().getVersion();
} else {
this.artifactVersion = getProject().getVersion().toString();
}
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
if (getProject().hasProperty("baritone.forge_build")) {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
} else if (getProject().hasProperty("baritone.fabric_build")) {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
} else {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
}
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
}
protected void verifyArtifacts() throws IllegalStateException {
if (!Files.exists(this.artifactPath)) {
throw new IllegalStateException("Artifact not found! Run build first!");
throw new IllegalStateException("Artifact not found! Run build first! Missing file: " + this.artifactPath);
}
}
@@ -99,7 +108,11 @@ class BaritoneGradleTask extends DefaultTask {
}
protected Path getRelativeFile(String file) {
return Paths.get(new File(file).getAbsolutePath());
return Paths.get(new File(getProject().getBuildDir(), file).getAbsolutePath());
}
protected Path getRootRelativeFile(String file) {
return Paths.get(new File(getProject().getRootDir(), file).getAbsolutePath());
}
protected Path getTemporaryFile(String file) {
@@ -107,6 +120,10 @@ class BaritoneGradleTask extends DefaultTask {
}
protected Path getBuildFile(String file) {
return getRelativeFile("build/libs/" + file);
return getRelativeFile("libs/" + file);
}
protected String addCompTypeFirst(String string) {
return compType == null ? string : compType + "-" + string;
}
}

View File

@@ -19,9 +19,11 @@ package baritone.gradle.task;
import org.gradle.api.tasks.TaskAction;
import javax.xml.bind.DatatypeConverter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.List;
@@ -39,15 +41,16 @@ public class CreateDistTask extends BaritoneGradleTask {
@TaskAction
protected void exec() throws Exception {
super.doFirst();
super.verifyArtifacts();
// Define the distribution file paths
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
Path api = getRootRelativeFile("dist/" + getFileName(artifactApiPath));
Path standalone = getRootRelativeFile("dist/" + getFileName(artifactStandalonePath));
Path unoptimized = getRootRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
// NIO will not automatically create directories
Path dir = getRelativeFile("dist/");
Path dir = getRootRelativeFile("dist/");
if (!Files.exists(dir)) {
Files.createDirectory(dir);
}
@@ -59,44 +62,42 @@ public class CreateDistTask extends BaritoneGradleTask {
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
// Calculate all checksums and format them like "shasum"
List<String> shasum = getAllDistJars().stream()
.filter(Files::exists)
List<String> shasum = Files.list(getRootRelativeFile("dist/"))
.filter(e -> e.getFileName().toString().endsWith(".jar"))
.map(path -> sha1(path) + " " + path.getFileName().toString())
.collect(Collectors.toList());
shasum.forEach(System.out::println);
// Write the checksums to a file
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
Files.write(getRootRelativeFile("dist/checksums.txt"), shasum);
}
private static String getFileName(Path p) {
return p.getFileName().toString();
}
private List<Path> getAllDistJars() {
return Arrays.asList(
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
);
}
private static synchronized String sha1(Path path) {
try {
if (SHA1_DIGEST == null) {
SHA1_DIGEST = MessageDigest.getInstance("SHA-1");
}
return DatatypeConverter.printHexBinary(SHA1_DIGEST.digest(Files.readAllBytes(path))).toLowerCase();
return bytesToHex(SHA1_DIGEST.digest(Files.readAllBytes(path))).toLowerCase();
} catch (Exception e) {
// haha no thanks
throw new IllegalStateException(e);
}
}
private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
public static String bytesToHex(byte[] bytes) {
byte[] hexChars = new byte[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars, StandardCharsets.UTF_8);
}
}

View File

@@ -22,23 +22,16 @@ import org.apache.commons.io.IOUtils;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.JavaVersion;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.internal.file.IdentityFileResolver;
import org.gradle.api.internal.plugins.DefaultConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.Pair;
import org.gradle.internal.jvm.Jvm;
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
import org.gradle.process.internal.DefaultExecActionFactory;
import xyz.wagyourtail.unimined.api.Constants;
import xyz.wagyourtail.unimined.api.minecraft.EnvType;
import xyz.wagyourtail.unimined.api.minecraft.MinecraftProvider;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -59,11 +52,20 @@ public class ProguardTask extends BaritoneGradleTask {
@Input
private String url;
public String getUrl() {
return url;
}
@Input
private String extract;
public String getExtract() {
return extract;
}
@TaskAction
protected void exec() throws Exception {
super.doFirst();
super.verifyArtifacts();
// "Haha brady why don't you make separate tasks"
@@ -76,6 +78,16 @@ public class ProguardTask extends BaritoneGradleTask {
cleanup();
}
MinecraftProvider<?, ?> provider = this.getProject().getExtensions().getByType(MinecraftProvider.class);
private File getMcJar() {
return provider.getMinecraftWithMapping(EnvType.COMBINED, provider.getMcPatcher().getProdNamespace(), provider.getMcPatcher().getProdNamespace()).toFile();
}
private boolean isMcJar(File f) {
return this.getProject().getConfigurations().getByName(Constants.MINECRAFT_COMBINED_PROVIDER).getFiles().contains(f);
}
private void processArtifact() throws Exception {
if (Files.exists(this.artifactUnoptimizedPath)) {
Files.delete(this.artifactUnoptimizedPath);
@@ -184,82 +196,82 @@ public class ProguardTask extends BaritoneGradleTask {
}
private boolean validateJavaVersion(String java) {
final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
if (!javaVersion.getMajorVersion().equals("8")) {
System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
// throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
return false;
}
System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
//TODO: fix for j16
// final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
//
// if (!javaVersion.getMajorVersion().equals("8")) {
// System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
// // throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
// return false;
// }
//
// System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
return true;
}
private void generateConfigs() throws Exception {
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
Files.copy(getRootRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
// Setup the template that will be used to derive the API and Standalone configs
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
template.add(0, "-injars '" + this.artifactPath.toString() + "'");
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
template.add(2, "-libraryjars '" + out + "'");
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
template.add(4, "-libraryjars <java.home>/jmods/jdk.unsupported.jmod(!**.jar;!module-info.class)");
{
final Stream<File> libraries;
File mcJar;
try {
mcJar = getMcJar();
} catch (Exception e) {
throw new RuntimeException("Failed to find Minecraft jar", e);
}
{
// Discover all of the libraries that we will need to acquire from gradle
final Stream<File> dependencies = acquireDependencies()
// remove MCP mapped jar
.filter(f -> !f.toString().endsWith("-recomp.jar"))
// go from the extra to the original downloaded client
.map(f -> f.toString().endsWith("client-extra.jar") ? new File(f.getParentFile(), "client.jar") : f);
// remove MCP mapped jar, and nashorn
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
if (getProject().hasProperty("baritone.forge_build")) {
libraries = dependencies
.map(f -> f.toString().endsWith("client.jar") ? getSrgMcJar() : f);
} else if (getProject().hasProperty("baritone.fabric_build")) {
libraries = dependencies
.map(f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") ? getSrgMcJar() : f);
} else {
libraries = dependencies;
}
libraries = dependencies
.map(f -> isMcJar(f) ? mcJar : f);
}
libraries.forEach(f -> {
template.add(2, "-libraryjars '" + f + "'");
});
}
Files.createDirectories(this.getRootRelativeFile(PROGUARD_MAPPING_DIR));
List<String> api = new ArrayList<>(template);
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(PROGUARD_API_CONFIG), template);
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"));
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
}
private File getSrgMcJar() {
return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("standalone.txt")));
Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone);
}
private Stream<File> acquireDependencies() {
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
.stream()
.filter(File::isFile);
}
private void proguardApi() throws Exception {
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
runProguard(getTemporaryFile(compType+PROGUARD_API_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
}
private void proguardStandalone() throws Exception {
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
runProguard(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
}
@@ -276,7 +288,6 @@ public class ProguardTask extends BaritoneGradleTask {
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)) {

103
fabric/build.gradle Normal file
View File

@@ -0,0 +1,103 @@
/*
* 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 "7.0.0"
}
archivesBaseName = archivesBaseName + "-fabric"
minecraft {
fabric()
}
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 {
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
if (sourceSet == rootProject.sourceSets.schematica_api) continue
common sourceSet.output
shadowCommon sourceSet.output
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
jar {
classifier "dev"
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
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'
compType "fabric"
}
task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "fabric"
}
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

@@ -21,11 +21,11 @@
"entrypoints": {
},
"mixins": [
"mixins.baritone.json"
"mixins.baritone.json"
],
"depends": {
"fabricloader": ">=0.7.4",
"minecraft": "1.16.x"
"fabricloader": ">=0.11.0",
"minecraft": "1.19.2"
}
}

122
forge/build.gradle Normal file
View File

@@ -0,0 +1,122 @@
/*
* 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 "7.0.0"
}
archivesBaseName = archivesBaseName + "-forge"
minecraft {
forge {
devFallbackNamespace = "intermediary"
mixinConfig = ["mixins.baritone.json"]
}
}
//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 {
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
if (sourceSet == rootProject.sourceSets.schematica_api) continue
common sourceSet.output
shadowCommon sourceSet.output
}
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
shadowJar {
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
jar {
classifier "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) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar'
compType "forge"
}
task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "forge"
}
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.
}
}

18
forge/gradle.properties Normal file
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

@@ -15,13 +15,8 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils;
package baritone.launch;import net.minecraftforge.fml.common.Mod;
/**
* @author Brady
*/
@FunctionalInterface
public interface BooleanBinaryOperator {
boolean applyAsBoolean(boolean a, boolean b);
@Mod("baritoe")
public class BaritoneForgeModXD {
}

View File

@@ -15,7 +15,7 @@ issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
# 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="${file.jarVersion}" #mandatory
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
@@ -31,3 +31,10 @@ description='''
A Minecraft pathfinder bot.
'''
[[dependencies.baritoe]]
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.2]"
ordering="NONE"
side="BOTH"

View File

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

9
gradle.properties Normal file
View File

@@ -0,0 +1,9 @@
org.gradle.jvmargs=-Xmx4G
mod_version=1.9.4
maven_group=baritone
archives_base_name=baritone
minecraft_version=1.19.2
forge_version=1.19.2-43.1.65
fabric_version=0.14.9

Binary file not shown.

View File

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

53
gradlew vendored
View File

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

43
gradlew.bat vendored
View File

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

4
jitpack.yml Normal file
View File

@@ -0,0 +1,4 @@
before_install:
- curl -s "https://get.sdkman.io" | bash
- sdk install java 17.0.5-tem
- sdk use java 17.0.5-tem

View File

@@ -339,6 +339,4 @@
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
-printmapping mapping.txt
}

View File

@@ -15,5 +15,36 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
pluginManagement {
repositories {
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/snapshots'
}
maven {
name = 'ForgeMaven'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal() {
content {
excludeGroup "org.apache.logging.log4j"
}
}
}
}
rootProject.name = 'baritone'
include("tweaker")
if (System.getProperty("Baritone.enabled_platforms") == null) {
System.setProperty("Baritone.enabled_platforms", "fabric,forge")
}
for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) {
include(platform)
}

View File

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

View File

@@ -21,11 +21,9 @@ import baritone.api.cache.IWorldScanner;
import baritone.api.command.ICommand;
import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
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.
@@ -48,18 +46,20 @@ public interface IBaritoneProvider {
* returned by {@link #getPrimaryBaritone()}.
*
* @return All active {@link IBaritone} instances.
* @see #getBaritoneForPlayer(ClientPlayerEntity)
* @see #getBaritoneForPlayer(LocalPlayer)
*/
List<IBaritone> getAllBaritones();
/**
* Provides the {@link IBaritone} instance for a given {@link ClientPlayerEntity}.
* Provides the {@link IBaritone} instance for a given {@link LocalPlayer}. This will likely be
* replaced with or be overloaded in addition to {@code #getBaritoneForUser(IBaritoneUser)} when
* {@code bot-system} is merged into {@code master}.
*
* @param player The player
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForPlayer(ClientPlayerEntity player) {
for (IBaritone baritone : this.getAllBaritones()) {
default IBaritone getBaritoneForPlayer(LocalPlayer player) {
for (IBaritone baritone : getAllBaritones()) {
if (Objects.equals(player, baritone.getPlayerContext().player())) {
return baritone;
}
@@ -67,39 +67,6 @@ public interface IBaritoneProvider {
return null;
}
/**
* Provides the {@link IBaritone} instance for a given {@link Minecraft}.
*
* @param minecraft The minecraft
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForMinecraft(Minecraft minecraft) {
for (IBaritone baritone : this.getAllBaritones()) {
if (Objects.equals(minecraft, baritone.getPlayerContext().minecraft())) {
return baritone;
}
}
return null;
}
/**
* 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,27 +17,24 @@
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.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.GuiMessageTag;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import java.awt.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.*;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -73,16 +70,6 @@ public final class Settings {
*/
public final Setting<Boolean> allowInventory = new Setting<>(false);
/**
* Wait this many ticks between InventoryBehavior moving inventory items
*/
public final Setting<Integer> ticksBetweenInventoryMoves = new Setting<>(1);
/**
* Come to a halt before doing any inventory moves. Intended for anticheat such as 2b2t
*/
public final Setting<Boolean> inventoryMoveOnlyIfStationary = new Setting<>(false);
/**
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
* <p>
@@ -624,13 +611,6 @@ 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
*/
@@ -732,17 +712,6 @@ public final class Settings {
*/
public final Setting<Boolean> freeLook = new Setting<>(true);
/**
* Break and place blocks without having to force the client-sided rotations. Requires {@link #freeLook}.
*/
public final Setting<Boolean> blockFreeLook = new Setting<>(false);
/**
* 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>
@@ -805,6 +774,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
*/
@@ -874,14 +848,10 @@ public final class Settings {
/**
* 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<>(255); // 1.17+ defaults to maximum possible world height
/**
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
*/
@@ -971,7 +941,7 @@ public final class Settings {
/**
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
*/
public final Setting<Vector3i> buildRepeat = new Setting<>(new Vector3i(0, 0, 0));
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
/**
* How many times to buildrepeat. -1 for infinite.
@@ -1100,7 +1070,7 @@ public final class Settings {
/**
* What Y level to go to for legit strip mining
*/
public final Setting<Integer> legitMineYLevel = new Setting<>(11);
public final Setting<Integer> legitMineYLevel = new Setting<>(-59);
/**
* Magically see ores that are separated diagonally from existing ores. Basically like mining around the ores that it finds
@@ -1178,15 +1148,16 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
@JavaOnly
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(msg -> Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(msg));
public final Setting<Consumer<Component>> logger = new Setting<>((msg) -> {
final GuiMessageTag tag = useMessageTag.value ? Helper.MESSAGE_TAG : null;
Minecraft.getInstance().gui.getChat().addMessage(msg, null, tag);
});
/**
* 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);
/**
@@ -1194,8 +1165,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<ITextComponent, ITextComponent>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
public final Setting<BiConsumer<Component, Component>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
/**
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors
@@ -1344,7 +1314,6 @@ public final class Settings {
public T value;
public final T defaultValue;
private String name;
private boolean javaOnly;
@SuppressWarnings("unchecked")
private Setting(T value) {
@@ -1353,7 +1322,6 @@ public final class Settings {
}
this.value = value;
this.defaultValue = value;
this.javaOnly = false;
}
/**
@@ -1390,25 +1358,8 @@ public final class Settings {
public final Type getType() {
return settingTypes.get(this);
}
/**
* This should always be the same as whether the setting can be parsed from or serialized to a string; in other
* words, the only way to modify it is by writing to {@link #value} programatically.
*
* @return {@code true} if the setting can not be set or read by the user
*/
public boolean isJavaOnly() {
return javaOnly;
}
}
/**
* Marks a {@link Setting} field as being {@link Setting#isJavaOnly() Java-only}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
private @interface JavaOnly {}
// here be dragons
Settings() {
@@ -1424,7 +1375,6 @@ public final class Settings {
Setting<?> setting = (Setting<?>) field.get(this);
String name = field.getName();
setting.name = name;
setting.javaOnly = field.isAnnotationPresent(JavaOnly.class);
name = name.toLowerCase();
if (tmpByName.containsKey(name)) {
throw new IllegalStateException("Duplicate setting name");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -19,11 +19,10 @@ package baritone.api.cache;
import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
/**
* @author Brady

View File

@@ -27,11 +27,10 @@ import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
import baritone.api.command.exception.CommandTooManyArgumentsException;
import baritone.api.utils.Helper;
import net.minecraft.util.Direction;
import java.util.Deque;
import java.util.LinkedList;
import java.util.stream.Stream;
import net.minecraft.core.Direction;
/**
* The {@link IArgConsumer} is how {@link ICommand}s read the arguments passed to them. This class has many benefits:

View File

@@ -19,7 +19,7 @@ package baritone.api.command.argument;
import baritone.api.command.argparser.IArgParser;
import baritone.api.command.exception.CommandInvalidTypeException;
import net.minecraft.util.Direction;
import net.minecraft.core.Direction;
/**
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of

View File

@@ -19,21 +19,14 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
public enum BlockById implements IDatatypeFor<Block> {
INSTANCE;
/**
* Matches (domain:)?name? where domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ respectively.
*/
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?[a-z0-9/_.-]*");
@Override
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
@@ -46,19 +39,13 @@ public enum BlockById implements IDatatypeFor<Block> {
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
String arg = ctx.getConsumer().getString();
if (!PATTERN.matcher(arg).matches()) {
return Stream.empty();
}
return new TabCompleteHelper()
.append(
Registry.BLOCK.keySet()
.stream()
.map(Object::toString)
)
.filterPrefixNamespaced(arg)
.filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically()
.stream();
}

View File

@@ -19,11 +19,10 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
public enum EntityClassById implements IDatatypeFor<EntityType> {
INSTANCE;

View File

@@ -1,43 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.util.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::getString).map(String::toLowerCase))
.filterPrefix(ctx.getConsumer().getString())
.stream();
}
}

View File

@@ -18,137 +18,20 @@
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.Block;
import net.minecraft.state.Property;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
INSTANCE;
/**
* Matches (domain:)?name([(property=value)*])? but the input can be truncated at any position.
* domain and name are [a-z0-9_.-]+ and [a-z0-9/_.-]+ because that's what mc 1.13+ accepts.
* property and value use the same format as domain.
*/
// Good luck reading this.
private static Pattern PATTERN = Pattern.compile("(?:[a-z0-9_.-]+:)?(?:[a-z0-9/_.-]+(?:\\[(?:(?:[a-z0-9_.-]+=[a-z0-9_.-]+,)*(?:[a-z0-9_.-]+(?:=(?:[a-z0-9_.-]+(?:\\])?)?)?)?|\\])?)?)?");
@Override
public BlockOptionalMeta get(IDatatypeContext ctx) throws CommandException {
return new BlockOptionalMeta(ctx.getConsumer().getString());
}
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
String arg = ctx.getConsumer().peekString();
if (!PATTERN.matcher(arg).matches()) {
// Invalid format; we can't complete this.
ctx.getConsumer().getString();
return Stream.empty();
}
if (arg.endsWith("]")) {
// We are already done.
ctx.getConsumer().getString();
return Stream.empty();
}
if (!arg.contains("[")) {
// no properties so we are completing the block id
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
}
ctx.getConsumer().getString();
// destructuring assignment? Please?
String blockId, properties;
{
String[] parts = splitLast(arg, '[');
blockId = parts[0];
properties = parts[1];
}
Block block = Registry.BLOCK.getOptional(new ResourceLocation(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.getStateContainer()
.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.getStateContainer().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.getAllowedValues().stream().map(property::getName);
public Stream<String> tabComplete(IDatatypeContext ctx) {
return ctx.getConsumer().tabCompleteDatatype(BlockById.INSTANCE);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,14 +23,13 @@ import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.ResourceLocation;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.resources.ResourceLocation;
/**
* The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper
@@ -253,7 +252,7 @@ public class TabCompleteHelper {
public TabCompleteHelper addSettings() {
return append(
BaritoneAPI.getSettings().allSettings.stream()
.filter(s -> !s.isJavaOnly())
.filter(s -> !SettingsUtil.javaOnlySetting(s))
.map(Settings.Setting::getName)
.sorted(String.CASE_INSENSITIVE_ORDER)
);

View File

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

View File

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

View File

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

View File

@@ -17,10 +17,9 @@
package baritone.api.event.events;
import baritone.api.utils.Rotation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
/**
* @author Brady
@@ -33,27 +32,14 @@ public final class RotationMoveEvent {
*/
private final Type type;
private final Rotation original;
/**
* The yaw rotation
*/
private float yaw;
/**
* The pitch rotation
*/
private float pitch;
public RotationMoveEvent(Type type, float yaw, float pitch) {
public RotationMoveEvent(Type type, float yaw) {
this.type = type;
this.original = new Rotation(yaw, pitch);
this.yaw = yaw;
this.pitch = pitch;
}
public Rotation getOriginal() {
return this.original;
}
/**
@@ -61,37 +47,21 @@ public final class RotationMoveEvent {
*
* @param yaw Yaw rotation
*/
public void setYaw(float yaw) {
public final void setYaw(float yaw) {
this.yaw = yaw;
}
/**
* @return The yaw rotation
*/
public float getYaw() {
public final float getYaw() {
return this.yaw;
}
/**
* Set the pitch movement rotation
*
* @param pitch Pitch rotation
*/
public void setPitch(float pitch) {
this.pitch = pitch;
}
/**
* @return The pitch rotation
*/
public float getPitch() {
return pitch;
}
/**
* @return The type of the event
*/
public Type getType() {
public final Type getType() {
return this.type;
}
@@ -100,7 +70,7 @@ public final class RotationMoveEvent {
/**
* Called when the player's motion is updated.
*
* @see Entity#moveRelative(float, Vector3d)
* @see Entity#moveRelative(float, Vec3)
*/
MOTION_UPDATE,

View File

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

View File

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

View File

@@ -17,7 +17,7 @@
package baritone.api.pathing.goals;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* An abstract Goal for pathing, can be anything from a specific block to just a Y coordinate.

View File

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

View File

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

View File

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

View File

@@ -17,8 +17,6 @@
package baritone.api.pathing.goals;
import java.util.Objects;
/**
* Invert any goal.
* <p>
@@ -52,24 +50,6 @@ 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,12 +17,11 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
public class GoalNear implements Goal, IGoalRenderPos {
@@ -87,27 +86,6 @@ 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

@@ -20,10 +20,9 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import java.util.Arrays;
import java.util.Objects;
/**
* Useful for automated combat (retreating specifically)
@@ -125,29 +124,6 @@ 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,10 +17,9 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
/**
* Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
@@ -37,8 +36,8 @@ public class GoalStrictDirection implements Goal {
x = origin.getX();
y = origin.getY();
z = origin.getZ();
dx = direction.getXOffset();
dz = direction.getZOffset();
dx = direction.getStepX();
dz = direction.getStepZ();
if (dx == 0 && dz == 0) {
throw new IllegalArgumentException(direction + "");
}
@@ -70,31 +69,6 @@ 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,10 +17,9 @@
package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
/**
* Useful if the goal is just to mine a block. This goal will be satisfied if the specified
@@ -73,26 +72,6 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
return new BlockPos(x, y, z);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalTwoBlocks goal = (GoalTwoBlocks) o;
return x == goal.x
&& y == goal.y
&& z == goal.z;
}
@Override
public int hashCode() {
return (int) BetterBlockPos.longHash(x, y, z) * 516508351;
}
@Override
public String toString() {
return String.format(

View File

@@ -20,8 +20,8 @@ package baritone.api.pathing.goals;
import baritone.api.BaritoneAPI;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
/**
* Useful for long-range goals that don't have a specific Y level.
@@ -64,27 +64,6 @@ public class GoalXZ implements Goal {
return calculate(xDiff, zDiff);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GoalXZ goal = (GoalXZ) o;
return x == goal.x && z == goal.z;
}
@Override
public int hashCode() {
int hash = 1791873246;
hash = hash * 222601791 + x;
hash = hash * -1331679453 + z;
return hash;
}
@Override
public String toString() {
return String.format(
@@ -115,11 +94,11 @@ public class GoalXZ implements Goal {
return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune
}
public static GoalXZ fromDirection(Vector3d origin, float yaw, double distance) {
public static GoalXZ fromDirection(Vec3 origin, float yaw, double distance) {
float theta = (float) Math.toRadians(yaw);
double x = origin.x - MathHelper.sin(theta) * distance;
double z = origin.z + MathHelper.cos(theta) * distance;
return new GoalXZ(MathHelper.floor(x), MathHelper.floor(z));
double x = origin.x - Mth.sin(theta) * distance;
double z = origin.z + Mth.cos(theta) * distance;
return new GoalXZ(Mth.floor(x), Mth.floor(z));
}
public int getX() {

View File

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

View File

@@ -65,8 +65,8 @@ public interface ActionCosts {
static double[] generateFallNBlocksCost() {
double[] costs = new double[257];
for (int i = 0; i < 257; i++) {
double[] costs = new double[4097];
for (int i = 0; i < 4097; i++) {
costs[i] = distanceToTicks(i);
}
return costs;

View File

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

View File

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

View File

@@ -17,7 +17,7 @@
package baritone.api.process;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
public interface IFarmProcess extends IBaritoneProcess {

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,8 @@
package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import java.util.List;

View File

@@ -17,10 +17,9 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import java.util.List;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
/**
* Basic representation of a schematic. Provides the dimensions and the desired state for a given position relative to

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic;
import net.minecraft.block.BlockState;
import net.minecraft.world.level.block.state.BlockState;
/**
* A static schematic is capable of providing the desired state at a given position without

View File

@@ -17,10 +17,8 @@
package baritone.api.schematic;
import baritone.api.schematic.mask.Mask;
import net.minecraft.block.BlockState;
import java.util.List;
import net.minecraft.world.level.block.state.BlockState;
public abstract class MaskSchematic extends AbstractSchematic {
@@ -42,14 +40,4 @@ 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

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

View File

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

View File

@@ -17,11 +17,11 @@
package baritone.api.schematic;
import net.minecraft.block.AirBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.BlockState;
import net.minecraft.state.Property;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import java.util.Collection;
import java.util.HashMap;
@@ -58,7 +58,7 @@ public class SubstituteSchematic extends AbstractSchematic {
}
for (Block substitute : substitutes) {
if (substitute instanceof AirBlock) {
return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.getDefaultState(); // can always "place" air
return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.defaultBlockState(); // can always "place" air
}
for (BlockState placeable : approxPlaceable) {
if (substitute.equals(placeable.getBlock())) {
@@ -66,15 +66,15 @@ public class SubstituteSchematic extends AbstractSchematic {
}
}
}
return substitutes.get(0).getDefaultState();
return substitutes.get(0).defaultBlockState();
}
private BlockState withBlock(BlockState state, Block block) {
if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) {
return blockStateCache.get(state).get(block);
}
Collection<Property<?>> properties = state.getBlock().getStateContainer().getProperties();
BlockState newState = block.getDefaultState();
Collection<Property<?>> properties = state.getProperties();
BlockState newState = block.defaultBlockState();
for (Property<?> property : properties) {
try {
newState = copySingleProp(state, newState, property);
@@ -86,6 +86,6 @@ public class SubstituteSchematic extends AbstractSchematic {
}
private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
return toState.with(prop, fromState.get(prop));
return toState.setValue(prop, fromState.getValue(prop));
}
}

View File

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

View File

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

View File

@@ -1,60 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.block.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

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

View File

@@ -1,82 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.block.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

@@ -1,79 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.operator;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask;
import baritone.api.utils.BooleanBinaryOperator;
import net.minecraft.block.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

@@ -1,56 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.operator;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask;
import net.minecraft.block.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

@@ -1,69 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic.mask.shape;
import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.StaticMask;
import net.minecraft.util.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

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

View File

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

View File

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

View File

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

View File

@@ -18,104 +18,71 @@
package baritone.api.utils;
import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.netty.util.concurrent.ThreadPerTaskExecutor;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.*;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.*;
import net.minecraft.state.Property;
import net.minecraft.util.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CompletableFuture;
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 Set<Integer> stateHashes;
private final Set<Integer> stackHashes;
private static LootTableManager manager;
private static LootPredicateManager predicate = new LootPredicateManager();
private final ImmutableSet<Integer> stateHashes;
private final ImmutableSet<Integer> stackHashes;
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
private static LootTables manager;
private static PredicateManager predicate = new PredicateManager();
private static Map<Block, List<Item>> drops = new HashMap<>();
public BlockOptionalMeta(@Nonnull Block block) {
this.block = block;
this.propertiesDescription = "{}";
this.blockstates = getStates(block, Collections.emptyMap());
this.blockstates = getStates(block);
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");
}
block = BlockUtils.stringToBlockRequired(matcher.group("id"));
MatchResult matchResult = matcher.toMatchResult();
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);
block = BlockUtils.stringToBlockRequired(matchResult.group(1));
blockstates = getStates(block);
stateHashes = getStateHashes(blockstates);
stackHashes = getStackHashes(blockstates);
}
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.getStateContainer().getProperty(rawKey);
Comparable<?> value = castToIProperty(key).parseValue(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.getStateContainer().getValidStates().stream()
.filter(blockstate -> properties.entrySet().stream().allMatch(entry ->
blockstate.get(entry.getKey()) == entry.getValue()
))
.collect(Collectors.toSet());
private static Set<BlockState> getStates(@Nonnull Block block) {
return new HashSet<>(block.getStateDefinition().getPossibleStates());
}
private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
@@ -156,14 +123,14 @@ public final class BlockOptionalMeta {
//noinspection ConstantConditions
int hash = ((IItemStack) (Object) stack).getBaritoneHash();
hash -= stack.getDamage();
hash -= stack.getDamageValue();
return stackHashes.contains(hash);
}
@Override
public String toString() {
return String.format("BlockOptionalMeta{block=%s,properties=%s}", block, propertiesDescription);
return String.format("BlockOptionalMeta{block=%s}", block);
}
public BlockState getAnyBlockState() {
@@ -174,24 +141,16 @@ public final class BlockOptionalMeta {
return null;
}
public Set<BlockState> getAllBlockStates() {
return blockstates;
}
public Set<Integer> stackHashes() {
return stackHashes;
}
public static LootTableManager getManager() {
public static LootTables getManager() {
if (manager == null) {
ResourcePackList rpl = new ResourcePackList(ResourcePackInfo::new, new ServerPackFinder());
rpl.reloadPacksFromFinders();
IResourcePack thePack = rpl.getAllPacks().iterator().next().getResourcePack();
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
manager = new LootTableManager(predicate);
resourceManager.addReloadListener(manager);
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
rpl.reload();
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
manager = new LootTables(predicate);
resourceManager.registerReloadListener(manager);
try {
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get();
} catch (Exception exception) {
throw new RuntimeException(exception);
}
@@ -199,27 +158,27 @@ public final class BlockOptionalMeta {
return manager;
}
public static LootPredicateManager getPredicateManager() {
public static PredicateManager getPredicateManager() {
return predicate;
}
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
ResourceLocation lootTableLocation = block.getLootTable();
if (lootTableLocation == LootTables.EMPTY) {
if (lootTableLocation == BuiltInLootTables.EMPTY) {
return Collections.emptyList();
} else {
List<Item> items = new ArrayList<>();
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
getManager().getLootTableFromLocation(lootTableLocation).generate(
new LootContext.Builder(null)
.withRandom(new Random())
.withParameter(LootParameters.field_237457_g_, Vector3d.copy(BlockPos.NULL_VECTOR))
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
.withParameter(LootParameters.BLOCK_STATE, block.getDefaultState())
.build(LootParameterSets.BLOCK),
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder((ServerLevel) null)
.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())
);
return items;

View File

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

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