Compare commits

..

229 Commits

Author SHA1 Message Date
Leijurv
1e7e504650 v1.6.4 2023-02-18 15:37:37 -08: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
leijurv
698d40d797 bump 2023-01-16 20:55:43 -08:00
Leijurv
2b6c59fa8a v1.2.17 2023-01-16 12:22:52 -08:00
leijurv
21bc830143 Merge pull request #3798 from ZacSharp/patch-12
Fix canWalkThrough caching
2023-01-16 12:20:11 -08:00
ZacSharp
432d42ade8 Fix #find results not being clickable 2023-01-15 20:22:58 +01:00
ZacSharp
aa9206381d Fix canWalkThrough caching 2023-01-15 14:53:04 +01:00
Leijurv
d6d9af65fb reformat 2023-01-15 01:04:15 -08:00
Leijurv
a3f70e7977 add fullypassable to precomputeddata 2023-01-15 00:56:30 -08: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
Leijurv
6bbdba7a21 bump 2023-01-13 11:17:57 -08:00
Leijurv
6a175379fb v1.2.16 2023-01-13 11:10:24 -08:00
leijurv
85c21fa8e3 add comment 2023-01-12 14:52:38 -08:00
leijurv
bc8c823045 Merge pull request #3775 from ZacSharp/pr/frostwalker
Allow pathing to use frostwalker
2023-01-12 14:51:35 -08:00
ZacSharp
9935da8a6f Add explanation and add extra check 2023-01-12 22:18:54 +01:00
ZacSharp
c39b6c3fe7 Don't grab state if we don't need it 2023-01-12 21:39:55 +01:00
leijurv
c47a6f92c5 Merge pull request #3786 from Entropy5/master
bugfix for odd height schematics
2023-01-12 12:03:51 -08:00
leijurv
778628da30 Merge pull request #3789 from Argentoz/patch-1
Fix world border check
2023-01-12 12:03:00 -08:00
leijurv
ba0ca0cc65 Merge pull request #3788 from ZacSharp/pr/detectBrokenLoadHook
Make the world cache work even when mods break our world load hook
2023-01-12 11:39:41 -08:00
leijurv
fba3828479 Merge pull request #3735 from ZacSharp/pr/breakNextToLava
Allow breaking next to some liquids
2023-01-12 10:08:09 -08:00
Argentoz
c8dd4f26f7 Fix :)
WTF
2023-01-12 15:02:54 +03:00
Entropy5
16a62625b3 this seems to work as well? 2023-01-12 04:29:31 +01:00
ZacSharp
de5f6d5fce Apply suggested reordering 2023-01-11 23:56:52 +01:00
Entropy5
98a87d099b zac suggestion 2023-01-11 04:36:15 +01:00
ZacSharp
a6f3c95684 Don't spam the log when in a replay 2023-01-10 18:58:17 +01:00
ZacSharp
75e39e7ef5 Log when doing things out of the ordinary 2023-01-10 18:56:33 +01:00
ZacSharp
77b2b26a7a Add fix for 1.19.3 here already 2023-01-10 18:55:46 +01:00
ZacSharp
1680eeb80d Handle mods breaking our world loading hook 2023-01-10 17:25:32 +01:00
Entropy5
9a9b4a1874 bugfix for odd height schematics 2023-01-10 05:56:30 +01: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
leijurv
145a944860 Merge pull request #3785 from Entropy5/master
buildonlyselection optimization
2023-01-08 19:03:49 -10:00
leijurv
dd127ff3e7 Merge pull request #3782 from ZacSharp/pr/updateWorkflows
Update workflows
2023-01-08 18:32:07 -10:00
Entropy5
b0fb474e1d buildinlayers ~ buildonlyselection lag fix for big schematics (skips layers more properly) 2023-01-09 02:33:10 +01:00
ZacSharp
a1a94ec0d1 Fix step name 2023-01-06 04:26:03 +01:00
ZacSharp
678f8bc77f Use Temurin JDK 2023-01-06 04:25:03 +01:00
ZacSharp
41968546d1 Update workflows 2023-01-06 04:09:56 +01:00
ZacSharp
b51b78f4e4 Merge branch 'master' into 1.13.2 2023-01-06 01:47:30 +01:00
ZacSharp
f76283ebfe Remove unused imports 2023-01-03 00:50:56 +01:00
ZacSharp
e59bf9ab97 Grab block only once 2022-12-30 16:09:45 +01:00
ZacSharp
b2f66241d5 Merge remote-tracking branch 'upstream/master' into pr/frostwalker 2022-12-30 15:57:17 +01:00
leijurv
cfdbc851a0 Merge pull request #3600 from Imeguras/master
Added the ability to use KmM as abreviatures
2022-12-24 00:14:04 -08:00
leijurv
6ccebdc978 Merge pull request #3703 from rycbar0/master
formula error
2022-12-24 00:12:47 -08:00
leijurv
df53040339 Merge pull request #3757 from Warpten/feature/paths-with-spaces-are-stupid
Improve handling spaces in paths during proguard pass
2022-12-24 00:08:04 -08:00
leijurv
42dc5b14b0 Merge pull request #3755 from wagyourtail/allowbreakanaywaymine
allowBreakAnyway should let mining happen
2022-12-24 00:07:00 -08:00
leijurv
e2538abcb1 Merge pull request #3743 from ZacSharp/patch-11
Fix Registry.unregister
2022-12-24 00:05:42 -08:00
leijurv
1697293f12 Merge pull request #3479 from scorbett123/caching_performance_upgrade
Caching performance upgrade
2022-12-23 23:57:14 -08:00
rycbar0
d60e1e8a05 Merge branch 'cabaletta:master' into master 2022-12-19 10:34:57 +01:00
Warpten
d157756d94 Improve handling spaces in paths during proguard pass 2022-12-12 01:08:49 +01:00
Wagyourtail
ea1914a248 missed a spot 2022-12-10 20:12:51 -07:00
Wagyourtail
85087ce04a smarter filter filtering 2022-12-10 19:25:57 -07:00
Wagyourtail
e09127eadf allowBreakAnyway should let mining happen 2022-12-10 16:35:51 -07:00
ZacSharp
e1095962a1 Fix Registry.unregister 2022-11-28 23:07:30 +01:00
ZacSharp
eabd1150b0 Allow breaking next to some liquids 2022-11-22 15:15:33 +01:00
Leijurv
93501248cd Merge pull request #3698 from ZacSharp/patch-10
Reliably clear keys when paused
2022-10-31 12:29:56 -07:00
Leijurv
3a945c8c10 Merge pull request #3697 from ZacSharp/pr/buildIgnoreProperties
 Add buildIgnoreProperties setting
