Compare commits

..

453 Commits

Author SHA1 Message Date
Leijurv
1d090d4292 v1.8.6 2024-01-06 11:43:35 -08:00
leijurv
7c9015d205 oh my GOD 2024-01-06 11:43:16 -08:00
Wagyourtail
d8d5343065 actually fix mine under 0 height 2024-01-06 11:43:10 -08:00
Leijurv
fec8910283 deprecate 1.18.2 2023-08-14 13:40:46 -07:00
Leijurv
dad25da709 v1.8.5 2023-08-14 13:39:42 -07:00
Brady Hahn
29301e8a39 Merge pull request #4059 from cabaletta/pr/render/vulkanCompatibility
VulkanMod Compatibility
2023-07-18 20:07:38 -05:00
Brady
dfa838a6f9 Replace Mth.fastInvSqrt with 1.0 / Math.sqrt 2023-07-18 19:19:08 -05:00
Brady
6a9694b03a Manually specify some normals, fix GoalXZ rendering 2023-07-18 15:24:21 -05:00
Brady
bf9cb76604 VulkanMod compatibility + use LINES instead of DEBUG_LINES 2023-07-17 16:34:01 -05:00
leijurv
b647c0fca0 Merge pull request #4050 from ZacSharp/1.18.2-update
Merge 1.16.5 into 1.18.2
2023-07-13 22:14:32 -07:00
ZacSharp
448e454cc8 Merge branch '1.17.1' into 1.18.2 2023-07-12 18:56:17 +02:00
ZacSharp
cbf0d79c9c Merge branch '1.16.5' into 1.17.1 2023-07-06 13:30:25 +02:00
leijurv
8ceb89d021 Merge pull request #4028 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2023-07-05 11:47:27 -07:00
ZacSharp
8e58dd9e64 Merge branch '1.15.2' into 1.16.5 2023-07-04 16:48:41 +02:00
ZacSharp
45abbb7fa1 Merge branch '1.14.4' into 1.15.2 2023-07-04 16:48:36 +02:00
ZacSharp
1d983d5fdc Merge branch '1.13.2' into 1.14.4 2023-07-04 16:48:31 +02:00
ZacSharp
be54b8ee5b Merge branch 'master' into 1.13.2 2023-07-04 16:47:58 +02:00
leijurv
0dd38ca65a Merge pull request #4012 from ZacSharp/pr/commands/usableTabCompletion
Fix tab completion with brigadier
2023-06-21 18:54:20 -07:00
leijurv
298256197b Merge pull request #3983 from John200410/1.18.2
Add proper level height to GoalXZ rendering (1.18+)
2023-06-12 14:26:05 -07:00
John200410
de80527702 Add proper level height to GoalXZ rendering 2023-06-12 17:16:07 -04:00
ZacSharp
9efc512253 Make tab completion usable
Now behaves almost identical to vanilla tab completion
2023-02-19 19:27:39 +01:00
Leijurv
24e047c12e v1.8.4 2023-02-18 15:41:19 -08:00
Leijurv
6e5fec576f v1.7.3 2023-02-18 15:38:40 -08:00
Leijurv
1e7e504650 v1.6.4 2023-02-18 15:37:37 -08:00
leijurv
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
6d5cfe4187 Merge pull request #3801 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2023-01-27 23:33:57 -08:00
ZacSharp
d3e0da7c5e Merge branch '1.15.2' into 1.16.5 2023-01-27 22:36:53 +01:00
ZacSharp
38fbc127e6 Merge branch '1.14.4' into 1.15.2 2023-01-27 22:34:12 +01:00
ZacSharp
25ef38aaf2 Merge branch '1.13.2' into 1.14.4 2023-01-27 22:30:51 +01:00
ZacSharp
d05d5fd98e Merge branch 'master' into 1.13.2 2023-01-27 22:20:20 +01:00
ZacSharp
432d42ade8 Fix #find results not being clickable 2023-01-15 20:22:58 +01:00
leijurv
0057f093db Merge pull request #3771 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2023-01-13 11:19:14 -08:00
ZacSharp
0e1fee352f Merge branch '1.15.2' into 1.16.5 2023-01-10 01:40:36 +01:00
ZacSharp
1136494fc6 Merge branch '1.14.4' into 1.15.2 2023-01-10 01:35:22 +01:00
ZacSharp
9b3e5cb444 Merge branch '1.13.2' into 1.14.4 2023-01-10 01:26:48 +01:00
ZacSharp
f13dc16af5 Merge branch 'master' into 1.13.2 2023-01-10 01:18:45 +01:00
ZacSharp
b51b78f4e4 Merge branch 'master' into 1.13.2 2023-01-06 01:47:30 +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
Leijurv
c1e12b8746 Merge pull request #3678 from rycbar0/1.16.5
Merging Master in 1.16.5
2022-10-04 13:02:41 -07:00
rycbar0
44c1438541 forgot to adjust version check 2022-10-04 19:38:16 +02:00
rycbar0
c2a857f4d6 merging main into 1.16.5 2022-10-04 03:41:38 +02:00
rycbar0
9d620f8137 merging main into 1.16.5 2022-10-04 03:35:49 +02:00
rycbar0
7c2327b743 Merge remote-tracking branch 'origin/master' into 1.16.5
# Conflicts:
#	scripts/proguard.pro
#	src/launch/resources/mixins.baritone.json
#	src/main/java/baritone/command/defaults/DefaultCommands.java
#	src/main/java/baritone/command/defaults/FindCommand.java
#	src/main/java/baritone/process/BuilderProcess.java
#	src/main/java/baritone/utils/schematic/format/DefaultSchematicFormats.java
#	src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java
#	src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java
#	src/schematica_api/java/fi/dy/masa/litematica/Litematica.java
#	src/schematica_api/java/fi/dy/masa/litematica/data/DataManager.java
#	src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SchematicPlacement.java
#	src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SchematicPlacementManager.java
#	src/schematica_api/java/fi/dy/masa/litematica/schematic/placement/SchematicPlacementUnloaded.java
2022-10-04 03:18:30 +02:00
rycbar0
d91abd5e45 Litematica support for 1.16.5 2022-10-04 02:09:07 +02:00
scorbett123
8f514bd782 Cleaner fix for water jump issue 2022-10-03 21:22:07 +01:00
Leijurv
04f5ca2647 Merge pull request #3642 from wagyourtail/1.16.5/removeschematica
remove schematica command because it doesn't work anyway on 1.13+
2022-10-03 12:21:38 -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
Leijurv
cd7c504c76 Merge pull request #3664 from ZacSharp/patch-9
Fix yet another cave air bug
2022-09-18 22:54:42 -10:00
ZacSharp
96ba589d4d Fix yet another cave air bug 2022-09-17 01:56:23 +02:00
wagyourtail
8803c618b1 remove schematica command because it doesn't work anyway on 1.13+ since sechematica doesn't exist past 1.12.2 2022-08-31 18:20:51 -07: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
Leijurv
348b02e4f8 Merge pull request #3368 from ZacSharp/patch-5
Remove false information from `#help mine`
2022-07-05 15:28:05 -07: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
ZacSharp
4a042510d8 Merge branch '1.17.1' into 1.18.2 2022-06-03 22:26:24 +02:00
ZacSharp
59b3fe7c3a Merge branch '1.16.5' into 1.17.1 2022-06-03 19:05:47 +02:00
Leijurv
b54ddeadf4 Merge pull request #3387 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2022-06-02 11:39:20 -07:00
ZacSharp
4e0a507ba0 Merge branch '1.15.2' into 1.16.5 2022-05-24 21:45:58 +02:00
ZacSharp
7d39aacd72 Merge branch '1.14.4' into 1.15.2 2022-05-24 21:42:46 +02:00
ZacSharp
a8ae8a6171 Merge branch '1.13.2' into 1.14.4 2022-05-24 21:39:14 +02:00
ZacSharp
9c99333759 Merge branch 'master' into 1.13.2 2022-05-24 21:35:43 +02:00
Leijurv
ec6ffb0f53 Merge pull request #3413 from wagyourtail/1.16.5/backport3308
backport #3308 to 1.16.5
2022-05-23 13:45:27 -07:00
ZacSharp
1544b09c82 Merge branch '1.15.2' into 1.16.5 2022-04-23 13:12:08 +02:00
ZacSharp
1d08b3e729 Merge branch '1.14.4' into 1.15.2 2022-04-23 13:07:22 +02:00
ZacSharp
8a150568ec Merge branch '1.13.2' into 1.14.4 2022-04-23 13:02:47 +02:00
ZacSharp
00b20b2158 Merge branch 'master' into 1.13.2 2022-04-23 13:00:16 +02:00
wagyourtail
25e8e1b5fe fix 2022-04-22 19:23:39 -07:00
wagyourtail
bf7c840ea3 backport 3308 2022-04-22 19:00:43 -07:00
Leijurv
78a5838aa1 Merge pull request #3392 from ZacSharp/fixMerge
Fix mistakes made while merging upwards
2022-04-19 16:34:55 -07:00
ZacSharp
4dcf260059 Fix mistakes made while merging upwards 2022-04-14 19:22:38 +02:00
ZacSharp
e885d2c221 Merge branch '1.15.2' into 1.16.5 2022-04-11 18:26:03 +02:00
ZacSharp
fe61a404d6 Merge branch '1.14.4' into 1.15.2 2022-04-11 18:03:10 +02:00
ZacSharp
97ac4bbd4f Merge branch '1.13.2' into 1.14.4 2022-04-11 18:00:00 +02:00
ZacSharp
dd29b72295 Merge branch 'master' into 1.13.2 2022-04-11 17:49:10 +02:00
Leijurv
23fa65cee0 Merge pull request #3372 from ZacSharp/patch-6
Fix dynamic mixin dependency to 0.8.3
2022-04-05 14:39:36 -07:00
ZacSharp
adc88d1fb9 Fix dynamic mixin dependency to 0.8.3
Newer Mixin versions use a class file format Proguard can't handle.
2022-04-02 23:44:29 +02:00
ZacSharp
2908c7499c Fix syntax
That's why you shouldn't make changes on Github
2022-04-01 00:33:27 +02:00
ZacSharp
ef4c2bbc98 Remove false information from #help mine
Baritone no longer caches ores on Minecraft 1.13+
Metadata values were removed in Minecraft 1.13
lit_redstone_ore was merged into redstone_ore in Minecraft 1.13
2022-03-31 23:53:58 +02: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
Leijurv
f033230548 Merge pull request #3360 from ZacSharp/1.16.5-update
Merge master into 1.16.5
2022-03-31 13:59:48 -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
ZacSharp
17b2245033 Merge branch '1.15.2' into 1.16.5 2022-03-24 18:27:50 +01:00
ZacSharp
7b7c49d7ad Merge branch '1.14.4' into 1.15.2 2022-03-22 22:16:06 +01:00
ZacSharp
1522d11df0 Merge branch '1.13.2' into 1.14.4 2022-03-21 23:15:22 +01:00
ZacSharp
7eecf69178 Merge branch 'master' into 1.13.2 2022-03-21 17:57:39 +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
d4ae351065 Merge branch '1.16.4' into 1.16.5 2022-02-02 00:19:06 -08:00
Leijurv
2b75241338 Merge branch '1.16.4' into 1.17.1 2022-02-02 00:17:09 -08:00
Leijurv
3de7fc81fb Merge branch '1.15.2' into 1.16.4 2022-02-02 00:15:04 -08:00
Leijurv
34501f5af3 Merge branch '1.14.4' into 1.15.2 2022-02-02 00:14:38 -08:00
Leijurv
696ec6756d Merge pull request #3077 from wagyourtail/1.18
1.18 support
2022-02-02 00:00:05 -08:00
Leijurv
6e03e6859c Merge pull request #3194 from wagyourtail/1.17.1
fix dripleaf and azalea behavior
2022-02-01 23:57:54 -08:00
Leijurv
5ce006170d Merge pull request #3068 from wagyourtail/fixfabricbuilding
Fix fabric building due to dependency issue
2022-02-01 23:55:13 -08:00
Leijurv
ffd7d7a23a Merge pull request #3067 from wagyourtail/collisionShapeFix
fix Null params on getCollisionShape causing NPEs
2022-02-01 23:55:01 -08:00
Wagyourtail
697c92ae77 Merge branch '1.17.1' into 1.18 2022-01-20 15:19:49 -07:00
Wagyourtail
e37d81d3fc fix runClient to actually have the right sourceSet by default 2022-01-20 15:19:35 -07:00
Wagyourtail
7f21362a2a fix dripleaf and azalea behavior
change so rebuilds
2022-01-10 16:58:17 -07:00
Wagyourtail
c4da682e84 Merge branch '1.17.1' into 1.18
change so rebuilds
2022-01-10 16:58:03 -07:00
Wagyourtail
33ee39dcce fix dripleaf and azalea behavior 2022-01-10 11:28:37 -07:00
Wagyourtail
587c2cc8e2 forge support 2021-12-02 11:13:56 -07:00
Wagyourtail
1c8899ceae 1.18 release
pre.5


pre.6


pre.7


rc.1


1.18 release
2021-11-30 14:06:03 -07:00
Wagyourtail
088009fe4a pre.3 2021-11-17 10:16:07 -07:00
Wagyourtail
90ac6f331e missed a spot 2021-11-16 16:47:37 -07:00
Wagyourtail
e80e4afa48 bump proguard version 2021-11-16 16:41:34 -07:00
Wagyourtail
b73295d180 bump to gradle 7.3, java 17 and 1.18-pre2 2021-11-16 16:30:37 -07:00
Wagyourtail
186a3cb6df shedainel says its fixed 2021-11-12 19:38:46 -07:00
Wagyourtail
b6fba56291 temp comment vanilla/forge 2021-11-12 19:38:46 -07:00
Wagyourtail
f52fee8254 revert this commit when shedaniel fixes arch-loom 2021-11-12 19:38:46 -07:00
Wagyourtail
f1061cfd31 fix baritone only ticking when screen open 2021-11-12 19:38:46 -07:00
Wagyourtail
9a9358bc78 WIP 2021-11-12 19:38:46 -07:00
Leijurv
749fd4fac3 Merge pull request #2850 from wagyourtail/1.17
1.17.X port, (uses changes from #2814)
2021-11-11 19:33:09 -08:00
Wagyourtail
62fe9888a2 eclipse dependency updated to java 11 on a minor version 2021-11-03 13:42:35 -06:00
Wagyourtail
08c00b8a42 surround with try/catch 2021-11-03 13:04:51 -06:00
Wagyourtail
43ecc906c7 cleanup 2021-10-28 08:03:37 -06:00
ZacSharp
bb91dc98de Merge branch 'master' into 1.13.2 2021-10-20 03:20:41 +02: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
Leijurv
373ad3efdd soul fire 2021-02-24 13:16:03 -08:00
Leijurv
a48ae2a9a8 v1.6.3 2021-02-05 22:17:20 -08:00
Leijurv
a9b956c12d empty 2021-02-05 21:01:02 -08:00
Leijurv
476b724471 1.16.5 2021-02-05 20:47:46 -08:00
Leijurv
98da144691 Merge branch '1.15.2' into 1.16.4 2021-02-02 17:09:56 -08:00
Leijurv
7320c3fd7e Merge branch '1.14.4' into 1.15.2 2021-02-02 17:09:31 -08:00
Leijurv
c37cdf78e4 Merge branch '1.13.2' into 1.14.4 2021-02-02 17:09:18 -08:00
Leijurv
6a1f716dc8 Merge branch 'master' into 1.13.2 2021-02-02 17:09:06 -08:00
Leijurv
a9d90786ff Merge pull request #2413 from wagyourtail/sodium-fix-mcpmappings
compatibility for SodiumChunkManager
2021-02-02 17:07:38 -08:00
wagyourtail
484c606dc1 Update MixinSodiumChunkProvider.java 2021-02-02 17:56:00 -07:00
wagyourtail
637c182114 sodium fix 2021-02-01 16:14:27 -07:00
Leijurv
2377694a6b Merge branch '1.15.2' into 1.16.4 2021-01-29 21:28:21 -08:00
Leijurv
1b3799d4d7 reorder dist to alphabetical 2021-01-29 21:28:11 -08:00
Leijurv
81fadde388 Merge branch '1.15.2' into 1.16.4 2021-01-29 21:21:07 -08:00
Leijurv
a61eabd60c Merge branch '1.14.4' into 1.15.2 2021-01-29 21:14:10 -08:00
Leijurv
bb75e68b0a Merge branch '1.13.2' into 1.14.4 2021-01-29 21:13:33 -08:00
Leijurv
e9b9977674 Merge branch 'master' into 1.13.2 2021-01-29 21:13:12 -08:00
Leijurv
825bad47ef add fabric build step 2021-01-29 21:06:37 -08:00
Leijurv
78acd2f945 reformatter 2021-01-29 21:02:57 -08:00
Leijurv
1183196e0d Merge pull request #2401 from wagyourtail/1.15.2-fabrictest
fabric support 1.15
2021-01-29 21:01:08 -08:00
Leijurv
e4947ec071 fake merge of 1.15.2 into 1.16.4 due to reformatting conflicts 2021-01-29 20:31:13 -08:00
Leijurv
5262f68215 a long overdue reformat of every file 2021-01-29 20:30:51 -08:00
Leijurv
4b45cc6f0b fake merge of 1.13.2 into 1.15.2 due to reformatting conflicts 2021-01-29 20:30:00 -08:00
Leijurv
a3da25ca27 a long overdue reformat of every file 2021-01-29 20:29:41 -08:00
Leijurv
eae6e4d804 fake merge of 1.13.2 into 1.14.4 due to reformatting conflicts 2021-01-29 20:28:32 -08:00
Leijurv
37cd50d435 a long overdue reformat of every file 2021-01-29 20:28:11 -08:00
Leijurv
3f65d46e12 fake merge of master into 1.13.2 due to reformatting conflicts 2021-01-29 20:26:22 -08:00
Leijurv
15fd313757 a long overdue reformat of every file 2021-01-29 20:26:06 -08:00
Leijurv
ca870af20e Merge branch '1.15.2' into 1.16.4 2021-01-29 20:13:56 -08:00
Leijurv
c98c54c985 Merge branch '1.14.4' into 1.15.2 2021-01-29 19:57:36 -08:00
Leijurv
4c9689fe19 Merge branch '1.13.2' into 1.14.4 2021-01-29 19:49:11 -08:00
Leijurv
f41c873852 Merge branch 'master' into 1.13.2 2021-01-29 19:31:16 -08:00
Leijurv
eb8a673165 Merge branch 'master' into 1.13.2 2021-01-29 19:30:56 -08:00
wagyourtail
9a7b07befc move mappings folder to better location and have it autocreate 2021-01-27 09:20:10 -07:00
wagyourtail
2c3f352d0d figure out how to revert "fix refmap location to be fabric-compliant"
I did some reading
2021-01-20 18:11:51 -07:00
wagyourtail
7fbe9c062e unique version names 2021-01-19 23:37:01 -07:00
wagyourtail
c1d7683896 fix version # 2021-01-19 23:14:37 -07:00
wagyourtail
b493c2ce89 remove debug, add ignore 2021-01-19 23:11:42 -07:00
wagyourtail
82436f30e1 cleanup 2021-01-19 23:11:08 -07:00
wagyourtail
f549e0e2d4 on the fly volderyarn mapping generation 2021-01-19 23:03:57 -07:00
wagyourtail
5494c43290 fabric task like forge 2021-01-19 23:03:40 -07:00
wagyourtail
f5d5457100 fix refmap location to be fabric-compliant 2021-01-19 23:03:35 -07:00
wagyourtail
d6cbb58e7e fabric with volder-mappings, soo close to working 2021-01-19 23:03:03 -07:00
Leijurv
dbb0f599fc v1.6.2 2020-12-16 13:32:11 -10:00
Brady
dcc0b82210 Update to 1.16.4 2020-12-16 16:42:35 -06:00
Leijurv
a92675e125 v1.6.1 2020-09-07 16:48:44 -07:00
Leijurv
7cbe5bfd2f Merge pull request #1967 from CDAGaming/1.16.2
Added the license field that forge is forcing
2020-08-22 02:04:05 -07:00
CDAGaming
69c4c7a3b8 Added the license field that forge is forcing 2020-08-21 19:36:15 -05:00
Leijurv
3b32c72d63 remove broken furry cringe 2020-08-17 17:41:13 -07:00
Leijurv
0102ce8fad Merge pull request #1946 from CDAGaming/1.16.2
✔️ 1.16.1 -> 1.16.2
2020-08-17 17:00:42 -07:00
CDAGaming
0b9bb9df2b 👌 Apply review suggestions from leijurv 2020-08-17 18:58:36 -05:00
CDAGaming
78dd64c73d Merge remote-tracking branch 'remote/master' into 1.16.2 2020-08-17 18:55:08 -05:00
CDAGaming
750cc619fb 🐛 Fix broken mixin 2020-08-17 18:51:04 -05:00
CDAGaming
6eaa3a27f2 Merge remote-tracking branch 'remote/master' into 1.16.2 2020-08-17 18:15:59 -05:00
CDAGaming
17e16498b6 [Change] 1.16.1 -> 1.16.2 2020-08-13 13:47:50 -05:00
Leijurv
3f3358d0b1 Merge pull request #1942 from CDAGaming/live/1.16.1
[1.16.1] Live Testing Week Changes
2020-08-10 13:16:34 -07:00
CDAGaming
c006005cc7 Merge branch 'master' into live/1.16.1 2020-08-07 22:12:44 -05:00
CDAGaming
6cd12bf84d [Fix] Attempted Fix for Forge Version Error 2020-07-26 09:47:05 -05:00
CDAGaming
a09f5d41f6 [Change] Also allow Forge Building
Also sets minimum Forge version to 32.0.72 so we don't need MixinBootstrap
2020-07-25 23:16:08 -05:00
CDAGaming
8aaa49c80d [Change] Edit CI to use Proguard Data 2020-07-25 22:59:33 -05:00
CDAGaming
4f1db04224 [Change] Updated Mappings 2020-07-25 22:53:22 -05:00
CDAGaming
dbeee33657 [Fix] Fix Proguard from Master Merge
Someone didn't verify this even built xD
2020-07-25 22:52:46 -05:00
CDAGaming
cd245f7f59 Merge remote-tracking branch 'remote/master' into live/1.16.1 2020-07-25 22:30:23 -05:00
CDAGaming
246dd2b0ad [Change] Added Auto Build Support 2020-07-25 22:28:38 -05:00
Brady
20fa2c6f3d Merge pull request #1894 from CDAGaming/1.16.1
[Fix] Fixed BaritoneAutoTest in 1.16.1
2020-07-20 00:54:59 -05:00
CDAGaming
9cb021ffa0 Merge remote-tracking branch 'remote/1.16.1' into 1.16.1 2020-07-19 18:34:16 -05:00
CDAGaming
2acb8f2a37 [Fix] Fixed BaritoneAutoTest in 1.16.1 2020-07-19 18:33:58 -05:00
Brady
b044d244d0 Merge pull request #1892 from CDAGaming/1.16.1
[Change] Updated Mappings + Simplified Port
2020-07-19 16:53:20 -05:00
CDAGaming
807b1b5eb0 [Change] Updated Mappings + Simplified Port 2020-07-19 16:47:30 -05:00
Brady
819178b280 wildcard 2020-07-19 16:46:00 -05:00
Brady
039898c654 This null check should fix it lol 2020-07-19 16:26:18 -05:00
Brady
854985e5b5 Baritone 1.16.1 2020-07-19 15:50:56 -05:00
Leijurv
6e78384bcf Merge pull request #1700 from babbaj/forge-mine-fix
Fix #mine in forge
2020-05-16 16:01:16 -07:00
Babbaj
47501ab8e1 fix terrible formatting 2020-05-16 18:23:38 -04:00
Babbaj
682de71ab7 Fix #mine in forge 2020-05-16 18:21:27 -04:00
Brady
410ea059fc Update mappings to 20200515-1.15.1 2020-05-15 21:03:08 -05:00
Leijurv
b7870d059c v1.5.3 2020-04-21 12:34:46 -07:00
Leijurv
06865f1561 Merge branch '1.14.4' into 1.15.2 2020-04-21 12:34:32 -07:00
Leijurv
fe0b54cfb4 v1.4.6 2020-04-21 12:23:47 -07:00
Leijurv
0bf7bb4b39 Merge branch '1.13.2' into 1.14.4 2020-04-21 12:17:54 -07:00
Leijurv
2a830b6b68 v1.3.8 2020-04-21 12:05:09 -07:00
Leijurv
fc620f8ba8 Merge branch 'master' into 1.13.2 2020-04-21 12:04:44 -07:00
Leijurv
315977e1f2 Merge branch '1.13.2' into 1.14.4 2020-04-07 23:45:48 -07:00
Leijurv
e7658b75ef Merge branch 'master' into 1.13.2 2020-04-07 23:45:42 -07:00
Leijurv
8c3fac977e unscuff 2020-03-25 21:19:15 -07:00
Leijurv
be2ee1a07c Merge pull request #1446 from babbaj/1.15.2
Add support for building forge jars
2020-03-25 21:07:45 -07:00
Babbaj
a4f7207089 ok 2020-03-25 21:00:25 -04:00
Babbaj
aead997b13 dont sha old jars 2020-03-25 20:53:37 -04:00
Leijurv
2d421e66dc v1.5.2 2020-03-25 17:51:56 -07:00
Leijurv
e8370f1348 Merge branch '1.14.4' into 1.15.2 2020-03-25 17:51:42 -07:00
Leijurv
16f6baf216 v1.4.5 2020-03-25 17:39:01 -07:00
Leijurv
89ab959fb4 Merge branch '1.13.2' into 1.14.4 2020-03-25 17:38:28 -07:00
Babbaj
b13b86b67a get the hash of all jars in the dist directory 2020-03-25 20:34:54 -04:00
Leijurv
b9a7efc25b v1.3.7 2020-03-25 17:26:18 -07:00
Leijurv
3b7f13babd Merge branch 'master' into 1.13.2 2020-03-25 17:25:25 -07:00
Babbaj
6cc31a9422 update mods.toml and fix modid 2020-03-25 20:23:41 -04:00
Babbaj
592a01f3e4 cleanup 2020-03-25 19:00:26 -04:00
Babbaj
db718a1781 Add @Mod annotated class 2020-03-25 01:16:30 -04:00
Babbaj
261bf005f6 Scuffed support for forge and building a forge jar 2020-03-25 00:28:55 -04:00
Leijurv
e926ff2a16 Merge branch '1.14.4' into 1.15.2 2020-03-14 12:35:33 -07:00
Leijurv
8794bfd79a fix javadoc errors 2020-03-14 12:35:03 -07:00
Leijurv
500643aec7 Merge branch '1.14.4' into 1.15.2 2020-03-14 12:25:46 -07:00
Leijurv
58bb6c4357 Merge branch '1.13.2' into 1.14.4 2020-03-14 12:25:36 -07:00
Leijurv
520142427d Merge branch 'master' into 1.13.2 2020-03-14 12:25:22 -07:00
Brady
369d726a96 Merge branch '1.14.4' into 1.15.2 2020-03-07 20:45:07 -06:00
Brady
e0beba38af Merge branch '1.13.2' into 1.14.4 2020-03-07 20:37:47 -06:00
Brady
ebe3f457c6 Fix additional injection points in 1.13.2 2020-03-07 20:27:29 -06:00
Brady
6289e540b8 Merge branch 'master' into 1.13.2 2020-03-07 20:23:09 -06:00
Brady
e0bd82d7ff lol? 2020-03-02 17:15:01 -06:00
Leijurv
5ec4b89caa Merge branch '1.14.4' into 1.15.2 2020-02-24 19:28:51 -08:00
Leijurv
5fd3e236e2 Merge branch '1.13.2' into 1.14.4 2020-02-24 19:28:42 -08:00
Leijurv
399037b866 Merge branch 'master' into 1.13.2 2020-02-24 19:28:05 -08:00
Leijurv
2d941f6264 Merge branch '1.14.4' into 1.15.2 2020-02-24 19:02:20 -08:00
Leijurv
1a8d93b946 Merge branch '1.13.2' into 1.14.4 2020-02-24 18:56:56 -08:00
Leijurv
50783e65a9 Merge branch 'master' into 1.13.2 2020-02-24 18:39:36 -08:00
Leijurv
606e9bf97c v1.5.1 2020-02-14 15:28:37 -08:00
Leijurv
47ae75a9d6 Merge branch '1.14.4' into 1.15.2 2020-02-14 15:26:34 -08:00
Leijurv
25587e317a fix link click crash 2020-02-14 15:26:03 -08:00
Leijurv
b3ba129fc5 honey is stupid lets just not 2020-02-13 18:59:08 -08:00
Leijurv
746b7b5c88 not unscuffed, just differently scuffed 2020-02-13 18:57:32 -08:00
Brady
db2f6ec78d Update mappings to 20200213-1.15.1 2020-02-13 14:44:29 -06:00
Leijurv
96bcabff8b v1.5.0 2020-02-13 12:04:29 -08:00
Leijurv
0a1fe857dc cant walk through honey blocks 2020-02-13 12:03:09 -08:00
Brady
49aaa55172 Fix click 2020-02-09 13:38:46 -06:00
Leijurv
e03e251541 fix crouching 2020-02-05 17:45:22 -08:00
Leijurv
f5380881f4 brady fix mixins im incompetent 2020-02-05 16:10:55 -08:00
Leijurv
a022778fb6 cursed but fixes blockoptionalmeta 2020-02-05 15:14:32 -08:00
Leijurv
8543a99fba compiles and can path 2020-02-05 14:54:03 -08:00
Brady
997888fe85 Merge branch '1.14.4' into 1.15.1 2020-01-10 20:15:43 -06:00
Brady
94a2e13561 Merge branch '1.13.2' into 1.14.4 2020-01-10 20:14:46 -06:00
Brady
f7041022d0 Merge branch 'master' into 1.13.2 2020-01-10 20:13:57 -06:00
Brady
2d2030ecdf Fix renderGoalXZBeacon 2020-01-10 20:07:33 -06:00
Brady
a3dec3a47e Render stuff should be fixed now.
There is likely a better solution, but I think this is fine in order to keep things in-line with the development over at Mojang.
2020-01-10 19:37:00 -06:00
Brady
eb348120d9 Fix Mixins 2020-01-10 18:59:57 -06:00
Brady
27cb708d40 Fix some render stuff but it's still broken 2020-01-09 20:09:49 -06:00
Leijurv
36bbe430d4 add fixmes 2020-01-09 17:27:28 -08:00
Leijurv
80952e091d comment out anything that isn't instantly obvious how to fix (e.g. anything involving rendering) 2020-01-09 17:15:05 -08:00
Leijurv
760ac5dd8f v1.4.4 2020-01-04 21:58:55 -08:00
Leijurv
dd76d2eabc v1.3.6 2020-01-04 21:58:21 -08:00
Brady
92966dc57c Merge branch '1.13.2' into 1.14.4 2019-12-31 21:57:55 -06:00
Brady
e3d3407de5 Remove normalizations from BlockOptionalMeta 2019-12-31 19:44:44 -06:00
Brady
f3d860e8fa Merge branch 'master' into 1.13.2 2019-12-31 19:40:14 -06:00
Leijurv
1edd7126fd Merge branch 'master' into 1.13.2 2019-12-31 15:44:03 -08:00
Leijurv
a57668bd15 Merge pull request #1073 from 0-x-2-2/1.13.2
Merged master into 1.13.2 branch. 😎
2019-10-17 13:54:06 -07:00
0x22
a324b58f55 Merged master into 1.13.2 branch. 😎 2019-10-17 16:01:35 -04:00
Leijurv
214225c08d v1.4.3 2019-10-13 22:53:05 -07:00
Leijurv
05b5894348 a much better way to deal with this 2019-10-13 10:53:25 -07:00
Leijurv
c528dba0ea v1.4.2 2019-10-11 17:52:11 -07:00
Leijurv
105c7d438a v1.3.5 2019-10-11 17:29:27 -07:00
Leijurv
2b3a302a5f Merge branch '1.13.2' into 1.14.4 2019-10-11 17:04:53 -07:00
Leijurv
1c00e167ca Merge branch 'master' into 1.13.2 2019-10-11 16:56:04 -07:00
Leijurv
861ee5049a unscuff 2019-10-11 16:15:38 -07:00
Brady
c1fe588de4 Leijurv is crying and shaking right now 2019-10-11 18:08:39 -05:00
Brady
8fa2dac261 This should fix tab complete scuff 2019-10-11 17:59:36 -05:00
Leijurv
f0ae31f455 fake merge of master into 1.13.2 2019-10-09 20:45:55 -07:00
Leijurv
dc7d64fb88 Merge commit 'ce2fc6f2514245987659b378687f795ab641cf1e' into 1.13.2 2019-10-09 20:44:22 -07:00
Brady
62df244db7 Initial Brigadier overriden tab completion 2019-10-09 21:19:58 -05:00
Leijurv
84a257faf4 fix air scuff 2019-10-06 17:37:07 -07:00
Leijurv
34620a448e Merge branch '1.13.2' into 1.14.4 2019-10-06 17:36:25 -07:00
Leijurv
2b4d6f4aa0 Merge branch 'master' into 1.13.2 2019-10-06 17:32:35 -07:00
Leijurv
e54d63576f Merge branch '1.13.2' into 1.14.4 2019-10-06 17:02:41 -07:00
Leijurv
7e505fc68f fix dropped items scanning 2019-10-06 16:00:26 -07:00
Leijurv
9c323aba91 Merge branch 'master' into 1.13.2 2019-10-06 15:51:27 -07:00
Leijurv
ae9671bff0 meme fix, things work now 2019-09-30 17:57:09 -07:00
Leijurv
d256f05787 Merge branch 'master' into 1.13.2 2019-09-30 17:52:47 -07:00
Leijurv
02419f8b07 v1.4.1 2019-08-20 15:25:30 -07:00
Leijurv
ddeb2a5c14 perhaps fix concurrent modification issues 2019-08-20 15:07:36 -07:00
Leijurv
8973b73bfa reduce spamminess 2019-08-20 14:58:00 -07:00
Leijurv
4557bab3c4 maybe travis fix 2019-08-20 14:49:16 -07:00
Leijurv
6e185b580c Merge branch '1.13.2' into 1.14.4 2019-08-20 14:33:18 -07:00
Leijurv
a9ba05bf5e Merge branch 'master' into 1.13.2 2019-08-20 14:28:59 -07:00
Leijurv
4e73880d4a Merge branch '1.14.4' of github.com:cabaletta/baritone into 1.14.4 2019-08-17 20:29:32 -07:00
Leijurv
0bb148844d Merge branch '1.13.2' into 1.14.4 2019-08-17 16:10:59 -07:00
Leijurv
e53b207148 Merge branch '1.13.2' into 1.14.4 2019-08-17 16:09:45 -07:00
Leijurv
7c9b812a5b Merge branch 'master' into 1.13.2 2019-08-17 16:07:26 -07:00
Leijurv
afc639ab4b bypass 2019-08-14 22:31:46 -07:00
Leijurv
afebdce1f8 fix crash and ice behavior 2019-07-25 16:02:29 -07:00
Leijurv
2ca4c3042a fix realms 2019-07-25 15:50:58 -07:00
Leijurv
a8226ba4c8 v1.3.4 2019-07-24 15:43:37 -07:00
Leijurv
e34b2d1392 Merge branch 'master' into 1.13.2 2019-07-24 15:36:20 -07:00
Leijurv
6bee5828a0 thank you brigadier very cool 2019-07-23 21:38:42 -07:00
Leijurv
8a5cc5b17d should be peaceful anyway 2019-07-23 20:54:00 -07:00
Leijurv
4e563c6130 could this be the worst possible way to copy a chunk array 2019-07-23 20:44:07 -07:00
Leijurv
01cf3c67a6 whatever this works lol 2019-07-23 19:25:48 -07:00
Leijurv
36315c5151 working for realsies 2019-07-23 15:47:18 -07:00
Leijurv
9f951f261d fixes 2019-07-23 15:39:19 -07:00
Leijurv
4c8907c629 it launches 2019-07-23 14:12:44 -07:00
Leijurv
223791cea7 Merge branch '1.13.2' into 1.14.2 2019-07-23 12:09:39 -07:00
Leijurv
de6e96b952 Merge branch 'master' into 1.13.2 2019-07-23 11:58:45 -07:00
Leijurv
9dd6856872 get called out 2019-07-21 14:36:02 -07:00
Leijurv
ed4753e968 now that impact locks to specific baritone versions this hack can finally be removed yay 2019-07-19 22:33:08 -07:00
Leijurv
1a4635df16 v1.3.3 2019-07-11 12:47:44 -07:00
Leijurv
1390af20b6 fix parkour and multithread farm 2019-07-11 12:46:24 -07:00
Leijurv
1427cf57a8 randomlooking 2019-07-11 11:56:44 -07:00
Leijurv
d70243b4c0 leijurv would never do this 2019-07-11 11:08:45 -07:00
Leijurv
8f63dd4ba6 Merge branch 'master' into 1.13.2 2019-07-11 10:51:29 -07:00
Brady
c7e1c917c3 Fix Baritone thinking it can walk through wall-placed skulls
Fixes #485
2019-07-08 19:21:09 -05:00
Leijurv
8758c77ac0 most of the way there 2019-06-10 18:25:20 -07:00
Leijurv
dba496471e api sourceset done 2019-06-10 12:43:02 -07:00
Leijurv
125facfbb6 Merge branch 'master' into 1.13.2 2019-06-10 11:50:14 -07:00
Leijurv
16b74ff53c v1.3.2 2019-05-16 14:57:26 -07:00
Leijurv
9297e98ac3 Merge branch 'master' into 1.13.2 2019-05-16 14:55:37 -07:00
Leijurv
b521d7bee1 fix dummy merge typo 2019-05-02 11:42:49 -07:00
Leijurv
4e96c5e5ee Merge branch 'master' into 1.13.2 2019-05-01 23:12:19 -07:00
Leijurv
ec819220b7 Merge branch 'master' into 1.13.2 2019-05-01 12:15:31 -07:00
Brady
3d3a5f420e Fix unsafe creation of potentially invalid ResourceLocation 2019-04-16 20:15:51 -05:00
Leijurv
9c9c9d4387 fix region pruning 2019-04-14 10:06:37 -07:00
Leijurv
82d09a536d v1.3.1 2019-04-13 19:21:44 -07:00
Leijurv
6e49adea33 i WUV impact 2019-04-13 19:10:13 -07:00
Leijurv
f85afdbc70 Merge branch 'master' into 1.13.2 2019-04-12 21:57:01 -07:00
Leijurv
563028a5b3 fix invalid player move packet, and a bunch of things in world scanner 2019-04-09 19:30:48 -07:00
Leijurv
d5c317b88b Merge branch 'master' into 1.13.2 2019-04-09 18:17:53 -07:00
Leijurv
c59ec9da10 blank space 2019-03-23 22:17:40 -08:00
Leijurv
3a675836da Merge pull request #370 from babbaj/patch-1
use runAutoTest
2019-03-23 13:03:19 -07:00
babbaj
7e0fc81246 use runAutoTest 2019-03-23 15:55:16 -04:00
Leijurv
f970f932c7 great 2019-03-23 10:52:03 -07:00
Leijurv
52d2741f52 and lets try making it fail delibrately 2019-03-23 10:31:36 -07:00
Leijurv
7bc6765cac rart 2019-03-23 10:13:14 -07:00
Leijurv
85b2aea6e9 where is this writing??? 2019-03-23 09:52:49 -07:00
Leijurv
c6ba5481d9 one final attempt 2019-03-22 22:33:40 -07:00
Leijurv
81f47d5632 forgot file name lollll 2019-03-22 22:19:13 -07:00
Leijurv
9b1440ed2c that needs to be allowed 2019-03-22 22:07:12 -07:00
Leijurv
2a8dcee028 write to a file to indicate success 2019-03-22 22:05:27 -07:00
Leijurv
277ba3643c Merge branch 'master' into 1.13.2 2019-03-22 21:24:43 -07:00
Leijurv
e5fbaf60f3 shutdownminecraftapplet 2019-03-22 21:04:35 -07:00
Leijurv
0deb854e1b v1.3.0 2019-03-21 16:40:18 -07:00
Leijurv
8268e3ec1b Merge branch 'master' into 1.13.2 2019-03-21 15:51:36 -07:00
Leijurv
af91da6a28 Merge branch 'master' into 1.13.2 2019-03-19 18:12:26 -07:00
Leijurv
9a15a65ad5 not needed anymore 2019-03-19 13:59:56 -07:00
Leijurv
0cbe9f81c8 Merge branch 'master' into 1.13.2 2019-03-15 16:58:23 -07:00
Leijurv
42afd2dd54 maybe proper exit code 2019-03-15 16:49:36 -07:00
Leijurv
315929f31c hey so what if we didnt do that 2019-03-15 16:39:59 -07:00
Leijurv
358aa80280 docker time 2019-03-15 16:22:51 -07:00
Leijurv
1dd9e11994 documentation resigned 2019-03-15 16:19:07 -07:00
Leijurv
5a8f02c944 unscuff everything 2019-03-15 16:11:14 -07:00
Leijurv
f248a5b677 make runClient work 2019-03-15 15:32:51 -07:00
Leijurv
e4a49c5529 fix launchtesting not found on runClient 2019-03-15 14:00:11 -07:00
Leijurv
449b44ba50 line 2019-03-14 16:32:14 -07:00
Leijurv
a00eec402e i love retina wtf 2019-03-14 16:32:04 -07:00
Leijurv
717779f742 air is stupid 2019-03-14 16:06:32 -07:00
Leijurv
6f843bd24d Merge branch 'master' into 1.13.2 2019-03-13 20:09:08 -07:00
Leijurv
d79fbea433 scuffed air 2019-03-13 18:08:15 -07:00
Leijurv
4d22c10ddb unscuff water, thanks wwe 2019-03-12 23:08:06 -07:00
Leijurv
1ea92a6092 😎 2019-03-12 22:49:23 -07:00
Leijurv
66eba84d06 consistent spacing 2019-03-12 18:54:36 -07:00
Leijurv
92e39b5d1d its over its done 2019-03-12 18:45:54 -07:00
Leijurv
0ddc47f473 i am rarted 2019-03-12 18:21:29 -07:00
Leijurv
ddfeca6947 unproject click cursed 2019-03-12 18:00:30 -07:00
Leijurv
6bd2e90cfd crash when pathing near shulker boxes 2019-03-12 17:18:58 -07:00
Leijurv
82505ddb01 online mode via env 2019-03-12 17:18:52 -07:00
Leijurv
2790d1d308 Merge branch 'master' into 1.13.2 2019-03-12 16:19:06 -07:00
Leijurv
11e503a022 many fixes 2019-03-12 16:17:43 -07:00
Leijurv
6fe49380ba pwned 2019-03-12 15:42:25 -07:00
Leijurv
1f2e267e3d fix a bunch of scuff 2019-03-12 15:41:58 -07:00
Leijurv
4cf6783622 fix the tests 2019-03-12 09:38:05 -07:00
Brady
82d77a7bac Update MixinGradle to 0.6.2
Includes fix ensuring that the SRGs are generated prior to Mixin annotation processing
2019-03-12 01:43:03 -05:00
Brady
841a927033 Merge remote-tracking branch 'origin/master' into 1.13.2 2019-03-12 01:09:11 -05:00
Brady
5a16561954 Working 1.13.2 development environment
Including a couple bugfixes to bad 1.13.2 code!!!
2019-03-12 01:05:39 -05:00
Brady
e2cc51908b Notch builds 2019-03-08 23:18:00 -06:00
Brady
1390e04435 Add versions in parenthesis for todos to fix stuff 2019-03-08 15:14:52 -06:00
Brady
84d961cbab Fix usages of Setting#get() 2019-03-08 15:12:55 -06:00
Brady
87b9d3915c Fix compiler errors
unproject needs to be resolved
2019-03-08 15:03:58 -06:00
Brady
c38d17563d Resolve merge conflicts
oh my god I should've updated my local branch before doing this
2019-03-08 14:44:49 -06:00
Brady
0c2af85ac0 Update to 1.13.2
Still need to setup method of launching, and Mixin support for ModLauncher
2019-03-08 14:30:43 -06:00
261 changed files with 4350 additions and 7803 deletions

View File

@@ -14,10 +14,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up JDK 8 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: '8' java-version: '17'
distribution: 'temurin' distribution: 'temurin'
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
@@ -25,7 +25,13 @@ jobs:
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew build run: ./gradlew build
- name: Build (fabric) with Gradle
run: ./gradlew build -Pbaritone.fabric_build
- name: Build (forge) with Gradle
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
- name: Archive Artifacts - name: Archive Artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:

View File

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

6
.gitignore vendored
View File

@@ -4,6 +4,7 @@
run/ run/
autotest/ autotest/
dist/ dist/
volderyarn/
# Gradle # Gradle
build/ build/
@@ -11,6 +12,8 @@ build/
classes/ classes/
*.class *.class
/out
# IntelliJ Files # IntelliJ Files
.idea/ .idea/
*.iml *.iml
@@ -29,6 +32,3 @@ baritone_Client.launch
!/.idea/copyright/profiles_settings.xml !/.idea/copyright/profiles_settings.xml
.vscode/launch.json .vscode/launch.json
libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
libs/java-objc-bridge-1.1.jar

14
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,14 @@
image: java:8
before_script:
- which java
- which javac
build:
script:
- ./gradlew build
- ./gradlew build -Pbaritone.forge_build
artifacts:
paths:
- dist/*
expire_in: 1 week

View File

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

138
README.md
View File

@@ -1,137 +1 @@
# Baritone This branch of Baritone is deprecated. It will no longer recieve updates. Updates to older versions of Minecraft will not be merged into this branch, even if a newer branch is not deprecated (this branch will be skipped). Bug reports that only affect deprecated branches will not be addressed.
<p align="center">
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/downloads/cabaletta/baritone/total.svg" alt="GitHub All Releases"/></a>
</p>
<p align="center">
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.17.1-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.4-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.20.1-brightgreen.svg" alt="Minecraft"/></a>
</p>
<p align="center">
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
<a href="https://www.codacy.com/gh/cabaletta/baritone/dashboard?utm_source=github.com&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/lambda-client/lambda"><img src="https://img.shields.io/badge/Lambda%20integration-v1.2.17-brightgreen.svg" alt="Lambda integration"/></a>
<a href="https://github.com/fr1kin/ForgeHax/"><img src="https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg" alt="ForgeHax integration"/></a>
<a href="https://aristois.net/"><img src="https://img.shields.io/badge/Aristois%20add--on%20integration-v1.6.3-green.svg" alt="Aristois add-on integration"/></a>
<a href="https://rootnet.dev/"><img src="https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg" alt="rootNET integration"/></a>
<a href="https://futureclient.net/"><img src="https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red" alt="Future integration"/></a>
<a href="https://rusherhack.org/"><img src="https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green" alt="RusherHack integration"/></a>
</p>
<p align="center">
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
</p>
A Minecraft pathfinder bot.
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
**Quick download links:**
| Forge | Fabric |
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.17/baritone-api-forge-1.2.17.jar) | |
| [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-forge-1.6.4.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-fabric-1.6.4.jar) |
| [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) |
| [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-forge-1.8.4.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-fabric-1.8.4.jar) |
| [1.19.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-forge-1.9.4.jar) | [1.19.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-fabric-1.9.4.jar) |
| [1.19.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-forge-1.9.1.jar) | [1.19.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-fabric-1.9.1.jar) |
| [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) |
| [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) |
**How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
For other versions of Minecraft or more complicated situations or for development, see [Installation & setup](SETUP.md). Also consider just installing [Impact](https://impactclient.net/), which comes with Baritone and is easier to install than wrangling with version JSONs and zips. For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#6313 on Baritone which I recommend.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
# Getting Started
Here are some links to help to get started:
- [Features](FEATURES.md)
- [Installation & setup](SETUP.md)
- [API Javadocs](https://baritone.leijurv.com/)
- [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)
- [Usage (chat control)](USAGE.md)
## Stars over time
[![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

@@ -15,41 +15,25 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
group 'baritone' plugins {
version '1.2.17' id 'java'
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
buildscript { id 'maven-publish'
repositories {
maven {
name = 'forge'
url = 'https://files.minecraftforge.net/maven'
}
maven {
name = 'SpongePowered'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
jcenter()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' // TODO: 5.+. `doHackyStuff` relies on 4.x internals.
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
} }
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
import baritone.gradle.task.CreateDistTask import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask import baritone.gradle.task.ProguardTask
apply plugin: 'java' def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
apply plugin: 'maven-publish'
apply plugin: 'net.minecraftforge.gradle' sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
apply from: 'hacks.gradle'
ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.task.GenerateSRG')) // TODO: fg 5.0 - `ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.tasks.GenerateSRG'))`
apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = targetCompatibility = '1.8'
compileJava { compileJava {
sourceCompatibility = targetCompatibility = '1.8'
options.encoding = "UTF-8" // allow emoji in comments :^) options.encoding = "UTF-8" // allow emoji in comments :^)
} }
@@ -68,122 +52,67 @@ sourceSets {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
} }
schematica_api { schematica_api {
compileClasspath += main.compileClasspath compileClasspath += main.compileClasspath
} }
main { main {
compileClasspath += schematica_api.output compileClasspath += schematica_api.output
} }
} }
minecraft { loom {
mappings channel: 'stable', version: '39-1.12' if (compileType.equals("FORGE")) {
forge {
mixinConfig 'mixins.baritone.json'
}
}
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
runs { runs {
def nativesOutput = extractNatives.output // TODO: fg 5.0 - `def nativesOutput = extractNatives.output.get()`
println("[Baritoe] Detected natives: ${nativesOutput}")
client { client {
workingDirectory project.file('run') source = sourceSets.launch
source sourceSets.launch
main 'net.minecraft.launchwrapper.Launch'
args '--gameDir', '.'
args '--version', '1.12.2'
args '--assetsDir', downloadAssets.output
args '--assetIndex', '{asset_index}'
args '--accessToken', 'INVALID'
args '--tweakClass', 'baritone.launch.BaritoneTweaker'
jvmArgs "-Dorg.lwjgl.librarypath=${nativesOutput}"
} }
} }
} }
repositories { repositories {
mavenCentral()
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven { maven {
name = 'impactdevelopment-repo' name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/' url = 'https://impactdevelopment.github.io/maven/'
} }
maven { maven {
name = 'babbaj-repo' name = "ldtteam"
url = 'https://babbaj.github.io/maven/' url = "https://maven.parchmentmc.net/"
}
}
// fix forge gradle 4+ bug with 1.12.2
afterEvaluate {
configurations.minecraft {
exclude group: 'net.minecraftforge', module: 'mergetool'
}
}
// lwjgl2 hack for running game on arm64 mac os
afterEvaluate {
def os = org.gradle.internal.os.OperatingSystem.current()
if (os.isMacOsX()) {
def arch = System.getProperty("os.arch").toLowerCase()
println("Detected Mac OS X running on ${arch}")
if (arch == "aarch64") {
println("Configurating aarch64 dependencies.")
configurations.minecraft {
exclude group: 'ca.weblite', module: 'java-objc-bridge'
}
dependencies {
// https://github.com/MinecraftMachina/lwjgl/releases/download/2.9.4-20150209-mmachina.2/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
minecraft files("libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")
// TODO: use prism launcher maven
// https://github.com/MinecraftMachina/Java-Objective-C-Bridge/releases/download/1.1.0-mmachina.1/java-objc-bridge-1.1.jar
minecraft files("libs/java-objc-bridge-1.1.jar") // TODO: use prism launcher maven
minecraft(group: 'net.java.dev.jna', name: 'jna') {
version {
strictly '5.12.1'
}
}
}
}
} }
mavenCentral()
} }
dependencies { dependencies {
minecraft group: 'net.minecraft', name: 'joined', version: '1.12.2' if (compileType.equals("FORGE")) {
implementation(group: 'net.minecraft', name: 'launchwrapper', version: '1.12') { forge "net.minecraftforge:forge:${project.forge_version}"
transitive = false }
mappings loom.layered() {
officialMojangMappings()
//technically optional, but really helpful in dev:
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
}
minecraft "com.mojang:minecraft:${project.minecraft_version}"
if (!compileType.equals("FORGE")) {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
}
// this makes it compile with the forge tweak stuff
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
implementation('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
exclude module: 'asm-debug-all'
} }
def asmVersion = '9.5' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation group: 'org.ow2.asm', name: 'asm', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-tree', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-commons', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion
implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion
launchImplementation('com.github.ImpactDevelopment:SimpleTweaker:1.2')
launchImplementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
// Mixin includes a lot of dependencies that are too up-to-date
transitive = false
}
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
launchImplementation('dev.babbaj:nether-pathfinder:0.34')
implementation 'dev.babbaj:nether-pathfinder:0.34'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
} }
mixin {
add sourceSets.launch, 'mixins.baritone.refmap.json'
}
javadoc { javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true options.linkSource true
@@ -192,6 +121,24 @@ javadoc {
classpath += sourceSets.api.compileClasspath classpath += sourceSets.api.compileClasspath
} }
// skidded from fabric-example-mod (comments and all)
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 16
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
jar { jar {
from sourceSets.launch.output, sourceSets.api.output from sourceSets.launch.output, sourceSets.api.output
@@ -203,21 +150,41 @@ jar {
preserveFileTimestamps = false preserveFileTimestamps = false
reproducibleFileOrder = true reproducibleFileOrder = true
if (getProject().hasProperty("baritone.fabric_build")) {
filesMatching("fabric.mod.json") {
expand "version": version
}
} else {
exclude("fabric.mod.json")
}
manifest { manifest {
attributes( attributes(
'MixinConfigs': 'mixins.baritone.json', 'MixinConfigs': 'mixins.baritone.json',
'TweakClass': 'baritone.launch.BaritoneTweaker', "MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone', 'Implementation-Title': 'Baritone',
'Implementation-Version': version 'Implementation-Version': version,
) )
} }
} }
if (compileType.equals("OFFICIAL")) {
remapJar {
toM.set "official"
}
}
task proguard(type: ProguardTask) { task proguard(type: ProguardTask) {
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip' url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
extract 'proguard6.0.3/lib/proguard.jar' extract 'proguard-7.2.0-beta2/lib/proguard.jar'
compType compileType
} }
task createDist(type: CreateDistTask, dependsOn: proguard) task createDist(type: CreateDistTask, dependsOn: proguard)
build.finalizedBy(createDist) build.finalizedBy(createDist)

View File

@@ -20,6 +20,7 @@ package baritone.gradle.task;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -32,45 +33,61 @@ import java.nio.file.Paths;
class BaritoneGradleTask extends DefaultTask { class BaritoneGradleTask extends DefaultTask {
protected static final String protected static final String
PROGUARD_ZIP = "proguard.zip", PROGUARD_ZIP = "proguard.zip",
PROGUARD_JAR = "proguard.jar", PROGUARD_JAR = "proguard.jar",
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro", PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
PROGUARD_CONFIG_DEST = "template.pro", PROGUARD_CONFIG_DEST = "template.pro",
PROGUARD_API_CONFIG = "api.pro", PROGUARD_API_CONFIG = "api.pro",
PROGUARD_STANDALONE_CONFIG = "standalone.pro", PROGUARD_STANDALONE_CONFIG = "standalone.pro",
PROGUARD_EXPORT_PATH = "proguard_out.jar", PROGUARD_EXPORT_PATH = "proguard_out.jar",
TEMP_LIBRARY_DIR = "tempLibraries/", ARTIFACT_STANDARD = "%s-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
ARTIFACT_STANDARD = "%s-%s.jar", ARTIFACT_API = "%s-api-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar", ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
ARTIFACT_API = "%s-api-%s.jar", ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
ARTIFACT_STANDALONE = "%s-standalone-%s.jar", ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar", ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar"; ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
protected String artifactName, artifactVersion; protected String artifactName, artifactVersion;
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgeApiPath, artifactForgeStandalonePath, proguardOut; protected final Path
artifactPath,
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
proguardOut;
protected void verifyArtifacts() throws IllegalStateException { public BaritoneGradleTask() {
this.artifactName = getProject().getName(); this.artifactName = getProject().getName();
this.artifactVersion = getProject().getVersion().toString(); this.artifactVersion = getProject().getVersion().toString();
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD)); this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API)); if (getProject().hasProperty("baritone.forge_build")) {
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE)); this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
this.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API)); this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE)); this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
} else if (getProject().hasProperty("baritone.fabric_build")) {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
} else {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
}
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH); this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
}
protected void verifyArtifacts() throws IllegalStateException {
if (!Files.exists(this.artifactPath)) { if (!Files.exists(this.artifactPath)) {
throw new IllegalStateException("Artifact not found! Run build first! " + this.artifactPath); throw new IllegalStateException("Artifact not found! Run build first! Missing file: " + this.artifactPath);
} }
} }
protected void write(InputStream stream, Path file) throws Exception { protected void write(InputStream stream, Path file) throws IOException {
if (Files.exists(file)) { if (Files.exists(file)) {
Files.delete(file); Files.delete(file);
} }
@@ -82,7 +99,7 @@ class BaritoneGradleTask extends DefaultTask {
} }
protected Path getRelativeFile(String file) { protected Path getRelativeFile(String file) {
return Paths.get(this.getProject().file(file).getAbsolutePath()); return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath());
} }
protected Path getTemporaryFile(String file) { protected Path getTemporaryFile(String file) {

View File

@@ -19,13 +19,13 @@ package baritone.gradle.task;
import org.gradle.api.tasks.TaskAction; 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.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
@@ -42,11 +42,9 @@ public class CreateDistTask extends BaritoneGradleTask {
super.verifyArtifacts(); super.verifyArtifacts();
// Define the distribution file paths // Define the distribution file paths
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API)); Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)); Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)); Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
Path forgeApi = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API));
Path forgeStandalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE));
// NIO will not automatically create directories // NIO will not automatically create directories
Path dir = getRelativeFile("dist/"); Path dir = getRelativeFile("dist/");
@@ -55,14 +53,14 @@ public class CreateDistTask extends BaritoneGradleTask {
} }
// Copy build jars to dist/ // Copy build jars to dist/
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING); // TODO: dont copy files that dont exist
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING); Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING); Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
Files.copy(this.artifactForgeApiPath, forgeApi, REPLACE_EXISTING); Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
Files.copy(this.artifactForgeStandalonePath, forgeStandalone, REPLACE_EXISTING);
// Calculate all checksums and format them like "shasum" // Calculate all checksums and format them like "shasum"
List<String> shasum = Stream.of(api, forgeApi, standalone, forgeStandalone, unoptimized) List<String> shasum = getAllDistJars().stream()
.filter(Files::exists)
.map(path -> sha1(path) + " " + path.getFileName().toString()) .map(path -> sha1(path) + " " + path.getFileName().toString())
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -72,15 +70,45 @@ public class CreateDistTask extends BaritoneGradleTask {
Files.write(getRelativeFile("dist/checksums.txt"), shasum); Files.write(getRelativeFile("dist/checksums.txt"), shasum);
} }
private static String getFileName(Path p) {
return p.getFileName().toString();
}
private List<Path> getAllDistJars() {
return Arrays.asList(
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
);
}
private static synchronized String sha1(Path path) { private static synchronized String sha1(Path path) {
try { try {
if (SHA1_DIGEST == null) { if (SHA1_DIGEST == null) {
SHA1_DIGEST = MessageDigest.getInstance("SHA-1"); 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) { } catch (Exception e) {
// haha no thanks // haha no thanks
throw new IllegalStateException(e); 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

@@ -19,9 +19,7 @@ package baritone.gradle.task;
import baritone.gradle.util.Determinizer; import baritone.gradle.util.Determinizer;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.gradle.api.Project; import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskCollection; import org.gradle.api.tasks.TaskCollection;
@@ -29,62 +27,96 @@ import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.jvm.Jvm; import org.gradle.internal.jvm.Jvm;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Objects;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.nio.file.Path;
import java.util.regex.Matcher; import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.List;
import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
/** /**
* @author Brady * @author Brady
* @since 10/11/2018 * @since 10/11/2018
*/ */
public class ProguardTask extends BaritoneGradleTask { public class ProguardTask extends BaritoneGradleTask {
private static final Pattern TEMP_LIBRARY_PATTERN = Pattern.compile("-libraryjars 'tempLibraries\\/([a-zA-Z0-9/_\\-\\.]+)\\.jar'");
@Input @Input
private String url; private String url;
public String getUrl() {
return url;
}
@Input @Input
private String extract; private String extract;
private List<String> requiredLibraries; public String getExtract() {
return extract;
}
private File mixin; @Input
private File pathfinder; private String compType;
public String getCompType() {
return compType;
}
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
@TaskAction @TaskAction
protected void exec() throws Exception { protected void exec() throws Exception {
super.verifyArtifacts(); super.verifyArtifacts();
copyMcJar();
// "Haha brady why don't you make separate tasks" // "Haha brady why don't you make separate tasks"
processArtifact();
downloadProguard(); downloadProguard();
extractProguard(); extractProguard();
generateConfigs(); generateConfigs();
acquireDependencies();
processArtifact();
proguardApi(); proguardApi();
proguardStandalone(); proguardStandalone();
cleanup(); cleanup();
} }
private boolean isMcJar(File f) {
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-mapped");
}
private void copyMcJar() throws IOException {
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter(this::isMcJar)
.map(f -> {
switch (compType) {
case "OFFICIAL":
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
case "FABRIC":
return new File(f.getParentFile(), "minecraft-intermediary.jar");
case "FORGE":
return new File(f.getParentFile(), "minecraft-srg.jar");
}
return null;
})
.findFirst()
.get();
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
}
private void processArtifact() throws Exception { private void processArtifact() throws Exception {
if (Files.exists(this.artifactUnoptimizedPath)) { if (Files.exists(this.artifactUnoptimizedPath)) {
Files.delete(this.artifactUnoptimizedPath); Files.delete(this.artifactUnoptimizedPath);
} }
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Arrays.asList(pathfinder), false); Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
} }
private void downloadProguard() throws Exception { private void downloadProguard() throws Exception {
@@ -109,7 +141,8 @@ public class ProguardTask extends BaritoneGradleTask {
try { try {
path = findJavaPathByGradleConfig(); path = findJavaPathByGradleConfig();
if (path != null) return path; if (path != null) return path;
} catch (Exception ex) { }
catch (Exception ex) {
System.err.println("Unable to find java by javaCompile options"); System.err.println("Unable to find java by javaCompile options");
ex.printStackTrace(); ex.printStackTrace();
} }
@@ -117,7 +150,8 @@ public class ProguardTask extends BaritoneGradleTask {
try { try {
path = findJavaByJavaHome(); path = findJavaByJavaHome();
if (path != null) return path; if (path != null) return path;
} catch (Exception ex) { }
catch(Exception ex) {
System.err.println("Unable to find java by JAVA_HOME"); System.err.println("Unable to find java by JAVA_HOME");
ex.printStackTrace(); ex.printStackTrace();
} }
@@ -125,23 +159,30 @@ public class ProguardTask extends BaritoneGradleTask {
path = findJavaByGradleCurrentRuntime(); path = findJavaByGradleCurrentRuntime();
if (path != null) return path; if (path != null) return path;
throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," + throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," +
" JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)"); " JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)");
} }
private String findJavaByGradleCurrentRuntime() { private String findJavaByGradleCurrentRuntime() {
String path = Jvm.current().getJavaExecutable().getAbsolutePath(); String path = Jvm.current().getJavaExecutable().getAbsolutePath();
System.out.println("Using Gradle's runtime Java for ProGuard");
return path; if (this.validateJavaVersion(path)) {
System.out.println("Using Gradle's runtime Java for ProGuard");
return path;
}
return null;
} }
private String findJavaByJavaHome() { private String findJavaByJavaHome() {
final String javaHomeEnv = System.getenv("JAVA_HOME"); final String javaHomeEnv = System.getenv("JAVA_HOME");
if (javaHomeEnv != null) { if (javaHomeEnv != null) {
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath(); String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
System.out.println("Detected Java path by JAVA_HOME"); if (this.validateJavaVersion(path)) {
return path; System.out.println("Detected Java path by JAVA_HOME");
return path;
}
} }
return null; return null;
} }
@@ -157,11 +198,19 @@ public class ProguardTask extends BaritoneGradleTask {
if (javacPath != null) { if (javacPath != null) {
File javacFile = new File(javacPath); File javacFile = new File(javacPath);
if (javacFile.exists()) { if (javacFile.exists()) {
File[] maybeJava = javacFile.getParentFile().listFiles((dir, name) -> name.equals("java")); File[] maybeJava = javacFile.getParentFile().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.equals("java");
}
});
if (maybeJava != null && maybeJava.length > 0) { if (maybeJava != null && maybeJava.length > 0) {
String path = maybeJava[0].getAbsolutePath(); String path = maybeJava[0].getAbsolutePath();
System.out.println("Detected Java path by forkOptions"); if (this.validateJavaVersion(path)) {
return path; System.out.println("Detected Java path by forkOptions");
return path;
}
} }
} }
} }
@@ -169,18 +218,46 @@ public class ProguardTask extends BaritoneGradleTask {
return null; return null;
} }
private boolean validateJavaVersion(String java) {
//TODO: fix for j16
// final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
//
// if (!javaVersion.getMajorVersion().equals("8")) {
// System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
// // throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
// return false;
// }
//
// System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
return true;
}
private void generateConfigs() throws Exception { private void generateConfigs() throws Exception {
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), StandardCopyOption.REPLACE_EXISTING); Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
// Setup the template that will be used to derive the API and Standalone configs // Setup the template that will be used to derive the API and Standalone configs
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST)); List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
template.add(0, "-injars '" + this.artifactPath.toString() + "'"); template.add(0, "-injars '" + this.artifactPath.toString() + "'");
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'"); template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+ template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start(); template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
template.add(2, "-libraryjars '" + out + "'"); {
final Stream<File> libraries;
{
// Discover all of the libraries that we will need to acquire from gradle
final Stream<File> dependencies = acquireDependencies()
// remove MCP mapped jar, and nashorn
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
libraries = dependencies
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
}
libraries.forEach(f -> {
template.add(2, "-libraryjars '" + f + "'");
});
}
// API config doesn't require any changes from the changes that we made to the template // API config doesn't require any changes from the changes that we made to the template
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template); Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
@@ -189,147 +266,26 @@ public class ProguardTask extends BaritoneGradleTask {
List<String> standalone = new ArrayList<>(template); List<String> standalone = new ArrayList<>(template);
standalone.removeIf(s -> s.contains("# this is the keep api")); standalone.removeIf(s -> s.contains("# this is the keep api"));
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone); Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
// Discover all of the libraries that we will need to acquire from gradle
this.requiredLibraries = new ArrayList<>();
template.forEach(line -> {
if (!line.startsWith("#")) {
Matcher m = TEMP_LIBRARY_PATTERN.matcher(line);
if (m.find()) {
this.requiredLibraries.add(m.group(1));
}
}
});
} }
private static final class Pair<A, B> { private File getSrgMcJar() {
public final A a; return getProject().getTasks().findByName("copyMcJar").getOutputs().getFiles().getSingleFile();
public final B b;
private Pair(final A a, final B b) {
this.a = a;
this.b = b;
}
@Override
public String toString() {
return "Pair{" +
"a=" + this.a +
", " +
"b=" + this.b +
'}';
}
} }
private void acquireDependencies() throws Exception { private Stream<File> acquireDependencies() {
// Create a map of all of the dependencies that we are able to access in this project return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
// Likely a better way to do this, I just pair the dependency with the first valid configuration .stream()
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>(); .filter(File::isFile);
Map<String, File> files = new HashMap<>();
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config -> {
for (File file : config.getFiles()) {
files.put(file.getName(), file);
}
config.getAllDependencies().forEach(dependency ->
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), new Pair<>(config, dependency)));
});
// Create the directory if it doesn't already exist
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
if (!Files.exists(tempLibraries)) {
Files.createDirectory(tempLibraries);
}
// Iterate the required libraries to copy them to tempLibraries
for (String lib : this.requiredLibraries) {
// copy from the forgegradle cache
if (lib.equals("minecraft")) {
Path cachedJar = getMinecraftJar();
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
// TODO: maybe try not to copy every time
Files.copy(cachedJar, inTempDir, StandardCopyOption.REPLACE_EXISTING);
continue;
}
// Find a configuration/dependency pair that matches the desired library
Pair<Configuration, Dependency> pair = null;
for (Map.Entry<String, Pair<Configuration, Dependency>> entry : dependencyLookupMap.entrySet()) {
if (entry.getKey().startsWith(lib)) {
pair = entry.getValue();
}
}
// Find the library jar file, and copy it to tempLibraries
if (pair == null) {
File libFile = files.get(lib + ".jar");
if (libFile == null) {
libFile = files.values().stream().filter(file -> file.getName().startsWith(lib)).findFirst().orElse(null);
if (libFile == null) {
throw new IllegalStateException(lib);
}
}
copyTempLib(lib, libFile);
} else {
for (File file : pair.a.files(pair.b)) {
if (file.getName().startsWith(lib)) {
copyTempLib(lib, file);
}
}
}
}
if (mixin == null) {
throw new IllegalStateException("Unable to find mixin jar");
}
if (pathfinder == null) {
throw new IllegalStateException("Unable to find pathfinder jar");
}
}
private void copyTempLib(String lib, File libFile) throws IOException {
if (lib.contains("mixin")) {
mixin = libFile;
}
if (lib.contains("nether-pathfinder")) {
pathfinder = libFile;
}
Files.copy(libFile.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), StandardCopyOption.REPLACE_EXISTING);
}
// a bunch of epic stuff to get the path to the cached jar
private Path getMinecraftJar() throws Exception {
return getObfuscatedMinecraftJar(getProject(), false); // always notch jar for now.
}
private static Path getObfuscatedMinecraftJar(final Project project, final boolean srg) throws Exception {
final Object extension = Objects.requireNonNull(project.getExtensions().findByName("minecraft"), "Unable to find Minecraft extension.");
final Class<?> mcpRepoClass = mcpRepoClass(extension.getClass().getClassLoader());
final Field mcpRepoInstanceField = mcpRepoClass.getDeclaredField("INSTANCE");
mcpRepoInstanceField.setAccessible(true);
final Method findMethod = mcpRepoClass.getDeclaredMethod(srg ? "findSrg" : "findRaw", String.class, String.class);
findMethod.setAccessible(true);
final Object mcpRepo = mcpRepoInstanceField.get(null);
final String mcpVersion = (String) Objects.requireNonNull(project.getExtensions().getExtraProperties().get("MCP_VERSION"), "Extra property \"MCP_VERSION\" not found");
return ((File) findMethod.invoke(mcpRepo, "joined", mcpVersion)).toPath();
}
private static Class<?> mcpRepoClass(final ClassLoader loader) throws Exception {
final Method forName0 = Class.class.getDeclaredMethod("forName0", String.class, boolean.class, ClassLoader.class, Class.class);
forName0.setAccessible(true);
return (Class<?>) forName0.invoke(null, "net.minecraftforge.gradle.mcp.MCPRepo", true, loader, null);
} }
private void proguardApi() throws Exception { private void proguardApi() throws Exception {
runProguard(getTemporaryFile(PROGUARD_API_CONFIG)); runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Arrays.asList(pathfinder), false); Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Arrays.asList(pathfinder, mixin), true);
} }
private void proguardStandalone() throws Exception { private void proguardStandalone() throws Exception {
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG)); runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Arrays.asList(pathfinder), false); Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Arrays.asList(pathfinder, mixin), true);
} }
private void cleanup() { private void cleanup() {
@@ -342,16 +298,12 @@ public class ProguardTask extends BaritoneGradleTask {
this.url = url; this.url = url;
} }
public String getUrl() {
return url;
}
public void setExtract(String extract) { public void setExtract(String extract) {
this.extract = extract; this.extract = extract;
} }
public String getExtract() { public void setCompType(String compType) {
return extract; this.compType = compType;
} }
private void runProguard(Path config) throws Exception { private void runProguard(Path config) throws Exception {
@@ -364,7 +316,7 @@ public class ProguardTask extends BaritoneGradleTask {
Path workingDirectory = getTemporaryFile(""); Path workingDirectory = getTemporaryFile("");
Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR)); Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR));
config = workingDirectory.relativize(config); config = workingDirectory.relativize(config);
// Honestly, if you still have spaces in your path at this point, you're SOL. // Honestly, if you still have spaces in your path at this point, you're SOL.
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString()) Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
@@ -378,7 +330,6 @@ public class ProguardTask extends BaritoneGradleTask {
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception // Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
int exitCode = p.waitFor(); int exitCode = p.waitFor();
if (exitCode != 0) { if (exitCode != 0) {
Thread.sleep(1000);
throw new IllegalStateException("Proguard exited with code " + exitCode); throw new IllegalStateException("Proguard exited with code " + exitCode);
} }
} }