2022-10-31 12:28:44 -07:00
rycbar0
3cef7a7911 formula error 2022-10-26 23:09:23 +02:00
ZacSharp
1cd2fb5b18 Reliably clear keys when paused 2022-10-24 22:49:12 +02:00
ZacSharp
ba3ca47f8c Add buildIgnoreProperties setting 2022-10-23 01:42:31 +02: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
4699b46744 Merge branch 'master' into caching_performance_upgrade 2022-10-03 21:25:23 +01:00
Leijurv
69ffdb7665 Merge pull request #3672 from rycbar0/master
Litematica Support for bariton
2022-10-03 12:52:18 -07:00
rycbar0
f9c5386e7a final changes 2022-10-03 21:39:53 +02:00
Leijurv
55273b5340 Merge pull request #3579 from lucasarden/master
Stop backfill from filling while paused
2022-10-03 12:23:02 -07: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
rycbar0
5cd1c9d15d Merge pull request #1 from rycbar0/LitematicaCommand
Adding a Litematica command to build loaded schematics.
2022-10-03 20:39:24 +02:00
rycbar0
b461b2af2f made a oopsie 2022-10-03 20:32:56 +02:00
rycbar0
3a5608566e auto formatting 2022-10-03 20:13:11 +02:00
rycbar0
fc65f22feb clean up and adding javadoc 2022-10-03 19:59:07 +02:00
rycbar0
f53bfa89a9 a fucking x and z mixup 2022-10-03 17:44:15 +02:00
rycbar0
fdfeeb2ffa need stronger pesticides, bugs keep multiplying 2022-10-03 02:35:25 +02:00
rycbar0
3e75cc7408 block mirroring and rotation 2022-10-01 22:59:47 +02:00
rycbar0
d1930e03e1 getCorrectedOrigin returns the correct origin 2022-10-01 22:51:36 +02:00
rycbar0
144a534bb3 debugging mirroring and rotating as well as refactoring 2022-10-01 17:14:05 +02:00
rycbar0
de1256cc80 remove spaghetti 2022-10-01 05:27:02 +02:00
rycbar0
76404c8af6 it works but its spaghetti 2022-10-01 02:01:46 +02:00
ZacSharp
fb814e912d Don't try parkouring out of water 2022-09-30 23:59:49 +02:00
ZacSharp
43ee86b4fe Don't try backplacing against water under carpet/lilypad 2022-09-30 22:41:09 +02:00
ZacSharp
eb697b7a17 Fix costs when assumeWalkOnWater stops us from relying on frostWalker 2022-09-30 22:40:23 +02:00
ZacSharp
3da5bbd267 Don't pillar from carpet/lilypad on water 2022-09-30 22:38:21 +02:00
ZacSharp
c14be17e53 Move this to a helper method and add missing cases 2022-09-30 22:27:32 +02:00
ZacSharp
45c0b38156 Fix jumping from packplaced blocks on water
Not having frostwalker means that we must have replaced the water with a throwaway, not that we are standing on water
2022-09-30 18:04:34 +02:00
rycbar0
025f6235f9 litematica command works and added schematic selection if more than 1 schematic is loaded
bug: if schematic origin isnt minimum corner schematic is built in the wrong place
2022-09-30 17:53:31 +02:00
rycbar0
4ba3c883e6 something is fishy with the getAllSchematicPlacements() methode but i want my progress saved 2022-09-30 13:32:31 +02:00
rycbar0
3a4168a661 Merge branch 'master' into LitematicaCommand 2022-09-30 00:42:17 +02:00
rycbar0
484b3326c7 auto-format all files I touched 2022-09-29 21:52:15 +02:00
rycbar0
e99fcbbe36 Change requests part two 2022-09-29 21:47:42 +02:00
rycbar0
7ba3de57d0 credits LitematicaBitArray 2022-09-29 20:20:38 +02:00
rycbar0
5ff274f040 Change requests part one 2022-09-29 19:58:05 +02:00
schmar03
293f5db172 LitematicaCommand added to build loaded schematics 2022-09-28 14:15:48 +02:00
schmar03
d928e705b9 LitematicaCommand added to build loaded schematics 2022-09-28 12:09:38 +02:00
rycbar0
7a48824ced codacy issue #2,#3 and #4 fix 2022-09-26 22:32:25 +02:00
rycbar0
8aa8918124 codacy issue #1 and #5 fix 2022-09-26 22:23:38 +02:00
rycbar0
a091c17b83 Added mixin to properly handle Long Arrays 2022-09-26 21:04:09 +02:00
rycbar0
52aa0d9b8a more cleanup 2022-09-26 20:04:57 +02:00
rycbar0
3d8eddc4e1 cleanup 2022-09-26 19:23:09 +02:00
rycbar0
295265c261 refactoring 2022-09-26 17:43:54 +02:00
rycbar0
376d6422ec refactoring 2022-09-26 16:18:43 +02:00
rycbar0
113e340474 version check added 2022-09-26 16:09:41 +02:00
rycbar0
c89d8b69e5 ref files removed 2022-09-26 16:08:37 +02:00
rycbar0
70303634f5 ref files added 2022-09-26 15:59:55 +02:00
rycbar0
325aa7201b bug fix 2022-09-26 02:51:06 +02:00
rycbar0
75a3fc699e Code clean up 2022-09-26 01:18:56 +02:00
rycbar0
3cd8ce8323 Multiple Sub-region support 2022-09-26 00:58:32 +02:00
rycbar0
240e81a9e0 Refactoring 2022-09-25 18:22:59 +02:00
rycbar0
40449400d3 State of Emerson 2022-09-25 16:55:08 +02: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
ZacSharp
9ffe4f2c25 Fix parkour with frostwalker with/without throwaways
* Placing throwaways with allowPlace disabled
* Failing without throwaways
2022-09-01 13:14:33 +02:00
ZacSharp
af95f77134 Fix OOB and check for direction and include parkour 2022-09-01 13:14:24 +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
ZacSharp
78f1c45e13 Don't overshoot descends before using frostwalker 2022-08-31 23:39:09 +02:00
ZacSharp
cf47573298 Merge remote-tracking branch 'upstream/master' into pr/frostwalker 2022-08-30 00:18:07 +02:00
ZacSharp
96ba96ca69 Fix some more edge cases 2022-08-29 18:47:54 +02:00
ZacSharp
da998eb469 Complete frostwalker usage 2022-08-29 16:59:01 +02:00
ZacSharp
e75a4b95cc Mostly working usage of frostwalker
* Sometimes overshoots Descend-Traverse chains onto water
* Unwanted interactions with assumeWalkOnWater
2022-08-29 12:53:02 +02:00
Imeguras
344085f4ef Added the ability to use KmM as abreviatures
for example 1m is equals to 1 million  while 1K is 1000
2022-08-08 12:00:48 +01:00
Lucas Arden
d37a6a0b2d Added check for placed blocks in backfill 2022-07-26 14:21:32 -07:00
Lucas Arden
d7fc916d20 Added check for pathing 2022-07-24 21:37:45 -07:00
Leijurv
80a4757242 baritone complies faster if the files are less bytes 2022-07-15 01:36:01 -07:00
Leijurv
658048ff2d fix snow and tweak others 2022-07-14 22:11:13 -07:00
Leijurv
0587223da8 better constants 2022-07-14 22:02:19 -07:00
Leijurv
2d1b81dc20 vastly increase cuteness by removing the optional boolean 2022-07-14 22:00:18 -07:00
Leijurv
0bd16fb81a bit literals are meh 2022-07-14 21:56:25 -07:00
Leijurv
0c1fec5d1e crucial performance optimization 2022-07-14 21:54:32 -07:00
Leijurv
ee16eb7fde funnier this way 2022-07-14 21:47:18 -07:00
Leijurv
5c9aeab6b4 add cmt 2022-07-14 21:44:42 -07:00
Leijurv
5c7cae9ab0 fix literally wrong comment that did not match subsequent code 2022-07-14 21:43:14 -07:00
Leijurv
93fa6cf875 introduce MAYBE and fix more allocation cases 2022-07-14 21:42:38 -07:00
Leijurv
5b7bee977b also don't construct an optional for slabs 2022-07-14 21:38:38 -07:00
Leijurv
8018dac396 fix default case that instantiated an optional for non stairs 2022-07-14 21:38:02 -07:00
Leijurv
85ab317c6c simplify, remove setting changed event, always construct new precomputeddata 2022-07-14 21:35:30 -07:00
scorbett123
6b0fb1721b These should be all the suggested changes for the caching of can walk through block states 2022-07-14 17:18:02 +01:00
scorbett123
fdcdcbb85f Switch to using an int[] for storing precomputed data, and also use lazy loading 2022-07-14 12:49:47 +01:00
Leijurv
4e2095d251 almost forgot 2022-07-09 22:15:20 -07:00
Leijurv
51275b3a65 make #paws be an alias for #pause 2022-07-09 22:06:39 -07:00
scorbett123
8d480cefb9 Switch to throwable and readd check for glass / stained glass 2022-07-06 14:45:54 +01:00
scorbett123
3e7f9039c4 Don't construct new optionals in movement helper 2022-07-06 14:38:33 +01:00
Leijurv
49828baae3 Merge pull request #3296 from ZacSharp/findImprovements
Find improvements
2022-07-05 15:32:02 -07: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
a73e1185dc Merge pull request #3533 from Echocage/SprintFix
Fix for a sprint bug that can cause death
2022-07-05 15:27:10 -07:00
Echocage
441dceb731 Narrowed scope and we now only call canSprintFromDescendInto when our next & next_next movements are both MovementDescends 2022-06-29 17:54:28 -05:00
Echocage
57c4f9e103 Undid previous change, updated to instead check the next and the next_next block 2022-06-27 18:38:54 -05:00
Echocage
2741fc2683 Swapped the order of checks within canSprintFromDescendInto 2022-06-27 15:06:27 -05:00
scorbett123
868c023dbd Fix a couple of things I missed 2022-06-08 14:20:25 +01:00
scorbett123
e7c357ab7f Make precomputed data refresh every 200 ticks (10 seconds) 2022-06-08 14:14:14 +01:00
scorbett123
9e1a5008ed Move caching functions into MovementHelper 2022-06-07 21:52:24 +01: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
scorbett123
a6557121a0 fix github actions compiling. 2022-05-31 15:08:52 +01:00
scorbett123
2dad6262cf Remove some benchmarking and fix loading of settings. 2022-05-31 14:56:23 +01:00
scorbett123
af1eb58bb8 Implement Leijurv's precomputed data idea 2022-05-31 14:43:58 +01: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
17a2aa42e9 Merge pull request #3463 from ZacSharp/patch-8
Deal with others replacing the chat gui
2022-05-23 13:47:22 -07:00
Leijurv
231f671400 Merge pull request #3433 from ZacSharp/patch-7
Fix "missing null"
2022-05-23 13:46:27 -07: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
221eba11dd Deal with others replacing the chat gui 2022-05-20 01:31:09 +02:00
ZacSharp
ad40a9225e Fix leaking incorrect positions
It was only cleared when the previous one was canceled, not when it was directly replaced by the next one.
2022-05-03 23:25:01 +02: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
Leijurv
cbef05838d Merge pull request #3388 from scorbett123/make_eta_show_ticks
Improve output to user in eta command
2022-04-19 16:33:37 -07:00
ZacSharp
4dcf260059 Fix mistakes made while merging upwards 2022-04-14 19:22:38 +02:00
scorbett123
2cf973809a eta command should default to NaN not just not showing the eta as suggested by ZacSharp 2022-04-12 12:15:42 +01:00
scorbett123
65974e15ba Improve output to user in eta command 2022-04-11 18:36:48 +01: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
dc6b32a154 Merge pull request #3356 from wagyourtail/forceAllowBreak
add `allowBreakAnyway` setting
2022-03-31 14:08:13 -07:00
Leijurv
76f593e4bb Merge pull request #3342 from PhlegethonAcheron/master
Added usage syntax to the documentation for buildValidSubstitutes and buildSubstitutes
2022-03-31 14:07:42 -07:00
Leijurv
15b991a48e Merge pull request #3309 from wagyourtail/patch-2
fix inner class attribute being stripped
2022-03-31 14:01:45 -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
Leijurv
702d0790bc Merge pull request #3327 from scorbett123/fix-chunk-saving-crash
If context.player() returns none we don't want to use its position for pruning.
2022-03-31 13:58:11 -07:00
Wagyourtail
2953e2c522 make codacy happy 2022-03-24 18:16:19 -07:00
Wagyourtail
bf450b7d68 rename to allowBreakAnyway 2022-03-24 17:34:31 -07:00
Wagyourtail
4e6b6d97ce add forceAllowBreak setting 2022-03-24 17:33:33 -07: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
PhlegethonAcheron
6aadd00e72 Added usage syntax to the documentation for buildValidSubstitutes and buildSubstitutes 2022-03-20 15:41:25 -04:00
scorbett123
e036f5360c If context.player() returns none we don't want to use its position for pruning. 2022-03-16 20:12:56 +00:00
Leijurv
8c2aae2ddc Merge pull request #3324 from wagyourtail/master
reimplement death and bed waypoints
2022-03-15 19:06:50 -07:00
Wagyourtail
511941c714 reimplement death and bed waypoints 2022-03-15 18:39:19 -07:00
wagyourtail
e58220e2c4 fix inner class attribute being stripped 2022-03-08 19:45:05 -07:00
Leijurv
02711a73ed fix codacy 2022-03-08 15:14:00 -08:00
Leijurv
25d418e96b 1.15 is deprecated 2022-03-08 15:04:34 -08:00
Leijurv
10430f8142 bump to 1.18.2 2022-03-08 15:01:48 -08:00
Leijurv
8aba97b577 update for 1.8.3 2022-03-08 15:00:14 -08:00
Leijurv
8fe5b2369a Merge pull request #3301 from wagyourtail/toolmaterial-fix
fix modded toolmaterials (1.12.2)
2022-03-08 14:45:45 -08:00
Wagyourtail
dc6c87b58d fix modded toolmaterials 2022-03-07 15:53:13 -07:00
ZacSharp
ef4e19002b Provide more information for #find
Always log something to chat so people don't think it's broken and make sure they know about the restriction to cached blocks.
2022-03-05 22:27:27 +01:00
ZacSharp
e6ee5fc6b8 Make positions from #find clickable 2022-03-05 21:42:27 +01:00
Leijurv
b19c935da1 Merge pull request #3256 from ehylo/master
Update Setup and Usage guides
2022-02-09 16:35:54 -08:00
ehylo
0ade37f14f Update Setup and Usage guides
Also fix 2 settings that just don't have a description for some reason, and add some information to the find command because that also for some reason did not have anything there. The descriptions I put may not be detailed enough so please let me know if things should change
2022-02-08 21:13:51 -08:00
Leijurv
91be4c4643 Merge pull request #3093 from ZacSharp/fixBlockOptionalMetaObfuscation
Fix chat error messages being obfuscated for block type arguments
2022-02-08 10:52:25 -08:00
Leijurv
d2b62e2d21 Merge pull request #3239 from scorbett123/world_border_checks
Add some world border checks
2022-02-08 10:49:00 -08:00
Leijurv
7052fe6225 put this on its own line 2022-02-07 22:03:31 -08:00
scorbett123
49357790f1 fix world border checks
Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com>
2022-02-03 08:06:01 +00:00
Leijurv
694219e497 Merge pull request #3243 from wagyourtail/master
fix getting stuck on cauldrons (fixes #3099)
2022-02-02 21:10:47 -08:00
Wagyourtail
9b70ace180 fix getting stuck on cauldrons (fixes #3099) 2022-02-02 22:04:15 -07:00
Leijurv
e0a53144db bump most recent jars 2022-02-02 16:10:14 -08:00
Leijurv
25de332492 mfw this also needs to be in master 2022-02-02 15:53:43 -08:00
Leijurv
2d0f10c79f link to branches 2022-02-02 15:53:24 -08:00
scorbett123
74ea803651 Add world border checks to MovementHelper 2022-02-02 20:36:36 +00:00
ZacSharp
21534d1c0b Fix chat error messages being obfuscated for block type arguments 2021-11-18 00:21:12 +01:00
ZacSharp
bb91dc98de Merge branch 'master' into 1.13.2 2021-10-20 03:20:41 +02:00
202 changed files with 4406 additions and 2302 deletions

View File

@@ -13,33 +13,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '16'
distribution: 'adopt'
java-version: '8'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build (fabric) with Gradle
run: ./gradlew build -Pbaritone.fabric_build
- name: Build (forge) with Gradle
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
run: ./gradlew build -Pbaritone.forge_build
- name: Archive Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: dist/
- name: Archive mapping.txt
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Mappings
path: build/tmp/proguard/mapping.txt

View File

@@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '16'
distribution: 'adopt'
java-version: '8'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew

1
.gitignore vendored
View File

@@ -32,3 +32,4 @@ baritone_Client.launch
!/.idea/copyright/profiles_settings.xml
.vscode/launch.json

View File

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

View File

@@ -4,20 +4,20 @@
</p>
<p align="center">
<img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.13.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.14.4-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.15.2-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/>
<img src="https://img.shields.io/badge/MC-1.18.1-brightgreen.svg" alt="Minecraft"/>
<a href="https://github.com/cabaletta/baritone/tree/master"><img src="https://img.shields.io/badge/MC-1.12.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.13.2"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.14.4"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.15.2"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.16.5"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.17.1"><img src="https://img.shields.io/badge/MC-1.17.1-brightgreen.svg" alt="Minecraft"/></a>
<a href="https://github.com/cabaletta/baritone/tree/1.18.2"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
</p>
<p align="center">
<a href="https://travis-ci.com/cabaletta/baritone/"><img src="https://travis-ci.com/cabaletta/baritone.svg?branch=master" alt="Build Status"/></a>
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/release/cabaletta/baritone.svg" alt="Release"/></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg" alt="License"/></a>
<a href="https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cabaletta/baritone&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400" alt="Codacy Badge"/></a>
<a href="https://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>
@@ -50,17 +50,19 @@ A Minecraft pathfinder bot.
[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr)
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do.
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar.
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to
install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click
[here](https://github.com/cabaletta/baritone/releases/download/v1.2.17/baritone-api-forge-1.2.17.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**.
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**.
If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.2/baritone-api-fabric-1.7.2.jar)**.
If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**.
If you need Forge or Fabric 1.18.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.3) and get the `api-forge` or `api-fabric` jar. **For 1.18.2 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-fabric-1.8.3.jar)**. **For 1.18.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.3/baritone-api-forge-1.8.3.jar)**.
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
@@ -95,7 +97,7 @@ 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;

View File