View File

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

13
gradle.properties Normal file
View File

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

Binary file not shown.

View File

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

2
gradlew vendored
View File

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

View File

@@ -1,161 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
ext.doHackyStuff = { final Class<?> clazz ->
def withExtension = { final File file, final String extension ->
def i = file.getName().lastIndexOf('.')
def name = file.getName().substring(0, i)
return new File(file.getParent(), "$name.$extension")
}
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/patcher/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java#L545
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/UserDevPlugin.java#L149
// create createMcp2Obf task
this.tasks.register('createMcpToObf', clazz)
.configure { task ->
task.setNotch(true)
task.setReverse(true)
}
afterEvaluate {
def createMcp2Obf = this.tasks.getByName('createMcpToObf')
def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
// configure createMcp2Obf task
if (createMcp2Obf.getSrg() == null) {
createMcp2Obf.setSrg(createMcp2Srg.getSrg())
createMcp2Obf.setMappings(createMcp2Srg.getMappings())
createMcp2Obf.dependsOn(createMcp2Srg)
}
def createSrgCopyTask = { final Task tsrgTask ->
def srgCopyTask = this.tasks.register("${tsrgTask.name}Srg", tsrgTask.getClass())
tsrgTask.getDependsOn().forEach({ dep ->
srgCopyTask.get().dependsOn(dep)
})
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/mcp/java/net/minecraftforge/gradle/mcp/task/GenerateSRG.java#L39
srgCopyTask.configure { task ->
task.setSrg(tsrgTask.getSrg())
task.setMappings(tsrgTask.getMappings())
// https://github.com/MinecraftForge/SrgUtils/blob/bb2ca35bb8d349a122ef512dedd24f54f7cd0bdf/src/main/java/net/minecraftforge/srgutils/IMappingFile.java#L44
task.setFormat('SRG')
task.setNotch(tsrgTask.getNotch())
task.setReverse(tsrgTask.getReverse())
task.setOutput(withExtension(tsrgTask.getOutput(), 'srg'))
}
return srgCopyTask
}
def createMcp2ObfSrgCopyTask = createSrgCopyTask(createMcp2Obf)
createMcp2Obf.dependsOn(createMcp2ObfSrgCopyTask)
def createMcp2SrgSrgCopyTask = createSrgCopyTask(createMcp2Srg)
createMcp2Srg.dependsOn(createMcp2SrgSrgCopyTask)
this.sourceSets.forEach({ set ->
def compileTask = this.project.tasks[set.compileJavaTaskName]
if (!(compileTask instanceof JavaCompile)) {
println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
return
}
compileTask.dependsOn(createMcp2Obf)
compileTask.doFirst {
// inject legacy notch srg file
def createMcp2ObfSrgCopy = createMcp2ObfSrgCopyTask.get()
def reobfNotchSrgFileArgument = "-AreobfNotchSrgFile=${createMcp2ObfSrgCopy.output.canonicalPath}"
compileTask.options.compilerArgs += reobfNotchSrgFileArgument
println("[Baritoe] Injecting compiler argument: ${reobfNotchSrgFileArgument}")
// inject legacy notch srg out file
def outTSrgFileArgument = '-AoutTsrgFile='
def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
while (compilerArgsIterator.hasNext()) {
def compilerArg = compilerArgsIterator.next()
if (compilerArg.startsWith(outTSrgFileArgument)) {
def argumentFileValue = new File(compilerArg.substring(outTSrgFileArgument.length(), compilerArg.length()))
def outNotchSrgFile = withExtension(argumentFileValue, 'notch.srg')
def outNotchSrgFileArgument = "-AoutNotchSrgFile=${outNotchSrgFile.canonicalPath}"
println("[Baritoe] Injecting compiler argument: ${outNotchSrgFileArgument}")
compilerArgsIterator.add(outNotchSrgFileArgument)
}
}
}
})
// register reobf jars
def reobfExtension = this.project.getExtensions().getByName('reobf')
if (!reobfExtension) {
throw new IllegalStateException("Could not find \"reobf\" extension")
}
def reobfNotchJar = reobfExtension.create(jar.getName())
reobfNotchJar.dependsOn(createMcp2Obf)
reobfNotchJar.setMappings(createMcp2Obf.getOutput())
// even more horrible hack :) for outNotchSrgFile injection
reobfNotchJar.doFirst {
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/tasks/RenameJar.java#L96
def extraMappings = reobfNotchJar.getExtraMappings()
println("[Baritoe] Extra mappings: ${extraMappings}")
def copy = new ArrayList<>()
extraMappings.forEach { extraMapping ->
copy.add(withExtension(extraMapping, 'notch.srg'))
}
println("[Baritoe] New extra mappings: ${copy}")
reobfNotchJar.setExtraMappings(copy)
}
}
}
// TODO: In-complete fg 5.0 port. Currently doesn't handle mixin notch srg mapping hack.
//ext.doHackyStuff = { final Class<?> clazz ->
// afterEvaluate {
// def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
// def createMcpToObf = this.tasks.register('createMcpToObf', clazz)
// createMcpToObf.configure { task ->
// task.setNotch(true)
// task.setReverse(true)
// task.getSrg().set(createMcp2Srg.getSrg().get())
// task.getMappings().set(createMcp2Srg.getMappings().get())
// task.dependsOn(createMcp2Srg)
// }
// reobf {
// jar {
// dependsOn(createMcpToObf)
// getMappings().set(createMcpToObf.get().getOutput().get())
// }
// }
// this.sourceSets.forEach({ set ->
// def compileTask = this.project.tasks[set.compileJavaTaskName]
// if (!(compileTask instanceof JavaCompile)) {
// println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
// return
// }
// compileTask.dependsOn(createMcpToObf)
// compileTask.doFirst {
// def reobfTSrgFile = '-AreobfTsrgFile='
// def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
// while (compilerArgsIterator.hasNext()) {
// def compilerArg = compilerArgsIterator.next()
// if (compilerArg.startsWith(reobfTSrgFile)) {
// compilerArgsIterator.remove()
// def toInject = "-AreobfTsrgFile=${createMcpToObf.get().output.get().asFile.canonicalPath}"
// compilerArgsIterator.add(toInject)
// println("[Baritoe] Injecting compiler argument: ${toInject}")
// }
// }
// println("[Baritoe] Compiler arguments: ${compileTask.options.compilerArgs}")
// }
// })
// }
//}

57
scripts/proguard.pro vendored
View File

@@ -15,7 +15,14 @@
# lwjgl is weird # lwjgl is weird
-dontwarn org.lwjgl.** -dontwarn org.lwjgl.**
# also lwjgl lol
-dontwarn module-info
# we dont have forge
-dontwarn baritone.launch.BaritoneForgeModXD
# progard doesn't like signature polymorphism
-dontwarn java.lang.invoke.MethodHandle
# please do not change the comment below
-keep class baritone.api.** { *; } # this is the keep api -keep class baritone.api.** { *; } # this is the keep api
# service provider needs these class names # service provider needs these class names
@@ -47,56 +54,6 @@
-dontwarn baritone.utils.schematic.schematica.** -dontwarn baritone.utils.schematic.schematica.**
-dontwarn baritone.utils.schematic.litematica.** -dontwarn baritone.utils.schematic.litematica.**
# copy all necessary libraries into tempLibraries to build
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
-libraryjars 'tempLibraries/minecraft.jar'
-libraryjars 'tempLibraries/SimpleTweaker-1.2.jar'
-libraryjars 'tempLibraries/authlib-1.5.25.jar'
-libraryjars 'tempLibraries/codecjorbis-20101023.jar'
-libraryjars 'tempLibraries/codecwav-20101023.jar'
-libraryjars 'tempLibraries/commons-codec-1.10.jar'
-libraryjars 'tempLibraries/commons-compress-1.8.1.jar'
-libraryjars 'tempLibraries/commons-io-2.5.jar'
-libraryjars 'tempLibraries/commons-lang3-3.5.jar'
-libraryjars 'tempLibraries/commons-logging-1.1.3.jar'
-libraryjars 'tempLibraries/fastutil-7.1.0.jar'
-libraryjars 'tempLibraries/gson-2.8.0.jar'
-libraryjars 'tempLibraries/guava-21.0.jar'
-libraryjars 'tempLibraries/httpclient-4.3.3.jar'
-libraryjars 'tempLibraries/httpcore-4.3.2.jar'
-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar'
-libraryjars 'tempLibraries/jinput-2.0.5.jar'
-libraryjars 'tempLibraries/jna-4.4.0.jar'
-libraryjars 'tempLibraries/jopt-simple-5.0.3.jar'
-libraryjars 'tempLibraries/jsr305-3.0.1.jar'
-libraryjars 'tempLibraries/jutils-1.0.0.jar'
-libraryjars 'tempLibraries/libraryjavasound-20101123.jar'
-libraryjars 'tempLibraries/librarylwjglopenal-20100824.jar'
-libraryjars 'tempLibraries/log4j-api-2.8.1.jar'
-libraryjars 'tempLibraries/log4j-core-2.8.1.jar'
# startsWith is used to check the library, and mac/linux differ in which version they use
# this is FINE
-libraryjars 'tempLibraries/lwjgl-.jar'
-libraryjars 'tempLibraries/lwjgl_util-.jar'
-libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar'
-libraryjars 'tempLibraries/oshi-core-1.1.jar'
-libraryjars 'tempLibraries/patchy-1.3.9.jar'
-libraryjars 'tempLibraries/platform-3.4.0.jar'
-libraryjars 'tempLibraries/realms-1.10.22.jar'
-libraryjars 'tempLibraries/soundsystem-20120107.jar'
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
-libraryjars 'tempLibraries/launchwrapper-1.12.jar'
-libraryjars 'tempLibraries/nether-pathfinder-.jar'
# Keep - Applications. Keep all application classes, along with their 'main' # Keep - Applications. Keep all application classes, along with their 'main'
# methods. # methods.
-keepclasseswithmembers public class * { -keepclasseswithmembers public class * {

View File

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

View File

@@ -19,9 +19,6 @@ package baritone.api;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import java.util.Iterator;
import java.util.ServiceLoader;
/** /**
* Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage. * Exposes the {@link IBaritoneProvider} instance and the {@link Settings} instance for API usage.
* *
@@ -37,9 +34,11 @@ public final class BaritoneAPI {
settings = new Settings(); settings = new Settings();
SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME); SettingsUtil.readAndApply(settings, SettingsUtil.SETTINGS_DEFAULT_NAME);
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class); try {
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator(); provider = (IBaritoneProvider) Class.forName("baritone.BaritoneProvider").newInstance();
provider = instances.next(); } catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
} }
public static IBaritoneProvider getProvider() { public static IBaritoneProvider getProvider() {

View File

@@ -17,7 +17,6 @@
package baritone.api; package baritone.api;
import baritone.api.behavior.IElytraBehavior;
import baritone.api.behavior.ILookBehavior; import baritone.api.behavior.ILookBehavior;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
import baritone.api.cache.IWorldProvider; import baritone.api.cache.IWorldProvider;
@@ -41,12 +40,6 @@ public interface IBaritone {
*/ */
IPathingBehavior getPathingBehavior(); IPathingBehavior getPathingBehavior();
/**
* @return The {@link IElytraBehavior} instance
* @see IElytraBehavior
*/
IElytraBehavior getElytraBehavior();
/** /**
* @return The {@link ILookBehavior} instance * @return The {@link ILookBehavior} instance
* @see ILookBehavior * @see ILookBehavior

View File

@@ -22,8 +22,7 @@ import baritone.api.command.ICommand;
import baritone.api.command.ICommandSystem; import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem; import baritone.api.schematic.ISchematicSystem;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.network.NetHandlerPlayClient;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -49,17 +48,17 @@ public interface IBaritoneProvider {
* returned by {@link #getPrimaryBaritone()}. * returned by {@link #getPrimaryBaritone()}.
* *
* @return All active {@link IBaritone} instances. * @return All active {@link IBaritone} instances.
* @see #getBaritoneForPlayer(EntityPlayerSP) * @see #getBaritoneForPlayer(LocalPlayer)
*/ */
List<IBaritone> getAllBaritones(); List<IBaritone> getAllBaritones();
/** /**
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. * Provides the {@link IBaritone} instance for a given {@link LocalPlayer}.
* *
* @param player The player * @param player The player
* @return The {@link IBaritone} instance. * @return The {@link IBaritone} instance.
*/ */
default IBaritone getBaritoneForPlayer(EntityPlayerSP player) { default IBaritone getBaritoneForPlayer(LocalPlayer player) {
for (IBaritone baritone : this.getAllBaritones()) { for (IBaritone baritone : this.getAllBaritones()) {
if (Objects.equals(player, baritone.getPlayerContext().player())) { if (Objects.equals(player, baritone.getPlayerContext().player())) {
return baritone; return baritone;
@@ -83,22 +82,6 @@ public interface IBaritoneProvider {
return null; return null;
} }
/**
* Provides the {@link IBaritone} instance for the player with the specified connection.
*
* @param connection The connection
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForConnection(NetHandlerPlayClient connection) {
for (IBaritone baritone : this.getAllBaritones()) {
final EntityPlayerSP player = baritone.getPlayerContext().player();
if (player != null && player.connection == connection) {
return baritone;
}
}
return null;
}
/** /**
* Creates and registers a new {@link IBaritone} instance using the specified {@link Minecraft}. The existing * Creates and registers a new {@link IBaritone} instance using the specified {@link Minecraft}. The existing
* instance is returned if already registered. * instance is returned if already registered.

View File

@@ -21,13 +21,14 @@ import baritone.api.utils.NotificationHelper;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import baritone.api.utils.TypeUtils; import baritone.api.utils.TypeUtils;
import baritone.api.utils.gui.BaritoneToast; import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks; import net.minecraft.core.Vec3i;
import net.minecraft.item.Item; import net.minecraft.network.chat.BaseComponent;
import net.minecraft.util.math.Vec3i; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.ITextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import java.awt.*; import java.awt.*;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@@ -36,9 +37,8 @@ import java.lang.annotation.Target;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.List;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -203,10 +203,10 @@ public final class Settings {
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.) * Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
*/ */
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList( public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
Item.getItemFromBlock(Blocks.DIRT), Blocks.DIRT.asItem(),
Item.getItemFromBlock(Blocks.COBBLESTONE), Blocks.COBBLESTONE.asItem(),
Item.getItemFromBlock(Blocks.NETHERRACK), Blocks.NETHERRACK.asItem(),
Item.getItemFromBlock(Blocks.STONE) Blocks.STONE.asItem()
))); )));
/** /**
@@ -229,11 +229,8 @@ public final class Settings {
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet? public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?
Blocks.CRAFTING_TABLE, Blocks.CRAFTING_TABLE,
Blocks.FURNACE, Blocks.FURNACE,
Blocks.LIT_FURNACE,
Blocks.CHEST, Blocks.CHEST,
Blocks.TRAPPED_CHEST, Blocks.TRAPPED_CHEST
Blocks.STANDING_SIGN,
Blocks.WALL_SIGN
))); )));
/** /**
@@ -373,6 +370,11 @@ public final class Settings {
*/ */
public final Setting<Integer> rightClickSpeed = new Setting<>(4); public final Setting<Integer> rightClickSpeed = new Setting<>(4);
/**
* How many degrees to randomize the yaw every tick. Set to 0 to disable
*/
public final Setting<Double> randomLooking113 = new Setting<>(2d);
/** /**
* Block reach distance * Block reach distance
*/ */
@@ -736,17 +738,6 @@ public final class Settings {
*/ */
public final Setting<Boolean> blockFreeLook = new Setting<>(false); public final Setting<Boolean> blockFreeLook = new Setting<>(false);
/**
* Automatically elytra fly without having to force the client-sided rotations. Requires {@link #freeLook}.
*/
public final Setting<Boolean> elytraFreeLook = new Setting<>(false);
/**
* Forces the client-sided rotations to an average of the last 10 ticks of server-sided rotations.
* Requires {@link #freeLook}.
*/
public final Setting<Boolean> smoothLook = new Setting<>(false);
/** /**
* When true, the player will remain with its existing look direction as often as possible. * 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. * Although, in some cases this can get it stuck, hence this setting to disable that behavior.
@@ -884,13 +875,14 @@ public final class Settings {
/** /**
* Sets the minimum y level whilst mining - set to 0 to turn off. * 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); public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
/** /**
* Sets the maximum y level to mine ores at. * 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 public final Setting<Integer> maxYLevelWhileMining = new Setting<>(2031);
/** /**
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them. * This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
@@ -1110,7 +1102,7 @@ public final class Settings {
/** /**
* What Y level to go to for legit strip mining * 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 * Magically see ores that are separated diagonally from existing ores. Basically like mining around the ores that it finds
@@ -1189,7 +1181,7 @@ public final class Settings {
* {@link Setting#value}; * {@link Setting#value};
*/ */
@JavaOnly @JavaOnly
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(msg -> Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(msg)); public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
/** /**
* The function that is called when Baritone will send a desktop notification. This function can be added to * The function that is called when Baritone will send a desktop notification. This function can be added to
@@ -1205,7 +1197,12 @@ public final class Settings {
* {@link Setting#value}; * {@link Setting#value};
*/ */
@JavaOnly @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
*/
public final Setting<Boolean> verboseCommandExceptions = new Setting<>(false);
/** /**
* The size of the box that is rendered when the current goal is a GoalYLevel * The size of the box that is rendered when the current goal is a GoalYLevel
@@ -1332,89 +1329,6 @@ public final class Settings {
*/ */
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true); public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
/**
* The number of ticks of elytra movement to simulate while firework boost is not active. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraSimulationTicks = new Setting<>(20);
/**
* The maximum allowed deviation in pitch from a direct line-of-sight to the flight target. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraPitchRange = new Setting<>(25);
/**
* The minimum speed that the player can drop to (in blocks/tick) before a firework is automatically deployed.
*/
public final Setting<Double> elytraFireworkSpeed = new Setting<>(0.6);
/**
* The delay after the player's position is set-back by the server that a firework may be automatically deployed.
* Value is in ticks.
*/
public final Setting<Integer> elytraFireworkSetbackUseDelay = new Setting<>(15);
/**
* The minimum padding value that is added to the player's hitbox when considering which point to fly to on the
* path. High values can result in points not being considered which are otherwise safe to fly to. Low values can
* result in flight paths which are extremely tight, and there's the possibility of crashing due to getting too low
* to the ground.
*/
public final Setting<Double> elytraMinimumAvoidance = new Setting<>(0.2);
/**
* If enabled, avoids using fireworks when descending along the flight path.
*/
public final Setting<Boolean> conserveFireworks = new Setting<>(true);
/**
* Renders the raytraces that are performed by the elytra fly calculation.
*/
public final Setting<Boolean> renderRaytraces = new Setting<>(false);
/**
* Renders the raytraces that are used in the hitbox part of the elytra fly calculation.
* Requires {@link #renderRaytraces}.
*/
public final Setting<Boolean> renderHitboxRaytraces = new Setting<>(false);
/**
* Renders the best elytra flight path that was simulated each tick.
*/
public final Setting<Boolean> renderElytraSimulation = new Setting<>(false);
/**
* Automatically path to and jump off of ledges to initiate elytra flight when grounded.
*/
public final Setting<Boolean> elytraAutoJump = new Setting<>(false);
/**
* The seed used to generate chunks for long distance elytra path-finding in the nether.
* Defaults to 2b2t's nether seed.
*/
public final Setting<Long> elytraNetherSeed = new Setting<>(146008555100680L);
/**
* Automatically swap the current elytra with a new one when the durability gets too low
*/
public final Setting<Boolean> elytraAutoSwap = new Setting<>(true);
/**
* The minimum durability an elytra can have before being swapped
*/
public final Setting<Integer> elytraMinimumDurability = new Setting<>(5);
/**
* Time between culling far away chunks from the nether pathfinder chunk cache
*/
public final Setting<Long> elytraTimeBetweenCacheCullSecs = new Setting<>(TimeUnit.MINUTES.toSeconds(3));
/**
* Maximum distance chunks can be before being culled from the nether pathfinder chunk cache
*/
public final Setting<Integer> elytraCacheCullDistance = new Setting<>(5000);
/** /**
* A map of lowercase setting field names to their respective setting * A map of lowercase setting field names to their respective setting
*/ */

View File

@@ -27,10 +27,4 @@ import baritone.api.event.listener.IGameEventListener;
* @see IGameEventListener * @see IGameEventListener
* @since 9/23/2018 * @since 9/23/2018
*/ */
public interface IBehavior extends AbstractGameEventListener { public interface IBehavior extends AbstractGameEventListener {}
/**
* Called after Baritone's initialization is complete
*/
default void onLoad() {}
}

View File

@@ -1,54 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.behavior;
import net.minecraft.util.math.BlockPos;
import java.util.concurrent.CompletableFuture;
public interface IElytraBehavior extends IBehavior {
/**
* Marks the nether pathfinder context to be reset when it is safe to do so. Because this operation is not
* immediate, a {@link CompletableFuture} is returned that will complete after the context has been reset.
*
* @return A {@link CompletableFuture} that is completed when the context is reset
*/
CompletableFuture<Void> resetContext();
void repackChunks();
void pathTo(BlockPos destination);
void cancel();
/**
* Returns {@code true} if the current {@link IElytraBehavior} is actively pathing.
*/
boolean isActive();
/**
* @return {@code true} if the native library loaded and elytra is actually usable
*/
boolean isLoaded();
/*
* FOR INTERNAL USE ONLY. MAY BE REMOVED AT ANY TIME.
*/
boolean isSafeToCancel();
}

View File

@@ -17,8 +17,8 @@
package baritone.api.cache; package baritone.api.cache;
import net.minecraft.block.state.IBlockState; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.state.BlockState;
/** /**
* @author Brady * @author Brady
@@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
*/ */
public interface IBlockTypeAccess { public interface IBlockTypeAccess {
IBlockState getBlock(int x, int y, int z); BlockState getBlock(int x, int y, int z);
default IBlockState getBlock(BlockPos pos) { default BlockState getBlock(BlockPos pos) {
return getBlock(pos.getX(), pos.getY(), pos.getZ()); return getBlock(pos.getX(), pos.getY(), pos.getZ());
} }
} }

View File

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

View File

@@ -19,11 +19,10 @@ package baritone.api.cache;
import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext; 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 java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
/** /**
* @author Brady * @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.CommandNotEnoughArgumentsException;
import baritone.api.command.exception.CommandTooManyArgumentsException; import baritone.api.command.exception.CommandTooManyArgumentsException;
import baritone.api.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.util.EnumFacing;
import java.util.Deque; import java.util.Deque;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.stream.Stream; 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: * The {@link IArgConsumer} is how {@link ICommand}s read the arguments passed to them. This class has many benefits:
@@ -404,8 +403,8 @@ public interface IArgConsumer {
/** /**
* Gets an enum value from the enum class with the same name as the next argument's value * Gets an enum value from the enum class with the same name as the next argument's value
* <p> * <p>
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return * For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
* {@link EnumFacing#UP} * {@link Direction#UP}
* *
* @param enumClass The enum class to search * @param enumClass The enum class to search
* @return An enum constant of that class with the same name as the next argument's value * @return An enum constant of that class with the same name as the next argument's value
@@ -419,8 +418,8 @@ public interface IArgConsumer {
/** /**
* Gets an enum value from the enum class with the same name as the next argument's value * Gets an enum value from the enum class with the same name as the next argument's value
* <p> * <p>
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return * For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
* {@link EnumFacing#UP} * {@link Direction#UP}
* *
* @param enumClass The enum class to search * @param enumClass The enum class to search
* @param def The default value * @param def The default value
@@ -436,8 +435,8 @@ public interface IArgConsumer {
/** /**
* Gets an enum value from the enum class with the same name as the next argument's value * Gets an enum value from the enum class with the same name as the next argument's value
* <p> * <p>
* For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return * For example if you getEnum as an {@link Direction}, and the next argument's value is "up", this will return
* {@link EnumFacing#UP} * {@link Direction#UP}
* *
* @param enumClass The enum class to search * @param enumClass The enum class to search
* @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it * @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it

View File

@@ -19,7 +19,7 @@ package baritone.api.command.argument;
import baritone.api.command.argparser.IArgParser; import baritone.api.command.argparser.IArgParser;
import baritone.api.command.exception.CommandInvalidTypeException; import baritone.api.command.exception.CommandInvalidTypeException;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Direction;
/** /**
* A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of * A {@link ICommandArgument} is an immutable object representing one command argument. It contains data on the index of
@@ -50,8 +50,8 @@ public interface ICommandArgument {
/** /**
* Gets an enum value from the enum class with the same name as this argument's value * Gets an enum value from the enum class with the same name as this argument's value
* <p> * <p>
* For example if you getEnum as an {@link EnumFacing}, and this argument's value is "up", it will return {@link * For example if you getEnum as an {@link Direction}, and this argument's value is "up", it will return {@link
* EnumFacing#UP} * Direction#UP}
* *
* @param enumClass The enum class to search * @param enumClass The enum class to search
* @return An enum constant of that class with the same name as this argument's value * @return An enum constant of that class with the same name as this argument's value

View File

@@ -19,9 +19,9 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.block.Block; import net.minecraft.core.Registry;
import net.minecraft.init.Blocks; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.level.block.Block;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -38,7 +38,7 @@ public enum BlockById implements IDatatypeFor<Block> {
public Block get(IDatatypeContext ctx) throws CommandException { public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString()); ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
Block block; Block block;
if ((block = Block.REGISTRY.getObject(id)) == Blocks.AIR) { if ((block = Registry.BLOCK.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id"); throw new IllegalArgumentException("no block found by that id");
} }
return block; return block;
@@ -54,7 +54,7 @@ public enum BlockById implements IDatatypeFor<Block> {
return new TabCompleteHelper() return new TabCompleteHelper()
.append( .append(
Block.REGISTRY.getKeys() Registry.BLOCK.keySet()
.stream() .stream()
.map(Object::toString) .map(Object::toString)
) )

View File

@@ -19,32 +19,19 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.util.ResourceLocation;
import java.util.stream.Stream; 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<Class<? extends Entity>> { public enum EntityClassById implements IDatatypeFor<EntityType> {
INSTANCE; INSTANCE;
@Override @Override
public Class<? extends Entity> get(IDatatypeContext ctx) throws CommandException { public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString()); ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
Class<? extends Entity> entity; EntityType entity;
try { if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
entity = EntityList.REGISTRY.getObject(id);
} catch (NoSuchFieldError e) {
// Forge removes EntityList.REGISTRY field and provides the getClass method as a replacement
// See https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/patches/minecraft/net/minecraft/entity/EntityList.java.patch
try {
entity = (Class<? extends Entity>) EntityList.class.getMethod("getClass", ResourceLocation.class).invoke(null, id);
} catch (Exception ex) {
throw new RuntimeException("EntityList.REGISTRY does not exist and failed to call the Forge-replacement method", ex);
}
}
if (entity == null) {
throw new IllegalArgumentException("no entity found by that id"); throw new IllegalArgumentException("no entity found by that id");
} }
return entity; return entity;
@@ -53,7 +40,7 @@ public enum EntityClassById implements IDatatypeFor<Class<? extends Entity>> {
@Override @Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(EntityList.getEntityNameList().stream().map(Object::toString)) .append(Registry.ENTITY_TYPE.stream().map(Object::toString))
.filterPrefixNamespaced(ctx.getConsumer().getString()) .filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically() .sortAlphabetically()
.stream(); .stream();

View File

@@ -19,24 +19,24 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Direction;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Stream; import java.util.stream.Stream;
public enum ForAxis implements IDatatypeFor<EnumFacing.Axis> { public enum ForAxis implements IDatatypeFor<Direction.Axis> {
INSTANCE; INSTANCE;
@Override @Override
public EnumFacing.Axis get(IDatatypeContext ctx) throws CommandException { public Direction.Axis get(IDatatypeContext ctx) throws CommandException {
return EnumFacing.Axis.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US)); return Direction.Axis.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
} }
@Override @Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(Stream.of(EnumFacing.Axis.values()) .append(Stream.of(Direction.Axis.values())
.map(EnumFacing.Axis::getName).map(String::toLowerCase)) .map(Direction.Axis::getName).map(String::toLowerCase))
.filterPrefix(ctx.getConsumer().getString()) .filterPrefix(ctx.getConsumer().getString())
.stream(); .stream();
} }

View File

@@ -20,9 +20,10 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.Block; import net.minecraft.core.Registry;
import net.minecraft.block.properties.IProperty; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.Property;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -76,7 +77,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
properties = parts[1]; properties = parts[1];
} }
Block block = Block.REGISTRY.getObject(new ResourceLocation(blockId)); Block block = Registry.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
if (block == null) { if (block == null) {
// This block doesn't exist so there's no properties to complete. // This block doesn't exist so there's no properties to complete.
return Stream.empty(); return Stream.empty();
@@ -98,10 +99,10 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
String prefix = arg.substring(0, arg.length() - lastProperty.length()); String prefix = arg.substring(0, arg.length() - lastProperty.length());
return new TabCompleteHelper() return new TabCompleteHelper()
.append( .append(
block.getBlockState() block.getStateDefinition()
.getProperties() .getProperties()
.stream() .stream()
.map(IProperty::getName) .map(Property::getName)
) )
.filter(prop -> !usedProps.contains(prop)) .filter(prop -> !usedProps.contains(prop))
.filterPrefix(lastProperty) .filterPrefix(lastProperty)
@@ -120,7 +121,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
// We are completing the value of a property // We are completing the value of a property
String prefix = arg.substring(0, arg.length() - lastValue.length()); String prefix = arg.substring(0, arg.length() - lastValue.length());
IProperty<?> property = block.getBlockState().getProperty(lastName); Property<?> property = block.getStateDefinition().getProperty(lastName);
if (property == null) { if (property == null) {
// The property does not exist so there's no values to complete // The property does not exist so there's no values to complete
return Stream.empty(); return Stream.empty();
@@ -147,7 +148,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
} }
// this shouldn't need to be a separate method? // this shouldn't need to be a separate method?
private static <T extends Comparable<T>> Stream<String> getValues(IProperty<T> property) { private static <T extends Comparable<T>> Stream<String> getValues(Property<T> property) {
return property.getAllowedValues().stream().map(property::getName); return property.getPossibleValues().stream().map(property::getName);
} }
} }

View File

@@ -19,24 +19,23 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.util.EnumFacing;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraft.core.Direction;
public enum ForEnumFacing implements IDatatypeFor<EnumFacing> { public enum ForDirection implements IDatatypeFor<Direction> {
INSTANCE; INSTANCE;
@Override @Override
public EnumFacing get(IDatatypeContext ctx) throws CommandException { public Direction get(IDatatypeContext ctx) throws CommandException {
return EnumFacing.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US)); return Direction.valueOf(ctx.getConsumer().getString().toUpperCase(Locale.US));
} }
@Override @Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException { public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(Stream.of(EnumFacing.values()) .append(Stream.of(Direction.values())
.map(EnumFacing::getName).map(String::toLowerCase)) .map(Direction::getName).map(String::toLowerCase))
.filterPrefix(ctx.getConsumer().getString()) .filterPrefix(ctx.getConsumer().getString())
.stream(); .stream();
} }

View File

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

View File

@@ -32,8 +32,6 @@ import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Stream; import java.util.stream.Stream;
import static baritone.api.utils.Helper.HELPER;
public enum RelativeFile implements IDatatypePost<File, File> { public enum RelativeFile implements IDatatypePost<File, File> {
INSTANCE; INSTANCE;
@@ -101,7 +99,7 @@ public enum RelativeFile implements IDatatypePost<File, File> {
} }
public static File gameDir(Minecraft mc) { public static File gameDir(Minecraft mc) {
File gameDir = mc.gameDir.getAbsoluteFile(); File gameDir = mc.gameDirectory.getAbsoluteFile();
if (gameDir.getName().equals(".")) { if (gameDir.getName().equals(".")) {
return gameDir.getParentFile(); return gameDir.getParentFile();
} }

View File

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

View File

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

View File

@@ -21,9 +21,8 @@ import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.GoalYLevel; import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.math.MathHelper;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraft.util.Mth;
public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> { public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockPos> {
INSTANCE; INSTANCE;
@@ -35,7 +34,7 @@ public enum RelativeGoalYLevel implements IDatatypePost<GoalYLevel, BetterBlockP
} }
return new GoalYLevel( 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,8 +19,8 @@ package baritone.api.command.exception;
import baritone.api.command.ICommand; import baritone.api.command.ICommand;
import baritone.api.command.argument.ICommandArgument; import baritone.api.command.argument.ICommandArgument;
import java.util.List; import java.util.List;
import net.minecraft.ChatFormatting;
import static baritone.api.utils.Helper.HELPER; import static baritone.api.utils.Helper.HELPER;
@@ -36,6 +36,10 @@ public class CommandUnhandledException extends RuntimeException implements IComm
@Override @Override
public void handle(ICommand command, List<ICommandArgument> args) { public void handle(ICommand command, List<ICommandArgument> args) {
HELPER.logUnhandledException(this); HELPER.logDirect("An unhandled exception occurred. " +
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
ChatFormatting.RED);
this.printStackTrace();
} }
} }

View File

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

View File

@@ -21,15 +21,15 @@ import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidTypeException; import baritone.api.command.exception.CommandInvalidTypeException;
import baritone.api.utils.Helper; import baritone.api.utils.Helper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
public class Paginator<E> implements Helper { public class Paginator<E> implements Helper {
@@ -63,59 +63,59 @@ public class Paginator<E> implements Helper {
return this; 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; int offset = (page - 1) * pageSize;
for (int i = offset; i < offset + pageSize; i++) { for (int i = offset; i < offset + pageSize; i++) {
if (i < entries.size()) { if (i < entries.size()) {
logDirect(transform.apply(entries.get(i))); logDirect(transform.apply(entries.get(i)));
} else { } else {
logDirect("--", TextFormatting.DARK_GRAY); logDirect("--", ChatFormatting.DARK_GRAY);
} }
} }
boolean hasPrevPage = commandPrefix != null && validPage(page - 1); boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
boolean hasNextPage = commandPrefix != null && validPage(page + 1); boolean hasNextPage = commandPrefix != null && validPage(page + 1);
ITextComponent prevPageComponent = new TextComponentString("<<"); BaseComponent prevPageComponent = new TextComponent("<<");
if (hasPrevPage) { if (hasPrevPage) {
prevPageComponent.getStyle() prevPageComponent.setStyle(prevPageComponent.getStyle()
.setClickEvent(new ClickEvent( .withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format("%s %d", commandPrefix, page - 1) String.format("%s %d", commandPrefix, page - 1)
)) ))
.setHoverEvent(new HoverEvent( .withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, HoverEvent.Action.SHOW_TEXT,
new TextComponentString("Click to view previous page") new TextComponent("Click to view previous page")
)); )));
} else { } else {
prevPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY); prevPageComponent.setStyle(prevPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
} }
ITextComponent nextPageComponent = new TextComponentString(">>"); BaseComponent nextPageComponent = new TextComponent(">>");
if (hasNextPage) { if (hasNextPage) {
nextPageComponent.getStyle() nextPageComponent.setStyle(nextPageComponent.getStyle()
.setClickEvent(new ClickEvent( .withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format("%s %d", commandPrefix, page + 1) String.format("%s %d", commandPrefix, page + 1)
)) ))
.setHoverEvent(new HoverEvent( .withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, HoverEvent.Action.SHOW_TEXT,
new TextComponentString("Click to view next page") new TextComponent("Click to view next page")
)); )));
} else { } else {
nextPageComponent.getStyle().setColor(TextFormatting.DARK_GRAY); nextPageComponent.setStyle(nextPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
} }
ITextComponent pagerComponent = new TextComponentString(""); BaseComponent pagerComponent = new TextComponent("");
pagerComponent.getStyle().setColor(TextFormatting.GRAY); pagerComponent.setStyle(pagerComponent.getStyle().withColor(ChatFormatting.GRAY));
pagerComponent.appendSibling(prevPageComponent); pagerComponent.append(prevPageComponent);
pagerComponent.appendText(" | "); pagerComponent.append(" | ");
pagerComponent.appendSibling(nextPageComponent); pagerComponent.append(nextPageComponent);
pagerComponent.appendText(String.format(" %d/%d", page, getMaxPage())); pagerComponent.append(String.format(" %d/%d", page, getMaxPage()));
logDirect(pagerComponent); logDirect(pagerComponent);
} }
public void display(Function<E, ITextComponent> transform) { public void display(Function<E, Component> transform) {
display(transform, null); 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; int page = 1;
consumer.requireMax(1); consumer.requireMax(1);
if (consumer.hasAny()) { if (consumer.hasAny()) {
@@ -138,47 +138,47 @@ public class Paginator<E> implements Helper {
pagi.display(transform, commandPrefix); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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.command.manager.ICommandManager;
import baritone.api.event.events.TabCompleteEvent; import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import net.minecraft.util.ResourceLocation;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; 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 * The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper

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.event.events;
import baritone.api.utils.Pair;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* @author Brady
*/
public final class BlockChangeEvent {
private final ChunkPos chunk;
private final List<Pair<BlockPos, IBlockState>> blocks;
public BlockChangeEvent(ChunkPos pos, List<Pair<BlockPos, IBlockState>> blocks) {
this.chunk = pos;
this.blocks = blocks;
}
public ChunkPos getChunkPos() {
return this.chunk;
}
public List<Pair<BlockPos, IBlockState>> getBlocks() {
return this.blocks;
}
}

View File

@@ -17,7 +17,7 @@
package baritone.api.event.events; 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}. * Called when the local player interacts with a block, can be either {@link Type#START_BREAK} or {@link Type#USE}.

View File

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

View File

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

View File

@@ -17,6 +17,9 @@
package baritone.api.event.events; package baritone.api.event.events;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
/** /**
* @author Brady * @author Brady
* @since 8/5/2018 * @since 8/5/2018
@@ -28,8 +31,13 @@ public final class RenderEvent {
*/ */
private final float partialTicks; private final float partialTicks;
public RenderEvent(float partialTicks) { private final Matrix4f projectionMatrix;
private final PoseStack modelViewStack;
public RenderEvent(float partialTicks, PoseStack modelViewStack, Matrix4f projectionMatrix) {
this.partialTicks = partialTicks; this.partialTicks = partialTicks;
this.modelViewStack = modelViewStack;
this.projectionMatrix = projectionMatrix;
} }
/** /**
@@ -38,4 +46,12 @@ public final class RenderEvent {
public final float getPartialTicks() { public final float getPartialTicks() {
return this.partialTicks; return this.partialTicks;
} }
public PoseStack getModelViewStack() {
return this.modelViewStack;
}
public Matrix4f getProjectionMatrix() {
return this.projectionMatrix;
}
} }

View File

@@ -18,8 +18,9 @@
package baritone.api.event.events; package baritone.api.event.events;
import baritone.api.utils.Rotation; import baritone.api.utils.Rotation;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
/** /**
* @author Brady * @author Brady
@@ -99,14 +100,14 @@ public final class RotationMoveEvent {
/** /**
* Called when the player's motion is updated. * Called when the player's motion is updated.
* *
* @see Entity#moveRelative(float, float, float, float) * @see Entity#moveRelative(float, Vec3)
*/ */
MOTION_UPDATE, MOTION_UPDATE,
/** /**
* Called when the player jumps. * Called when the player jumps.
* *
* @see EntityLivingBase#jump * @see LivingEntity
*/ */
JUMP JUMP
} }