@@ -11,7 +11,7 @@ These releases are not always completely up to date with latest features, and ar
Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL)
v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.5, v1.7.* is for 1.17.1, v1.8.* is for 1.18.1
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.
@@ -22,15 +22,16 @@ The build is fully deterministic and reproducible, and you can verify Travis did
Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
**The Forge release can simply be added as a Forge mod.**
**The Forge and Fabric releases can simply be added as a Forge/Fabric mods.**
If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar`
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration.
- **Forge/Fabric API**: Same as API, but packaged for Forge/Fabric. This should be used where another mod has a Baritone integration.
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone.
- **Forge/Fabric Standalone**: Same as Standalone, but packaged for Forge/Fabric. This should be used when Baritone is your only Forge/Fabric mod, or none of your other Forge/Fabric mods integrate with Baritone.
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
- **Forge/Fabric Unoptimized**: Same as Unoptimized, but packaged for Forge/Fabric.
## Build it yourself
- Clone or download Baritone
@@ -42,13 +43,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone
## Command Line
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16 for 1.17.1, and JDK 17 for 1.18.1.
To check which java you are using do
`java -version` in a command prompt or terminal.
If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
Open JDK 8 download: https://openjdk.java.net/install/
Open JDK download: https://openjdk.java.net/install/
#### macOS guide
In order to get JDK 8, Try running the following command:
`% /usr/libexec/java_home -V`
@@ -84,6 +85,12 @@ For minecraft 1.15.2+, run the following instead to include the Forge jars:
$ gradlew build -Pbaritone.forge_build
```
Do this instead for Fabric jars:
```
$ gradlew build -Pbaritone.fabric_build
```
Running Baritone:
```

View File

@@ -32,13 +32,13 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.
Some common examples:
Commands in Baritone:
- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
- `goal` to set the goal to your player's feet
- `goal clear` to clear the goal
- `cancel` or `stop` to stop everything
- `cancel` or `stop` to stop everything, `forcecancel` is also an option
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine 64 diamond_ore`.
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to select an area (`#help sel` to see what you can do with that selection).
@@ -51,11 +51,19 @@ Some common examples:
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.
- `come` tells Baritone to head towards your camera, useful when freecam doesn't move your player position.
- `blacklist` will stop baritone from going to the closest block so it won't attempt to get to it.
- `eta` to get information about the estimated time until the next segment and the goal, be aware that the ETA to your goal is really unprecise.
- `proc` to view miscellaneous information about the process currently controlling Baritone.
- `repack` to re-cache the chunks around you.
- `gc` to call `System.gc()` which may free up some memory.
- `render` to fix glitched chunk rendering without having to reload all of them.
- `reloadall` to reload Baritone's world cache or `saveall` to save Baritone's world cache.
- `find` to search through Baritone's cache and attempt to find the location of the block.
- `surface` or `top` to tell Baritone to head towards the closest surface-like area, this can be the surface or highest available air space.
- `version` to get the version of Baritone you're running
- `damn` daniel
For the rest of the commands, you can take a look at the code [here](https://baritone.leijurv.com/baritone/api/Settings.html).
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>. If you find HTML easier to read than Javadoc, you can look <a href="https://baritone.leijurv.com/baritone/api/Settings.html#field.detail">here</a>.
There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links.

View File

@@ -15,28 +15,67 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id 'java'
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
id 'maven-publish'
group 'baritone'
version '1.6.4'
buildscript {
repositories {
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
maven {
url = 'https://maven.fabricmc.net/'
}
maven {
url = 'https://libraries.minecraft.net/'
}
mavenCentral()
jcenter()
}
dependencies {
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
classpath group: 'net.fabricmc', name: 'fabric-loom', version: '0.7-SNAPSHOT'
}
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
import baritone.gradle.fabric.CreateVolderYarn
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace
import org.apache.tools.ant.taskdefs.condition.Os
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16
def mcpVersion = [channel: 'snapshot', version: '20201028-1.16.3']
if (getProject().hasProperty("baritone.fabric_build")) {
CreateVolderYarn.genMappings("1.16.5", mcpVersion)
apply plugin: 'fabric-loom'
} else {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
}
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
options.encoding = "UTF-8" // allow emoji in comments :^)
}
sourceSets {
api {
compileClasspath += main.compileClasspath
@@ -52,63 +91,122 @@ sourceSets {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
schematica_api {
compileClasspath += main.compileClasspath
}
main {
compileClasspath += schematica_api.output
}
}
loom {
if (compileType.equals("FORGE")) {
forge {
mixinConfig 'mixins.baritone.json'
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.api.allSource
}
if (getProject().hasProperty("baritone.fabric_build")) {
minecraft.refmapName = "mixins.baritone.refmap.json"
} else {
minecraft {
mappings mcpVersion
if (getProject().hasProperty("baritone.forge_build")) {
reobfMappings 'searge'
} else {
reobfMappings 'notch'
}
runs {
client {
workingDirectory project.file('run')
source sourceSets.launch
main 'baritone.launch.LaunchTesting'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', downloadAssets.output
environment 'nativesDirectory', extractNatives.output
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
if (Os.isFamily(Os.FAMILY_MAC)) {
jvmArgs "-XstartOnFirstThread"
}
}
autoTest {
workingDirectory project.file('autotest')
source sourceSets.launch
main 'baritone.launch.LaunchTesting'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', downloadAssets.output
environment 'nativesDirectory', extractNatives.output
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
environment 'BARITONE_AUTO_TEST', 'true'
if (Os.isFamily(Os.FAMILY_MAC)) {
jvmArgs "-XstartOnFirstThread"
}
}
}
}
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
runs {
client {
source = sourceSets.launch
}
mixin {
defaultObfuscationEnv searge
add sourceSets.launch, 'mixins.baritone.refmap.json'
}
}
repositories {
mavenCentral()
maven {
name = 'SpongePowered'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
name = "ldtteam"
url = "https://maven.parchmentmc.net/"
url = 'https://www.dogforce-games.com/maven/'
}
mavenCentral()
}
dependencies {
if (compileType.equals("FORGE")) {
forge "net.minecraftforge:forge:${project.forge_version}"
}
mappings loom.layered() {
officialMojangMappings()
//technically optional, but really helpful in dev:
parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String)
}
minecraft "com.mojang:minecraft:${project.minecraft_version}"
if (!compileType.equals("FORGE")) {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
}
// this makes it compile with the forge tweak stuff
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
implementation('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
exclude module: 'asm-debug-all'
}
if (getProject().hasProperty("baritone.fabric_build")) {
minecraft "com.mojang:minecraft:1.16.5"
mappings fileTree(dir: "./build/volderyarn", include: "**.jar")
modImplementation "net.fabricmc:fabric-loader:0.9.1+build.205"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
// this makes it compile with the forge tweak stuff
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
implementation('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'
} else {
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.5'
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
}
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
runtime launchCompile('org.spongepowered:mixin:0.8.3') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
}
testImplementation 'junit:junit:4.12'
}
@@ -121,24 +219,25 @@ javadoc {
classpath += sourceSets.api.compileClasspath
}
// skidded from fabric-example-mod (comments and all)
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (getProject().hasProperty("baritone.fabric_build")) {
// skidded from fabric-example-mod (comments and all)
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 16
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
jar {
from sourceSets.launch.output, sourceSets.api.output
@@ -170,21 +269,93 @@ jar {
}
}
if (compileType.equals("OFFICIAL")) {
remapJar {
toM.set "official"
// skidded from ProguardTask
File getClientJar() {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter({ f -> f.toString().endsWith("client-extra.jar") })
.map({ f -> new File(f.getParentFile(), "client.jar") })
.findFirst()
.get()
}
File getClientJarFabric() {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter({ f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") })
.map({ f -> new File(f.getParentFile().getParentFile(), f.getName().toString().replace("mapped", "intermediary")) })
.findFirst()
.get()
}
if (getProject().hasProperty("baritone.fabric_build")) {
task copyMcJar(type: Copy) {
def mcJar = { getClientJarFabric() }
from mcJar
into 'build/createMcIntermediaryJar/'
rename { 'client.jar' }
}
task proguard(type: ProguardTask, dependsOn: copyMcJar) {
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
extract 'proguard6.0.3/lib/proguard.jar'
}
task createDist(type: CreateDistTask, dependsOn: proguard)
} else {
task copyMcJar(type: Copy) {
def mcJar = { getClientJar() }
from mcJar
into 'build/createMcSrgJar/'
rename { 'client-srg.jar' }
}
task createSrgMc(type: RenameJarInPlace) {
setInput(new File(copyMcJar.getOutputs().getFiles().getSingleFile(), "client-srg.jar"))
setClasspath(files({ getClientJar() }))
// fork
setMappingType(net.minecraftforge.gradle.common.util.MappingFile.Mapping.SEARGE)
setJarTask('trans alaska pipeline')
}
project.afterEvaluate {
createSrgMc.dependsOn(extractSrg, copyMcJar)
createSrgMc.setMappings(extractSrg.getOutput())
}
task proguard(type: ProguardTask, dependsOn: createSrgMc) { // TODO: dont need to create srg mc if doing notch build
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
extract 'proguard6.0.3/lib/proguard.jar'
}
task createDist(type: CreateDistTask, dependsOn: proguard)
}
build.finalizedBy(createDist)
install {
def jarApiName = String.format("%s-api-%s", rootProject.name, version.toString())
def jarApiForgeName = String.format("%s-api-forge-%s", rootProject.name, version.toString())
def jarSAName = String.format("%s-standalone-%s", rootProject.name, version.toString())
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
artifacts {
archives file("$buildDir/libs/"+jarApiName+".jar")
archives file("$buildDir/libs/"+jarApiForgeName+".jar")
archives file("$buildDir/libs/"+jarSAName+".jar")
archives file("$buildDir/libs/"+jarSAForgeName+".jar")
}
repositories.mavenInstaller {
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
}
}
task proguard(type: ProguardTask) {
url 'https://downloads.sourceforge.net/project/proguard/v7.1.0-beta5/proguard-7.1.0-beta5.zip'
extract 'proguard-7.1.0-beta5/lib/proguard.jar'
compType compileType
}
task createDist(type: CreateDistTask, dependsOn: proguard)
build.finalizedBy(createDist)
install.dependsOn(build)

View File

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

View File

@@ -0,0 +1,259 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.gradle.fabric;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/**
* @Author Wagyourtail
*/
public class CreateVolderYarn {
public static String VOLDERYARNFOLDER = "./build/volderyarn/";
public static String VOLDERYARN = "volderyarn-%s-%s-%s.jar";
public static void genMappings(String mcVersion, Map<String, String> mcpVersion) throws IOException {
//download yarn intermediary
URL intURL = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%s/intermediary-%s-v2.jar", mcVersion, mcVersion));
String intermediary = readZipContentFromURL(intURL, "mappings/mappings.tiny").get("mappings/mappings.tiny");
Map<String, ClassData> mappings = parseTinyMap(intermediary);
//download srg
URL srgURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_config/%s/mcp_config-%s.zip", mcVersion, mcVersion));
String tsrg = readZipContentFromURL(srgURL, "config/joined.tsrg").get("config/joined.tsrg");
MCPData mcpData = addTSRGData(mappings, tsrg);
//download mcp
URL mcpURL = new URL(String.format("https://files.minecraftforge.net/maven/de/oceanlabs/mcp/mcp_%s/%s/mcp_%s-%s.zip", mcpVersion.get("channel"), mcpVersion.get("version"), mcpVersion.get("channel"), mcpVersion.get("version")));
Map<String, String> mcpfiles = readZipContentFromURL(mcpURL, "fields.csv", "methods.csv");
addMCPData(mcpData, mcpfiles.get("fields.csv"), mcpfiles.get("methods.csv"));
StringBuilder builder = new StringBuilder("tiny\t2\t0\tintermediary\tnamed");
for (ClassData clazz : mappings.values()) {
builder.append("\n").append(clazz.getIntToMCP());
}
File outputFolder = new File(VOLDERYARNFOLDER);
if (!outputFolder.exists() && !outputFolder.mkdirs())
throw new RuntimeException("Failed to create dir for volderyarn mappings.");
for (File f : outputFolder.listFiles()) {
if (!f.isDirectory()) f.delete();
}
File outputFile = new File(outputFolder, String.format(VOLDERYARN, mcVersion, mcpVersion.get("channel"), mcpVersion.get("version")));
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdir())
throw new FileNotFoundException("Failed to create folder for volderyarn!");
}
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outputFile))) {
output.putNextEntry(new ZipEntry("mappings/mappings.tiny"));
byte[] outData = builder.toString().getBytes(StandardCharsets.UTF_8);
output.write(outData, 0, outData.length);
}
}
private static Map<String, ClassData> parseTinyMap(String map) {
Map<String, ClassData> mappings = new LinkedHashMap<>();
ClassData clazzdata = null;
for (String line : map.split("\n")) {
String[] parts = line.trim().split("\t");
switch (parts[0]) {
case "c":
mappings.put(parts[1], clazzdata = new ClassData(mappings, parts[1], parts[2]));
break;
case "m":
assert clazzdata != null;
clazzdata.addMethod(parts[2], parts[1], parts[3]);
break;
case "f":
assert clazzdata != null;
clazzdata.addField(parts[2], parts[1], parts[3]);
break;
default:
}
}
return mappings;
}
private static MCPData addTSRGData(Map<String, ClassData> mappings, String tsrg) {
MCPData mcpData = new MCPData();
String[] classes = String.join("\t", tsrg.split("\n\t")).split("\n");
for (String c : classes) {
String[] lines = c.split("\t");
String[] classData = lines[0].split("\\s+");
ClassData clazz = mappings.get(classData[0]);
if (clazz == null) continue;
clazz.mcpName = classData[1];
for (int i = 1; i < lines.length; ++i) {
String[] lineData = lines[i].split("\\s+");
//method
if (lineData.length == 3) {
if (!mcpData.methods.containsKey(lineData[2])) mcpData.methods.put(lineData[2], new LinkedList<>());
MethodData d = clazz.methods.get(lineData[0] + lineData[1]);
if (d == null) continue;
d.mcpName = lineData[2];
mcpData.methods.get(lineData[2]).add(d);
//field
} else {
if (!mcpData.fields.containsKey(lineData[1])) mcpData.fields.put(lineData[1], new LinkedList<>());
FieldData d = clazz.fields.get(lineData[0]);
if (d == null) continue;
d.mcpName = lineData[1];
mcpData.fields.get(lineData[1]).add(d);
}
}
}
return mcpData;
}
private static void addMCPData(MCPData mcpData, String fields, String methods) {
for (String field : fields.split("\n")) {
String[] fieldData = field.split(",");
mcpData.fields.getOrDefault(fieldData[0].trim(), new LinkedList<>()).forEach(f -> f.mcpName = fieldData[1].trim());
}
for (String method : methods.split("\n")) {
String[] methodData = method.split(",");
mcpData.methods.getOrDefault(methodData[0].trim(), new LinkedList<>()).forEach(m -> m.mcpName = methodData[1].trim());
}
}
private static Map<String, String> readZipContentFromURL(URL remote, String... files) throws IOException {
try (ZipInputStream is = new ZipInputStream(new BufferedInputStream(remote.openStream(), 1024))) {
byte[] buff = new byte[1024];
ZipEntry entry;
Set<String> fileList = new HashSet<>(Arrays.asList(files));
Map<String, String> fileContents = new HashMap<>();
while ((entry = is.getNextEntry()) != null) {
if (fileList.contains(entry.getName())) {
StringBuilder builder = new StringBuilder();
int read;
while ((read = is.read(buff, 0, 1024)) > 0) {
builder.append(new String(buff, 0, read));
}
fileContents.put(entry.getName(), builder.toString());
}
}
return fileContents;
}
}
private static class ClassData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final Map<String, MethodData> methods = new LinkedHashMap<>();
final Map<String, FieldData> fields = new LinkedHashMap<>();
public ClassData(Map<String, ClassData> classMap, String obf, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.intermediary = intermediary;
}
public void addMethod(String obf, String obfSig, String intermediary) {
methods.put(obf + obfSig, new MethodData(classMap, obf, obfSig, intermediary));
}
public void addField(String obf, String obfSig, String intermediary) {
fields.put(obf, new FieldData(classMap, obf, obfSig, intermediary));
}
public String getIntToMCP() {
StringBuilder builder = new StringBuilder("c\t").append(intermediary).append("\t").append(mcpName);
for (MethodData method : methods.values()) {
builder.append("\n\tm\t").append(method.getIntermediarySig()).append("\t").append(method.intermediary).append("\t").append(method.mcpName);
}
for (FieldData field : fields.values()) {
builder.append("\n\tf\t").append(field.getIntermediarySig()).append("\t").append(field.intermediary).append("\t").append(field.mcpName);
}
return builder.toString();
}
}
private static class MethodData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final String obfSig;
public MethodData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.obfSig = obfSig;
this.intermediary = intermediary;
}
public String getIntermediarySig() {
int offset = 0;
Matcher m = Pattern.compile("L(.+?);").matcher(obfSig);
String intSig = obfSig;
while (m.find()) {
if (!classMap.containsKey(m.group(1))) continue;
String intName = classMap.get(m.group(1)).intermediary;
intSig = intSig.substring(0, m.start(1) + offset) + intName + intSig.substring(m.end(1) + offset);
offset += intName.length() - m.group(1).length();
}
return intSig;
}
}
private static class FieldData {
final Map<String, ClassData> classMap;
final String obf;
final String intermediary;
String mcpName;
final String obfSig;
public FieldData(Map<String, ClassData> classMap, String obf, String obfSig, String intermediary) {
this.classMap = classMap;
this.obf = obf;
this.obfSig = obfSig;
this.intermediary = intermediary;
}
public String getIntermediarySig() {
Matcher m = Pattern.compile("(\\[*)L(.+?);").matcher(obfSig);
if (m.find()) {
if (!classMap.containsKey(m.group(2))) return obfSig;
return m.group(1) + "L" + classMap.get(m.group(2)).intermediary + ";";
} else {
return obfSig;
}
}
}
private static class MCPData {
final Map<String, List<MethodData>> methods = new HashMap<>();
final Map<String, List<FieldData>> fields = new HashMap<>();
}
}

View File

@@ -99,7 +99,7 @@ class BaritoneGradleTask extends DefaultTask {
}
protected Path getRelativeFile(String file) {
return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath());
return Paths.get(new File(file).getAbsolutePath());
}
protected Path getTemporaryFile(String file) {

View File

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

View File

@@ -22,10 +22,21 @@ import org.apache.commons.io.IOUtils;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.JavaVersion;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.internal.file.IdentityFileResolver;
import org.gradle.api.internal.plugins.DefaultConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.Pair;
import org.gradle.internal.jvm.Jvm;
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
import org.gradle.process.internal.DefaultExecActionFactory;
import java.io.*;
import java.net.URL;
@@ -48,33 +59,13 @@ public class ProguardTask extends BaritoneGradleTask {
@Input
private String url;
public String getUrl() {
return url;
}
@Input
private String extract;
public String getExtract() {
return extract;
}
@Input
private String compType;
public String getCompType() {
return compType;
}
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
@TaskAction
protected void exec() throws Exception {
super.verifyArtifacts();
copyMcJar();
// "Haha brady why don't you make separate tasks"
processArtifact();
downloadProguard();
@@ -85,32 +76,6 @@ public class ProguardTask extends BaritoneGradleTask {
cleanup();
}
private boolean isMcJar(File f) {
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-mapped");
}
private void copyMcJar() throws IOException {
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles()
.stream()
.filter(this::isMcJar)
.map(f -> {
switch (compType) {
case "OFFICIAL":
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
case "FABRIC":
return new File(f.getParentFile(), "minecraft-intermediary.jar");
case "FORGE":
return new File(f.getParentFile(), "minecraft-srg.jar");
}
return null;
})
.findFirst()
.get();
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
}
private void processArtifact() throws Exception {
if (Files.exists(this.artifactUnoptimizedPath)) {
Files.delete(this.artifactUnoptimizedPath);
@@ -219,16 +184,15 @@ public class ProguardTask extends BaritoneGradleTask {
}
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");
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;
}
@@ -237,22 +201,33 @@ public class ProguardTask extends BaritoneGradleTask {
// Setup the template that will be used to derive the API and Standalone configs
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
template.add(0, "-injars " + this.artifactPath.toString());
template.add(1, "-outjars " + this.getTemporaryFile(PROGUARD_EXPORT_PATH));
template.add(0, "-injars '" + this.artifactPath.toString() + "'");
template.add(1, "-outjars '" + this.getTemporaryFile(PROGUARD_EXPORT_PATH) + "'");
template.add(2, "-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)");
template.add(3, "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)");
// Acquire the RT jar using "java -verbose". This doesn't work on Java 9+
Process p = new ProcessBuilder(this.getJavaBinPathForProguard(), "-verbose").start();
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
template.add(2, "-libraryjars '" + out + "'");
{
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"));
// remove MCP mapped jar
.filter(f -> !f.toString().endsWith("-recomp.jar"))
// go from the extra to the original downloaded client
.map(f -> f.toString().endsWith("client-extra.jar") ? new File(f.getParentFile(), "client.jar") : f);
libraries = dependencies
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
if (getProject().hasProperty("baritone.forge_build")) {
libraries = dependencies
.map(f -> f.toString().endsWith("client.jar") ? getSrgMcJar() : f);
} else if (getProject().hasProperty("baritone.fabric_build")) {
libraries = dependencies
.map(f -> f.getName().endsWith("-v2.jar") && f.getName().startsWith("minecraft-") ? getSrgMcJar() : f);
} else {
libraries = dependencies;
}
}
libraries.forEach(f -> {
template.add(2, "-libraryjars '" + f + "'");
@@ -302,19 +277,21 @@ public class ProguardTask extends BaritoneGradleTask {
this.extract = extract;
}
public void setCompType(String compType) {
this.compType = compType;
}
private void runProguard(Path config) throws Exception {
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
if (Files.exists(this.proguardOut)) {
Files.delete(this.proguardOut);
}
Path proguardJar = getTemporaryFile(PROGUARD_JAR);
// Make paths relative to work directory; fixes spaces in path to config, @"" doesn't work
Path workingDirectory = getTemporaryFile("");
Path proguardJar = workingDirectory.relativize(getTemporaryFile(PROGUARD_JAR));
config = workingDirectory.relativize(config);
// Honestly, if you still have spaces in your path at this point, you're SOL.
Process p = new ProcessBuilder("java", "-jar", proguardJar.toString(), "@" + config.toString())
.directory(getTemporaryFile("").toFile()) // Set the working directory to the temporary folder]
.directory(workingDirectory.toFile()) // Set the working directory to the temporary folder]
.start();
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this

View File

@@ -1,13 +0,0 @@
org.gradle.jvmargs=-Xmx2048M
mod_version=1.7.2
maven_group=baritone
archives_base_name=baritone
minecraft_version=1.17.1
forge_version=1.17.1-37.0.69
fabric_version=0.11.6
# # 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,6 @@
#Tue Jul 31 21:56:56 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

View File

@@ -1,5 +1,6 @@
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes InnerClasses
-optimizationpasses 5
-verbose
@@ -27,6 +28,7 @@
-keep class baritone.api.IBaritoneProvider
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
-keepname class baritone.api.utils.BlockOptionalMeta # this name is exposed to the user, so we need to keep it in all builds
# Keep any class or member annotated with @KeepName so we dont have to put everything in the script
-keep,allowobfuscation @interface baritone.KeepName
@@ -45,9 +47,10 @@
#try to keep usage of schematica in separate classes
-keep class baritone.utils.schematic.schematica.**
-keep class baritone.utils.schematic.litematica.**
#proguard doesnt like it when it cant find our fake schematica classes
-dontwarn baritone.utils.schematic.schematica.**
-dontwarn baritone.utils.schematic.litematica.**
# Keep - Applications. Keep all application classes, along with their 'main'
# methods.

View File

@@ -15,26 +15,5 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
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

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

View File

@@ -21,22 +21,21 @@ import baritone.api.utils.NotificationHelper;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.TypeUtils;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.text.ITextComponent;
import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.List;
import java.util.function.Consumer;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
/**
* Baritone's settings. Settings apply to all Baritone instances.
@@ -50,6 +49,11 @@ public final class Settings {
*/
public final Setting<Boolean> allowBreak = new Setting<>(true);
/**
* Blocks that baritone will be allowed to break even with allowBreak set to false
*/
public final Setting<List<Block>> allowBreakAnyway = new Setting<>(new ArrayList<>());
/**
* Allow Baritone to sprint
*/
@@ -103,6 +107,13 @@ public final class Settings {
*/
public final Setting<Double> walkOnWaterOnePenalty = new Setting<>(3D);
/**
* Don't allow breaking blocks next to liquids.
* <p>
* Enable if you have mods adding custom fluid physics.
*/
public final Setting<Boolean> strictLiquidCheck = new Setting<>(false);
/**
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
* Reliability: questionable.
@@ -112,6 +123,8 @@ public final class Settings {
/**
* Allow Baritone to assume it can walk on still water just like any other block.
* This functionality is assumed to be provided by a separate library that might have imported Baritone.
* <p>
* Note: This will prevent some usage of the frostwalker enchantment, like pillaring up from water.
*/
public final Setting<Boolean> assumeWalkOnWater = new Setting<>(false);
@@ -192,7 +205,7 @@ public final class Settings {
* Blocks that Baritone is not allowed to break
*/
public final Setting<List<Block>> blocksToDisallowBreaking = new Setting<>(new ArrayList<>(
// Leave Empty by Default
// Leave Empty by Default
));
/**
@@ -232,6 +245,8 @@ public final class Settings {
* A mapping of blocks to blocks treated as correct in their position
* <p>
* If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well
* <p>
* Syntax same as <a href="https://baritone.leijurv.com/baritone/api/Settings.html#buildSubstitutes">buildSubstitutes</a>
*/
public final Setting<Map<Block, List<Block>>> buildValidSubstitutes = new Setting<>(new HashMap<>());
@@ -239,6 +254,15 @@ public final class Settings {
* A mapping of blocks to blocks to be built instead
* <p>
* If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list
* <p>
* Usage Syntax:
* <pre>
* sourceblockA->blockToSubstituteA1,blockToSubstituteA2,...blockToSubstituteAN,sourceBlockB->blockToSubstituteB1,blockToSubstituteB2,...blockToSubstituteBN,...sourceBlockX->blockToSubstituteX1,blockToSubstituteX2...blockToSubstituteXN
* </pre>
* Example:
* <pre>
* stone->cobblestone,andesite,oak_planks->birch_planks,acacia_planks,glass
* </pre>
*/
public final Setting<Map<Block, List<Block>>> buildSubstitutes = new Setting<>(new HashMap<>());
@@ -261,6 +285,12 @@ public final class Settings {
*/
public final Setting<Boolean> buildIgnoreDirection = new Setting<>(false);
/**
* A list of names of block properties the builder will ignore.
*/
public final Setting<List<String>> buildIgnoreProperties = new Setting<>(new ArrayList<>(Arrays.asList(
)));
/**
* If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block.
* <p>
@@ -388,6 +418,9 @@ public final class Settings {
*/
public final Setting<Double> mobSpawnerAvoidanceCoefficient = new Setting<>(2.0);
/**
* Distance to avoid mob spawners.
*/
public final Setting<Integer> mobSpawnerAvoidanceRadius = new Setting<>(16);
/**
@@ -397,6 +430,9 @@ public final class Settings {
*/
public final Setting<Double> mobAvoidanceCoefficient = new Setting<>(1.5);
/**
* Distance to avoid mobs.
*/
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
/**
@@ -547,6 +583,17 @@ public final class Settings {
*/
public final Setting<Long> slowPathTimeoutMS = new Setting<>(40000L);
/**
* allows baritone to save bed waypoints when interacting with beds
*/
public final Setting<Boolean> doBedWaypoints = new Setting<>(true);
/**
* allows baritone to save death waypoints
*/
public final Setting<Boolean> doDeathWaypoints = new Setting<>(true);
/**
* The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing.
*/
@@ -795,7 +842,6 @@ public final class Settings {
/**
* Sets the minimum y level whilst mining - set to 0 to turn off.
* if world has negative y values, subtract the min world height to get the value to put here
*/
public final Setting<Integer> minYLevelWhileMining = new Setting<>(0);
@@ -883,12 +929,12 @@ public final class Settings {
/**
* Only build the selected part of schematics
*/
public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
public final Setting<Boolean> buildOnlySelection = new Setting<>(false);
/**
* How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely
*/
public final Setting<Vec3i> buildRepeat = new Setting<>(new Vec3i(0, 0, 0));
public final Setting<Vector3i> buildRepeat = new Setting<>(new Vector3i(0, 0, 0));
/**
* How many times to buildrepeat. -1 for infinite.
@@ -1095,7 +1141,7 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
public final Setting<Consumer<Component>> logger = new Setting<>(Minecraft.getInstance().gui.getChat()::addMessage);
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(msg -> Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(msg));
/**
* The function that is called when Baritone will send a desktop notification. This function can be added to
@@ -1109,7 +1155,7 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
public final Setting<BiConsumer<Component, Component>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
public final Setting<BiConsumer<ITextComponent, ITextComponent>> toaster = new Setting<>(BaritoneToast::addOrUpdate);
/**
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,7 +26,8 @@ import java.util.stream.Stream;
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
INSTANCE;
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
private static String ScalesAliasRegex = "[kKmM]";
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(" + ScalesAliasRegex + "?)|)$");
@Override
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
@@ -41,11 +42,15 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
boolean isRelative = !matcher.group(1).isEmpty();
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll(ScalesAliasRegex, ""));
if (matcher.group(2).contains("k")) {
if (matcher.group(2).toLowerCase().contains("k")) {
offset *= 1000;
}
if (matcher.group(2).toLowerCase().contains("m")) {
offset *= 1000000;
}
if (isRelative) {
return origin + offset;

View File

@@ -83,10 +83,10 @@ public enum RelativeFile implements IDatatypePost<File, File> {
boolean useParent = !currentPathStringThing.isEmpty() && !currentPathStringThing.endsWith(File.separator);
File currentFile = currentPath.isAbsolute() ? currentPath.toFile() : new File(base, currentPathStringThing);
return Stream.of(Objects.requireNonNull(getCanonicalFileUnchecked(
useParent
? currentFile.getParentFile()
: currentFile
).listFiles()))
useParent
? currentFile.getParentFile()
: currentFile
).listFiles()))
.map(f -> (currentPath.isAbsolute() ? f : basePath.relativize(f.toPath()).toString()) +
(f.isDirectory() ? File.separator : ""))
.filter(s -> s.toLowerCase(Locale.US).startsWith(currentPathStringThing.toLowerCase(Locale.US)))
@@ -94,7 +94,7 @@ public enum RelativeFile implements IDatatypePost<File, File> {
}
public static File gameDir() {
File gameDir = HELPER.mc.gameDirectory.getAbsoluteFile();
File gameDir = HELPER.mc.gameDir.getAbsoluteFile();
if (gameDir.getName().equals(".")) {
return gameDir.getParentFile();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,13 +23,14 @@ import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil;
import net.minecraft.util.ResourceLocation;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.resources.ResourceLocation;
/**
* The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper

View File

@@ -84,7 +84,7 @@ public class Registry<V> {
* @param entry The entry to unregister.
*/
public void unregister(V entry) {
if (registered(entry)) {
if (!registered(entry)) {
return;
}
_entries.remove(entry);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,10 +18,11 @@
package baritone.api.pathing.goals;
import baritone.api.utils.SettingsUtil;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays;
import net.minecraft.core.BlockPos;
/**
* Useful for automated combat (retreating specifically)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,9 +18,9 @@
package baritone.api.schematic;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.block.BlockState;
import java.util.List;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
public class FillSchematic extends AbstractSchematic {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,11 +17,11 @@
package baritone.api.schematic;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.block.AirBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.BlockState;
import net.minecraft.state.Property;
import java.util.Collection;
import java.util.HashMap;
@@ -34,7 +34,7 @@ public class SubstituteSchematic extends AbstractSchematic {
private final Map<Block, List<Block>> substitutions;
private final Map<BlockState, Map<Block, BlockState>> blockStateCache = new HashMap<>();
public SubstituteSchematic(ISchematic schematic, Map<Block,List<Block>> substitutions) {
public SubstituteSchematic(ISchematic schematic, Map<Block, List<Block>> substitutions) {
super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
this.schematic = schematic;
this.substitutions = substitutions;
@@ -58,7 +58,7 @@ public class SubstituteSchematic extends AbstractSchematic {
}
for (Block substitute : substitutes) {
if (substitute instanceof AirBlock) {
return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.defaultBlockState(); // can always "place" air
return current.getBlock() instanceof AirBlock ? current : Blocks.AIR.getDefaultState(); // can always "place" air
}
for (BlockState placeable : approxPlaceable) {
if (substitute.equals(placeable.getBlock())) {
@@ -66,25 +66,26 @@ public class SubstituteSchematic extends AbstractSchematic {
}
}
}
return substitutes.get(0).defaultBlockState();
return substitutes.get(0).getDefaultState();
}
private BlockState withBlock(BlockState state, Block block) {
if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) {
return blockStateCache.get(state).get(block);
}
Collection<Property<?>> properties = state.getProperties();
BlockState newState = block.defaultBlockState();
Collection<Property<?>> properties = state.getBlock().getStateContainer().getProperties();
BlockState newState = block.getDefaultState();
for (Property<?> property : properties) {
try {
newState = copySingleProp(state, newState, property);
} catch (IllegalArgumentException e) { //property does not exist for target block
}
}
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block,BlockState>()).put(block, newState);
blockStateCache.computeIfAbsent(state, s -> new HashMap<Block, BlockState>()).put(block, newState);
return newState;
}
private <T extends Comparable<T>> BlockState copySingleProp(BlockState fromState, BlockState toState, Property<T> prop) {
return toState.setValue(prop, fromState.getValue(prop));
return toState.with(prop, fromState.get(prop));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,12 +18,12 @@
package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TextFormatting;
import java.util.Arrays;
import java.util.Calendar;
import java.util.stream.Stream;
@@ -47,19 +47,19 @@ public interface Helper {
*/
Minecraft mc = Minecraft.getInstance();
static Component getPrefix() {
static ITextComponent getPrefix() {
// Inner text component
final Calendar now = Calendar.getInstance();
final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3;
BaseComponent baritone = new TextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
TextComponent baritone = new StringTextComponent(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.setStyle(baritone.getStyle().setFormatting(TextFormatting.LIGHT_PURPLE));
// Outer brackets
BaseComponent prefix = new TextComponent("");
prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
prefix.append("[");
TextComponent prefix = new StringTextComponent("");
prefix.setStyle(baritone.getStyle().setFormatting(TextFormatting.DARK_PURPLE));
prefix.appendString("[");
prefix.append(baritone);
prefix.append("]");
prefix.appendString("]");
return prefix;
}
@@ -70,7 +70,7 @@ public interface Helper {
* @param title The title to display in the popup
* @param message The message to display in the popup
*/
default void logToast(Component title, Component message) {
default void logToast(ITextComponent title, ITextComponent message) {
mc.execute(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message));
}
@@ -81,7 +81,7 @@ public interface Helper {
* @param message The message to display in the popup
*/
default void logToast(String title, String message) {
logToast(new TextComponent(title), new TextComponent(message));
logToast(new StringTextComponent(title), new StringTextComponent(message));
}
/**
@@ -90,7 +90,7 @@ public interface Helper {
* @param message The message to display in the popup
*/
default void logToast(String message) {
logToast(Helper.getPrefix(), new TextComponent(message));
logToast(Helper.getPrefix(), new StringTextComponent(message));
}
/**
@@ -157,10 +157,10 @@ public interface Helper {
* @param logAsToast Whether to log as a toast notification
* @param components The components to send
*/
default void logDirect(boolean logAsToast, Component... components) {
BaseComponent component = new TextComponent("");
default void logDirect(boolean logAsToast, ITextComponent... components) {
TextComponent component = new StringTextComponent("");
component.append(getPrefix());
component.append(new TextComponent(" "));
component.append(new StringTextComponent(" "));
Arrays.asList(components).forEach(component::append);
if (logAsToast) {
logToast(getPrefix(), component);
@@ -174,7 +174,7 @@ public interface Helper {
*
* @param components The components to send
*/
default void logDirect(Component... components) {
default void logDirect(ITextComponent... components) {
logDirect(BaritoneAPI.getSettings().logAsToast.value, components);
}
@@ -186,10 +186,10 @@ public interface Helper {
* @param color The color to print that message in
* @param logAsToast Whether to log as a toast notification
*/
default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
default void logDirect(String message, TextFormatting color, boolean logAsToast) {
Stream.of(message.split("\n")).forEach(line -> {
BaseComponent component = new TextComponent(line.replace("\t", " "));
component.setStyle(component.getStyle().withColor(color));
TextComponent component = new StringTextComponent(line.replace("\t", " "));
component.setStyle(component.getStyle().setFormatting(color));
logDirect(logAsToast, component);
});
}
@@ -201,7 +201,7 @@ public interface Helper {
* @param message The message to display in chat
* @param color The color to print that message in
*/
default void logDirect(String message, ChatFormatting color) {
default void logDirect(String message, TextFormatting color) {
logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value);
}
@@ -213,7 +213,7 @@ public interface Helper {
* @param logAsToast Whether to log as a toast notification
*/
default void logDirect(String message, boolean logAsToast) {
logDirect(message, ChatFormatting.GRAY, logAsToast);
logDirect(message, TextFormatting.GRAY, logAsToast);
}
/**

View File

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

View File

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

View File

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

View File

@@ -19,19 +19,20 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.BlockState;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d;
import java.util.Optional;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
/**
* @author Brady
@@ -52,13 +53,13 @@ public final class RotationUtils {
/**
* Offsets from the root block position to the center of each side.
*/
private static final Vec3[] BLOCK_SIDE_MULTIPLIERS = new Vec3[]{
new Vec3(0.5, 0, 0.5), // Down
new Vec3(0.5, 1, 0.5), // Up
new Vec3(0.5, 0.5, 0), // North
new Vec3(0.5, 0.5, 1), // South
new Vec3(0, 0.5, 0.5), // West
new Vec3(1, 0.5, 0.5) // East
private static final Vector3d[] BLOCK_SIDE_MULTIPLIERS = new Vector3d[]{
new Vector3d(0.5, 0, 0.5), // Down
new Vector3d(0.5, 1, 0.5), // Up
new Vector3d(0.5, 0.5, 0), // North
new Vector3d(0.5, 0.5, 1), // South
new Vector3d(0, 0.5, 0.5), // West
new Vector3d(1, 0.5, 0.5) // East
};
private RotationUtils() {}
@@ -71,7 +72,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination
*/
public static Rotation calcRotationFromCoords(BlockPos orig, BlockPos dest) {
return calcRotationFromVec3d(new Vec3(orig.getX(), orig.getY(), orig.getZ()), new Vec3(dest.getX(), dest.getY(), dest.getZ()));
return calcRotationFromVec3d(new Vector3d(orig.getX(), orig.getY(), orig.getZ()), new Vector3d(dest.getX(), dest.getY(), dest.getZ()));
}
/**
@@ -100,7 +101,7 @@ public final class RotationUtils {
* @return The rotation from the origin to the destination
* @see #wrapAnglesToRelative(Rotation, Rotation)
*/
public static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest, Rotation current) {
public static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest, Rotation current) {
return wrapAnglesToRelative(current, calcRotationFromVec3d(orig, dest));
}
@@ -111,11 +112,11 @@ public final class RotationUtils {
* @param dest The destination position
* @return The rotation from the origin to the destination
*/
private static Rotation calcRotationFromVec3d(Vec3 orig, Vec3 dest) {
private static Rotation calcRotationFromVec3d(Vector3d orig, Vector3d dest) {
double[] delta = {orig.x - dest.x, orig.y - dest.y, orig.z - dest.z};
double yaw = Mth.atan2(delta[0], -delta[2]);
double yaw = MathHelper.atan2(delta[0], -delta[2]);
double dist = Math.sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
double pitch = Mth.atan2(delta[1], dist);
double pitch = MathHelper.atan2(delta[1], dist);
return new Rotation(
(float) (yaw * RAD_TO_DEG),
(float) (pitch * RAD_TO_DEG)
@@ -128,19 +129,19 @@ public final class RotationUtils {
* @param rotation The input rotation
* @return Look vector for the rotation
*/
public static Vec3 calcVector3dFromRotation(Rotation rotation) {
float f = Mth.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f1 = Mth.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f2 = -Mth.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float f3 = Mth.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vec3((double) (f1 * f2), (double) f3, (double) (f * f2));
public static Vector3d calcVector3dFromRotation(Rotation rotation) {
float f = MathHelper.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f1 = MathHelper.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f2 = -MathHelper.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float f3 = MathHelper.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vector3d((double) (f1 * f2), (double) f3, (double) (f * f2));
}
/**
* @param ctx Context for the viewing entity
* @param pos The target block position
* @return The optional rotation
* @see #reachable(LocalPlayer, BlockPos, double)
* @see #reachable(ClientPlayerEntity, BlockPos, double)
*/
public static Optional<Rotation> reachable(IPlayerContext ctx, BlockPos pos) {
return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
@@ -162,11 +163,11 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance) {
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance) {
return reachable(entity, pos, blockReachDistance, false);
}
public static Optional<Rotation> reachable(LocalPlayer entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
public static Optional<Rotation> reachable(ClientPlayerEntity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity);
if (baritone.getPlayerContext().isLookingAt(pos)) {
/*
@@ -179,11 +180,11 @@ public final class RotationUtils {
*
* or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level
*/
Rotation hypothetical = new Rotation(entity.getYRot(), entity.getXRot() + 0.0001F);
Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F);
if (wouldSneak) {
// the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are
HitResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
if (result != null && result.getType() == HitResult.Type.BLOCK && ((BlockHitResult) result).getBlockPos().equals(pos)) {
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true);
if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(pos)) {
return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block
}
} else {
@@ -196,16 +197,16 @@ public final class RotationUtils {
return possibleRotation;
}
BlockState state = entity.level.getBlockState(pos);
VoxelShape shape = state.getShape(entity.level, pos);
BlockState state = entity.world.getBlockState(pos);
VoxelShape shape = state.getShape(entity.world, pos);
if (shape.isEmpty()) {
shape = Shapes.block();
shape = VoxelShapes.fullCube();
}
for (Vec3 sideOffset : BLOCK_SIDE_MULTIPLIERS) {
double xDiff = shape.min(Direction.Axis.X) * sideOffset.x + shape.max(Direction.Axis.X) * (1 - sideOffset.x);
double yDiff = shape.min(Direction.Axis.Y) * sideOffset.y + shape.max(Direction.Axis.Y) * (1 - sideOffset.y);
double zDiff = shape.min(Direction.Axis.Z) * sideOffset.z + shape.max(Direction.Axis.Z) * (1 - sideOffset.z);
possibleRotation = reachableOffset(entity, pos, new Vec3(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
for (Vector3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
double xDiff = shape.getStart(Direction.Axis.X) * sideOffset.x + shape.getEnd(Direction.Axis.X) * (1 - sideOffset.x);
double yDiff = shape.getStart(Direction.Axis.Y) * sideOffset.y + shape.getEnd(Direction.Axis.Y) * (1 - sideOffset.y);
double zDiff = shape.getStart(Direction.Axis.Z) * sideOffset.z + shape.getEnd(Direction.Axis.Z) * (1 - sideOffset.z);
possibleRotation = reachableOffset(entity, pos, new Vector3d(pos.getX(), pos.getY(), pos.getZ()).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak);
if (possibleRotation.isPresent()) {
return possibleRotation;
}
@@ -224,16 +225,16 @@ public final class RotationUtils {
* @param blockReachDistance The block reach distance of the entity
* @return The optional rotation
*/
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) {
Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.getYRot(), entity.getXRot()));
HitResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vector3d offsetPos, double blockReachDistance, boolean wouldSneak) {
Vector3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F);
Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak);
//System.out.println(result);
if (result != null && result.getType() == HitResult.Type.BLOCK) {
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
if (((BlockRayTraceResult) result).getPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
if (entity.world.getBlockState(pos).getBlock() instanceof AbstractFireBlock && ((BlockRayTraceResult) result).getPos().equals(pos.down())) {
return Optional.of(rotation);
}
}
@@ -250,6 +251,6 @@ public final class RotationUtils {
* @return The optional rotation
*/
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
}
}

View File

@@ -19,13 +19,14 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.item.Item;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.registry.Registry;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -49,7 +50,7 @@ import java.util.stream.Stream;
public class SettingsUtil {
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDirectory.toPath().resolve("baritone").resolve("settings.txt");
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDir.toPath().resolve("baritone").resolve("settings.txt");
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space
private static final String[] JAVA_ONLY_SETTINGS = {"logger", "notifier", "toaster"};
@@ -178,7 +179,7 @@ public class SettingsUtil {
/**
* This should always be the same as whether the setting can be parsed from or serialized to a string
*
* @param the setting
* @param setting The Setting
* @return true if the setting can not be set or read by the user
*/
public static boolean javaOnlySetting(Settings.Setting setting) {
@@ -241,8 +242,8 @@ public class SettingsUtil {
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
),
VEC3I(
Vec3i.class,
str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
Vector3i.class,
str -> new Vector3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ()
),
BLOCK(
@@ -252,7 +253,7 @@ public class SettingsUtil {
),
ITEM(
Item.class,
str -> Registry.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
str -> Registry.ITEM.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> Registry.ITEM.getKey(item).toString()
),
LIST() {
@@ -300,7 +301,7 @@ public class SettingsUtil {
Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType);
return ((Map<?,?>) value).entrySet().stream()
return ((Map<?, ?>) value).entrySet().stream()
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
.collect(Collectors.joining(","));
}

View File

@@ -17,14 +17,14 @@
package baritone.api.utils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.block.AbstractFireBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
/**
* @author Brady
@@ -42,22 +42,22 @@ public final class VecUtils {
* @return The center of the block's bounding box
* @see #getBlockPosCenter(BlockPos)
*/
public static Vec3 calculateBlockCenter(Level world, BlockPos pos) {
public static Vector3d calculateBlockCenter(World world, BlockPos pos) {
BlockState b = world.getBlockState(pos);
VoxelShape shape = b.getCollisionShape(world, pos);
if (shape.isEmpty()) {
return getBlockPosCenter(pos);
}
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;
double xDiff = (shape.getStart(Direction.Axis.X) + shape.getEnd(Direction.Axis.X)) / 2;
double yDiff = (shape.getStart(Direction.Axis.Y) + shape.getEnd(Direction.Axis.Y)) / 2;
double zDiff = (shape.getStart(Direction.Axis.Z) + shape.getEnd(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
if (b.getBlock() instanceof AbstractFireBlock) {//look at bottom of fire when putting it out
yDiff = 0;
}
return new Vec3(
return new Vector3d(
pos.getX() + xDiff,
pos.getY() + yDiff,
pos.getZ() + zDiff
@@ -72,10 +72,10 @@ public final class VecUtils {
*
* @param pos The block position
* @return The assumed center of the position
* @see #calculateBlockCenter(Level, BlockPos)
* @see #calculateBlockCenter(World, BlockPos)
*/
public static Vec3 getBlockPosCenter(BlockPos pos) {
return new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
public static Vector3d getBlockPosCenter(BlockPos pos) {
return new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
}
/**
@@ -105,7 +105,7 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos)
*/
public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
return distanceToCenter(pos, entity.position().x, entity.position().y, entity.position().z);
return distanceToCenter(pos, entity.getPositionVec().x, entity.getPositionVec().y, entity.getPositionVec().z);
}
/**
@@ -118,6 +118,6 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos)
*/
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
return distanceToCenter(pos, entity.position().x, pos.getY() + 0.5, entity.position().z);
return distanceToCenter(pos, entity.getPositionVec().x, pos.getY() + 0.5, entity.getPositionVec().z);
}
}

View File

@@ -17,66 +17,63 @@
package baritone.api.utils.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.gui.toasts.IToast;
import net.minecraft.client.gui.toasts.ToastGui;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
public class BaritoneToast implements Toast {
public class BaritoneToast implements IToast {
private String title;
private String subtitle;
private long firstDrawTime;
private boolean newDisplay;
private long totalShowTime;
public BaritoneToast(Component titleComponent, Component subtitleComponent, long totalShowTime) {
public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) {
this.title = titleComponent.getString();
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
this.totalShowTime = totalShowTime;
}
public Visibility render(PoseStack matrixStack, ToastComponent toastGui, long delta) {
public Visibility func_230444_a_(MatrixStack matrixStack, ToastGui toastGui, long delta) {
if (this.newDisplay) {
this.firstDrawTime = delta;
this.newDisplay = false;
}
//TODO: check
toastGui.getMinecraft().getTextureManager().bindForSetup(new ResourceLocation("textures/gui/toasts.png"));
//GlStateManager._color4f(1.0F, 1.0F, 1.0F, 255.0F);
toastGui.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/toasts.png"));
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 255.0f);
toastGui.blit(matrixStack, 0, 0, 0, 32, 160, 32);
if (this.subtitle == null) {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 12, -11534256);
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.title, 18, 12, -11534256);
} else {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 7, -11534256);
toastGui.getMinecraft().font.draw(matrixStack, this.subtitle, 18, 18, -16777216);
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.title, 18, 7, -11534256);
toastGui.getMinecraft().fontRenderer.drawString(matrixStack, this.subtitle, 18, 18, -16777216);
}
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
}
public void setDisplayedText(Component titleComponent, Component subtitleComponent) {
public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) {
this.title = titleComponent.getString();
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
this.newDisplay = true;
}
public static void addOrUpdate(ToastComponent toast, Component title, Component subtitle, long totalShowTime) {
public static void addOrUpdate(ToastGui toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) {
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
if (baritonetoast == null) {
toast.addToast(new BaritoneToast(title, subtitle, totalShowTime));
toast.add(new BaritoneToast(title, subtitle, totalShowTime));
} else {
baritonetoast.setDisplayedText(title, subtitle);
}
}
public static void addOrUpdate(Component title, Component subtitle) {
addOrUpdate(Minecraft.getInstance().getToasts(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value);
public static void addOrUpdate(ITextComponent title, ITextComponent subtitle) {
addOrUpdate(net.minecraft.client.Minecraft.getInstance().getToastGui(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value);
}
}

View File

@@ -17,7 +17,7 @@
package baritone.api.utils.interfaces;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos;
public interface IGoalRenderPos {

View File

@@ -18,68 +18,68 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkArray;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.Chunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.concurrent.atomic.AtomicReferenceArray;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.LevelChunk;
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkCache$Storage")
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkProvider$ChunkArray")
public abstract class MixinChunkArray implements IChunkArray {
@Shadow
private AtomicReferenceArray<LevelChunk> chunks;
private AtomicReferenceArray<Chunk> chunks;
@Shadow
private int chunkRadius;
private int viewDistance;
@Shadow
private int viewRange;
private int sideLength;
@Shadow
private int viewCenterX;
private int centerX;
@Shadow
private int viewCenterZ;
private int centerZ;
@Shadow
private int chunkCount;
private int loaded;
@Shadow
protected abstract boolean inRange(int x, int z);
protected abstract boolean inView(int x, int z);
@Shadow
protected abstract int getIndex(int x, int z);
@Shadow
protected abstract void replace(int index, LevelChunk chunk);
protected abstract void replace(int index, Chunk chunk);
@Override
public int centerX() {
return viewCenterX;
return centerX;
}
@Override
public int centerZ() {
return viewCenterZ;
return centerZ;
}
@Override
public int viewDistance() {
return chunkRadius;
return viewDistance;
}
@Override
public AtomicReferenceArray<LevelChunk> getChunks() {
public AtomicReferenceArray<Chunk> getChunks() {
return chunks;
}
@Override
public void copyFrom(IChunkArray other) {
viewCenterX = other.centerX();
viewCenterZ = other.centerZ();
centerX = other.centerX();
centerZ = other.centerZ();
AtomicReferenceArray<LevelChunk> copyingFrom = other.getChunks();
AtomicReferenceArray<Chunk> copyingFrom = other.getChunks();
for (int k = 0; k < copyingFrom.length(); ++k) {
LevelChunk chunk = copyingFrom.get(k);
Chunk chunk = copyingFrom.get(k);
if (chunk != null) {
ChunkPos chunkpos = chunk.getPos();
if (inRange(chunkpos.x, chunkpos.z)) {
if (inView(chunkpos.x, chunkpos.z)) {
int index = getIndex(chunkpos.x, chunkpos.z);
if (chunks.get(index) != null) {
throw new IllegalStateException("Doing this would mutate the client's REAL loaded chunks?!");

View File

@@ -19,26 +19,24 @@ package baritone.launch.mixins;
import baritone.utils.accessor.IChunkArray;
import baritone.utils.accessor.IClientChunkProvider;
import org.spongepowered.asm.mixin.Final;
import net.minecraft.client.multiplayer.ClientChunkProvider;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.lang.reflect.Field;
import java.util.Arrays;
import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.client.multiplayer.ClientLevel;
@Mixin(ClientChunkCache.class)
@Mixin(ClientChunkProvider.class)
public class MixinClientChunkProvider implements IClientChunkProvider {
@Final
@Shadow
ClientLevel level;
private ClientWorld world;
@Override
public ClientChunkCache createThreadSafeCopy() {
public ClientChunkProvider createThreadSafeCopy() {
IChunkArray arr = extractReferenceArray();
ClientChunkCache result = new ClientChunkCache(level, arr.viewDistance() - 3); // -3 because its adds 3 for no reason lmao
ClientChunkProvider result = new ClientChunkProvider(world, arr.viewDistance() - 3); // -3 because its adds 3 for no reason lmao
IChunkArray copyArr = ((IClientChunkProvider) result).extractReferenceArray();
copyArr.copyFrom(arr);
if (copyArr.viewDistance() != arr.viewDistance()) {
@@ -49,7 +47,7 @@ public class MixinClientChunkProvider implements IClientChunkProvider {
@Override
public IChunkArray extractReferenceArray() {
for (Field f : ClientChunkCache.class.getDeclaredFields()) {
for (Field f : ClientChunkProvider.class.getDeclaredFields()) {
if (IChunkArray.class.isAssignableFrom(f.getType())) {
try {
return (IChunkArray) f.get(this);
@@ -58,6 +56,6 @@ public class MixinClientChunkProvider implements IClientChunkProvider {
}
}
}
throw new RuntimeException(Arrays.toString(ClientChunkCache.class.getDeclaredFields()));
throw new RuntimeException(Arrays.toString(ClientChunkProvider.class.getDeclaredFields()));
}
}

View File

@@ -23,10 +23,10 @@ import baritone.api.IBaritone;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.type.EventState;
import baritone.cache.CachedChunk;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.game.*;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.network.play.server.*;
import net.minecraft.util.math.ChunkPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -36,7 +36,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
* @author Brady
* @since 8/3/2018
*/
@Mixin(ClientPacketListener.class)
@Mixin(ClientPlayNetHandler.class)
public class MixinClientPlayNetHandler {
// unused lol
@@ -64,19 +64,19 @@ public class MixinClientPlayNetHandler {
}*/
@Inject(
method = "handleLevelChunk",
method = "handleChunkData",
at = @At("RETURN")
)
private void postHandleChunkData(ClientboundLevelChunkPacket packetIn, CallbackInfo ci) {
private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
!packetIn.isSkippable() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
packetIn.getX(),
packetIn.getZ()
packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL,
packetIn.getChunkX(),
packetIn.getChunkZ()
)
);
}
@@ -84,13 +84,13 @@ public class MixinClientPlayNetHandler {
}
@Inject(
method = "handleForgetLevelChunk",
method = "processChunkUnload",
at = @At("HEAD")
)
private void preChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackInfo ci) {
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@@ -99,13 +99,13 @@ public class MixinClientPlayNetHandler {
}
@Inject(
method = "handleForgetLevelChunk",
method = "processChunkUnload",
at = @At("RETURN")
)
private void postChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackInfo ci) {
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@@ -114,19 +114,19 @@ public class MixinClientPlayNetHandler {
}
@Inject(
method = "handleBlockUpdate",
method = "handleBlockChange",
at = @At("RETURN")
)
private void postHandleBlockChange(ClientboundBlockUpdatePacket packetIn, CallbackInfo ci) {
private void postHandleBlockChange(SChangeBlockPacket packetIn, CallbackInfo ci) {
if (!Baritone.settings().repackOnAnyBlockChange.value) {
return;
}
if (!CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(packetIn.getBlockState().getBlock())) {
if (!CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(packetIn.getState().getBlock())) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
@@ -140,15 +140,15 @@ public class MixinClientPlayNetHandler {
}
@Inject(
method = "handleChunkBlocksUpdate",
method = "handleMultiBlockChange",
at = @At("RETURN")
)
private void postHandleMultiBlockChange(ClientboundSectionBlocksUpdatePacket packetIn, CallbackInfo ci) {
private void postHandleMultiBlockChange(SMultiBlockChangePacket packetIn, CallbackInfo ci) {
if (!Baritone.settings().repackOnAnyBlockChange.value) {
return;
}
ChunkPos[] chunkPos = new ChunkPos[1];
packetIn.runUpdates((pos, state) -> {
packetIn.func_244310_a((pos, state) -> {
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(state.getBlock())) {
chunkPos[0] = new ChunkPos(pos);
}
@@ -157,8 +157,8 @@ public class MixinClientPlayNetHandler {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
@@ -172,16 +172,16 @@ public class MixinClientPlayNetHandler {
}
@Inject(
method = "handlePlayerCombatKill",
method = "handleCombatEvent",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"
target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/screen/Screen;)V"
)
)
private void onPlayerDeath(ClientboundPlayerCombatKillPacket packetIn, CallbackInfo ci) {
private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onPlayerDeath();
}
}

View File

@@ -24,9 +24,9 @@ import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.type.EventState;
import baritone.behavior.LookBehavior;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.player.Abilities;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.PlayerAbilities;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -37,17 +37,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
* @author Brady
* @since 8/1/2018
*/
@Mixin(LocalPlayer.class)
@Mixin(ClientPlayerEntity.class)
public class MixinClientPlayerEntity {
@Inject(
method = "chat",
method = "sendChatMessage",
at = @At("HEAD"),
cancellable = true
)
private void sendChatMessage(String msg, CallbackInfo ci) {
ChatEvent event = new ChatEvent(msg);
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone == null) {
return;
}
@@ -61,13 +61,13 @@ public class MixinClientPlayerEntity {
method = "tick",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/player/LocalPlayer.isPassenger()Z",
target = "net/minecraft/client/entity/player/ClientPlayerEntity.isPassenger()Z",
shift = At.Shift.BY,
by = -3
)
)
private void onPreUpdate(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone != null) {
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE));
}
@@ -77,44 +77,44 @@ public class MixinClientPlayerEntity {
method = "tick",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/player/LocalPlayer.sendPosition()V",
target = "net/minecraft/client/entity/player/ClientPlayerEntity.onUpdateWalkingPlayer()V",
shift = At.Shift.BY,
by = 2
)
)
private void onPostUpdate(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone != null) {
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
}
}
@Redirect(
method = "aiStep",
method = "livingTick",
at = @At(
value = "FIELD",
target = "net/minecraft/world/entity/player/Abilities.mayfly:Z"
target = "net/minecraft/entity/player/PlayerAbilities.allowFlying:Z"
)
)
private boolean isAllowFlying(Abilities capabilities) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
private boolean isAllowFlying(PlayerAbilities capabilities) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone == null) {
return capabilities.mayfly;
return capabilities.allowFlying;
}
return !baritone.getPathingBehavior().isPathing() && capabilities.mayfly;
return !baritone.getPathingBehavior().isPathing() && capabilities.allowFlying;
}
@Redirect(
method = "aiStep",
method = "livingTick",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/KeyMapping.isDown()Z"
target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z"
)
)
private boolean isKeyDown(KeyMapping keyBinding) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
private boolean isKeyDown(KeyBinding keyBinding) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone == null) {
return keyBinding.isDown();
return keyBinding.isKeyDown();
}
SprintStateEvent event = new SprintStateEvent();
baritone.getGameEventHandler().onPlayerSprintState(event);
@@ -125,17 +125,17 @@ public class MixinClientPlayerEntity {
// hitting control shouldn't make all bots sprint
return false;
}
return keyBinding.isDown();
return keyBinding.isKeyDown();
}
@Inject(
method = "rideTick",
method = "updateRidden",
at = @At(
value = "HEAD"
)
)
private void updateRidden(CallbackInfo cb) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone != null) {
((LookBehavior) baritone.getLookBehavior()).pig();
}

View File

@@ -22,6 +22,8 @@ import baritone.api.event.events.TabCompleteEvent;
import com.mojang.brigadier.context.StringRange;
import com.mojang.brigadier.suggestion.Suggestion;
import com.mojang.brigadier.suggestion.Suggestions;
import net.minecraft.client.gui.CommandSuggestionHelper;
import net.minecraft.client.gui.widget.TextFieldWidget;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -33,35 +35,33 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.client.gui.components.CommandSuggestions;
import net.minecraft.client.gui.components.EditBox;
/**
* @author Brady
* @since 10/9/2019
*/
@Mixin(CommandSuggestions.class)
@Mixin(CommandSuggestionHelper.class)
public class MixinCommandSuggestionHelper {
@Shadow
@Final
EditBox input;
private TextFieldWidget inputField;
@Shadow
@Final
private List<String> commandUsage;
private List<String> exceptionList;
@Shadow
private CompletableFuture<Suggestions> pendingSuggestions;
private CompletableFuture<Suggestions> suggestionsFuture;
@Inject(
method = "updateCommandInfo",
method = "init",
at = @At("HEAD"),
cancellable = true
)
private void preUpdateSuggestion(CallbackInfo ci) {
// Anything that is present in the input text before the cursor position
String prefix = this.input.getValue().substring(0, Math.min(this.input.getValue().length(), this.input.getCursorPosition()));
String prefix = this.inputField.getText().substring(0, Math.min(this.inputField.getText().length(), this.inputField.getCursorPosition()));
TabCompleteEvent event = new TabCompleteEvent(prefix);
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onPreTabComplete(event);
@@ -75,14 +75,14 @@ public class MixinCommandSuggestionHelper {
ci.cancel();
// TODO: Support populating the command usage
this.commandUsage.clear();
this.exceptionList.clear();
if (event.completions.length == 0) {
this.pendingSuggestions = Suggestions.empty();
this.suggestionsFuture = Suggestions.empty();
} else {
int offset = this.input.getValue().endsWith(" ")
? this.input.getCursorPosition()
: this.input.getValue().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
int offset = this.inputField.getText().endsWith(" ")
? this.inputField.getCursorPosition()
: this.inputField.getText().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
List<Suggestion> suggestionList = Stream.of(event.completions)
.map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s))
@@ -92,8 +92,8 @@ public class MixinCommandSuggestionHelper {
StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)),
suggestionList);
this.pendingSuggestions = new CompletableFuture<>();
this.pendingSuggestions.complete(suggestions);
this.suggestionsFuture = new CompletableFuture<>();
this.suggestionsFuture.complete(suggestions);
}
}
}

View File

@@ -19,8 +19,8 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.event.events.RotationMoveEvent;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinEntity {
@Shadow
private float yRot;
private float rotationYaw;
float yawRestore;
@@ -40,14 +40,14 @@ public class MixinEntity {
at = @At("HEAD")
)
private void moveRelativeHead(CallbackInfo info) {
this.yawRestore = this.yRot;
this.yawRestore = this.rotationYaw;
// noinspection ConstantConditions
if (!LocalPlayer.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this) == null) {
if (!ClientPlayerEntity.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) == null) {
return;
}
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.yRot);
BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
this.yRot = motionUpdateRotationEvent.getYaw();
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
this.rotationYaw = motionUpdateRotationEvent.getYaw();
}
@Inject(
@@ -55,6 +55,6 @@ public class MixinEntity {
at = @At("RETURN")
)
private void moveRelativeReturn(CallbackInfo info) {
this.yRot = this.yawRestore;
this.rotationYaw = this.yawRestore;
}
}

View File

@@ -18,25 +18,25 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IEntityRenderManager;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(EntityRenderDispatcher.class)
@Mixin(EntityRendererManager.class)
public class MixinEntityRenderManager implements IEntityRenderManager {
@Override
public double renderPosX() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().x;
return ((EntityRendererManager) (Object) this).info.getProjectedView().x;
}
@Override
public double renderPosY() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().y;
return ((EntityRendererManager) (Object) this).info.getProjectedView().y;
}
@Override
public double renderPosZ() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().z;
return ((EntityRendererManager) (Object) this).info.getProjectedView().z;
}
}

View File

@@ -18,8 +18,8 @@
package baritone.launch.mixins;
import baritone.api.utils.accessor.IItemStack;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -39,10 +39,10 @@ public abstract class MixinItemStack implements IItemStack {
private int baritoneHash;
@Shadow
protected abstract int getDamageValue();
protected abstract int getDamage();
private void recalculateHash() {
baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue();
baritoneHash = item == null ? -1 : item.hashCode() + getDamage();
}
@Inject(
@@ -54,7 +54,7 @@ public abstract class MixinItemStack implements IItemStack {
}
@Inject(
method = "setDamageValue",
method = "setDamage",
at = @At("TAIL")
)
private void onItemDamageSet(CallbackInfo ci) {
@@ -63,8 +63,6 @@ public abstract class MixinItemStack implements IItemStack {
@Override
public int getBaritoneHash() {
// TODO: figure out why <init> mixin not working, was 0 for some reason
if (baritoneHash == 0) recalculateHash();
return baritoneHash;
}
}

View File

@@ -20,11 +20,11 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RotationMoveEvent;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -45,37 +45,38 @@ public abstract class MixinLivingEntity extends Entity {
*/
private RotationMoveEvent jumpRotationEvent;
public MixinLivingEntity(EntityType<?> entityTypeIn, Level worldIn) {
public MixinLivingEntity(EntityType<?> entityTypeIn, World worldIn) {
super(entityTypeIn, worldIn);
}
@Inject(
method = "jumpFromGround",
method = "jump",
at = @At("HEAD")
)
private void preMoveRelative(CallbackInfo ci) {
// noinspection ConstantConditions
if (LocalPlayer.class.isInstance(this)) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
if (ClientPlayerEntity.class.isInstance(this)) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this);
if (baritone != null) {
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.getYRot());
this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw);
baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent);
}
}
}
@Redirect(
method = "jumpFromGround",
method = "jump",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.getYRot()F"
value = "FIELD",
opcode = GETFIELD,
target = "net/minecraft/entity/LivingEntity.rotationYaw:F"
)
)
private float overrideYaw(LivingEntity self) {
if (self instanceof LocalPlayer && BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this) != null) {
if (self instanceof ClientPlayerEntity && BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) != null) {
return this.jumpRotationEvent.getYaw();
}
return self.getYRot();
return self.rotationYaw;
}

View File

@@ -18,11 +18,11 @@
package baritone.launch.mixins;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootPredicateManager;
import net.minecraft.loot.LootTableManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -31,13 +31,13 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public class MixinLootContext {
@Redirect(
method = "create",
method = "build",
at = @At(
value = "INVOKE",
target = "net/minecraft/server/level/ServerLevel.getServer()Lnet/minecraft/server/MinecraftServer;"
target = "net/minecraft/world/server/ServerWorld.getServer()Lnet/minecraft/server/MinecraftServer;"
)
)
private MinecraftServer getServer(ServerLevel world) {
private MinecraftServer getServer(ServerWorld world) {
if (world == null) {
return null;
}
@@ -45,30 +45,30 @@ public class MixinLootContext {
}
@Redirect(
method = "create",
method = "build",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getLootTables()Lnet/minecraft/world/level/storage/loot/LootTables;"
target = "net/minecraft/server/MinecraftServer.getLootTableManager()Lnet/minecraft/loot/LootTableManager;"
)
)
private LootTables getLootTableManager(MinecraftServer server) {
private LootTableManager getLootTableManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getManager();
}
return server.getLootTables();
return server.getLootTableManager();
}
@Redirect(
method = "create",
method = "build",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getPredicateManager()Lnet/minecraft/world/level/storage/loot/PredicateManager;"
target = "net/minecraft/server/MinecraftServer.func_229736_aP_()Lnet/minecraft/loot/LootPredicateManager;"
)
)
private PredicateManager getLootPredicateManager(MinecraftServer server) {
private LootPredicateManager getLootPredicateManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getPredicateManager();
}
return server.getPredicateManager();
return server.func_229736_aP_();
}
}

View File

@@ -23,9 +23,9 @@ import baritone.api.event.events.TickEvent;
import baritone.api.event.events.WorldEvent;
import baritone.api.event.events.type.EventState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.world.ClientWorld;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -44,9 +44,9 @@ import java.util.function.BiFunction;
public class MixinMinecraft {
@Shadow
public LocalPlayer player;
public ClientPlayerEntity player;
@Shadow
public ClientLevel level;
public ClientWorld world;
@Inject(
method = "<init>",
@@ -58,14 +58,14 @@ public class MixinMinecraft {
@Inject(
method = "tick",
method = "runTick",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;",
ordinal = 5,
shift = At.Shift.BY,
by = -3
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
ordinal = 5,
shift = At.Shift.BY,
by = -3
)
)
private void runTick(CallbackInfo ci) {
@@ -83,12 +83,12 @@ public class MixinMinecraft {
}
@Inject(
method = "setLevel",
method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V",
at = @At("HEAD")
)
private void preLoadWorld(ClientLevel world, CallbackInfo ci) {
private void preLoadWorld(ClientWorld world, CallbackInfo ci) {
// If we're unloading the world but one doesn't exist, ignore it
if (this.level == null && world == null) {
if (this.world == null && world == null) {
return;
}
@@ -103,10 +103,10 @@ public class MixinMinecraft {
}
@Inject(
method = "setLevel",
method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V",
at = @At("RETURN")
)
private void postLoadWorld(ClientLevel world, CallbackInfo ci) {
private void postLoadWorld(ClientWorld world, CallbackInfo ci) {
// still fire event for both null, as that means we've just finished exiting a world
// mc.world changing is only the primary baritone
@@ -119,11 +119,11 @@ public class MixinMinecraft {
}
@Redirect(
method = "tick",
method = "runTick",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/gui/screens/Screen;passEvents:Z"
target = "net/minecraft/client/gui/screen/Screen.passEvents:Z"
)
)
private boolean passEvents(Screen screen) {

View File

@@ -25,9 +25,9 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.IPacket;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.PacketDirection;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -39,7 +39,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
* @author Brady
* @since 8/6/2018
*/
@Mixin(Connection.class)
@Mixin(NetworkManager.class)
public class MixinNetworkManager {
@Shadow
@@ -47,36 +47,36 @@ public class MixinNetworkManager {
@Shadow
@Final
private PacketFlow receiving;
private PacketDirection direction;
@Inject(
method = "sendPacket",
method = "dispatchPacket",
at = @At("HEAD")
)
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
private void preDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, inPacket));
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket));
}
}
}
@Inject(
method = "sendPacket",
method = "dispatchPacket",
at = @At("RETURN")
)
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
private void postDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, inPacket));
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket));
}
}
}
@@ -85,16 +85,16 @@ public class MixinNetworkManager {
method = "channelRead0",
at = @At(
value = "INVOKE",
target = "net/minecraft/network/Connection.genericsFtw(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;)V"
target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;)V"
)
)
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
private void preProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((Connection) (Object) this, EventState.PRE, packet));
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet));
}
}
}
@@ -103,13 +103,13 @@ public class MixinNetworkManager {
method = "channelRead0",
at = @At("RETURN")
)
private void postProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
if (!this.channel.isOpen() || this.receiving != PacketFlow.CLIENTBOUND) {
private void postProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
if (!this.channel.isOpen() || this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((Connection) (Object) this, EventState.POST, packet));
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet));
}
}
}

View File

@@ -18,24 +18,24 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IPlayerControllerMP;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.core.BlockPos;
import net.minecraft.client.multiplayer.PlayerController;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(MultiPlayerGameMode.class)
@Mixin(PlayerController.class)
public abstract class MixinPlayerController implements IPlayerControllerMP {
@Accessor("isDestroying")
@Accessor
@Override
public abstract void setIsHittingBlock(boolean isHittingBlock);
@Accessor("destroyBlockPos")
@Accessor
@Override
public abstract BlockPos getCurrentBlock();
@Invoker("ensureHasSentCarriedItem")
@Invoker
@Override
public abstract void callSyncCurrentPlayItem();
}

View File

@@ -18,11 +18,11 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import java.net.URI;
import net.minecraft.client.gui.screens.Screen;
@Mixin(Screen.class)
public abstract class MixinScreen implements IGuiScreen {

View File

@@ -0,0 +1,94 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkArray;
import baritone.utils.accessor.IClientChunkProvider;
import baritone.utils.accessor.ISodiumChunkArray;
import net.minecraft.client.multiplayer.ClientChunkProvider;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.concurrent.locks.StampedLock;
@Pseudo
@Mixin(targets = "me.jellysquid.mods.sodium.client.world.SodiumChunkManager", remap = false)
public class MixinSodiumChunkProvider implements IClientChunkProvider {
@Shadow
@Final
private StampedLock lock;
@Shadow
@Final
private ClientWorld world;
@Shadow
private int radius;
@Unique
private static Constructor<?> thisConstructor = null;
@Unique
private static Field chunkArrayField = null;
@Override
public ClientChunkProvider createThreadSafeCopy() {
// similar operation to https://github.com/jellysquid3/sodium-fabric/blob/d3528521d48a130322c910c6f0725cf365ebae6f/src/main/java/me/jellysquid/mods/sodium/client/world/SodiumChunkManager.java#L139
long stamp = this.lock.writeLock();
try {
ISodiumChunkArray refArray = extractReferenceArray();
if (thisConstructor == null) {
thisConstructor = this.getClass().getConstructor(ClientWorld.class, int.class);
}
ClientChunkProvider result = (ClientChunkProvider) thisConstructor.newInstance(world, radius - 3); // -3 because it adds 3 for no reason here too lmao
IChunkArray copyArr = ((IClientChunkProvider) result).extractReferenceArray();
copyArr.copyFrom(refArray);
return result;
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException("Sodium chunk manager initialization for baritone failed", e);
} finally {
// put this in finally so we can't break anything.
this.lock.unlockWrite(stamp);
}
}
@Override
public ISodiumChunkArray extractReferenceArray() {
https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.15
if (chunkArrayField == null) {
for (Field f : this.getClass().getDeclaredFields()) {
if (ISodiumChunkArray.class.isAssignableFrom(f.getType())) {
chunkArrayField = f;
break https;
}
}
throw new RuntimeException(Arrays.toString(this.getClass().getDeclaredFields()));
}
try {
return (ISodiumChunkArray) chunkArrayField.get(this);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,80 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkArray;
import baritone.utils.accessor.ISodiumChunkArray;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import net.minecraft.world.chunk.Chunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
import java.util.concurrent.atomic.AtomicReferenceArray;
@Pseudo
@Mixin(targets = "me.jellysquid.mods.sodium.client.util.collections.FixedLongHashTable", remap = false)
public abstract class MixinSodiumFixedLongHashTable implements ISodiumChunkArray {
@Shadow
public abstract ObjectIterator<Long2ObjectMap.Entry<Object>> iterator();
@Shadow
public abstract Object put(final long k, final Object v);
/**
* similar to https://github.com/jellysquid3/sodium-fabric/blob/d3528521d48a130322c910c6f0725cf365ebae6f/src/main/java/me/jellysquid/mods/sodium/client/world/SodiumChunkManager.java#L149
* except that since we aren't changing the radius, the key value doesn't change.
*/
@Override
public void copyFrom(IChunkArray other) {
ObjectIterator<Long2ObjectMap.Entry<Object>> it = ((ISodiumChunkArray) other).callIterator();
while (it.hasNext()) {
Long2ObjectMap.Entry<Object> entry = it.next();
this.put(entry.getLongKey(), entry.getValue());
}
}
@Override
public ObjectIterator<Long2ObjectMap.Entry<Object>> callIterator() {
return iterator();
}
//these are useless here...
@Override
public AtomicReferenceArray<Chunk> getChunks() {
return null;
}
@Override
public int centerX() {
return 0;
}
@Override
public int centerZ() {
return 0;
}
@Override
public int viewDistance() {
return 0;
}
}

View File

@@ -20,12 +20,12 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.math.vector.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -36,15 +36,15 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
* @author Brady
* @since 2/13/2020
*/
@Mixin(LevelRenderer.class)
@Mixin(WorldRenderer.class)
public class MixinWorldRenderer {
@Inject(
method = "renderLevel",
method = "updateCameraAndRender",
at = @At("RETURN"),
locals = LocalCapture.CAPTURE_FAILSOFT
)
private void onStartHand(PoseStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, Camera activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
private void onStartHand(MatrixStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, ActiveRenderInfo activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn));
}

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