View File

@@ -22,7 +22,7 @@ import baritone.api.event.events.type.Cancellable;
/** /**
* @author LoganDark * @author LoganDark
*/ */
public class TabCompleteEvent extends Cancellable { public final class TabCompleteEvent extends Cancellable {
public final String prefix; public final String prefix;
public String[] completions; public String[] completions;

View File

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

View File

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

View File

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

View File

@@ -18,14 +18,13 @@
package baritone.api.event.listener; package baritone.api.event.listener;
import baritone.api.event.events.*; import baritone.api.event.events.*;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.screens.DeathScreen;
import net.minecraft.client.gui.GuiGameOver; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.settings.GameSettings; import net.minecraft.network.protocol.Packet;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.network.Packet; import net.minecraft.world.phys.Vec3;
/** /**
* @author Brady * @author Brady
@@ -37,23 +36,15 @@ public interface IGameEventListener {
* Run once per game tick before screen input is handled. * Run once per game tick before screen input is handled.
* *
* @param event The event * @param event The event
* @see Minecraft#runTick() * @see Minecraft#tick()
*/ */
void onTick(TickEvent event); void onTick(TickEvent event);
/**
* Run once per game tick after the tick is completed
*
* @param event The event
* @see Minecraft#runTick()
*/
void onPostTick(TickEvent event);
/** /**
* Run once per game tick from before and after the player rotation is sent to the server. * Run once per game tick from before and after the player rotation is sent to the server.
* *
* @param event The event * @param event The event
* @see EntityPlayerSP#onUpdate() * @see LocalPlayer#tick()
*/ */
void onPlayerUpdate(PlayerUpdateEvent event); void onPlayerUpdate(PlayerUpdateEvent event);
@@ -61,7 +52,7 @@ public interface IGameEventListener {
* Runs whenever the client player sends a message to the server. * Runs whenever the client player sends a message to the server.
* *
* @param event The event * @param event The event
* @see EntityPlayerSP#sendChatMessage(String) * @see LocalPlayer#chat(String)
*/ */
void onSendChatMessage(ChatEvent event); void onSendChatMessage(ChatEvent event);
@@ -76,21 +67,11 @@ public interface IGameEventListener {
* Runs before and after whenever a chunk is either loaded, unloaded, or populated. * Runs before and after whenever a chunk is either loaded, unloaded, or populated.
* *
* @param event The event * @param event The event
* @see WorldClient#doPreChunk(int, int, boolean)
*/ */
void onChunkEvent(ChunkEvent event); void onChunkEvent(ChunkEvent event);
/** /**
* Runs after a single or multi block change packet is received and processed. * Runs once per world render pass.
*
* @param event The event
*/
void onBlockChange(BlockChangeEvent event);
/**
* Runs once per world render pass. Two passes are made when {@link GameSettings#anaglyph} is on.
* <p>
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
* *
* @param event The event * @param event The event
*/ */
@@ -100,7 +81,7 @@ public interface IGameEventListener {
* Runs before and after whenever a new world is loaded * Runs before and after whenever a new world is loaded
* *
* @param event The event * @param event The event
* @see Minecraft#loadWorld(WorldClient, String) * @see Minecraft#setLevel(ClientLevel)
*/ */
void onWorldEvent(WorldEvent event); void onWorldEvent(WorldEvent event);
@@ -109,7 +90,6 @@ public interface IGameEventListener {
* *
* @param event The event * @param event The event
* @see Packet * @see Packet
* @see GenericFutureListener
*/ */
void onSendPacket(PacketEvent event); void onSendPacket(PacketEvent event);
@@ -118,7 +98,6 @@ public interface IGameEventListener {
* *
* @param event The event * @param event The event
* @see Packet * @see Packet
* @see GenericFutureListener
*/ */
void onReceivePacket(PacketEvent event); void onReceivePacket(PacketEvent event);
@@ -127,15 +106,15 @@ public interface IGameEventListener {
* and before and after the player jumps. * and before and after the player jumps.
* *
* @param event The event * @param event The event
* @see Entity#moveRelative(float, float, float, float) * @see Entity#moveRelative(float, Vec3)
*/ */
void onPlayerRotationMove(RotationMoveEvent event); void onPlayerRotationMove(RotationMoveEvent event);
/** /**
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate} * Called whenever the sprint keybind state is checked in {@link LocalPlayer#aiStep}
* *
* @param event The event * @param event The event
* @see EntityPlayerSP#onLivingUpdate() * @see LocalPlayer#aiStep()
*/ */
void onPlayerSprintState(SprintStateEvent event); void onPlayerSprintState(SprintStateEvent event);
@@ -147,9 +126,9 @@ public interface IGameEventListener {
void onBlockInteract(BlockInteractEvent event); void onBlockInteract(BlockInteractEvent event);
/** /**
* Called when the local player dies, as indicated by the creation of the {@link GuiGameOver} screen. * Called when the local player dies, as indicated by the creation of the {@link DeathScreen} screen.
* *
* @see GuiGameOver * @see DeathScreen
*/ */
void onPlayerDeath(); void onPlayerDeath();

View File

@@ -17,7 +17,7 @@
package baritone.api.pathing.goals; 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. * An abstract Goal for pathing, can be anything from a specific block to just a Y coordinate.

View File

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

View File

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

View File

@@ -22,7 +22,7 @@ import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.api.utils.interfaces.IGoalRenderPos;
import it.unimi.dsi.fastutil.doubles.DoubleIterator; import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
public class GoalNear implements Goal, IGoalRenderPos { public class GoalNear implements Goal, IGoalRenderPos {

View File

@@ -20,7 +20,7 @@ package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import it.unimi.dsi.fastutil.doubles.DoubleIterator; import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; 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.Arrays;
import java.util.Objects; import java.util.Objects;

View File

@@ -19,8 +19,8 @@ package baritone.api.pathing.goals;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
import net.minecraft.util.EnumFacing; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.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 * Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
@@ -33,12 +33,12 @@ public class GoalStrictDirection implements Goal {
public final int dx; public final int dx;
public final int dz; public final int dz;
public GoalStrictDirection(BlockPos origin, EnumFacing direction) { public GoalStrictDirection(BlockPos origin, Direction direction) {
x = origin.getX(); x = origin.getX();
y = origin.getY(); y = origin.getY();
z = origin.getZ(); z = origin.getZ();
dx = direction.getXOffset(); dx = direction.getStepX();
dz = direction.getZOffset(); dz = direction.getStepZ();
if (dx == 0 && dz == 0) { if (dx == 0 && dz == 0) {
throw new IllegalArgumentException(direction + ""); throw new IllegalArgumentException(direction + "");
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,11 +18,10 @@
package baritone.api.process; package baritone.api.process;
import baritone.api.schematic.ISchematic; import baritone.api.schematic.ISchematic;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.BlockState;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@@ -53,7 +52,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
@Deprecated @Deprecated
default boolean build(String schematicFile, BlockPos origin) { default boolean build(String schematicFile, BlockPos origin) {
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile); File file = new File(new File(Minecraft.getInstance().gameDirectory, "schematics"), schematicFile);
return build(schematicFile, file, origin); return build(schematicFile, file, origin);
} }
@@ -74,5 +73,5 @@ public interface IBuilderProcess extends IBaritoneProcess {
* schematics, for example, to pick a state that the builder process will be happy with, because any variation will * schematics, for example, to pick a state that the builder process will be happy with, because any variation will
* cause it to give up. This is updated every tick, but only while the builder process is active. * cause it to give up. This is updated every tick, but only while the builder process is active.
*/ */
List<IBlockState> getApproxPlaceable(); List<BlockState> getApproxPlaceable();
} }

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@
package baritone.api.process; package baritone.api.process;
import baritone.api.utils.BlockOptionalMeta; 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 * 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.BlockOptionalMeta;
import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.BlockOptionalMetaLookup;
import net.minecraft.block.Block;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraft.world.level.block.Block;
/** /**
* @author Brady * @author Brady

View File

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

View File

@@ -17,10 +17,9 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.state.IBlockState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.world.level.block.state.BlockState;
public class CompositeSchematic extends AbstractSchematic { public class CompositeSchematic extends AbstractSchematic {
@@ -47,7 +46,7 @@ public class CompositeSchematic extends AbstractSchematic {
recalcArr(); recalcArr();
} }
private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) { private CompositeSchematicEntry getSchematic(int x, int y, int z, BlockState currentState) {
for (CompositeSchematicEntry entry : schematicArr) { for (CompositeSchematicEntry entry : schematicArr) {
if (x >= entry.x && y >= entry.y && z >= entry.z && if (x >= entry.x && y >= entry.y && z >= entry.z &&
entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) { entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
@@ -58,13 +57,13 @@ public class CompositeSchematic extends AbstractSchematic {
} }
@Override @Override
public boolean inSchematic(int x, int y, int z, IBlockState currentState) { public boolean inSchematic(int x, int y, int z, BlockState currentState) {
CompositeSchematicEntry entry = getSchematic(x, y, z, currentState); CompositeSchematicEntry entry = getSchematic(x, y, z, currentState);
return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState); return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState);
} }
@Override @Override
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) { public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
CompositeSchematicEntry entry = getSchematic(x, y, z, current); CompositeSchematicEntry entry = getSchematic(x, y, z, current);
if (entry == null) { if (entry == null) {
throw new IllegalStateException("couldn't find schematic for this position"); throw new IllegalStateException("couldn't find schematic for this position");

View File

@@ -18,7 +18,8 @@
package baritone.api.schematic; package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import java.util.List; import java.util.List;
@@ -31,8 +32,8 @@ public class FillSchematic extends AbstractSchematic {
this.bom = bom; this.bom = bom;
} }
public FillSchematic(int x, int y, int z, IBlockState state) { public FillSchematic(int x, int y, int z, BlockState state) {
this(x, y, z, new BlockOptionalMeta(state.getBlock(), state.getBlock().getMetaFromState(state))); this(x, y, z, new BlockOptionalMeta(state.getBlock()));
} }
public BlockOptionalMeta getBom() { public BlockOptionalMeta getBom() {
@@ -40,11 +41,11 @@ public class FillSchematic extends AbstractSchematic {
} }
@Override @Override
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) { public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
if (bom.matches(current)) { if (bom.matches(current)) {
return current; return current;
} }
for (IBlockState placeable : approxPlaceable) { for (BlockState placeable : approxPlaceable) {
if (bom.matches(placeable)) { if (bom.matches(placeable)) {
return placeable; return placeable;
} }

View File

@@ -17,10 +17,9 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import java.util.List; 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 * Basic representation of a schematic. Provides the dimensions and the desired state for a given position relative to
@@ -44,11 +43,11 @@ public interface ISchematic {
* @param currentState The current state of that block in the world, or null * @param currentState The current state of that block in the world, or null
* @return Whether or not the specified position is within the bounds of this schematic * @return Whether or not the specified position is within the bounds of this schematic
*/ */
default boolean inSchematic(int x, int y, int z, IBlockState currentState) { default boolean inSchematic(int x, int y, int z, BlockState currentState) {
return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ(); return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ();
} }
default int size(EnumFacing.Axis axis) { default int size(Direction.Axis axis) {
switch (axis) { switch (axis) {
case X: case X:
return widthX(); return widthX();
@@ -71,7 +70,7 @@ public interface ISchematic {
* @param approxPlaceable The list of blockstates estimated to be placeable * @param approxPlaceable The list of blockstates estimated to be placeable
* @return The desired block state at the specified position * @return The desired block state at the specified position
*/ */
IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable); BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable);
/** /**
* Resets possible caches to avoid wrong behavior when moving the schematic around * Resets possible caches to avoid wrong behavior when moving the schematic around

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
/** /**
* A static schematic is capable of providing the desired state at a given position without * A static schematic is capable of providing the desired state at a given position without
@@ -30,7 +30,7 @@ import net.minecraft.block.state.IBlockState;
public interface IStaticSchematic extends ISchematic { public interface IStaticSchematic extends ISchematic {
/** /**
* Gets the {@link IBlockState} for a given position in this schematic. It should be guaranteed * Gets the {@link BlockState} for a given position in this schematic. It should be guaranteed
* that the return value of this method will not change given that the parameters are the same. * that the return value of this method will not change given that the parameters are the same.
* *
* @param x The X block position * @param x The X block position
@@ -38,19 +38,19 @@ public interface IStaticSchematic extends ISchematic {
* @param z The Z block position * @param z The Z block position
* @return The desired state at the specified position. * @return The desired state at the specified position.
*/ */
IBlockState getDirect(int x, int y, int z); BlockState getDirect(int x, int y, int z);
/** /**
* Returns an {@link IBlockState} array of size {@link #heightY()} which contains all * Returns an {@link BlockState} array of size {@link #heightY()} which contains all
* desired block states in the specified vertical column. The index of {@link IBlockState}s * desired block states in the specified vertical column. The index of {@link BlockState}s
* in the array are equivalent to their Y position in the schematic. * in the array are equivalent to their Y position in the schematic.
* *
* @param x The X column position * @param x The X column position
* @param z The Z column position * @param z The Z column position
* @return An {@link IBlockState} array * @return An {@link BlockState} array
*/ */
default IBlockState[] getColumn(int x, int z) { default BlockState[] getColumn(int x, int z) {
IBlockState[] column = new IBlockState[this.heightY()]; BlockState[] column = new BlockState[this.heightY()];
for (int i = 0; i < this.heightY(); i++) { for (int i = 0; i < this.heightY(); i++) {
column[i] = getDirect(x, i, z); column[i] = getDirect(x, i, z);
} }

View File

@@ -18,7 +18,7 @@
package baritone.api.schematic; package baritone.api.schematic;
import baritone.api.schematic.mask.Mask; import baritone.api.schematic.mask.Mask;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
import java.util.List; import java.util.List;
@@ -31,15 +31,15 @@ public abstract class MaskSchematic extends AbstractSchematic {
this.schematic = schematic; this.schematic = schematic;
} }
protected abstract boolean partOfMask(int x, int y, int z, IBlockState currentState); protected abstract boolean partOfMask(int x, int y, int z, BlockState currentState);
@Override @Override
public boolean inSchematic(int x, int y, int z, IBlockState currentState) { public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState); return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState);
} }
@Override @Override
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) { public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return schematic.desiredState(x, y, z, current, approxPlaceable); return schematic.desiredState(x, y, z, current, approxPlaceable);
} }
@@ -47,7 +47,7 @@ public abstract class MaskSchematic extends AbstractSchematic {
return new MaskSchematic(schematic) { return new MaskSchematic(schematic) {
@Override @Override
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
return function.partOfMask(x, y, z, currentState); return function.partOfMask(x, y, z, currentState);
} }
}; };

View File

@@ -18,7 +18,7 @@
package baritone.api.schematic; package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.BlockOptionalMetaLookup;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
public class ReplaceSchematic extends MaskSchematic { public class ReplaceSchematic extends MaskSchematic {
@@ -44,7 +44,7 @@ public class ReplaceSchematic extends MaskSchematic {
} }
@Override @Override
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
if (cache[x][y][z] == null) { if (cache[x][y][z] == null) {
cache[x][y][z] = filter.has(currentState); cache[x][y][z] = filter.has(currentState);
} }

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
public class ShellSchematic extends MaskSchematic { public class ShellSchematic extends MaskSchematic {
@@ -26,7 +26,7 @@ public class ShellSchematic extends MaskSchematic {
} }
@Override @Override
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1; return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1;
} }
} }

View File

@@ -17,11 +17,11 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.Block; import net.minecraft.world.level.block.AirBlock;
import net.minecraft.block.BlockAir; import net.minecraft.world.level.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.world.level.block.Blocks;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.init.Blocks; import net.minecraft.world.level.block.state.properties.Property;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@@ -32,7 +32,7 @@ public class SubstituteSchematic extends AbstractSchematic {
private final ISchematic schematic; private final ISchematic schematic;
private final Map<Block, List<Block>> substitutions; private final Map<Block, List<Block>> substitutions;
private final Map<IBlockState, Map<Block, IBlockState>> blockStateCache = new HashMap<>(); private final Map<BlockState, Map<Block, BlockState>> blockStateCache = new HashMap<>();
public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) { public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ()); super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
@@ -41,51 +41,51 @@ public class SubstituteSchematic extends AbstractSchematic {
} }
@Override @Override
public boolean inSchematic(int x, int y, int z, IBlockState currentState) { public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(x, y, z, currentState); return schematic.inSchematic(x, y, z, currentState);
} }
@Override @Override
public IBlockState desiredState(int x, int y, int z, IBlockState current, List<IBlockState> approxPlaceable) { public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
IBlockState desired = schematic.desiredState(x, y, z, current, approxPlaceable); BlockState desired = schematic.desiredState(x, y, z, current, approxPlaceable);
Block desiredBlock = desired.getBlock(); Block desiredBlock = desired.getBlock();
if (!substitutions.containsKey(desiredBlock)) { if (!substitutions.containsKey(desiredBlock)) {
return desired; return desired;
} }
List<Block> substitutes = substitutions.get(desiredBlock); List<Block> substitutes = substitutions.get(desiredBlock);
if (substitutes.contains(current.getBlock()) && !(current.getBlock() instanceof BlockAir)) {// don't preserve air, it's almost always there and almost never wanted if (substitutes.contains(current.getBlock()) && !(current.getBlock() instanceof AirBlock)) {// don't preserve air, it's almost always there and almost never wanted
return withBlock(desired, current.getBlock()); return withBlock(desired, current.getBlock());
} }
for (Block substitute : substitutes) { for (Block substitute : substitutes) {
if (substitute instanceof BlockAir) { if (substitute instanceof AirBlock) {
return current.getBlock() instanceof BlockAir ? current : Blocks.AIR.getDefaultState(); // can always "place" air return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.defaultBlockState(); // can always "place" air
} }
for (IBlockState placeable : approxPlaceable) { for (BlockState placeable : approxPlaceable) {
if (substitute.equals(placeable.getBlock())) { if (substitute.equals(placeable.getBlock())) {
return withBlock(desired, placeable.getBlock()); return withBlock(desired, placeable.getBlock());
} }
} }
} }
return substitutes.get(0).getDefaultState(); return substitutes.get(0).defaultBlockState();
} }
private IBlockState withBlock(IBlockState state, Block block) { private BlockState withBlock(BlockState state, Block block) {
if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) { if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) {
return blockStateCache.get(state).get(block); return blockStateCache.get(state).get(block);
} }
Collection<IProperty<?>> properties = state.getPropertyKeys(); Collection<Property<?>> properties = state.getProperties();
IBlockState newState = block.getDefaultState(); BlockState newState = block.defaultBlockState();
for (IProperty<?> property : properties) { for (Property<?> property : properties) {
try { try {
newState = copySingleProp(state, newState, property); newState = copySingleProp(state, newState, property);
} catch (IllegalArgumentException e) { //property does not exist for target block } catch (IllegalArgumentException e) { //property does not exist for target block
} }
} }
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, IBlockState>()).put(block, newState); blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, BlockState>()).put(block, newState);
return newState; return newState;
} }
private <T extends Comparable<T>> IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty<T> prop) { private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
return toState.withProperty(prop, fromState.getValue(prop)); return toState.setValue(prop, fromState.getValue(prop));
} }
} }

View File

@@ -17,7 +17,7 @@
package baritone.api.schematic; package baritone.api.schematic;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
public class WallsSchematic extends MaskSchematic { public class WallsSchematic extends MaskSchematic {
@@ -26,7 +26,7 @@ public class WallsSchematic extends MaskSchematic {
} }
@Override @Override
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, BlockState currentState) {
return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1; return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1;
} }
} }

View File

@@ -20,7 +20,7 @@ package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask; import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask; import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators; import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
/** /**
* @author Brady * @author Brady
@@ -34,7 +34,7 @@ public interface Mask {
* @param currentState The current state of that block in the world, may be {@code null} * @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 * @return Whether the given position is included in this mask
*/ */
boolean partOfMask(int x, int y, int z, IBlockState currentState); boolean partOfMask(int x, int y, int z, BlockState currentState);
int widthX(); int widthX();

View File

@@ -20,7 +20,7 @@ package baritone.api.schematic.mask;
import baritone.api.schematic.mask.operator.BinaryOperatorMask; import baritone.api.schematic.mask.operator.BinaryOperatorMask;
import baritone.api.schematic.mask.operator.NotMask; import baritone.api.schematic.mask.operator.NotMask;
import baritone.api.utils.BooleanBinaryOperators; import baritone.api.utils.BooleanBinaryOperators;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
/** /**
* A mask that is context-free. In other words, it doesn't require the current block state to determine if a relative * A mask that is context-free. In other words, it doesn't require the current block state to determine if a relative
@@ -42,7 +42,7 @@ public interface StaticMask extends Mask {
/** /**
* Implements the parent {@link Mask#partOfMask partOfMask function} by calling the static function * Implements the parent {@link Mask#partOfMask partOfMask function} by calling the static function
* provided in this functional interface without needing the {@link IBlockState} argument. This {@code default} * provided in this functional interface without needing the {@link BlockState} argument. This {@code default}
* implementation should <b><u>NOT</u></b> be overriden. * implementation should <b><u>NOT</u></b> be overriden.
* *
* @param x The relative x position of the block * @param x The relative x position of the block
@@ -52,7 +52,7 @@ public interface StaticMask extends Mask {
* @return Whether the given position is included in this mask * @return Whether the given position is included in this mask
*/ */
@Override @Override
default boolean partOfMask(int x, int y, int z, IBlockState currentState) { default boolean partOfMask(int x, int y, int z, BlockState currentState) {
return this.partOfMask(x, y, z); return this.partOfMask(x, y, z);
} }

View File

@@ -21,7 +21,7 @@ import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask; import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask; import baritone.api.schematic.mask.StaticMask;
import baritone.api.utils.BooleanBinaryOperator; import baritone.api.utils.BooleanBinaryOperator;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
/** /**
* @author Brady * @author Brady
@@ -40,14 +40,14 @@ public final class BinaryOperatorMask extends AbstractMask {
} }
@Override @Override
public boolean partOfMask(int x, int y, int z, IBlockState currentState) { public boolean partOfMask(int x, int y, int z, BlockState currentState) {
return this.operator.applyAsBoolean( return this.operator.applyAsBoolean(
partOfMask(a, x, y, z, currentState), partOfMask(a, x, y, z, currentState),
partOfMask(b, x, y, z, currentState) partOfMask(b, x, y, z, currentState)
); );
} }
private static boolean partOfMask(Mask mask, int x, int y, int z, IBlockState 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); return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z, currentState);
} }

View File

@@ -20,7 +20,7 @@ package baritone.api.schematic.mask.operator;
import baritone.api.schematic.mask.AbstractMask; import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.Mask; import baritone.api.schematic.mask.Mask;
import baritone.api.schematic.mask.StaticMask; import baritone.api.schematic.mask.StaticMask;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.state.BlockState;
/** /**
* @author Brady * @author Brady
@@ -35,7 +35,7 @@ public final class NotMask extends AbstractMask {
} }
@Override @Override
public boolean partOfMask(int x, int y, int z, IBlockState currentState) { public boolean partOfMask(int x, int y, int z, BlockState currentState) {
return !this.source.partOfMask(x, y, z, currentState); return !this.source.partOfMask(x, y, z, currentState);
} }

View File

@@ -19,7 +19,7 @@ package baritone.api.schematic.mask.shape;
import baritone.api.schematic.mask.AbstractMask; import baritone.api.schematic.mask.AbstractMask;
import baritone.api.schematic.mask.StaticMask; import baritone.api.schematic.mask.StaticMask;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Direction;
/** /**
* @author Brady * @author Brady
@@ -31,9 +31,9 @@ public final class CylinderMask extends AbstractMask implements StaticMask {
private final double radiusSqA; private final double radiusSqA;
private final double radiusSqB; private final double radiusSqB;
private final boolean filled; private final boolean filled;
private final EnumFacing.Axis alignment; private final Direction.Axis alignment;
public CylinderMask(int widthX, int heightY, int lengthZ, boolean filled, EnumFacing.Axis alignment) { public CylinderMask(int widthX, int heightY, int lengthZ, boolean filled, Direction.Axis alignment) {
super(widthX, heightY, lengthZ); super(widthX, heightY, lengthZ);
this.centerA = this.getA(widthX, heightY, alignment) / 2.0; this.centerA = this.getA(widthX, heightY, alignment) / 2.0;
this.centerB = this.getB(heightY, lengthZ, alignment) / 2.0; this.centerB = this.getB(heightY, lengthZ, alignment) / 2.0;
@@ -59,11 +59,11 @@ public final class CylinderMask extends AbstractMask implements StaticMask {
return da * da / this.radiusSqA + db * db / this.radiusSqB > 1; return da * da / this.radiusSqA + db * db / this.radiusSqB > 1;
} }
private static int getA(int x, int y, EnumFacing.Axis alignment) { private static int getA(int x, int y, Direction.Axis alignment) {
return alignment == EnumFacing.Axis.X ? y : x; return alignment == Direction.Axis.X ? y : x;
} }
private static int getB(int y, int z, EnumFacing.Axis alignment) { private static int getB(int y, int z, Direction.Axis alignment) {
return alignment == EnumFacing.Axis.Z ? y : z; return alignment == Direction.Axis.Z ? y : z;
} }
} }

View File

@@ -18,9 +18,9 @@
package baritone.api.selection; package baritone.api.selection;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Direction;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.core.Vec3i;
import net.minecraft.util.math.Vec3i; import net.minecraft.world.phys.AABB;
/** /**
* A selection is an immutable object representing the current selection. The selection is commonly used for certain * A selection is an immutable object representing the current selection. The selection is commonly used for certain
@@ -54,9 +54,9 @@ public interface ISelection {
Vec3i 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. * Returns a new {@link ISelection} expanded in the specified direction by the specified number of blocks.
@@ -65,7 +65,7 @@ public interface ISelection {
* @param blocks How many blocks to expand it. * @param blocks How many blocks to expand it.
* @return A new selection, expanded as specified. * @return A new selection, expanded as specified.
*/ */
ISelection expand(EnumFacing direction, int blocks); ISelection expand(Direction direction, int blocks);
/** /**
* Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks. * Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
@@ -77,7 +77,7 @@ public interface ISelection {
* @param blocks How many blocks to contract it. * @param blocks How many blocks to contract it.
* @return A new selection, contracted as specified. * @return A new selection, contracted as specified.
*/ */
ISelection contract(EnumFacing direction, int blocks); ISelection contract(Direction direction, int blocks);
/** /**
* Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves * Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves
@@ -87,5 +87,5 @@ public interface ISelection {
* @param blocks How many blocks to shift it. * @param blocks How many blocks to shift it.
* @return A new selection, shifted as specified. * @return A new selection, shifted as specified.
*/ */
ISelection shift(EnumFacing direction, int blocks); ISelection shift(Direction direction, int blocks);
} }

View File

@@ -18,7 +18,7 @@
package baritone.api.selection; package baritone.api.selection;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Direction;
/** /**
* The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving * The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving
@@ -87,7 +87,7 @@ public interface ISelectionManager {
* @param blocks How many blocks to expand it. * @param blocks How many blocks to expand it.
* @return The new selection, expanded as specified. * @return The new selection, expanded as specified.
*/ */
ISelection expand(ISelection selection, EnumFacing direction, int blocks); ISelection expand(ISelection selection, Direction direction, int blocks);
/** /**
* Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number * Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
@@ -101,7 +101,7 @@ public interface ISelectionManager {
* @param blocks How many blocks to contract it. * @param blocks How many blocks to contract it.
* @return The new selection, contracted as specified. * @return The new selection, contracted as specified.
*/ */
ISelection contract(ISelection selection, EnumFacing direction, int blocks); ISelection contract(ISelection selection, Direction direction, int blocks);
/** /**
* Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of * Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of
@@ -112,5 +112,5 @@ public interface ISelectionManager {
* @param blocks How many blocks to shift it. * @param blocks How many blocks to shift it.
* @return The new selection, shifted as specified. * @return The new selection, shifted as specified.
*/ */
ISelection shift(ISelection selection, EnumFacing direction, int blocks); ISelection shift(ISelection selection, Direction direction, int blocks);
} }

View File

@@ -17,12 +17,11 @@
package baritone.api.utils; package baritone.api.utils;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import javax.annotation.Nonnull; 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) * A better BlockPos that has fewer hash collisions (and slightly more performant offsets)
@@ -35,15 +34,6 @@ import javax.annotation.Nonnull;
*/ */
public final class BetterBlockPos extends BlockPos { public final class BetterBlockPos extends BlockPos {
private static final int NUM_X_BITS = 26;
private static final int NUM_Z_BITS = NUM_X_BITS;
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
private static final int Y_SHIFT = NUM_Z_BITS;
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0); public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0);
public final int x; public final int x;
@@ -58,7 +48,7 @@ public final class BetterBlockPos extends BlockPos {
} }
public BetterBlockPos(double x, double y, double z) { 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) { public BetterBlockPos(BlockPos pos) {
@@ -125,49 +115,49 @@ public final class BetterBlockPos extends BlockPos {
} }
@Override @Override
public BetterBlockPos up() { public BetterBlockPos above() {
// this is unimaginably faster than blockpos.up // this is unimaginably faster than blockpos.up
// that literally calls // that literally calls
// this.up(1) // this.up(1)
// which calls this.offset(EnumFacing.UP, 1) // which calls this.offset(Direction.UP, 1)
// which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n); // which does return n == 0 ? this : new BlockPos(this.getX() + facing.getXOffset() * n, this.getY() + facing.getYOffset() * n, this.getZ() + facing.getZOffset() * n);
// how many function calls is that? up(), up(int), offset(EnumFacing, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset // how many function calls is that? up(), up(int), offset(Direction, int), new BlockPos, getX, getXOffset, getY, getYOffset, getZ, getZOffset
// that's ten. // that's ten.
// this is one function call. // this is one function call.
return new BetterBlockPos(x, y + 1, z); return new BetterBlockPos(x, y + 1, z);
} }
@Override @Override
public BetterBlockPos up(int amt) { public BetterBlockPos above(int amt) {
// see comment in up() // see comment in up()
return amt == 0 ? this : new BetterBlockPos(x, y + amt, z); return amt == 0 ? this : new BetterBlockPos(x, y + amt, z);
} }
@Override @Override
public BetterBlockPos down() { public BetterBlockPos below() {
// see comment in up() // see comment in up()
return new BetterBlockPos(x, y - 1, z); return new BetterBlockPos(x, y - 1, z);
} }
@Override @Override
public BetterBlockPos down(int amt) { public BetterBlockPos below(int amt) {
// see comment in up() // see comment in up()
return amt == 0 ? this : new BetterBlockPos(x, y - amt, z); return amt == 0 ? this : new BetterBlockPos(x, y - amt, z);
} }
@Override @Override
public BetterBlockPos offset(EnumFacing dir) { public BetterBlockPos relative(Direction dir) {
Vec3i vec = dir.getDirectionVec(); Vec3i vec = dir.getNormal();
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ()); return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
} }
@Override @Override
public BetterBlockPos offset(EnumFacing dir, int dist) { public BetterBlockPos relative(Direction dir, int dist) {
if (dist == 0) { if (dist == 0) {
return this; return this;
} }
Vec3i vec = dir.getDirectionVec(); Vec3i vec = dir.getNormal();
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
} }
@@ -211,20 +201,6 @@ public final class BetterBlockPos extends BlockPos {
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z); return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
} }
public double distanceSq(final BetterBlockPos to) {
double dx = (double) this.x - to.x;
double dy = (double) this.y - to.y;
double dz = (double) this.z - to.z;
return dx * dx + dy * dy + dz * dz;
}
public double distanceTo(final BetterBlockPos to) {
double dx = (double) this.x - to.x;
double dy = (double) this.y - to.y;
double dz = (double) this.z - to.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
@Override @Override
@Nonnull @Nonnull
public String toString() { public String toString() {
@@ -235,15 +211,4 @@ public final class BetterBlockPos extends BlockPos {
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }
public static long serializeToLong(final int x, final int y, final int z) {
return ((long) x & X_MASK) << X_SHIFT | ((long) y & Y_MASK) << Y_SHIFT | ((long) z & Z_MASK);
}
public static BetterBlockPos deserializeFromLong(final long serialized) {
final int x = (int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
final int y = (int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
final int z = (int) (serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
return new BetterBlockPos(x, y, z);
}
} }

View File

@@ -18,49 +18,62 @@
package baritone.api.utils; package baritone.api.utils;
import baritone.api.utils.accessor.IItemStack; import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.minecraft.block.*; import com.google.common.collect.ImmutableSet;
import net.minecraft.block.properties.IProperty; import io.netty.util.concurrent.ThreadPerTaskExecutor;
import net.minecraft.block.state.IBlockState; import net.minecraft.core.BlockPos;
import net.minecraft.item.ItemStack; import net.minecraft.resources.*;
import net.minecraft.util.EnumFacing; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ResourceLocation; 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.Unit;
import net.minecraft.world.level.block.state.properties.Property;
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 javax.annotation.Nonnull;
import javax.annotation.Nullable; import java.util.ArrayList;
import java.util.*; import java.util.Collections;
import java.util.function.Consumer; import java.util.HashMap;
import java.util.regex.MatchResult; import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public final class BlockOptionalMeta { public final class BlockOptionalMeta {
// id:meta or id[] or id[properties] where id and properties are any text with at least one character and meta is a one or two digit number // 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>.+?)(?::(?<meta>\\d\\d?)|\\[(?<properties>.+?)?\\])?$"); private static final Pattern PATTERN = Pattern.compile("^(?<id>.+?)(?:\\[(?<properties>.+?)?\\])?$");
private final Block block; private final Block block;
private final int meta;
private final boolean noMeta;
private final String propertiesDescription; // exists so toString() can return something more useful than a list of all blockstates private final String propertiesDescription; // exists so toString() can return something more useful than a list of all blockstates
private final Set<IBlockState> blockstates; private final Set<BlockState> blockstates;
private final Set<Integer> stateHashes; private final Set<Integer> stateHashes;
private final Set<Integer> stackHashes; private final Set<Integer> stackHashes;
private static final Map<Object, Object> normalizations; private static LootTables manager;
private static PredicateManager predicate = new PredicateManager();
public BlockOptionalMeta(@Nonnull Block block, @Nullable Integer meta) { private static Map<Block, List<Item>> drops = new HashMap<>();
this.block = block;
this.noMeta = meta == null;
this.meta = noMeta ? 0 : meta;
this.propertiesDescription = "{}";
this.blockstates = getStates(block, meta, Collections.emptyMap());
this.stateHashes = getStateHashes(blockstates);
this.stackHashes = getStackHashes(blockstates);
}
public BlockOptionalMeta(@Nonnull Block block) { public BlockOptionalMeta(@Nonnull Block block) {
this(block, null); this.block = block;
this.propertiesDescription = "{}";
this.blockstates = getStates(block, Collections.emptyMap());
this.stateHashes = getStateHashes(blockstates);
this.stackHashes = getStackHashes(blockstates);
} }
public BlockOptionalMeta(@Nonnull String selector) { public BlockOptionalMeta(@Nonnull String selector) {
@@ -70,188 +83,24 @@ public final class BlockOptionalMeta {
throw new IllegalArgumentException("invalid block selector"); throw new IllegalArgumentException("invalid block selector");
} }
noMeta = matcher.group("meta") == null; block = BlockUtils.stringToBlockRequired(matcher.group("id"));
ResourceLocation id = new ResourceLocation(matcher.group("id"));
if (!Block.REGISTRY.containsKey(id)) {
throw new IllegalArgumentException("Invalid block ID");
}
block = Block.REGISTRY.getObject(id);
String props = matcher.group("properties"); String props = matcher.group("properties");
Map<IProperty<?>, ?> properties = props == null || props.equals("") ? Collections.emptyMap() : parseProperties(block, props); Map<Property<?>, ?> properties = props == null || props.equals("") ? Collections.emptyMap() : parseProperties(block, props);
propertiesDescription = props == null ? "{}" : "{" + props.replace("=", ":") + "}"; propertiesDescription = props == null ? "{}" : "{" + props.replace("=", ":") + "}";
meta = noMeta ? 0 : Integer.parseInt(matcher.group("meta")); blockstates = getStates(block, properties);
blockstates = getStates(block, getMeta(), properties);
stateHashes = getStateHashes(blockstates); stateHashes = getStateHashes(blockstates);
stackHashes = getStackHashes(blockstates); stackHashes = getStackHashes(blockstates);
} }
static { private static <C extends Comparable<C>, P extends Property<C>> P castToIProperty(Object value) {
Map<Object, Object> _normalizations = new HashMap<>();
Consumer<Enum> put = instance -> _normalizations.put(instance.getClass(), instance);
put.accept(EnumFacing.NORTH);
put.accept(EnumFacing.Axis.Y);
put.accept(BlockLog.EnumAxis.Y);
put.accept(BlockStairs.EnumHalf.BOTTOM);
put.accept(BlockStairs.EnumShape.STRAIGHT);
put.accept(BlockLever.EnumOrientation.DOWN_X);
put.accept(BlockDoublePlant.EnumBlockHalf.LOWER);
put.accept(BlockSlab.EnumBlockHalf.BOTTOM);
put.accept(BlockDoor.EnumDoorHalf.LOWER);
put.accept(BlockDoor.EnumHingePosition.LEFT);
put.accept(BlockBed.EnumPartType.HEAD);
put.accept(BlockRailBase.EnumRailDirection.NORTH_SOUTH);
put.accept(BlockTrapDoor.DoorHalf.BOTTOM);
_normalizations.put(BlockBanner.ROTATION, 0);
_normalizations.put(BlockBed.OCCUPIED, false);
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[0], false);
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[1], false);
_normalizations.put(BlockBrewingStand.HAS_BOTTLE[2], false);
_normalizations.put(BlockButton.POWERED, false);
// _normalizations.put(BlockCactus.AGE, 0);
// _normalizations.put(BlockCauldron.LEVEL, 0);
// _normalizations.put(BlockChorusFlower.AGE, 0);
_normalizations.put(BlockChorusPlant.NORTH, false);
_normalizations.put(BlockChorusPlant.EAST, false);
_normalizations.put(BlockChorusPlant.SOUTH, false);
_normalizations.put(BlockChorusPlant.WEST, false);
_normalizations.put(BlockChorusPlant.UP, false);
_normalizations.put(BlockChorusPlant.DOWN, false);
// _normalizations.put(BlockCocoa.AGE, 0);
// _normalizations.put(BlockCrops.AGE, 0);
_normalizations.put(BlockDirt.SNOWY, false);
_normalizations.put(BlockDoor.OPEN, false);
_normalizations.put(BlockDoor.POWERED, false);
// _normalizations.put(BlockFarmland.MOISTURE, 0);
_normalizations.put(BlockFence.NORTH, false);
_normalizations.put(BlockFence.EAST, false);
_normalizations.put(BlockFence.WEST, false);
_normalizations.put(BlockFence.SOUTH, false);
// _normalizations.put(BlockFenceGate.POWERED, false);
// _normalizations.put(BlockFenceGate.IN_WALL, false);
_normalizations.put(BlockFire.AGE, 0);
_normalizations.put(BlockFire.NORTH, false);
_normalizations.put(BlockFire.EAST, false);
_normalizations.put(BlockFire.SOUTH, false);
_normalizations.put(BlockFire.WEST, false);
_normalizations.put(BlockFire.UPPER, false);
// _normalizations.put(BlockFrostedIce.AGE, 0);
_normalizations.put(BlockGrass.SNOWY, false);
// _normalizations.put(BlockHopper.ENABLED, true);
// _normalizations.put(BlockLever.POWERED, false);
// _normalizations.put(BlockLiquid.LEVEL, 0);
// _normalizations.put(BlockMycelium.SNOWY, false);
// _normalizations.put(BlockNetherWart.AGE, false);
_normalizations.put(BlockLeaves.CHECK_DECAY, false);
// _normalizations.put(BlockLeaves.DECAYABLE, false);
// _normalizations.put(BlockObserver.POWERED, false);
_normalizations.put(BlockPane.NORTH, false);
_normalizations.put(BlockPane.EAST, false);
_normalizations.put(BlockPane.WEST, false);
_normalizations.put(BlockPane.SOUTH, false);
// _normalizations.put(BlockPistonBase.EXTENDED, false);
// _normalizations.put(BlockPressurePlate.POWERED, false);
// _normalizations.put(BlockPressurePlateWeighted.POWER, false);
_normalizations.put(BlockQuartz.EnumType.LINES_X, BlockQuartz.EnumType.LINES_Y);
_normalizations.put(BlockQuartz.EnumType.LINES_Z, BlockQuartz.EnumType.LINES_Y);
// _normalizations.put(BlockRailDetector.POWERED, false);
// _normalizations.put(BlockRailPowered.POWERED, false);
_normalizations.put(BlockRedstoneWire.NORTH, false);
_normalizations.put(BlockRedstoneWire.EAST, false);
_normalizations.put(BlockRedstoneWire.SOUTH, false);
_normalizations.put(BlockRedstoneWire.WEST, false);
// _normalizations.put(BlockReed.AGE, false);
_normalizations.put(BlockSapling.STAGE, 0);
_normalizations.put(BlockSkull.NODROP, false);
_normalizations.put(BlockStandingSign.ROTATION, 0);
_normalizations.put(BlockStem.AGE, 0);
_normalizations.put(BlockTripWire.NORTH, false);
_normalizations.put(BlockTripWire.EAST, false);
_normalizations.put(BlockTripWire.WEST, false);
_normalizations.put(BlockTripWire.SOUTH, false);
_normalizations.put(BlockVine.NORTH, false);
_normalizations.put(BlockVine.EAST, false);
_normalizations.put(BlockVine.SOUTH, false);
_normalizations.put(BlockVine.WEST, false);
_normalizations.put(BlockVine.UP, false);
_normalizations.put(BlockWall.UP, false);
_normalizations.put(BlockWall.NORTH, false);
_normalizations.put(BlockWall.EAST, false);
_normalizations.put(BlockWall.WEST, false);
_normalizations.put(BlockWall.SOUTH, false);
normalizations = Collections.unmodifiableMap(_normalizations);
}
public static <C extends Comparable<C>, P extends IProperty<C>> P castToIProperty(Object value) {
//noinspection unchecked //noinspection unchecked
return (P) value; return (P) value;
} }
public static <C extends Comparable<C>, P extends IProperty<C>> C castToIPropertyValue(P iproperty, Object value) { private static Map<Property<?>, ?> parseProperties(Block block, String raw) {
//noinspection unchecked ImmutableMap.Builder<Property<?>, Object> builder = ImmutableMap.builder();
return (C) value;
}
/**
* Normalizes the specified blockstate by setting meta-affecting properties which
* are not being targeted by the meta parameter to their default values.
* <p>
* For example, block variant/color is the primary target for the meta value, so properties
* such as rotation/facing direction will be set to default values in order to nullify
* the effect that they have on the state's meta value.
*
* @param state The state to normalize
* @return The normalized block state
*/
public static IBlockState normalize(IBlockState state) {
IBlockState newState = state;
for (IProperty<?> property : state.getProperties().keySet()) {
Class<?> valueClass = property.getValueClass();
if (normalizations.containsKey(property)) {
try {
newState = newState.withProperty(
castToIProperty(property),
castToIPropertyValue(property, normalizations.get(property))
);
} catch (IllegalArgumentException ignored) {}
} else if (normalizations.containsKey(state.getValue(property))) {
try {
newState = newState.withProperty(
castToIProperty(property),
castToIPropertyValue(property, normalizations.get(state.getValue(property)))
);
} catch (IllegalArgumentException ignored) {}
} else if (normalizations.containsKey(valueClass)) {
try {
newState = newState.withProperty(
castToIProperty(property),
castToIPropertyValue(property, normalizations.get(valueClass))
);
} catch (IllegalArgumentException ignored) {}
}
}
return newState;
}
/**
* Evaluate the target meta value for the specified state. The target meta value is
* most often that which is influenced by the variant/color property of the block state.
*
* @param state The state to check
* @return The target meta of the state
* @see #normalize(IBlockState)
*/
public static int stateMeta(IBlockState state) {
return state.getBlock().getMetaFromState(normalize(state));
}
private static Map<IProperty<?>, ?> parseProperties(Block block, String raw) {
ImmutableMap.Builder<IProperty<?>, Object> builder = ImmutableMap.builder();
for (String pair : raw.split(",")) { for (String pair : raw.split(",")) {
String[] parts = pair.split("="); String[] parts = pair.split("=");
if (parts.length != 2) { if (parts.length != 2) {
@@ -259,9 +108,9 @@ public final class BlockOptionalMeta {
} }
String rawKey = parts[0]; String rawKey = parts[0];
String rawValue = parts[1]; String rawValue = parts[1];
IProperty<?> key = block.getBlockState().getProperty(rawKey); Property<?> key = block.getStateDefinition().getProperty(rawKey);
Comparable<?> value = castToIProperty(key).parseValue(rawValue) Comparable<?> value = castToIProperty(key).getValue(rawValue)
.toJavaUtil().orElseThrow(() -> new IllegalArgumentException(String.format( .orElseThrow(() -> new IllegalArgumentException(String.format(
"\"%s\" is not a valid value for %s on %s", "\"%s\" is not a valid value for %s on %s",
rawValue, key, block rawValue, key, block
))); )));
@@ -270,31 +119,30 @@ public final class BlockOptionalMeta {
return builder.build(); return builder.build();
} }
private static Set<IBlockState> getStates(@Nonnull Block block, @Nullable Integer meta, @Nonnull Map<IProperty<?>, ?> properties) { private static Set<BlockState> getStates(@Nonnull Block block, @Nonnull Map<Property<?>, ?> properties) {
return block.getBlockState().getValidStates().stream() return block.getStateDefinition().getPossibleStates().stream()
.filter(blockstate -> meta == null || stateMeta(blockstate) == meta)
.filter(blockstate -> properties.entrySet().stream().allMatch(entry -> .filter(blockstate -> properties.entrySet().stream().allMatch(entry ->
blockstate.getValue(entry.getKey()) == entry.getValue() blockstate.getValue(entry.getKey()) == entry.getValue()
)) ))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
private static ImmutableSet<Integer> getStateHashes(Set<IBlockState> blockstates) { private static ImmutableSet<Integer> getStateHashes(Set<BlockState> blockstates) {
return ImmutableSet.copyOf( return ImmutableSet.copyOf(
blockstates.stream() blockstates.stream()
.map(IBlockState::hashCode) .map(BlockState::hashCode)
.toArray(Integer[]::new) .toArray(Integer[]::new)
); );
} }
private static ImmutableSet<Integer> getStackHashes(Set<IBlockState> blockstates) { private static ImmutableSet<Integer> getStackHashes(Set<BlockState> blockstates) {
//noinspection ConstantConditions //noinspection ConstantConditions
return ImmutableSet.copyOf( return ImmutableSet.copyOf(
blockstates.stream() blockstates.stream()
.map(state -> new ItemStack( .flatMap(state -> drops(state.getBlock())
state.getBlock().getItemDropped(state, new Random(), 0), .stream()
state.getBlock().damageDropped(state) .map(item -> new ItemStack(item, 1))
)) )
.map(stack -> ((IItemStack) (Object) stack).getBaritoneHash()) .map(stack -> ((IItemStack) (Object) stack).getBaritoneHash())
.toArray(Integer[]::new) .toArray(Integer[]::new)
); );
@@ -304,16 +152,11 @@ public final class BlockOptionalMeta {
return block; return block;
} }
@Deprecated // deprecated because getMeta() == null no longer implies that this BOM only cares about the block
public Integer getMeta() {
return noMeta ? null : meta;
}
public boolean matches(@Nonnull Block block) { public boolean matches(@Nonnull Block block) {
return block == this.block; return block == this.block;
} }
public boolean matches(@Nonnull IBlockState blockstate) { public boolean matches(@Nonnull BlockState blockstate) {
Block block = blockstate.getBlock(); Block block = blockstate.getBlock();
return block == this.block && stateHashes.contains(blockstate.hashCode()); return block == this.block && stateHashes.contains(blockstate.hashCode());
} }
@@ -322,28 +165,17 @@ public final class BlockOptionalMeta {
//noinspection ConstantConditions //noinspection ConstantConditions
int hash = ((IItemStack) (Object) stack).getBaritoneHash(); int hash = ((IItemStack) (Object) stack).getBaritoneHash();
if (noMeta) { hash -= stack.getDamageValue();
hash -= stack.getItemDamage();
}
return stackHashes.contains(hash); return stackHashes.contains(hash);
} }
@Override @Override
public String toString() { public String toString() {
if (noMeta) { return String.format("BlockOptionalMeta{block=%s,properties=%s}", block, propertiesDescription);
return String.format("BlockOptionalMeta{block=%s,properties=%s}", block, propertiesDescription);
} else {
return String.format("BlockOptionalMeta{block=%s,meta=%s}", block, getMeta());
}
} }
public static IBlockState blockStateFromStack(ItemStack stack) { public BlockState getAnyBlockState() {
//noinspection deprecation
return Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata());
}
public IBlockState getAnyBlockState() {
if (blockstates.size() > 0) { if (blockstates.size() > 0) {
return blockstates.iterator().next(); return blockstates.iterator().next();
} }
@@ -351,11 +183,56 @@ public final class BlockOptionalMeta {
return null; return null;
} }
public Set<IBlockState> getAllBlockStates() { public Set<BlockState> getAllBlockStates() {
return blockstates; return blockstates;
} }
public Set<Integer> stackHashes() { public Set<Integer> stackHashes() {
return stackHashes; return stackHashes;
} }
public static LootTables getManager() {
if (manager == null) {
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.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);
}
}
return manager;
}
public static PredicateManager getPredicateManager() {
return predicate;
}
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
ResourceLocation lootTableLocation = block.getLootTable();
if (lootTableLocation == BuiltInLootTables.EMPTY) {
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().get(lootTableLocation).getRandomItems(
new LootContext.Builder((ServerLevel) null)
.withRandom(new Random())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK),
stack -> items.add(stack.getItem())
);
return items;
}
});
}
} }

View File

@@ -19,9 +19,9 @@ package baritone.api.utils;
import baritone.api.utils.accessor.IItemStack; import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block; import net.minecraft.world.item.ItemStack;
import net.minecraft.block.state.IBlockState; import net.minecraft.world.level.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.world.level.block.state.BlockState;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@@ -31,14 +31,14 @@ import java.util.stream.Stream;
public class BlockOptionalMetaLookup { public class BlockOptionalMetaLookup {
private final ImmutableSet<Block> blockSet; private final ImmutableSet<Block> blockSet;
private final ImmutableSet<IBlockState> blockStateSet; private final ImmutableSet<BlockState> blockStateSet;
private final ImmutableSet<Integer> stackHashes; private final ImmutableSet<Integer> stackHashes;
private final BlockOptionalMeta[] boms; private final BlockOptionalMeta[] boms;
public BlockOptionalMetaLookup(BlockOptionalMeta... boms) { public BlockOptionalMetaLookup(BlockOptionalMeta... boms) {
this.boms = boms; this.boms = boms;
Set<Block> blocks = new HashSet<>(); Set<Block> blocks = new HashSet<>();
Set<IBlockState> blockStates = new HashSet<>(); Set<BlockState> blockStates = new HashSet<>();
Set<Integer> stacks = new HashSet<>(); Set<Integer> stacks = new HashSet<>();
for (BlockOptionalMeta bom : boms) { for (BlockOptionalMeta bom : boms) {
blocks.add(bom.getBlock()); blocks.add(bom.getBlock());
@@ -73,14 +73,14 @@ public class BlockOptionalMetaLookup {
return blockSet.contains(block); return blockSet.contains(block);
} }
public boolean has(IBlockState state) { public boolean has(BlockState state) {
return blockStateSet.contains(state); return blockStateSet.contains(state);
} }
public boolean has(ItemStack stack) { public boolean has(ItemStack stack) {
int hash = ((IItemStack) (Object) stack).getBaritoneHash(); int hash = ((IItemStack) (Object) stack).getBaritoneHash();
return stackHashes.contains(hash) hash -= stack.getDamageValue();
|| stackHashes.contains(hash - stack.getItemDamage()); return stackHashes.contains(hash);
} }
public List<BlockOptionalMeta> blocks() { public List<BlockOptionalMeta> blocks() {

View File

@@ -17,18 +17,18 @@
package baritone.api.utils; package baritone.api.utils;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
public class BlockUtils { public class BlockUtils {
private static transient Map<String, Block> resourceCache = new HashMap<>(); private static transient Map<String, Block> resourceCache = new HashMap<>();
public static String blockToString(Block block) { public static String blockToString(Block block) {
ResourceLocation loc = Block.REGISTRY.getNameForObject(block); ResourceLocation loc = Registry.BLOCK.getKey(block);
String name = loc.getPath(); // normally, only write the part after the minecraft: String name = loc.getPath(); // normally, only write the part after the minecraft:
if (!loc.getNamespace().equals("minecraft")) { if (!loc.getNamespace().equals("minecraft")) {
// Baritone is running on top of forge with mods installed, perhaps? // Baritone is running on top of forge with mods installed, perhaps?
@@ -56,7 +56,7 @@ public class BlockUtils {
if (resourceCache.containsKey(name)) { if (resourceCache.containsKey(name)) {
return null; // cached as null return null; // cached as null
} }
block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name); block = Registry.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block); copy.put(name, block);
resourceCache = copy; resourceCache = copy;

View File

@@ -18,11 +18,12 @@
package baritone.api.utils; package baritone.api.utils;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ITextComponent; import net.minecraft.network.chat.BaseComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.network.chat.Component;
import net.minecraft.util.text.TextFormatting; import net.minecraft.network.chat.TextComponent;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -42,25 +43,25 @@ public interface Helper {
Helper HELPER = new Helper() {}; Helper HELPER = new Helper() {};
/** /**
* The main game instance returned by {@link Minecraft#getMinecraft()}. * The main game instance returned by {@link Minecraft#getInstance()}.
* Deprecated since {@link IPlayerContext#minecraft()} should be used instead (In the majority of cases). * Deprecated since {@link IPlayerContext#minecraft()} should be used instead (In the majority of cases).
*/ */
@Deprecated @Deprecated
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getInstance();
static ITextComponent getPrefix() { static Component getPrefix() {
// Inner text component // Inner text component
final Calendar now = Calendar.getInstance(); final Calendar now = Calendar.getInstance();
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3; final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
ITextComponent baritone = new TextComponentString(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone"); BaseComponent baritone = new TextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE); baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
// Outer brackets // Outer brackets
ITextComponent prefix = new TextComponentString(""); BaseComponent prefix = new TextComponent("");
prefix.getStyle().setColor(TextFormatting.DARK_PURPLE); prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
prefix.appendText("["); prefix.append("[");
prefix.appendSibling(baritone); prefix.append(baritone);
prefix.appendText("]"); prefix.append("]");
return prefix; return prefix;
} }
@@ -71,8 +72,8 @@ public interface Helper {
* @param title The title to display in the popup * @param title The title to display in the popup
* @param message The message to display in the popup * @param message The message to display in the popup
*/ */
default void logToast(ITextComponent title, ITextComponent message) { default void logToast(Component title, Component message) {
Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message)); Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message));
} }
/** /**
@@ -82,7 +83,7 @@ public interface Helper {
* @param message The message to display in the popup * @param message The message to display in the popup
*/ */
default void logToast(String title, String message) { default void logToast(String title, String message) {
logToast(new TextComponentString(title), new TextComponentString(message)); logToast(new TextComponent(title), new TextComponent(message));
} }
/** /**
@@ -91,7 +92,7 @@ public interface Helper {
* @param message The message to display in the popup * @param message The message to display in the popup
*/ */
default void logToast(String message) { default void logToast(String message) {
logToast(Helper.getPrefix(), new TextComponentString(message)); logToast(Helper.getPrefix(), new TextComponent(message));
} }
/** /**
@@ -133,7 +134,7 @@ public interface Helper {
* @param error Whether to log as an error * @param error Whether to log as an error
*/ */
default void logNotificationDirect(String message, boolean error) { default void logNotificationDirect(String message, boolean error) {
Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error)); Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error));
} }
/** /**
@@ -158,19 +159,15 @@ public interface Helper {
* @param logAsToast Whether to log as a toast notification * @param logAsToast Whether to log as a toast notification
* @param components The components to send * @param components The components to send
*/ */
default void logDirect(boolean logAsToast, ITextComponent... components) { default void logDirect(boolean logAsToast, Component... components) {
ITextComponent component = new TextComponentString(""); BaseComponent component = new TextComponent("");
if (!logAsToast) { component.append(getPrefix());
// If we are not logging as a Toast component.append(new TextComponent(" "));
// Append the prefix to the base component line Arrays.asList(components).forEach(component::append);
component.appendSibling(getPrefix());
component.appendSibling(new TextComponentString(" "));
}
Arrays.asList(components).forEach(component::appendSibling);
if (logAsToast) { if (logAsToast) {
logToast(getPrefix(), component); logToast(getPrefix(), component);
} else { } else {
Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component)); Minecraft.getInstance().execute(() -> BaritoneAPI.getSettings().logger.value.accept(component));
} }
} }
@@ -179,7 +176,7 @@ public interface Helper {
* *
* @param components The components to send * @param components The components to send
*/ */
default void logDirect(ITextComponent... components) { default void logDirect(Component... components) {
logDirect(BaritoneAPI.getSettings().logAsToast.value, components); logDirect(BaritoneAPI.getSettings().logAsToast.value, components);
} }
@@ -191,10 +188,10 @@ public interface Helper {
* @param color The color to print that message in * @param color The color to print that message in
* @param logAsToast Whether to log as a toast notification * @param logAsToast Whether to log as a toast notification
*/ */
default void logDirect(String message, TextFormatting color, boolean logAsToast) { default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
Stream.of(message.split("\n")).forEach(line -> { Stream.of(message.split("\n")).forEach(line -> {
ITextComponent component = new TextComponentString(line.replace("\t", " ")); BaseComponent component = new TextComponent(line.replace("\t", " "));
component.getStyle().setColor(color); component.setStyle(component.getStyle().withColor(color));
logDirect(logAsToast, component); logDirect(logAsToast, component);
}); });
} }
@@ -206,7 +203,7 @@ public interface Helper {
* @param message The message to display in chat * @param message The message to display in chat
* @param color The color to print that message in * @param color The color to print that message in
*/ */
default void logDirect(String message, TextFormatting color) { default void logDirect(String message, ChatFormatting color) {
logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value); logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value);
} }
@@ -218,7 +215,7 @@ public interface Helper {
* @param logAsToast Whether to log as a toast notification * @param logAsToast Whether to log as a toast notification
*/ */
default void logDirect(String message, boolean logAsToast) { default void logDirect(String message, boolean logAsToast) {
logDirect(message, TextFormatting.GRAY, logAsToast); logDirect(message, ChatFormatting.GRAY, logAsToast);
} }
/** /**
@@ -230,11 +227,4 @@ public interface Helper {
default void logDirect(String message) { default void logDirect(String message) {
logDirect(message, BaritoneAPI.getSettings().logAsToast.value); logDirect(message, BaritoneAPI.getSettings().logAsToast.value);
} }
default void logUnhandledException(final Throwable exception) {
HELPER.logDirect("An unhandled exception occurred. " +
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
TextFormatting.RED);
exception.printStackTrace();
}
} }

View File

@@ -18,15 +18,20 @@
package baritone.api.utils; package baritone.api.utils;
import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldData;
import net.minecraft.block.BlockSlab;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.util.math.BlockPos; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.entity.Entity;
import net.minecraft.world.World; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/** /**
* @author Brady * @author Brady
@@ -36,19 +41,28 @@ public interface IPlayerContext {
Minecraft minecraft(); Minecraft minecraft();
EntityPlayerSP player(); LocalPlayer player();
IPlayerController playerController(); IPlayerController playerController();
World world(); Level world();
default Iterable<Entity> entities() {
return ((ClientLevel) world()).entitiesForRendering();
}
default Stream<Entity> entitiesStream() {
return StreamSupport.stream(entities().spliterator(), false);
}
IWorldData worldData(); IWorldData worldData();
RayTraceResult objectMouseOver(); HitResult objectMouseOver();
default BetterBlockPos playerFeet() { default BetterBlockPos playerFeet() {
// TODO find a better way to deal with soul sand!!!!! // TODO find a better way to deal with soul sand!!!!!
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ); BetterBlockPos feet = new BetterBlockPos(player().position().x, player().position().y + 0.1251, player().position().z);
// sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException // sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException
// that causes the game to immediately crash // that causes the game to immediately crash
@@ -59,34 +73,30 @@ public interface IPlayerContext {
// this does not impact performance at all since we're not null checking constantly // this does not impact performance at all since we're not null checking constantly
// if there is an exception, the only overhead is Java generating the exception object... so we can ignore it // if there is an exception, the only overhead is Java generating the exception object... so we can ignore it
try { try {
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) { if (world().getBlockState(feet).getBlock() instanceof SlabBlock) {
return feet.up(); return feet.above();
} }
} catch (NullPointerException ignored) {} } catch (NullPointerException ignored) {}
return feet; return feet;
} }
default Vec3d playerFeetAsVec() { default Vec3 playerFeetAsVec() {
return new Vec3d(player().posX, player().posY, player().posZ); return new Vec3(player().position().x, player().position().y, player().position().z);
} }
default Vec3d playerHead() { default Vec3 playerHead() {
return new Vec3d(player().posX, player().posY + player().getEyeHeight(), player().posZ); return new Vec3(player().position().x, player().position().y + player().getEyeHeight(), player().position().z);
}
default Vec3d playerMotion() {
return new Vec3d(player().motionX, player().motionY, player().motionZ);
} }
BetterBlockPos viewerPos(); BetterBlockPos viewerPos();
default Rotation playerRotations() { default Rotation playerRotations() {
return new Rotation(player().rotationYaw, player().rotationPitch); return new Rotation(player().getYRot(), player().getXRot());
} }
static double eyeHeight(boolean ifSneaking) { static double eyeHeight(boolean ifSneaking) {
return ifSneaking ? 1.54 : 1.62; return ifSneaking ? 1.27 : 1.62;
} }
/** /**
@@ -95,9 +105,9 @@ public interface IPlayerContext {
* @return The position of the highlighted block * @return The position of the highlighted block
*/ */
default Optional<BlockPos> getSelectedBlock() { default Optional<BlockPos> getSelectedBlock() {
RayTraceResult result = objectMouseOver(); HitResult result = objectMouseOver();
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { if (result != null && result.getType() == HitResult.Type.BLOCK) {
return Optional.of(result.getBlockPos()); return Optional.of(((BlockHitResult) result).getBlockPos());
} }
return Optional.empty(); return Optional.empty();
} }

View File

@@ -18,17 +18,16 @@
package baritone.api.utils; package baritone.api.utils;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.core.BlockPos;
import net.minecraft.inventory.ClickType; import net.minecraft.core.Direction;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionHand;
import net.minecraft.util.EnumActionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.util.EnumFacing; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.EnumHand; import net.minecraft.world.inventory.ClickType;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.GameType;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.level.Level;
import net.minecraft.world.GameType; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.World;
/** /**
* @author Brady * @author Brady
@@ -40,19 +39,19 @@ public interface IPlayerController {
boolean hasBrokenBlock(); boolean hasBrokenBlock();
boolean onPlayerDamageBlock(BlockPos pos, EnumFacing side); boolean onPlayerDamageBlock(BlockPos pos, Direction side);
void resetBlockRemoving(); void resetBlockRemoving();
ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player); void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player);
GameType getGameType(); GameType getGameType();
EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand); InteractionResult processRightClickBlock(LocalPlayer player, Level world, InteractionHand hand, BlockHitResult result);
EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand); InteractionResult processRightClick(LocalPlayer player, Level world, InteractionHand hand);
boolean clickBlock(BlockPos loc, EnumFacing face); boolean clickBlock(BlockPos loc, Direction face);
void setHittingBlock(boolean hittingBlock); void setHittingBlock(boolean hittingBlock);

View File

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

View File

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

View File

@@ -36,6 +36,9 @@ public class Rotation {
public Rotation(float yaw, float pitch) { public Rotation(float yaw, float pitch) {
this.yaw = yaw; this.yaw = yaw;
this.pitch = pitch; this.pitch = pitch;
if (Float.isInfinite(yaw) || Float.isNaN(yaw) || Float.isInfinite(pitch) || Float.isNaN(pitch)) {
throw new IllegalStateException(yaw + " " + pitch);
}
} }
/** /**

View File

@@ -19,13 +19,19 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import net.minecraft.block.BlockFire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.*;
import java.util.Optional; import java.util.Optional;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
/** /**
* @author Brady * @author Brady
@@ -37,24 +43,22 @@ public final class RotationUtils {
* Constant that a degree value is multiplied by to get the equivalent radian value * Constant that a degree value is multiplied by to get the equivalent radian value
*/ */
public static final double DEG_TO_RAD = Math.PI / 180.0; public static final double DEG_TO_RAD = Math.PI / 180.0;
public static final float DEG_TO_RAD_F = (float) DEG_TO_RAD;
/** /**
* Constant that a radian value is multiplied by to get the equivalent degree value * Constant that a radian value is multiplied by to get the equivalent degree value
*/ */
public static final double RAD_TO_DEG = 180.0 / Math.PI; public static final double RAD_TO_DEG = 180.0 / Math.PI;
public static final float RAD_TO_DEG_F = (float) RAD_TO_DEG;
/** /**
* Offsets from the root block position to the center of each side. * Offsets from the root block position to the center of each side.
*/ */
private static final Vec3d[] BLOCK_SIDE_MULTIPLIERS = new Vec3d[]{ private static final Vec3[] BLOCK_SIDE_MULTIPLIERS = new Vec3[]{
new Vec3d(0.5, 0, 0.5), // Down new Vec3(0.5, 0, 0.5), // Down
new Vec3d(0.5, 1, 0.5), // Up new Vec3(0.5, 1, 0.5), // Up
new Vec3d(0.5, 0.5, 0), // North new Vec3(0.5, 0.5, 0), // North
new Vec3d(0.5, 0.5, 1), // South new Vec3(0.5, 0.5, 1), // South
new Vec3d(0, 0.5, 0.5), // West new Vec3(0, 0.5, 0.5), // West
new Vec3d(1, 0.5, 0.5) // East new Vec3(1, 0.5, 0.5) // East
}; };
private RotationUtils() {} private RotationUtils() {}
@@ -67,7 +71,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination * @return The rotation from the origin to the destination
*/ */
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) { public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
return calcRotationFromVec3d(new Vec3d(orig), new Vec3d(dest)); return calcRotationFromVec3d(new Vec3(orig.getX(), orig.getY(), orig.getZ()), new Vec3(dest.getX(), dest.getY(), dest.getZ()));
} }
/** /**
@@ -96,7 +100,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination * @return The rotation from the origin to the destination
* @see #wrapAnglesToRelative(Rotation, Rotation) * @see #wrapAnglesToRelative(Rotation, Rotation)
*/ */
public static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest, Rotation current) { public static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest, Rotation current) {
return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest)); return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest));
} }
@@ -107,11 +111,11 @@ public final class RotationUtils {
* @param dest The destination position * @param dest The destination position
* @return The rotation from the origin to the destination * @return The rotation from the origin to the destination
*/ */
private static Rotation calcRotationFromVec3d(Vec3d orig, Vec3d dest) { private static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest) {
double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z}; double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z};
double yaw = MathHelper.atan2(delta[0], -delta[2]); double yaw = Mth.atan2(delta[0], -delta[2]);
double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]); double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
double pitch = MathHelper.atan2(delta[1], dist); double pitch = Mth.atan2(delta[1], dist);
return new Rotation( return new Rotation(
(float) (yaw * RAD_TO_DEG), (float) (yaw * RAD_TO_DEG),
(float) (pitch * RAD_TO_DEG) (float) (pitch * RAD_TO_DEG)
@@ -124,17 +128,12 @@ public final class RotationUtils {
* @param rotation The input rotation * @param rotation The input rotation
* @return Look vector for the rotation * @return Look vector for the rotation
*/ */
public static Vec3d calcLookDirectionFromRotation(Rotation rotation) { public static Vec3 calcVector3dFromRotation(Rotation rotation) {
float flatZ = MathHelper.cos((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI); float f = Mth.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float flatX = MathHelper.sin((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI); float f1 = Mth.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float pitchBase = -MathHelper.cos(-rotation.getPitch() * DEG_TO_RAD_F); float f2 = -Mth.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float pitchHeight = MathHelper.sin(-rotation.getPitch() * DEG_TO_RAD_F); float f3 = Mth.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vec3d(flatX * pitchBase, pitchHeight, flatZ * pitchBase); return new Vec3((double) (f1 * f2), (double) f3, (double) (f * f2));
}
@Deprecated
public static Vec3d calcVec3dFromRotation(Rotation rotation) {
return calcLookDirectionFromRotation(rotation);
} }
/** /**
@@ -182,8 +181,8 @@ public final class RotationUtils {
Rotation hypothetical = ctx.playerRotations().add(new Rotation(0, 0.0001F)); Rotation hypothetical = ctx.playerRotations().add(new Rotation(0, 0.0001F));
if (wouldSneak) { if (wouldSneak) {
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are // the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), hypothetical, blockReachDistance, true); HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), hypothetical, blockReachDistance, true);
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(pos)) { if (result != null && result.getType() == HitResult.Type.BLOCK && ((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
} }
} else { } else {
@@ -196,13 +195,16 @@ public final class RotationUtils {
return possibleRotation; return possibleRotation;
} }
IBlockState state = ctx.world().getBlockState(pos); BlockState state = ctx.world().getBlockState(pos);
AxisAlignedBB aabb = state.getBoundingBox(ctx.world(), pos); VoxelShape shape = state.getShape(ctx.world(), pos);
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) { if (shape.isEmpty()) {
double xDiff = aabb.minX * sideOffset.x + aabb.maxX * (1 - sideOffset.x); shape = Shapes.block();
double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y); }
double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z); for (Vec3 sideOffset : BLOCK_SIDE_MULTIPLIERS) {
possibleRotation = reachableOffset(ctx, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak); double xDiff = shape.min(Direction.Axis.X) * sideOffset.x + shape.max(Direction.Axis.X) * (1 - sideOffset.x);
double yDiff = shape.min(Direction.Axis.Y) * sideOffset.y + shape.max(Direction.Axis.Y) * (1 - sideOffset.y);
double zDiff = shape.min(Direction.Axis.Z) * sideOffset.z + shape.max(Direction.Axis.Z) * (1 - sideOffset.z);
possibleRotation = reachableOffset(ctx, pos, new Vec3(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
if (possibleRotation.isPresent()) { if (possibleRotation.isPresent()) {
return possibleRotation; return possibleRotation;
} }
@@ -221,17 +223,17 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity * @param blockReachDistance The block reach distance of the entity
* @return The optional rotation * @return The optional rotation
*/ */
public static Optional<Rotation> reachableOffset(IPlayerContext ctx, BlockPos pos, Vec3d offsetPos, double blockReachDistance, boolean wouldSneak) { public static Optional<Rotation> reachableOffset(IPlayerContext ctx, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(ctx.player()) : ctx.player().getPositionEyes(1.0F); Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(ctx.player()) : ctx.player().getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, ctx.playerRotations()); Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, ctx.playerRotations());
Rotation actualRotation = BaritoneAPI.getProvider().getBaritoneForPlayer(ctx.player()).getLookBehavior().getAimProcessor().peekRotation(rotation); Rotation actualRotation = BaritoneAPI.getProvider().getBaritoneForPlayer(ctx.player()).getLookBehavior().getAimProcessor().peekRotation(rotation);
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), actualRotation, blockReachDistance, wouldSneak); HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), actualRotation, blockReachDistance, wouldSneak);
//System.out.println(result); //System.out.println(result);
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { if (result != null && result.getType() == HitResult.Type.BLOCK) {
if (result.getBlockPos().equals(pos)) { if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation); return Optional.of(rotation);
} }
if (ctx.world().getBlockState(pos).getBlock() instanceof BlockFire && result.getBlockPos().equals(pos.down())) { if (ctx.world().getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation); return Optional.of(rotation);
} }
} }
@@ -252,28 +254,28 @@ public final class RotationUtils {
} }
@Deprecated @Deprecated
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) { public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false); return reachable(entity, pos, blockReachDistance, false);
} }
@Deprecated @Deprecated
public static Optional<Rotation> reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) { public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity); IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
IPlayerContext ctx = baritone.getPlayerContext(); IPlayerContext ctx = baritone.getPlayerContext();
return reachable(ctx, pos, blockReachDistance, wouldSneak); return reachable(ctx, pos, blockReachDistance, wouldSneak);
} }
@Deprecated @Deprecated
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance, boolean wouldSneak) { public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getPositionEyes(1.0F); Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch)); Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.getYRot(), entity.getXRot()));
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak); HitResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
//System.out.println(result); //System.out.println(result);
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { if (result != null && result.getType() == HitResult.Type.BLOCK) {
if (result.getBlockPos().equals(pos)) { if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation); return Optional.of(rotation);
} }
if (entity.world.getBlockState(pos).getBlock() instanceof BlockFire && result.getBlockPos().equals(pos.down())) { if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation); return Optional.of(rotation);
} }
} }
@@ -282,6 +284,6 @@ public final class RotationUtils {
@Deprecated @Deprecated
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) { public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak); return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
} }
} }

View File

@@ -19,12 +19,13 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.Settings; import baritone.api.Settings;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.Item; import net.minecraft.core.Direction;
import net.minecraft.util.EnumFacing; import net.minecraft.core.Registry;
import net.minecraft.util.math.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.awt.*; import java.awt.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@@ -50,6 +51,7 @@ public class SettingsUtil {
public static final String SETTINGS_DEFAULT_NAME = "settings.txt"; public static final String SETTINGS_DEFAULT_NAME = "settings.txt";
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space
private static boolean isComment(String line) { private static boolean isComment(String line) {
return line.startsWith("#") || line.startsWith("//"); return line.startsWith("#") || line.startsWith("//");
} }
@@ -104,7 +106,7 @@ public class SettingsUtil {
} }
private static Path settingsByName(String name) { private static Path settingsByName(String name) {
return Minecraft.getMinecraft().gameDir.toPath().resolve("baritone").resolve(name); return Minecraft.getInstance().gameDirectory.toPath().resolve("baritone").resolve(name);
} }
public static List<Settings.Setting> modifiedSettings(Settings settings) { public static List<Settings.Setting> modifiedSettings(Settings settings) {
@@ -230,7 +232,7 @@ public class SettingsUtil {
FLOAT(Float.class, Float::parseFloat), FLOAT(Float.class, Float::parseFloat),
LONG(Long.class, Long::parseLong), LONG(Long.class, Long::parseLong),
STRING(String.class, String::new), STRING(String.class, String::new),
ENUMFACING(EnumFacing.class, EnumFacing::byName), DIRECTION(Direction.class, Direction::byName),
COLOR( COLOR(
Color.class, Color.class,
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])), str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
@@ -248,15 +250,14 @@ public class SettingsUtil {
), ),
ITEM( ITEM(
Item.class, Item.class,
str -> Item.getByNameOrId(str.trim()), str -> Registry.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> Item.REGISTRY.getNameForObject(item).toString() item -> Registry.ITEM.getKey(item).toString()
), ),
LIST() { LIST() {
@Override @Override
public Object parse(ParserContext context, String raw) { public Object parse(ParserContext context, String raw) {
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0]; Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Parser parser = Parser.getParser(type); Parser parser = Parser.getParser(type);
return Stream.of(raw.split(",")) return Stream.of(raw.split(","))
.map(s -> parser.parse(context, s)) .map(s -> parser.parse(context, s))
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@@ -17,13 +17,14 @@
package baritone.api.utils; package baritone.api.utils;
import net.minecraft.block.BlockFire; import net.minecraft.core.BlockPos;
import net.minecraft.block.state.IBlockState; import net.minecraft.core.Direction;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.level.Level;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.World; import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
/** /**
* @author Brady * @author Brady
@@ -41,16 +42,22 @@ public final class VecUtils {
* @return The center of the block's bounding box * @return The center of the block's bounding box
* @see #getBlockPosCenter(BlockPos) * @see #getBlockPosCenter(BlockPos)
*/ */
public static Vec3d calculateBlockCenter(World world, BlockPos pos) { public static Vec3 calculateBlockCenter(Level world, BlockPos pos) {
IBlockState b = world.getBlockState(pos); BlockState b = world.getBlockState(pos);
AxisAlignedBB bbox = b.getBoundingBox(world, pos); VoxelShape shape = b.getCollisionShape(world, pos);
double xDiff = (bbox.minX + bbox.maxX) / 2; if (shape.isEmpty()) {
double yDiff = (bbox.minY + bbox.maxY) / 2; return getBlockPosCenter(pos);
double zDiff = (bbox.minZ + bbox.maxZ) / 2; }
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out double xDiff = (shape.min(Direction.Axis.X) + shape.max(Direction.Axis.X)) / 2;
double yDiff = (shape.min(Direction.Axis.Y) + shape.max(Direction.Axis.Y)) / 2;
double zDiff = (shape.min(Direction.Axis.Z) + shape.max(Direction.Axis.Z)) / 2;
if (Double.isNaN(xDiff) || Double.isNaN(yDiff) || Double.isNaN(zDiff)) {
throw new IllegalStateException(b + " " + pos + " " + shape);
}
if (b.getBlock() instanceof BaseFireBlock) {//look at bottom of fire when putting it out
yDiff = 0; yDiff = 0;
} }
return new Vec3d( return new Vec3(
pos.getX() + xDiff, pos.getX() + xDiff,
pos.getY() + yDiff, pos.getY() + yDiff,
pos.getZ() + zDiff pos.getZ() + zDiff
@@ -65,10 +72,10 @@ public final class VecUtils {
* *
* @param pos The block position * @param pos The block position
* @return The assumed center of the position * @return The assumed center of the position
* @see #calculateBlockCenter(World, BlockPos) * @see #calculateBlockCenter(Level, BlockPos)
*/ */
public static Vec3d getBlockPosCenter(BlockPos pos) { public static Vec3 getBlockPosCenter(BlockPos pos) {
return new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); return new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
} }
/** /**
@@ -98,7 +105,7 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos) * @see #getBlockPosCenter(BlockPos)
*/ */
public static double entityDistanceToCenter(Entity entity, BlockPos pos) { public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
return distanceToCenter(pos, entity.posX, entity.posY, entity.posZ); return distanceToCenter(pos, entity.position().x, entity.position().y, entity.position().z);
} }
/** /**
@@ -111,6 +118,6 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos) * @see #getBlockPosCenter(BlockPos)
*/ */
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) { public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
return distanceToCenter(pos, entity.posX, pos.getY() + 0.5, entity.posZ); return distanceToCenter(pos, entity.position().x, pos.getY() + 0.5, entity.position().z);
} }
} }

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