Compare commits

...

572 Commits

Author SHA1 Message Date
ZacSharp
647daf23aa v1.9.5
previous commit was mistaken v1.9.4 already exists
2025-05-13 19:35:28 +02:00
ZacSharp
01379f5474 v1.9.4 2025-05-13 19:32:29 +02:00
leijurv
fd49333db6 Merge pull request #4747 from ZacSharp/pr/1.19.4/setting/migrateAllowJumpAt256
Migrate `allowJumpAt256` to `allowJumpAtBuildLimit` in settings files
2025-05-12 13:30:24 -07:00
ZacSharp
31b30e3a31 Migrate allowJumpAt256 to allowJumpAtBuildLimit in settings files 2025-05-10 20:24:26 +02:00
leijurv
0fe8c628c7 Merge pull request #4745 from ZacSharp/pr/1.19.4/misc/bsi/fixWrapperHeight
Fix height vs. max build height mixup
2025-05-10 11:07:24 -07:00
ZacSharp
f86f0ab6cd Fix height vs. max build height mixup 2025-05-10 15:51:20 +02:00
Murat Bayraktar
40e83423bc Update build limits (#4736)
* Update minimum build limit

* Update MovementDescend.java to work for any minimum height

* Update RenderCommand.java for dynamic build heights.

* Fix so it actually compiles.

* Small syntax change.

* Simpler formatting

* Fix more height issues.

* Remove allowJumpAt256 as redundant.

* Remove allowJumpAt256 as redundant.

* Update CalculationContext.java

* Update Settings.java

* Update Settings.java

* Deprecate allowJumpAt256.

* Re-introduce build limit jump setting.

* Update MovementParkour.java

* Update CalculationContext.java

* Update Settings.java

* Update CalculationContext.java

* Update src/api/java/baritone/api/Settings.java

Co-authored-by: ZacSharp <68165024+ZacSharp@users.noreply.github.com>

---------

Co-authored-by: Murat65536 <bob65536@proton.me>
Co-authored-by: ZacSharp <68165024+ZacSharp@users.noreply.github.com>
2025-05-09 22:36:17 -07:00
leijurv
d74420b265 Merge pull request #4720 from ZacSharp/pr/1.19.4/commands/preventRemoteCommandExecution
Don't let servers trick users into running arbitrary Baritone commands
2025-04-21 16:23:49 -07:00
ZacSharp
7aab08ae0f Don't let servers trick users into running arbitrary Baritone commands
As of now there shouldn't be any exploitable commands, but better be safe
2025-04-22 00:50:02 +02:00
leijurv
2fc8490c72 Merge pull request #4712 from ZacSharp/pr/1.19.4/misc/moreExceptionMessages
Add messages to more exceptions and improve some existing ones
2025-04-19 00:08:40 -07:00
leijurv
ddc2820418 Merge pull request #4713 from ZacSharp/pr/1.19.4/misc/useMinecraftEyeHeight
Use minecraft method to determine sneaking eye height
2025-04-18 15:30:30 -07:00
ZacSharp
9e1e89b91f Fix ancient comment 2025-04-18 23:34:16 +02:00
ZacSharp
7c4036dfb1 Don't leak coordinates in exceptions 2025-04-18 23:28:39 +02:00
ZacSharp
bbaa602fe9 Use minecraft method to determine sneaking eye height
Co-authored-by: Matthew Herber <matthewherber@sbcglobal.net>
2025-04-18 22:49:03 +02:00
ZacSharp
921822acd7 Add messages to more exceptions and improve some existing ones 2025-04-18 00:58:16 +02:00
leijurv
f019b81bd9 Merge pull request #2527 from ZacSharp/itemFollowing
Item following
2025-03-29 20:42:14 -07:00
leijurv
50df7b2026 Merge pull request #4677 from ZacSharp/pr/1.19.4/misc/backportCurrentLayerAndMenuLinks
Backport #4634 and #4205 to 1.19.4
2025-03-20 14:42:51 -07:00
Jack
92130f1642 Add issues links and link to Discord for ModMenu 2025-03-16 11:17:18 +01:00
Ic3Tank
fd13d5cbdc Expose current layer in IBuilderProcess 2025-03-16 11:14:51 +01:00
ZacSharp
209b51b253 Fix parsing invalid ResourceLocations once again
This is to fix `ItemById` by making `filterPrefixNamespaced` not fail on invalid prefixes
2025-03-15 20:16:06 +01:00
ZacSharp
3fa0f34c1e Remove unused import 2025-03-15 20:14:50 +01:00
ZacSharp
bf0c47c85c Command to pickup items 2025-03-15 20:14:38 +01:00
leijurv
9de3074041 Merge pull request #4662 from ZacSharp/pr/1.19.4/mine/fixCanWalkThroughButAvoidBreaking
Fix `MineProcess` stalling on blocks which are `canWalkThrough` but shouldn't be broken
2025-03-14 11:49:00 -07:00
leijurv
37a95aea97 Merge pull request #4661 from ZacSharp/pr/1.19.4/schematics/betterErrorMessage
Improve error messages from `#build`
2025-03-14 11:48:27 -07:00
leijurv
3116405953 Merge pull request #4660 from ZacSharp/pr/1.19.4/elytra/keepNetherPathfinderClasses
Fix nether-pathfinder with optimized forge/neoforge builds
2025-03-14 11:48:10 -07:00
leijurv
ed4f9cee78 Merge pull request #4659 from ZacSharp/pr/1.19.4/mixin/backportForgeFix
Backport #4138 to 1.19.4
2025-03-14 11:46:35 -07:00
ZacSharp
b8ac867fb9 Break from eye level outwards
We might be standing inside passable blocks (e.g. sugar cane) so the
block at foot level is occluded by the one at eye level.
This does still break if we are standing inside a non-target with a
target above or below.
2025-03-13 19:32:35 +01:00
ZacSharp
3f6c87a8ed Better error message for unsupported formats 2025-03-08 23:35:23 +01:00
ZacSharp
bf08c4fcf4 Improve error messages from #build 2025-02-27 18:36:35 +01:00
ZacSharp
f357eb230b Remove spam 2025-02-27 15:55:09 +01:00
ZacSharp
f3086c2231 Filter blocks where avoidBreaking returns false
shaft-mining checks `avoidBreaking` so not checking it here can cause
Baritone to walk to a position and then do nothing.
2025-02-27 15:36:59 +01:00
ZacSharp
002415425a Slightly rephrase compatibility message
We cannot distinguish between unsupported systems and failures on supported systems
so strongly implying the former is potentially misleading.
2025-02-26 17:05:40 +01:00
ZacSharp
c54d878d1c Fix nether-pathfinder on forge 2025-02-26 17:05:23 +01:00
rfresh2
590f5d98ee fix forge mixin crash
cherry-picked from 7902517663
2025-02-26 16:12:21 +01:00
leijurv
849072f8ca Merge pull request #4636 from Lyzev/1.19.4
add(Settings): added settings to control block placement in fluid sources and flowing fluids
2025-02-08 10:57:21 -08:00
Lyzev
59157c1ee0 fix(CostOfPlacingAt): improve fluid placement checks in CalculationContext 2025-02-08 12:15:55 +01:00
leijurv
3c9f5b2c91 Merge pull request #4596 from cattyngmd/1.19.4-follow-target-max-distance
Added followTargetMaxDistance setting
2025-02-07 16:58:17 -08:00
Lyzev
cdfa86c977 add(Settings): added settings to control block placement in fluid sources and flowing fluids 2025-02-06 18:48:51 +01:00
cattyn
64fdad424f added maximum distance setting for FollowProcess 2024-12-28 14:29:05 +03:00
leijurv
a5668532b1 Merge pull request #4587 from ZacSharp/pr/1.19.4/documenation/updateBuildInstructions
Update build instructions
2024-12-21 23:07:03 -08:00
ZacSharp
bac24af90e Update SETUP.md 2024-12-14 16:29:49 +01:00
leijurv
497fb74829 Merge pull request #4560 from rfresh2/litematica-fix-1.19.4
fix litematica remapping error
2024-11-20 20:02:14 -08:00
leijurv
91a1f05ff2 Update README.md 2024-11-20 01:23:03 -08:00
rfresh2
1a258b2bec fix litematica remapping error 2024-11-18 11:20:52 -08:00
leijurv
93dee4fd19 Merge pull request #4532 from babbaj/fix-loops
fix loops in path
2024-10-21 14:03:42 -07:00
Babbaj
f6657846d3 fix loops in path (fixes #4528) 2024-10-21 02:09:31 -04:00
leijurv
db163867df Merge pull request #4531 from ZacSharp/pr/1.19.4/pathing/canWalkOnSoulSand
Allow walking on soul sand once again
2024-10-20 20:02:43 -07:00
leijurv
58fcf328b9 Merge pull request #4530 from ZacSharp/pr/1.19.4/builder/fixPositionOutOfBounds
Handle positions going out of bounds between ticks
2024-10-20 20:01:25 -07:00
leijurv
8e8cfdd2a6 Merge pull request #4529 from ZacSharp/pr/1.19.4/builder/fixEmptyShapeCrash
Don't call `shape.bounds()` on empty shapes
2024-10-20 20:00:53 -07:00
ZacSharp
991d822557 Make soul sand canWalkOn again 2024-10-20 21:23:38 +02:00
ZacSharp
c25b1325da Handle positions going out of bounds between ticks
They also have to be removed rather than ignored because they won't be scanned
again and would stay in `incorrectPositions` indefinitely.
2024-10-20 18:34:17 +02:00
ZacSharp
ea1de44ca8 Don't call shape.bounds() on empty shapes
`minecraft:moving_piston` is the only block I currently know which could cause this to crash.
2024-10-20 18:13:15 +02:00
leijurv
f22f4aed00 Merge pull request #4519 from babbaj/edge-fix
Fix not moving from edge of block
2024-10-15 16:04:17 -07:00
Babbaj
d644c5b754 a bit more elegant 2024-10-15 18:56:46 -04:00
Babbaj
1e2ae34dbe crucial performance optimization 2024-10-15 18:25:42 -04:00
Babbaj
a690e1eca4 prepend feet to the path if start is adjacent to feet 2024-10-14 17:25:20 -04:00
leijurv
d25d6c2611 Merge pull request #4452 from ZacSharp/pr/1.19.4/builder/rotateAndMirrorSchematics
Add settings to rotate/mirror schematics
2024-09-15 23:34:52 -07:00
leijurv
ef72c56833 Merge pull request #4453 from ZacSharp/pr/1.19.4/schematics/litematicaRework
Almost rewrite litematic handling
2024-08-22 11:01:27 -07:00
ZacSharp
7e8c852528 Setting to mirror schematics 2024-08-02 01:42:46 +02:00
ZacSharp
42032890ed Setting to rotate schematics 2024-08-02 01:41:50 +02:00
ZacSharp
6b6931c86d Remove unused stub
The class doesn't even exist in the version of Litematica I'm using so it doesn't
seem to have an effect on descriptor strings in our bytecode. Otherwise my game
would crash.
2024-07-30 19:26:05 +02:00
ZacSharp
b915151ae3 We don't expect any exceptions here anymore 2024-07-30 19:26:05 +02:00
ZacSharp
7609f3082e Keep subregions as separate boxes 2024-07-30 19:26:05 +02:00
ZacSharp
99f9dd1671 Performance 2024-07-30 19:26:05 +02:00
ZacSharp
1a0cca794c Use toString like for schematica 2024-07-30 19:26:04 +02:00
ZacSharp
e71547b9ef Take blocks from the schematic world 2024-07-30 19:26:04 +02:00
ZacSharp
246a246cb7 Less nested schematics 2024-07-30 19:26:04 +02:00
ZacSharp
b87a1fa420 Take data directly from Litematica 2024-07-30 19:25:57 +02:00
ZacSharp
b12c4e9f8c Merge loading steps 2024-07-30 19:17:13 +02:00
ZacSharp
330089f1e2 Shorten / simplify some Litematica related things 2024-07-30 19:17:08 +02:00
leijurv
f6045b7cb4 Merge pull request #4438 from ZacSharp/pr/1.19.4/build/syncMixinAndAsm
Sync mixin and asm versions between common and tweaker
2024-07-28 00:39:37 -07:00
ZacSharp
a07d7d0526 Sync mixin and asm versions between common and tweaker 2024-07-21 13:33:00 +02:00
leijurv
edb433ea6e Merge pull request #4432 from ZacSharp/pr/1.19.4/build/fixClassloaderExclusion
Move `BaritoneTweaker` to its own package
2024-07-20 11:50:23 -07:00
leijurv
a02704e097 Merge pull request #4430 from ZacSharp/pr/1.19.4/farm/addBamboo
Add bamboo to `FarmProcess` targets
2024-07-20 11:50:12 -07:00
ZacSharp
1947459acf Move tweak class to its own package
Launchwrapper automatically adds a classloader exclusion for every package containing a tweak class, forcing the whole package to load through the parent class loader.
2024-07-14 13:47:52 +02:00
ZacSharp
52aa609ac7 Add bamboo to FarmProcess targets 2024-07-14 10:37:31 +02:00
leijurv
92bc067633 Merge pull request #4395 from wagyourtail/1.19/proguard-cleanup
clean up proguard task
2024-06-19 18:20:08 -07:00
leijurv
64639b377f Merge pull request #4385 from ZacSharp/pr/1.19.4/farm/unhardcodeScanLimit
Unhardcode farm scan limit
2024-06-19 18:18:29 -07:00
Wagyourtail
42c62a0559 clean up proguard task 2024-06-16 23:46:27 -05:00
ZacSharp
b25a6305ce Don't bother testing reachability for far away blocks
This is a massive performance improvement for big farms.
2024-06-09 18:14:41 +02:00
ZacSharp
98e90e72f7 Make farm scan limit configurable 2024-06-09 18:14:41 +02:00
ZacSharp
10851ddf14 Only create scan list when needed 2024-06-09 18:14:40 +02:00
ZacSharp
402079d7db Fail if there is no target position 2024-06-09 18:14:35 +02:00
leijurv
b184141db2 Merge pull request #4374 from ZacSharp/pr/1.19.4/guiclick/removeLogspam
Remove logspam from `GuiClick`
2024-06-07 00:45:33 -07:00
ZacSharp
f9a8aa0c2b Remove logspam 2024-05-26 03:19:35 +02:00
leijurv
0c09441154 Merge pull request #4324 from ZacSharp/pr/1.19.4/setting/fixRecursiveParserType
Fix recursive setting parsers
2024-04-24 12:50:21 -07:00
leijurv
69d3bc0c2e Merge pull request #4320 from rfresh2/instabreak-fix
don't apply block break delay to insta-breaks
2024-04-24 12:50:06 -07:00
leijurv
b31e0a87cb Merge pull request #4333 from ZacSharp/pr/1.19.4/misc/toolset/fixHardnessCrash
Fix NPE in break time calculation
2024-04-24 12:49:15 -07:00
ZacSharp
4572b75db7 Fix NPE in break time calculation 2024-04-10 14:03:48 +02:00
rfresh2
15fdbb2312 revert API renaming 2024-04-07 20:30:16 -07:00
ZacSharp
848b7c6de0 Fix recursive parsers
Does not affect existing parsers since all nested parameterized setting types
are `Map<String, List<String>>` so there is no difference between the first
parameter of the inner type and the first parameter of the outer type
2024-04-02 21:32:01 +02:00
rfresh2
2b96a2e463 don't apply block break delay to insta-breaks 2024-04-01 15:21:24 -07:00
leijurv
62b2f81ba1 Merge pull request #4314 from ZacSharp/pr/1.19.4/builder/fixBuildSkipBlocksNPE
Fix NPE
2024-03-28 19:25:58 -07:00
ZacSharp
5826931eea Fix NPE 2024-03-29 03:17:00 +01:00
leijurv
a8119366a1 Merge pull request #4292 from rfresh2/place-delay-patch
align rightClickSpeed setting with actual delay
2024-03-28 16:53:33 -07:00
leijurv
b0575fbe0c Merge pull request #4291 from rfresh2/block-break-delay
Block break delay setting
2024-03-28 16:53:13 -07:00
leijurv
866cf34f50 Merge pull request #4303 from ZacSharp/pr/1.19.4/builder/placeIncorrectBlockPenaltyMultiplier
Add a `placeIncorrectBlockPenaltyMultiplier` setting
2024-03-28 16:52:31 -07:00
leijurv
23908ad14f Merge pull request #4289 from ZacSharp/pr/1.19.4/ci/updateWorkflows
Update workflows
2024-03-28 16:51:43 -07:00
rfresh2
18d3c4c2bd align rightClickSpeed setting with actual delay 2024-03-10 21:05:30 -07:00
rfresh2
faece77e8c align setting value with actual tick delay between breaks 2024-03-10 16:49:59 -07:00
rfresh2
413c11a23e block break delay setting 2024-03-09 15:26:18 -08:00
ZacSharp
4c9253fa5e Add placeIncorrectBlockPenaltyMultiplier builder setting 2024-03-08 17:49:51 +01:00
ZacSharp
d86a34a527 Fix too low bound and log spam 2024-03-08 17:49:45 +01:00
ZacSharp
92aba1b78e Update workflows 2024-03-06 02:26:58 +01:00
ZacSharp
28ba97c3de Move up and fix access modifiers 2024-02-22 14:16:52 +01:00
ZacSharp
24c23e28ec Reduce recursion limit and fix visibility 2024-02-20 21:35:59 +01:00
ZacSharp
2a2842361b Consistently use helper method
and make a safe cast unnecessary
2024-02-20 21:33:53 +01:00
ZacSharp
632e05c4c2 Make buildSkipBlocks use a wrapper schematic 2024-02-20 21:32:55 +01:00
leijurv
4144344acd Merge pull request #4251 from wagyourtail/1.19/fix/feather-crash
Fix feather crashing by catching error
2024-01-23 14:40:28 -08:00
leijurv
e962c39506 Merge pull request #4248 from ZacSharp/pr/1.19.4/mine/unhardcodeMaxOreLocations
Unhardcode `ORE_LOCATIONS_COUNT`
2024-01-23 14:40:02 -08:00
leijurv
48f309ac05 Merge pull request #4247 from ZacSharp/pr/1.19.4/elytra/removeUnsafeCast
Remove unsafe generic cast
2024-01-23 14:39:44 -08:00
leijurv
0688a57a38 Merge pull request #4252 from wagyourtail/1.19/fix/build-fail
fix 1.19 build failing
2024-01-23 11:04:14 -08:00
Wagyourtail
078b3909b3 fix build failing, by making nether pathfinder version consistent 2024-01-23 08:18:58 -07:00
Wagyourtail
d51b23bd1e Fix feather crashing by catching error 2024-01-22 10:39:12 -07:00
ZacSharp
9378f7e8a0 Unhardcode ORE_LOCATIONS_COUNT 2024-01-21 01:32:30 +01:00
ZacSharp
e7e434a95b Remove unsafe generic cast 2024-01-20 23:35:54 +01:00
leijurv
be1203fabb Merge pull request #4244 from wagyourtail/1.19/fix/null-elytra
fix 🪨🧠 preventing null elytra process from working
2024-01-20 08:50:31 -08:00
Wagyourtail
340d2a1d54 fix 🪨🧠 preventing null elytra process from working 2024-01-20 07:53:11 -07:00
leijurv
f84b749ff4 Update README.md 2024-01-06 12:21:52 -08:00
leijurv
f147519a5c Merge pull request #4195 from ZacSharp/pr/1.19.4/worldscanner/fixSingleValuePalette
Fix scanning chunks using a SingleValuePalette
2023-11-17 17:50:53 -08:00
ZacSharp
19accb0d90 Fix scanning in chunks using a SingleValuePalette 2023-11-16 23:52:12 +01:00
leijurv
44bcd4251d Merge pull request #4114 from wagyourtail/just-unimined-update
bump unimined
2023-11-14 14:48:14 -08:00
William Gray
5795baab1a Merge branch '1.19.4' into just-unimined-update 2023-11-14 07:12:23 -07:00
leijurv
e183dcba17 Merge pull request #4137 from babbaj/1.19.4
silence elytra chat spam
2023-10-31 11:27:25 -07:00
leijurv
ea964a976c Merge pull request #4168 from ZacSharp/pr/build/1.19.4/improvedVersionDetection
Improve version detection
2023-10-31 11:26:10 -07:00
leijurv
1409c92e69 Merge pull request #4153 from xiaodown/xiaodown/add_git_to_dockerfile_apt
Adds git to the Dockerfile apt install (Windows build functionality)
2023-10-31 11:25:08 -07:00
leijurv
a0914192d0 Merge pull request #4158 from ZacSharp/pr/1.19.4/builder/restoreBuildIgnoreExisting
Restore `buildIgnoreExisting`
2023-10-31 11:23:44 -07:00
leijurv
e19fd1161d Merge pull request #4157 from ZacSharp/pr/1.19.4/worldscanner/handleDuplicatePaletteEntries
Handle duplicate palette entries
2023-10-31 11:23:26 -07:00
ZacSharp
9accb2bfb0 Don't crash the build if git is not available 2023-10-26 21:19:26 +02:00
ZacSharp
20d62c68bf Slightly better version strings 2023-10-26 21:19:26 +02:00
ZacSharp
0ca81b14bf Restore buildIgnoreExisting 2023-10-18 16:39:26 +02:00
ZacSharp
1dd2a334d6 Handle duplicate palette entries 2023-10-18 12:45:31 +02:00
Xiaodown
3332ec9e1f Adds git to the Dockerfile apt install
I saw in setup.md "(if you have docker on Windows, I'd be grateful if
you could let me know if it works there too)".  So I went to build
it on Windows.

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

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

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

yes honey
2023-08-01 01:12:38 -04:00
Babbaj
7aa3eda3f6 fix nudgeToLevel with smoothLook 2023-07-31 19:13:53 -04:00
Babbaj
0ca173f5dc separate smooth look setting for elytra 2023-07-31 19:13:53 -04:00
Babbaj
c0a1e6540f simplify smoothLook into one setting and separate smoothLook from freeLook 2023-07-31 19:13:52 -04:00
Leijurv
46f38f2ce7 orderly shutdown 2023-07-31 15:06:25 -07:00
Leijurv
64a881f990 elytra warning 2023-07-31 01:36:01 -07:00
Leijurv
541b710ea7 too aggressive 2023-07-31 00:27:50 -07:00
Leijurv
cc8afe95c5 setting for nether fortress 2023-07-31 00:18:43 -07:00
Leijurv
83feddf6be recalc if all points out of view 2023-07-31 00:12:15 -07:00
Leijurv
7662810405 add back unsegmenting 2023-07-31 00:12:01 -07:00
Leijurv
d921d2e367 live a little 2023-07-30 23:33:49 -07:00
Leijurv
9630224e78 whatever 2023-07-30 23:26:46 -07:00
Leijurv
134bfb2a16 fix two cases where it could get stuck indefinitely 2023-07-30 23:24:04 -07:00
Leijurv
36df7b17f8 destroy async 2023-07-30 22:56:33 -07:00
Leijurv
7e9cf2e1e9 ok its based now 2023-07-30 22:47:39 -07:00
leijurv
54511f13d9 Merge pull request #4081 from babbaj/elytra
increase air bubble radius, append destination to path when landing
2023-07-30 22:30:07 -07:00
Babbaj
27e45b816d increase air bubble radius, append destination to path when landing 2023-07-30 19:45:25 -04:00
Brady
3a6e5541fb Don't deploy elytra while PathingBehavior is active 2023-07-30 17:48:53 -05:00
Leijurv
a83d275622 forgot 2023-07-30 15:47:43 -07:00
Leijurv
d6adb52718 tweaks 2023-07-30 15:46:18 -07:00
leijurv
976f3439eb Merge pull request #4077 from babbaj/elytra
safer elytra landing
2023-07-30 14:23:33 -07:00
Babbaj
2e2c0ecc0b use MutableBlockPos 2023-07-29 11:52:37 -04:00
Babbaj
31d1656c48 safer landing 2023-07-29 00:22:52 -04:00
Brady
4b5a094f30 Render fields can be private now 2023-07-28 01:41:03 -05:00
Brady
6b611cf4c7 Move more state into SolverContext 2023-07-28 01:30:54 -05:00
Brady
90f2b39fba Remove glPushAttrib/glPopAttrib usage 2023-07-26 19:52:25 -05:00
leijurv
2164857408 Merge pull request #4070 from babbaj/elytra
fixes for comments in elytra pr
2023-07-26 13:13:03 -07:00
Babbaj
601a781983 improve control flow (fixes behavior.onTick() being called twice) 2023-07-24 08:21:46 -04:00
Babbaj
f14bb282f0 add null check to resetState 2023-07-24 04:41:19 -04:00
Babbaj
1e0dce8f41 127 instead of 128 2023-07-24 03:30:38 -04:00
Babbaj
45400a9685 fix concurrency concerns 2023-07-24 03:30:06 -04:00
leijurv
6ffe31b59e Merge pull request #4068 from babbaj/elytra
add dimension checks to elytra
2023-07-23 17:47:46 -07:00
Babbaj
293b556b56 add dimension checks 2023-07-23 20:46:12 -04:00
leijurv
dbf38efd83 Merge pull request #4067 from babbaj/elytra
elytra command improvements
2023-07-23 12:11:37 -07:00
Babbaj
e63aad7825 elytra command improvements 2023-07-23 15:09:56 -04:00
Leijurv
212ef4d4cc waste fireworks smiling_imp 2023-07-23 11:44:29 -07:00
leijurv
31e082b8dc Merge pull request #4066 from babbaj/elytra
safe landing improvements
2023-07-23 11:29:40 -07:00
Babbaj
75e8035551 safe landing improvements 2023-07-23 14:26:31 -04:00
Leijurv
f7f0521093 not legacy 2023-07-22 23:29:07 -07:00
leijurv
684fda2d1b Merge pull request #4063 from babbaj/elytra
make elytra play nice with CustomGoalProcess
2023-07-22 23:12:07 -07:00
leijurv
886091df50 Merge branch 'elytra' into elytra 2023-07-22 23:08:45 -07:00
Leijurv
9707dd7ce8 redo checkedpositions given y descending iteration order 2023-07-22 23:02:29 -07:00
Babbaj
b81d712a33 higher priority is good enough lol 2023-07-23 01:57:27 -04:00
leijurv
3ffacbf375 Merge pull request #4064 from babbaj/safe-landing
find safe landing spot for elytra
2023-07-22 22:48:00 -07:00
Babbaj
eec85b20be fix bias in comparator 2023-07-23 01:45:39 -04:00
Babbaj
c0ead0147a use priority queue to bias upwards 2023-07-23 01:38:07 -04:00
leijurv
bafd41837e Merge pull request #4062 from ZacSharp/1.19.4-update
Merge 1.18.2 into 1.19.4
2023-07-22 22:15:46 -07:00
Babbaj
9bfa2025d5 memoize isSafeLandingSPot 2023-07-23 01:14:19 -04:00
Babbaj
bf63ffbc1d cringe fence hater 😭 2023-07-23 01:01:59 -04:00
Babbaj
985148b49a check for specific blocks to land on and anything non air is lava 2023-07-23 01:00:23 -04:00
Babbaj
9e78443595 resolve comment 2023-07-23 00:53:26 -04:00
Babbaj
58723a33ca hate cherry pick now 2023-07-23 00:05:11 -04:00
Babbaj
c9aa1658b2 improvements/fixes 2023-07-23 00:03:31 -04:00
Babbaj
7f9e50bbe2 initial safe landing impl 2023-07-23 00:02:46 -04:00
Babbaj
664375a678 make elytra play nice with CustomGoalProcess 2023-07-22 01:55:12 -04:00
Brady
097e30850f Move WalkOffCalculationContext into ElytraProcess 2023-07-18 23:35:09 -05:00
Brady Hahn
a63cbab013 Merge pull request #4060 from babbaj/elytra
refactor elytra into process
2023-07-18 23:23:25 -05:00
ZacSharp
37f1c30ad0 Merge branch '1.19.2' into 1.19.4 2023-07-19 04:32:08 +02:00
ZacSharp
217dca5363 Merge branch '1.18.2' into 1.19.2 2023-07-19 04:13:47 +02:00
ZacSharp
15e97268ed Fake merge branch '1.19.2' into 1.19.4 2023-07-19 04:09:37 +02:00
Brady
218de1cb98 Requested changes 2023-07-18 16:48:00 -05:00
Babbaj
0239a2cad4 notificationOnPathComplete and disconnectOnArrival 2023-07-18 15:36:29 -04:00
Babbaj
38553b3324 behavior can't be null in onTick 2023-07-18 14:52:09 -04:00
Babbaj
ba78c48a75 shutdown solverExecutor 2023-07-18 13:36:55 -04:00
Babbaj
f4996137a3 minor code improvements 2023-07-18 13:36:55 -04:00
Babbaj
ccd80dfc8f that isn't necessary 2023-07-18 13:36:55 -04:00
Babbaj
ff1b3e7c5f simplify management of elytra state 2023-07-18 13:36:55 -04:00
Babbaj
2f0497756b simplify icky code 2023-07-18 13:36:54 -04:00
Babbaj
afe9359d3e don't call onTick if we are pawsed 2023-07-18 13:36:54 -04:00
Babbaj
4b5d629df6 fix off by one error (causing the last point to be stuck in terrain) 2023-07-18 13:36:54 -04:00
Babbaj
dbc0a46b10 call elytra event handlers from ElytraProcess 2023-07-18 13:36:54 -04:00
Babbaj
9a6241af8a refactor elytra into being just a process 2023-07-18 13:36:53 -04:00
Brady
1b82bd1f33 pitch smooth look and setting for ticks 2023-07-17 17:58:08 -05:00
Brady Hahn
90cfd82810 Merge pull request #4056 from babbaj/elytra
consistent elytra setting naming
2023-07-16 20:30:35 -05:00
Brady
108dbdae5d partially appease codacy 2023-07-16 20:29:30 -05:00
Brady
32a4c4644e Move cull code 2023-07-16 20:21:40 -05:00
Leijurv
edc92753cf Revert "shrimple"
This reverts commit 0e567f2f90.
2023-07-16 18:17:53 -07:00
Leijurv
0e567f2f90 shrimple 2023-07-16 18:17:15 -07:00
Babbaj
41e8c69db9 consistent elytra setting naming 2023-07-16 18:58:42 -04:00
Brady Hahn
a83d1901f2 Merge pull request #4055 from babbaj/elytra
cull far away chunks from the cache
2023-07-16 17:00:42 -05:00
Babbaj
f3bb5a0cb2 make sure BlockStateOctreeInterface doesn't use freed chunk pointers 2023-07-16 13:53:02 -04:00
Babbaj
76d3a13f58 cull far away chunks from the cache 2023-07-16 01:19:51 -04:00
Brady Hahn
6f99f891dc Merge pull request #4054 from babbaj/elytra
simple way to land at the goal
2023-07-15 22:24:42 -05:00
Brady Hahn
e579bf980d Update NetherPath.java 2023-07-15 22:23:59 -05:00
Brady Hahn
716b3ae0d2 Update ElytraBehavior.java
i love github web editor
2023-07-15 22:23:35 -05:00
Babbaj
b468b8eb95 landing procedure 2023-07-15 22:17:21 -04:00
Brady
1d109d4b9f crucial performance optimization 2023-07-13 14:47:19 -05:00
Brady
29bf046aa8 BlockStateOctreeInterface 2023-07-13 14:28:51 -05:00
Brady Hahn
4399b7c2fb Merge pull request #4053 from babbaj/elytra
auto swap elytra
2023-07-13 13:37:30 -05:00
Babbaj
d35571923f appease brady 2023-07-13 14:35:33 -04:00
Babbaj
461f56c4d6 countdown instead of count up 2023-07-13 14:21:15 -04:00
Babbaj
0b5d5b8176 use ticksBetweenInventoryMoves 2023-07-12 22:54:04 -04:00
Babbaj
42771686c6 auto swap elytra 2023-07-12 16:42:14 -04:00
Brady
8f5105c454 trolled pt2 2023-07-11 22:50:35 -05:00
Brady
7c696b7055 trolled 2023-07-11 22:49:51 -05:00
Brady
349c951b55 Better handling of unsupported systems 2023-07-11 22:47:09 -05:00
Leijurv
5dc403e643 crucial performance optimization 2023-07-10 00:12:10 -07:00
Brady Hahn
a8e1b16dee Merge pull request #4048 from babbaj/elytra
don't send the whole chunk for small changes
2023-07-09 22:31:42 -07:00
Babbaj
dc53a95bef don't send the whole chunk for small changes 2023-07-10 00:45:12 -04:00
Brady
eec4edea05 Remove old pack method 2023-07-09 20:00:35 -07:00
Brady Hahn
70249e5fa7 Merge pull request #4047 from babbaj/elytra
optimize uploading chunk data
2023-07-09 19:58:59 -07:00
Babbaj
96a64b454e optimize uploading chunk data 2023-07-09 22:29:31 -04:00
Brady
7a935fb2ea Fix simulation not respecting ignoreLava 2023-07-09 09:12:21 -07:00
Brady
c0cdfb7781 Add commands for pathfinder reset and chunk repack 2023-07-07 19:44:59 -07:00
Brady
487b3a759a mostRecentGoal, fixes immediate goal clear 2023-07-07 18:35:02 -07:00
Brady
fe67489419 Combine VALIDATE_PATH and LOCATE_JUMP states 2023-07-07 14:38:11 -07:00
Brady
308b9bbfea Apply minimum fall height to regular falls too 2023-07-07 13:26:43 -07:00
Brady
bfb4ffcafc Reset context on world load/unload 2023-07-07 11:19:18 -07:00
Brady
537100a5e5 Nether seed setting and automatic context reset 2023-07-07 10:44:56 -07:00
Brady
b6bf4427ef Use soft references for nether chunk packing queue 2023-07-07 00:30:07 -07:00
Brady
8de239f468 Use soft references for chunks queued for packing 2023-07-06 23:15:35 -07:00
Brady
ecfd664f30 Fix isSafeToCancel() return value 2023-07-06 20:11:50 -07:00
Brady
c4ac23837f Set safeToCancel to false while flying 2023-07-06 19:31:37 -07:00
Brady
aeeb001205 Fix some codacy issues 2023-07-06 19:02:13 -07:00
Brady
2552eb8dca Add setting documentation 2023-07-06 18:57:51 -07:00
Brady
4c0c263d11 trolling 2023-07-03 13:28:53 -05:00
Brady
c8259d3e90 ZOOM 2023-07-03 13:27:23 -05:00
Brady
d892ef54f0 Merge branch 'master' into elytra 2023-07-02 20:04:04 -05:00
Brady
fc209599af Update nether-pathfinder to 0.21 2023-07-02 01:03:34 -05:00
Brady
dee7df1534 I HATE OLD MIXIN!!!!
awesome buggy 0.7.11 hates referencing shadows in mixin superclasses wooooooo
2023-07-01 19:38:38 -05:00
Brady
ccd737d0a1 Actually fix Forge by reverting Mixin change completely 2023-07-01 18:38:13 -05:00
Brady
14b5a0cec3 Fix Forge support 2023-07-01 17:28:23 -05:00
Brady
2f7dc2397e Better start position selection and validation 2023-07-01 01:32:03 -05:00
Brady
3498082f2b Better state switch and start path halfway down fall 2023-06-30 20:53:42 -05:00
Brady
83066fc57c Find jump off spot using INSANE custom CalculationContext 2023-06-30 20:42:03 -05:00
Brady
d32f1b2a16 Add hit pos raytrace method to context 2023-06-30 20:38:45 -05:00
Brady
4590ba3ff8 Use separate executor for solver 2023-06-29 23:35:12 -05:00
Brady
b4578931d3 Reduce passing around of ignoreLava 2023-06-29 22:59:15 -05:00
Brady
b8ede0a652 Remove unnecessary IPlayerContext argument 2023-06-29 22:54:55 -05:00
Brady
3eb7610f89 Block lookup optimization 2023-06-29 20:45:59 -05:00
Brady
5a48f4119e Reduce number of raytraces when validating simulation 2023-06-29 19:15:06 -05:00
Brady
974b86aac1 Bump nether-pathfinder to 0.20 2023-06-29 18:50:29 -05:00
Brady
f30cb916bd Remove addressed TODO 2023-06-29 14:53:55 -05:00
Brady
494ebfa10d More accurate isActive return value 2023-06-29 14:53:12 -05:00
Brady
222f53b105 Use Arrays.fill 2023-06-29 14:46:42 -05:00
Brady
12898df2f1 Reduce main thread recalculations after using a firework 2023-06-29 14:46:04 -05:00
Brady
fbb66a0586 Tweaks 2023-06-29 14:14:49 -05:00
Brady
48462da473 Disable interp on relaxation 0 2023-06-28 21:47:37 -05:00
Brady
4b689bd946 Fix Supplier meme 2023-06-28 17:55:47 -05:00
Brady
5126ec9c36 interp double 2023-06-28 17:49:33 -05:00
Brady
d640ebb02d Reliability improvements 2023-06-28 17:47:01 -05:00
Brady
0bb6f1b094 Invalidate pendingSolution 2023-06-28 01:05:22 -05:00
Brady
bb39fea415 Considerations 2023-06-28 01:04:08 -05:00
Brady
7a61ab8137 We need event priorities. 2023-06-28 00:58:51 -05:00
Brady
7861860187 Clarify 2023-06-28 00:48:28 -05:00
Brady
70166f385d That should be in the other tick method 2023-06-28 00:47:20 -05:00
Brady
03ee30bca9 Call elytra tick() from the process 2023-06-28 00:46:14 -05:00
Brady
c48de32860 PitchResult 2023-06-27 16:31:08 -05:00
Brady
3b31387092 Render simulation line from player pos 2023-06-27 13:02:01 -05:00
Brady
ff12832a21 whoops 2023-06-27 12:30:41 -05:00
Brady
4ccaf681c5 Somewhat functional elytraAutoJump, but mostly scuffed 2023-06-27 02:54:53 -05:00
Brady
02fc62f1c4 Stop simulation when goal reached 2023-06-26 18:37:06 -05:00
Brady
04a5a1a620 Replace bool firework with ticksBoosted in solvePitch 2023-06-26 16:58:29 -05:00
Brady
3e94cac567 clarity 2023-06-26 16:25:21 -05:00
Brady
452b2c278b Fix renderElytraSimulation 2023-06-26 16:21:15 -05:00
Brady
db0bfbe722 Move elytra simulation into new method 2023-06-26 16:12:56 -05:00
Brady
f0148a625e Move steps into solvePitch 2023-06-26 16:04:05 -05:00
Brady
0b5a310f18 Move firework boost calculation into solvePitch 2023-06-26 15:35:40 -05:00
Brady
c18715b8d7 Reset minimumBoostTicks to 0 earlier 2023-06-26 14:00:38 -05:00
Brady
d244a39040 Make MixinEntityLivingBase extend MixinEntity 2023-06-26 13:57:24 -05:00
Brady
0981114b78 Create FireworkBoost class for additional boost context
Also initialize `boostedEntity` in `EntityFireworkRocket` if `null` since it's lazily initialized in `onUpdate()`
2023-06-26 13:55:18 -05:00
Brady
9bd0856445 lol 2023-06-25 15:32:02 -07:00
Brady
9d1addd114 Add smoothLook setting 2023-06-25 15:28:06 -07:00
Brady
1902e6c1f3 Reset minimumBoostTicks to 0 when not boosted 2023-06-24 22:37:21 -07:00
Brady
a1a3d93dc1 Add renderElytraSimulation setting 2023-06-24 22:27:38 -07:00
Brady
32b7c82650 Add renderHitboxRaytraces setting 2023-06-24 22:11:08 -07:00
Brady
615266ed96 Replace manual calculation with util method 2023-06-24 21:57:00 -07:00
Brady
2ccd464a49 Utilize aim processor API for correct elytra simulation 2023-06-24 21:44:08 -07:00
Brady
f2374edd8b Merge branch 'master' into elytra
# Conflicts:
#	src/launch/java/baritone/launch/mixins/MixinMinecraft.java
#	src/main/java/baritone/Baritone.java
#	src/main/java/baritone/behavior/LookBehavior.java
2023-06-23 23:31:43 -07:00
Brady
f56e0569a2 Add minimumBoostTicks 2023-06-23 16:30:10 -07:00
Brady
c10903be69 Remove firstFireworks from InventoryBehavior 2023-06-23 16:17:59 -07:00
Brady
878a32228a Add avoidance setting 2023-06-22 18:22:40 -05:00
Brady
bce2c74a8e NO MORE CONCUSSIONS! 2023-06-22 18:07:11 -05:00
Brady
90434b3178 A bit more flexibility 2023-06-22 12:54:30 -05:00
Brady
9cf5538058 Improve stepper collision detection 2023-06-22 12:50:06 -05:00
Brady
f4a99253f4 Prevent head bonks 2023-06-22 12:08:30 -05:00
Brady
b366b1b1d1 Fix other null checks 2023-06-22 11:40:45 -05:00
Brady Hahn
a90e720956 Merge pull request #4017 from babbaj/elytra
simplify null check
2023-06-22 11:40:08 -05:00
Babbaj
535fd17a42 simplify null check 2023-06-22 08:30:25 -04:00
Brady
47dc0f9b94 Add missing exception null check to async completed callback 2023-06-21 21:30:04 -05:00
Brady
4776fa1876 Don't update playerNear on an empty path 2023-06-21 21:19:12 -05:00
leijurv
944405e4df Merge pull request #4014 from jdbool/1.19.2
Add useMessageTag setting
2023-06-21 18:55:06 -07:00
Mike
7ef4307ab7 Clean up useMessageTag 2023-06-21 18:25:24 -07:00
Brady
0aff31b768 Perfect elytra simulation 2023-06-21 18:59:44 -05:00
Mike
a5ca664a6a Add useMessageTag setting 2023-06-21 15:14:54 -07:00
Brady
877fd25608 Distinguish unexpected exceptions in path calc 2023-06-21 00:52:43 -05:00
Brady
cfd9a69052 Revert how PathManager tick works 2023-06-21 00:21:37 -05:00
Brady
d42bfcfa53 Fix NPE 2023-06-20 23:15:45 -05:00
Brady
defa6399e2 Tweak hitbox constraints 2023-06-20 23:01:07 -05:00
Brady
699e8bdea6 troll concurrency fix for rn 2023-06-20 22:36:27 -05:00
Brady
2eb912835a Restore interp values 2023-06-20 21:28:30 -05:00
Brady
bd7a57f7aa We do a little trolling 2023-06-20 21:27:54 -05:00
Brady
e76f79214e Replace pathAt with NetherPath 2023-06-20 21:07:21 -05:00
Brady
141a48a15e Some refactoring, more precise goingTo 2023-06-20 20:30:10 -05:00
Brady
fa158c6e67 Remove unnecessary conversions to Vec3d 2023-06-20 20:18:56 -05:00
Brady
7a12ef530c Cancel solver on behavior cancel 2023-06-20 20:11:34 -05:00
Brady
1d092a7165 Compute angles on another thread between ticks 2023-06-20 20:09:53 -05:00
Brady
57a17e907e Add missing CallbackInfo 2023-06-20 17:30:38 -05:00
Brady
2a82f6048a Implement POST TickEvent with new onPostTick callback 2023-06-20 17:18:30 -05:00
Brady
4076263afa Un-scuff PRE TickEvent injector 2023-06-20 17:00:42 -05:00
Brady
e3c8283158 Move solver into separate method 2023-06-20 15:15:02 -05:00
Brady
0aad3470d9 Differ between no pitch solution and no solution at all 2023-06-20 15:05:59 -05:00
Brady Hahn
553c85f0f6 Merge pull request #4011 from babbaj/elytra
fix 0.5 offset in elytra path rendering
2023-06-20 14:49:00 -05:00
Babbaj
c057081f07 fix 0.5 offset in elytra path rendering 2023-06-20 15:48:12 -04:00
Brady
7d22a71507 Only count unchanged ticks when using elytra 2023-06-20 13:50:26 -05:00
Brady
0ecabdd047 Update nether-pathfinder to 0.18 2023-06-20 13:43:42 -05:00
Brady
6c6b44ee65 Recalculate path if stuck 2023-06-20 13:43:14 -05:00
Brady
14ff90ccf1 remaining ticks mojang incident 2023-06-19 23:12:46 -05:00
Brady
5d7655fbdf Fix silly 0x integer wraparound trolle 2023-06-19 22:52:27 -05:00
Brady
ee0a6c2523 Use new single trace isVisible api 2023-06-19 21:45:52 -05:00
Brady
753b1cf1c3 Interpolate path positions
- Update `nether-pathfinder` to 0.17
- Utilize new batched visibility raytracing to efficiently trace bounding box paths
2023-06-19 21:38:08 -05:00
0x22
cd1c07deef added elytraFireworkSetbackUseDelay setting. 2023-06-19 22:22:57 -04:00
Brady Hahn
9d05043fa0 Merge pull request #4005 from babbaj/elytra
use legacy raytrace with ignore liquid to get out of lava
2023-06-19 18:04:14 -05:00
Babbaj
5f709eef9c use world raytrace 2023-06-19 18:26:00 -04:00
Babbaj
e57a84ded4 use legacy raytrace with ignore liquid to get out of lava 2023-06-19 17:58:06 -04:00
Brady
959b4cddbd Remove unneeded while (true) 2023-06-19 15:29:30 -05:00
Brady
82156250df Update nether-pathfinder to 0.16 2023-06-19 15:20:04 -05:00
Brady
90f401a067 Remove legacy raytracing methods 2023-06-19 15:19:32 -05:00
Brady
c6a6624045 Reorder fields 2023-06-19 15:16:11 -05:00
Brady
7d17ace15d Reset recalculating flag on clear 2023-06-19 15:15:29 -05:00
Brady
8d3b0c8f07 Always enforce sinceFirework 2023-06-19 14:10:41 -05:00
0x22
6741dff12b replaced (PI / 180) constants, RotationUtils calcVec3dFromRotation->calcLookDirectionFromRotation and named local variables. 2023-06-19 14:17:54 -04:00
Brady
9e10faa4c5 Elytra inventory modifications
- Use `throwaway` to switch items
- Remove inventory settings
- Prioritizes boost fireworks, but works without
- Avoids explosion fireworks
2023-06-19 12:32:25 -05:00
Brady Hahn
579e6d6e4c Merge pull request #4003 from rycbar0/elytra
prevent <player> went off with a bang
2023-06-19 12:12:15 -05:00
rycbar0
a32ac59ec1 prevent <player> went off with a bang 2023-06-19 12:44:32 +02:00
Leijurv
2b259d6dee cuter debug 2023-06-18 23:09:43 -07:00
Brady
67efb7a5b6 Add experimentalRaytrace setting for native raytrace
Update `nether-pathfinder` to 0.15
2023-06-19 00:34:22 -05:00
Brady
1da7ab2c22 Fix raytracer rendering 2023-06-18 23:58:20 -05:00
Brady
1257a0128c Remove unnecessary Baritone casts 2023-06-18 21:46:56 -05:00
Brady
0886f176b3 Make elytra API changes 2023-06-18 21:46:03 -05:00
Brady
7a8f8e8d47 fix noob error from resolving merge conflicts 2023-06-18 21:42:04 -05:00
Brady Hahn
7046927394 Merge pull request #3996 from rfresh2/elytra
firework inv management + pause/resume
2023-06-18 21:41:11 -05:00
Brady Hahn
d2b1398cea Merge branch 'elytra' into elytra 2023-06-18 21:39:09 -05:00
Brady
9808f62fe4 Send chunks to nether-pathfinder on BlockUpdateEvent 2023-06-18 21:25:00 -05:00
Brady
1837b66bb5 Add BlockChangeEvent
Moves the cache repack on block change functionality into `GameEventHandler`
2023-06-18 21:24:13 -05:00
Leijurv
efae476bc0 solved 2023-06-18 18:16:13 -07:00
Leijurv
a236031435 fix raytracer 2023-06-18 18:09:45 -07:00
Leijurv
812be14375 debug 2023-06-18 18:06:32 -07:00
Brady
1dbfc9abe3 optimize block lookups and move goingTo to local 2023-06-18 19:57:29 -05:00
rfresh2
8dc32ae03c firework inv management + pause/resume 2023-06-18 13:34:55 -07:00
Brady
68901695ca Add experimental takeoff feature 2023-06-18 13:23:41 -05:00
0x22
aec683d80f fast raytrace 2023-06-18 12:21:01 -04:00
Brady
d4e6a84ec9 Remove usage of realms Pair class 2023-06-18 10:57:13 -05:00
Brady
d66b8f1dd8 Extract currentSpeed into variable 2023-06-18 00:13:55 -05:00
Brady
688bbb83c8 Rename wasteFireworks to conserveFireworks and invert 2023-06-18 00:11:40 -05:00
Brady
da31a643b3 unscuff 2023-06-17 23:56:08 -05:00
Babbaj
76c5c1155f Fix ElytraCommand throwing exception for invalid goals 2023-06-18 00:51:07 -04:00
Leijurv
94027d17f2 gaming 2023-06-17 20:12:05 -07:00
Leijurv
fef7ba4701 tweaks 2023-06-17 20:03:30 -07:00
Brady
fcf8cd35d2 Handle exception to ensure recalculating is reset 2023-06-17 19:58:19 -05:00
Brady
91609f4ebf Use player bounding box in isClear 2023-06-17 19:36:29 -05:00
Brady
64a5ceabd8 Fix the regular pathfinder issue 2023-06-17 15:35:26 -05:00
Brady
4c2984a9a0 Consistent path prefix for methods 2023-06-17 14:21:32 -05:00
Brady
d1a6de06e2 😼 PathManager 2023-06-17 14:15:57 -05:00
Brady
0290b344dc Cancel before shutting down executor 2023-06-17 02:33:43 -05:00
Brady
395706edc9 move context wrapper to new class 2023-06-17 02:02:26 -05:00
Brady
a67889ab42 refactoring 2023-06-17 01:55:07 -05:00
Brady
97e91ed680 one var 2023-06-17 01:42:49 -05:00
Brady
424f27c798 remove debug msg 2023-06-17 01:41:17 -05:00
Brady
c5475498ca so cute 2023-06-17 01:39:21 -05:00
Leijurv
157e4db7c5 fireworks hack 2023-06-16 22:39:50 -07:00
Leijurv
1f303e69b0 cut at render distance 2023-06-16 22:21:52 -07:00
Leijurv
dc53c79393 gaming 2023-06-16 21:35:56 -07:00
Brady
37167746b5 Merge remote-tracking branch 'origin/master' into elytra 2023-06-16 22:52:24 -05:00
Brady
a046708867 Merge remote-tracking branch 'origin/elytra-buildScriptOverhaul' into elytra 2023-06-16 22:41:14 -05:00
Brady
f798ff26f6 fixed seed 2023-06-16 22:31:53 -05:00
Brady
071e6164fe Fix nether-pathfinder on Windows 2023-06-16 21:55:08 -05:00
0x22
b72bbfce5e make all json deterministic 2023-06-16 22:36:58 -04:00
0x22
cb7c2d7171 1.12.2 build script overhaul.
- Updated to ForgeGradle 4.0, MixinGradle 0.7 and Gradle 6.9.4
- Added a hack to run the game on arm64 on Mac OS X natively.
2023-06-16 22:04:16 -04:00
Brady
800cb2e747 Replace sublist troll in PathRenderer with visiblePath 2023-06-16 20:53:53 -05:00
Brady
5b39eb5041 clean up 2023-06-16 20:38:29 -05:00
Brady
53a0069704 Remove Java pathfinder in preparation for insertChunkData 2023-06-16 19:54:37 -05:00
Brady
8c12416348 Use new nether-pathfinder API
Doesn't stitch segments, just partially functional
2023-06-16 18:59:57 -05:00
Leijurv
e01093eb9a build with pathfinder 2023-06-15 20:59:15 -07:00
Brady
a9e9cd978d cancel lol 2023-06-15 22:59:01 -05:00
Brady
fe8ec19b6d Fix renderRaytraces crash 2023-06-15 22:07:44 -05:00
leijurv
0e87f350b3 Merge pull request #3990 from cabaletta/elytra-freelook
Merge `elytra-freelook` into `elytra`
2023-06-15 20:00:45 -07:00
Leijurv
8df6778641 sort of integrated nether pathfinder 2023-06-15 00:32:26 -07:00
Brady
06d11c1874 Revert file path 2023-06-14 16:59:03 -05:00
Brady
91bf7d726b Un-scuff and add setting 2023-06-14 16:32:56 -05:00
Brady
bde0c620ad Allow freeLook when using elytra 2023-06-14 16:11:11 -05:00
Brady
9672bd2c6d Fix compile 2023-06-14 16:08:34 -05:00
Brady
7b6f9b3eb6 Merge remote-tracking branch 'origin/master' into elytra 2023-06-14 15:48:16 -05:00
Leijurv
92509f07e9 normal raytracer skips flowing lava (aka lavafalls) which is no good 2023-06-12 22:00:23 -07:00
Leijurv
44cd5dcd41 go around glowstone and nether fortresses 2023-06-12 21:43:10 -07:00
Leijurv
410cfcf21a typo, fix crash at end of path 2023-06-11 22:40:35 -07:00
Leijurv
4148b98187 typo 2023-06-11 22:22:49 -07:00
Leijurv
b9054cdfc9 use more fireworks 2023-06-11 22:22:01 -07:00
Leijurv
35a996e2b0 firework more often 2023-06-11 20:59:28 -07:00
Leijurv
c48c2aa45c allow even more desperate motion 2023-06-11 13:57:21 -07:00
Leijurv
a602863426 better elytra 2023-06-11 12:49:31 -07:00
Leijurv
705a5a0712 elytra prototype mvp 2023-06-11 00:33:35 -07:00
Leijurv
7bb311687b v1.9.3 2023-04-13 14:03:51 -07:00
Leijurv
6eeeeb3a1b v1.9.4 2023-04-11 19:50:51 -07:00
leijurv
e3c6b312ef Merge pull request #3900 from wagyourtail/1.19.2
remove 1.19.3 method in blockOptionalMeta
2023-04-02 17:57:27 -07:00
Wagyourtail
acce20c573 remove 1.19.3 method in blockOptionalMeta 2023-04-02 17:01:57 -07:00
Leijurv
e4d725d9aa Revert "loottables broke & #click not working"
This reverts commit 3e082b21d5.
2023-04-02 15:24:50 -07:00
Leijurv
0cf89e0b2a Revert "fix items and #click"
This reverts commit 4168401aa1.
2023-04-02 15:20:26 -07:00
Leijurv
d1a55c43e1 v1.9.2 2023-03-14 18:26:48 -07:00
Leijurv
63e3dfc9b8 1.19.4 2023-03-14 18:20:27 -07:00
leijurv
6db376c02e Merge pull request #3876 from wagyourtail/1.19/1.19.4
1.19.4
2023-03-14 18:19:57 -07:00
Wagyourtail
a1e797ab53 rc3 2023-03-13 15:47:54 -07:00
Wagyourtail
fe64f1fd8a 1.19.4-rc1 2023-03-09 10:17:54 -07:00
leijurv
7a5c4f1f03 Merge pull request #3843 from wagyourtail/1.19/fix/1.19.3-fixdistnames
fix dist names to match previous versions
2023-02-18 16:08:45 -08:00
Wagyourtail
787644181a fix dist names to match previous versions 2023-02-18 16:59:39 -07:00
Leijurv
7b60943714 v1.9.1 2023-02-18 15:01:48 -08:00
leijurv
7879b6909a Merge pull request #3837 from ZacSharp/1.19.2-update
Merge 1.18.2 into 1.19.3
2023-02-18 15:00:01 -08:00
ZacSharp
9898e0da26 Merge branch '1.18.2' into 1.19.3 2023-02-12 23:50:54 +01:00
leijurv
7677ed8240 Merge pull request #3744 from wagyourtail/1.19/1.19.3
1.19/1.19.3
2023-01-13 11:08:57 -08:00
leijurv
7ad1a2dac7 Merge pull request #3774 from wagyourtail/patch-2
fix jitpack.yml so 1.19 builds there again
2023-01-01 23:38:51 -10:00
William Gray
fd55e455a1 Update jitpack.yml 2022-12-30 00:42:53 +00:00
William Gray
e7e25abc0b Update jitpack.yml 2022-12-30 00:39:29 +00:00
leijurv
4bc9884a95 Merge pull request #3731 from EvilCodeZ/1.19.1
Removed System.out.println.
2022-12-24 00:08:46 -08:00
Wagyourtail
0e35a3e62b fix #3756 by allowing to recompute worldData if null 2022-12-19 07:42:23 -07:00
Wagyourtail
1112feff5b cache 2022-12-12 13:24:43 -07:00
Wagyourtail
967dc6cbd6 bump unimined version 2022-12-12 13:23:36 -07:00
Wagyourtail
2ce60fbb79 fix tweaker build, don't include schematica api 2022-12-12 13:12:14 -07:00
Wagyourtail
35b7c48430 some people are getting a null worldData bug. add a debug line to see if its here 2022-12-12 12:54:06 -07:00
Wagyourtail
db842445f6 forge support 2022-12-08 12:31:12 -07:00
Wagyourtail
3a8d438d7c update to release 2022-12-07 22:58:20 -07:00
Wagyourtail
386caf5d1e add parchment back 2022-12-06 18:30:43 -07:00
Wagyourtail
f7f0c84407 fix proguard not seeing unsafe 2 2022-12-02 14:39:57 -07:00
Wagyourtail
75cd4600a0 fix proguard not seeing unsafe 2022-12-02 14:31:00 -07:00
Wagyourtail
e6642a2122 fix ci 2022-12-02 14:24:29 -07:00
Wagyourtail
e7252f5b3f remove the mixin from api 2022-12-02 14:23:16 -07:00
Wagyourtail
4168401aa1 fix items and #click 2022-12-02 14:09:47 -07:00
Wagyourtail
3e082b21d5 loottables broke & #click not working 2022-12-02 01:17:25 -07:00
Wagyourtail
85790c0b2f switch to unimined 2022-12-01 23:04:40 -07:00
EvilCodeZ
c20d40f8dd Removed System.out.println. 2022-11-18 19:39:39 +01:00
Leijurv
4fa43ce201 Merge pull request #3707 from ZacSharp/1.19.2-update
Merge 1.18.2 into 1.19.1
2022-11-07 01:39:51 -08:00
ZacSharp
f51f835b11 Merge branch '1.18.2' into 1.19.1 2022-11-01 00:11:26 +01:00
Leijurv
ec2941bede Merge pull request #3597 from wagyourtail/1.19/1.19.2
1.19.2
2022-10-03 12:29:07 -07:00
Leijurv
5b37b68363 Merge pull request #3592 from wagyourtail/1.19/1.19
fix click menus for baritone control
2022-10-03 12:22:10 -07:00
Wagyourtail
52d077de49 1.19.2 2022-08-07 14:47:18 -06:00
Wagyourtail
b1f35e93dc fix click menus for baritone control, closes #3587 2022-08-03 20:17:10 -06:00
Leijurv
076326dcc3 Merge pull request #3478 from wagyourtail/1.19/1.19
1.19/1.19
2022-08-01 12:48:03 -07:00
wagyourtail
b1b8288d05 Merge branch '1.19.1' into 1.19/1.19 2022-07-28 13:07:03 -06:00
Wagyourtail
df62427fee forge 2022-07-28 12:37:30 -06:00
Wagyourtail
61b9762a22 1.19.1 2022-07-27 19:59:44 -06:00
Wagyourtail
06be5f5372 1.19.1-rc2 2022-07-21 12:16:21 -06:00
Wagyourtail
fcd20b10f1 WORKING TWEAKER!!! 2022-06-11 11:54:30 +00:00
Wagyourtail
fd43dace70 rework this again and fix dist 2022-06-08 10:16:09 -06:00
Wagyourtail
a475f522ef artifact_standard needs project artifact name 2022-06-08 10:01:55 -06:00
Wagyourtail
e6cc9b1131 oops 2022-06-08 09:35:49 -06:00
Wagyourtail
347027a8e0 handle this differently (grab archive name from root project) 2022-06-08 09:26:47 -06:00
Wagyourtail
f204fbb08e froge support 2022-06-08 02:28:22 -06:00
Wagyourtail
606f9c55a8 1.19! 2022-06-07 12:07:12 -06:00
Wagyourtail
f2a11df616 prepare for release day 2022-06-07 05:13:56 -06:00
Wagyourtail
5773da36bd Merge remote-tracking branch 'zacsharp/1.17.1-update' into 1.19/1.19 2022-06-07 05:11:47 -06:00
Wagyourtail
86303ed495 Merge branch '1.12/beta-versioning' into 1.19/1.19 2022-06-07 04:52:05 -06:00
Wagyourtail
2b4da2a46c deep checkout so we actually get tag names in CI 2022-06-03 14:46:39 -06:00
Wagyourtail
f699be7973 so umm, it's not using right version number in CI... 2022-06-03 14:42:23 -06:00
Wagyourtail
ed381d6b33 fix CI not having access to git when run via gradle 2022-06-03 14:29:51 -06:00
Wagyourtail
1caa99fee3 oops 2022-06-03 14:26:27 -06:00
Wagyourtail
ffbe683e86 versioning with normal build 2022-06-03 14:24:17 -06:00
Wagyourtail
4dba5a4399 use git describe instead 2022-06-03 14:09:37 -06:00
Wagyourtail
8cfdcbdc9e rc.2 2022-06-03 13:47:09 -06:00
Wagyourtail
6e37221b3c rc.1 2022-06-02 13:37:51 -06:00
Wagyourtail
caa88c5b60 DONT on tags 2022-06-01 16:28:53 -06:00
Wagyourtail
1b3139c99a oops 2022-06-01 16:21:21 -06:00
Wagyourtail
3d95f0ad65 auto-increment version number as well 2022-06-01 16:16:41 -06:00
Wagyourtail
0df45a89be don't do the other stuff 2022-06-01 15:51:25 -06:00
Wagyourtail
b0266cd14b do beta versioning on gh action builds 2022-06-01 15:49:41 -06:00
Wagyourtail
9bf40dd60b pre.5 2022-06-01 15:17:45 -06:00
Wagyourtail
56b44496bf verify fabric/tweaker builds are valid 2022-05-31 03:03:43 -06:00
Wagyourtail
3df451677c use loom 11 to allow building 2022-05-31 02:42:17 -06:00
Wagyourtail
9e021d2875 1.19 2022-05-31 02:38:55 -06:00
Wagyourtail
db9ee98762 Merge remote-tracking branch 'wagyourtail/1.18.2/cached-chunk-oopsie' into rework-buildscript-117 2022-05-31 01:58:12 -06:00
Wagyourtail
d0d74b1591 freeze version numbers at known working 2022-04-16 04:02:45 -07:00
Wagyourtail
056107a356 fix checksums, this'll probably confuse someone.
I couldn't figure out how to fix it the other way...
2022-04-16 03:46:41 -07:00
Wagyourtail
93a16f356d cleanup. move tweaker classes 2022-04-16 03:22:53 -07:00
Wagyourtail
070083dc9b properly remap refmap for tweaker 2022-04-16 02:57:29 -07:00
Wagyourtail
af646bd313 yeet change I forgot to yeet 2 commits ago 2022-04-04 20:45:17 -07:00
Wagyourtail
c3c88c50d1 jitpack.yml 2022-04-04 20:11:15 -07:00
Wagyourtail
16f93ce769 explicitly include mixin "properly", mavenpublish should work now 2022-04-04 20:10:25 -07:00
Wagyourtail
3cee66229a proper mappings per proguard run 2022-04-04 19:15:21 -07:00
Wagyourtail
88c00f2fec java 17 is lts, so use java 17 2022-04-04 18:53:29 -07:00
Wagyourtail
394b4fd5b8 proguard builds now 2022-04-04 18:38:23 -07:00
Wagyourtail
48b34bfbb8 some jank to sourcesets to get dev launching 2022-04-04 18:11:03 -07:00
wagyourtail
4b2d1fe6b0 fix an oopsie in chunk caches with dynamic world height 2022-04-04 14:18:25 -07:00
Wagyourtail
01c75db38a rework buildscript (part 1) 2022-04-02 21:36:18 -07:00
161 changed files with 6011 additions and 1369 deletions

View File

@@ -13,33 +13,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build (fabric) with Gradle
run: ./gradlew build -Pbaritone.fabric_build
- name: Build (forge) with Gradle
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)"
- name: Archive Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: dist/
- name: Archive mapping.txt
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Mappings
path: build/tmp/proguard/mapping.txt
path: mapping/

View File

@@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
@@ -23,4 +23,4 @@ jobs:
- name: Executing tests
run: ./gradlew test

12
.gitignore vendored
View File

@@ -21,6 +21,9 @@ classes/
*.iws
/logs/
tweaker/logs/
common/logs/
# Eclipse Files
.classpath
.project
@@ -32,3 +35,12 @@ baritone_Client.launch
!/.idea/copyright/profiles_settings.xml
.vscode/launch.json
.architectury-transformer
mapping
libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
libs/java-objc-bridge-1.1.jar
mapping

View File

@@ -6,6 +6,7 @@ RUN apt update -y
RUN apt install \
openjdk-17-jdk \
git \
--assume-yes
COPY . /code
@@ -13,5 +14,3 @@ COPY . /code
WORKDIR /code
RUN ./gradlew build
RUN ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
RUN ./gradlew build -Pbaritone.fabric_build

View File

@@ -8,12 +8,13 @@
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.13.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.14.4-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.15.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.16.5-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.16.5-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.17.1-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.18.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.18.2-yellow.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.2-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.19.4-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.20.1-brightgreen.svg" alt="Minecraft"/></a>
<a href="#Baritone"><img src="https://img.shields.io/badge/MC-1.21.3-brightgreen.svg" alt="Minecraft"/></a>
</p>
<p align="center">
@@ -31,7 +32,8 @@
<a href="https://github.com/cabaletta/baritone/commit/"><img src="https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg" alt="GitHub commits"/></a>
<img src="https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg" alt="Code size"/>
<img src="https://img.shields.io/github/repo-size/cabaletta/baritone.svg" alt="GitHub repo size"/>
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code" alt="Lines of Code"/>
<img src="https://tokei.rs/b1/github/cabaletta/baritone?category=code&style=flat" alt="Lines of Code"/>
<img src="https://img.shields.io/badge/Badges-36-blue.svg" alt="yes"/>
</p>
<p align="center">
@@ -45,8 +47,8 @@
</p>
<p align="center">
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/built-with-swag.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
</p>
A Minecraft pathfinder bot.
@@ -59,16 +61,21 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s
| Forge | Fabric |
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.17/baritone-api-forge-1.2.17.jar) | |
| [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-forge-1.6.4.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.4/baritone-api-fabric-1.6.4.jar) |
| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.19/baritone-api-forge-1.2.19.jar) | |
| [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-forge-1.6.5.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-fabric-1.6.5.jar) |
| [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) |
| [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-forge-1.8.4.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.4/baritone-api-fabric-1.8.4.jar) |
| [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.6/baritone-api-forge-1.8.6.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.6/baritone-api-fabric-1.8.6.jar) |
| [1.19.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-forge-1.9.4.jar) | [1.19.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.4/baritone-api-fabric-1.9.4.jar) |
| [1.19.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-forge-1.9.1.jar) | [1.19.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.1/baritone-api-fabric-1.9.1.jar) |
| [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) |
| [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) |
| [1.20.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-forge-1.10.2.jar) | [1.20.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-fabric-1.10.2.jar) |
| [1.20.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-forge-1.10.2.jar) | [1.20.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.2/baritone-api-fabric-1.10.2.jar) |
| [1.21.3 Forge](https://github.com/cabaletta/baritone/releases/download/v1.11.1/baritone-api-forge-1.11.1.jar) | [1.21.3 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.11.1/baritone-api-fabric-1.11.1.jar) |
**How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa)
**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). It supports 1.19.4 and 1.20.1, Forge or Fabric. If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ).
**How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa). Also try `#elytra` for Elytra flying in the Nether using fireworks.
For other versions of Minecraft or more complicated situations or for development, see [Installation & setup](SETUP.md). Also consider just installing [Impact](https://impactclient.net/), which comes with Baritone and is easier to install than wrangling with version JSONs and zips. For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#6313 on Baritone which I recommend.

View File

@@ -1,78 +1,87 @@
# Installation
The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version or the [1.16.5](https://www.dropbox.com/s/i6f292o2i7o9acp/1.16.5-Baritone.zip?dl=1) version.
The easiest way to install Baritone is to install it as Forge/Neoforge/Fabric mod, but if you know how you can also use with a custom `version.json`
(Examples: [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1), [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1), [1.16.5](https://www.dropbox.com/s/i6f292o2i7o9acp/1.16.5-Baritone.zip?dl=1)).
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
## Prebuilt official releases
These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself)
Releases are made rarely and are not always up to date with the latest features and bug fixes.
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.5, v1.7.* is for 1.17.1, v1.8.* is for 1.18.1
The mapping between major Minecraft versions and major Baritone versions is as follows
| Minecraft version | 1.12 | 1.13 | 1.14 | 1.15 | 1.16 | 1.17 | 1.18 | 1.19 | 1.20 | 1.21 |
|-------------------|------|------|------|------|------|------|------|------|-------|-------|
| Baritone version | v1.2 | v1.3 | v1.4 | v1.5 | v1.6 | v1.7 | v1.8 | v1.9 | v1.10 | v1.11 |
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.
The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
The build is fully deterministic and reproducible, and you can verify that by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).
## Artifacts
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).
Building Baritone will create the final artifacts in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
**The Forge and Fabric releases can simply be added as a Forge/Fabric mods.**
**The Forge, NeoForge and Fabric releases can simply be added as a Forge/Neoforge/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`
If another one of your other mods has a Baritone integration, you want `baritone-api-*-VERSION.jar`.
If you want to report a bug and spare us some effort, you want `baritone-unoptimized-*-VERSION.jar`.
Otherwise, you want `baritone-standalone-*-VERSION.jar`
Here's what the various qualifiers mean
- **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/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/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.
- **Standalone**: Everything is obfuscated. Other mods cannot use Baritone, but you get a bit of extra performance.
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used in production, but is really helpful for crash reports.
- **No loader**: Loadable as a launchwrapper tweaker against vanilla Minecraft using a custom `version.json`.
- **Forge/Neoforge/Fabric**: Loadable as a standard mod using the respective loader. The fabric build may or may not work on Quilt.
If you build from source you will also find mapping files in the `dist` directory. These contain the renamings done by ProGuard and are useful if you want to read obfuscated stack traces.
## Build it yourself
- Clone or download Baritone
![Image](https://i.imgur.com/kbqBtoN.png)
- If you choose to download, make sure you extract the ZIP archive.
- If you choose to download, make sure you download the correct branch and extract the ZIP archive.
- Follow one of the instruction sets below, based on your preference
## Command Line
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16+ for 1.17.1, and JDK 17+ for 1.18.1.
To check which java you are using do
`java -version` in a command prompt or terminal.
If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes.
The recommended Java versions by Minecraft version are
| Minecraft version | Java version |
|-------------------------------|---------------|
| 1.12.2 - 1.16.5 | 8 |
| 1.17.1 | 16 |
| 1.18.2 - 1.20.4 | 17 |
| 1.20.5 - 1.21.4 | 21 |
Download java: https://adoptium.net/
#### macOS guide
In order to get JDK 8, Try running the following command:
`% /usr/libexec/java_home -V`
If it doesn't work try this guide: https://stackoverflow.com/questions/46513639/how-to-downgrade-java-from-9-to-8-on-a-macos-eclipse-is-not-running-with-java-9
If you see something like
`% 1.8.0_VERSION, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_VERSION.jdk/Contents/Home`
in the list then you've got JDK 8 installed.
In order to get JDK 8 running in the **current terminal window** you will have to run this command:
`% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)`
To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc
To check which java version you are using do `java -version` in a command prompt or terminal.
### Building Baritone
These tasks depend on the minecraft version, but are (for the most part) standard for building mods.
for more details, see [the build ci action](/.github/workflows/gradle_build.yml)
For more details, see [the build ci action](/.github/workflows/gradle_build.yml) of the branch you want to build.
For most branches `gradlew build` should build everything, but there are exceptions and this file might be out of date.
More specifically, on older branches the setup used to be that `gradlew build` builds the tweaker jar
and `gradlew build -Pbaritone.forge_build` / `gradlew build -Pbaritone.fabric_build` are needed to build
for Forge/Fabric instead. And you might have to run `setupDecompWorkspace` first.
## IntelliJ
- Open the project in IntelliJ as a Gradle project
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
- depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working
- Depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working
## Github Actions
Most branches have a CI workflow at `.github/workflows/gradle_build.yml`. If you fork this repository and enable actions for your fork
you can push a dummy commit to trigger it and have GitHub build Baritone for you.
If the commit you want to build is less than 90 days old, you can also find the corresponding workflow run in
[this list](https://github.com/cabaletta/baritone/actions/workflows/gradle_build.yml) and download the artifacts from there.

View File

@@ -15,34 +15,110 @@
* 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'
allprojects {
apply plugin: 'java'
apply plugin: "xyz.wagyourtail.unimined"
apply plugin: "maven-publish"
archivesBaseName = rootProject.archives_base_name
def vers = ""
try {
vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim()
} catch (Exception e) {
println "Version detection failed: " + e
}
if (!vers.startsWith("v")) {
println "using version number: " + rootProject.mod_version
version = rootProject.mod_version
} else {
version = vers.substring(1)
println "Detected version " + version
}
group = rootProject.maven_group
sourceCompatibility = targetCompatibility = JavaVersion.toVersion(project.java_version)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(sourceCompatibility.majorVersion.toInteger()))
}
}
repositories {
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'fabric-maven'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
name = "ldtteam"
url = "https://maven.parchmentmc.net/"
}
// for the newer version of launchwrapper
maven {
name = "multimc-maven"
url = "https://files.multimc.org/maven/"
metadataSources {
artifact()
}
}
mavenCentral()
maven {
name = 'babbaj-repo'
url = 'https://babbaj.github.io/maven/'
}
}
dependencies {
compileOnly "org.spongepowered:mixin:${project.mixin_version}"
compileOnly "org.ow2.asm:asm:${project.asm_version}"
implementation "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
unimined.minecraft(sourceSets.main, true) {
version rootProject.minecraft_version
mappings {
intermediary()
mojmap()
parchment("2023.06.26")
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
def targetVersion = project.java_version.toInteger()
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
def compileType = project.hasProperty("baritone.fabric_build") ? "FABRIC" : project.hasProperty("baritone.forge_build") ? "FORGE" : "OFFICIAL"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
compileJava {
options.encoding = "UTF-8" // allow emoji in comments :^)
unimined.minecraft {
runs.off = true
defaultRemapJar = false
}
archivesBaseName = archivesBaseName + "-common"
sourceSets {
api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += api.output
runtimeClasspath += api.output
}
test {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
@@ -54,63 +130,20 @@ sourceSets {
}
schematica_api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += schematica_api.output
runtimeClasspath += schematica_api.output
}
}
loom {
if (compileType.equals("FORGE")) {
forge {
mixinConfig 'mixins.baritone.json'
}
}
mixin.defaultRefmapName = "mixins.baritone.refmap.json"
runs {
client {
source = sourceSets.launch
}
}
}
repositories {
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
name = "ldtteam"
url = "https://maven.parchmentmc.net/"
}
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'
}
testImplementation 'junit:junit:4.13.2'
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.12'
jar {
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
}
javadoc {
@@ -120,71 +153,3 @@ javadoc {
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
}
// skidded from fabric-example-mod (comments and all)
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 16
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
jar {
from sourceSets.launch.output, sourceSets.api.output
if (!getProject().hasProperty("baritone.forge_build")) {
exclude "**/BaritoneForgeModXD.class"
exclude "**/mods.toml"
}
preserveFileTimestamps = false
reproducibleFileOrder = true
if (getProject().hasProperty("baritone.fabric_build")) {
filesMatching("fabric.mod.json") {
expand "version": version
}
} else {
exclude("fabric.mod.json")
}
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone',
'Implementation-Version': version,
)
}
}
if (compileType.equals("OFFICIAL")) {
remapJar {
toM.set "official"
}
}
task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.0-beta2/proguard-7.2.0-beta2.zip'
extract 'proguard-7.2.0-beta2/lib/proguard.jar'
compType compileType
}
task createDist(type: CreateDistTask, dependsOn: proguard)
build.finalizedBy(createDist)

View File

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

View File

@@ -18,6 +18,9 @@
package baritone.gradle.task;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import java.io.File;
import java.io.IOException;
@@ -33,50 +36,56 @@ import java.nio.file.Paths;
class BaritoneGradleTask extends DefaultTask {
protected static final String
PROGUARD_ZIP = "proguard.zip",
PROGUARD_JAR = "proguard.jar",
PROGUARD_ZIP = "proguard-%s.zip",
PROGUARD_JAR = "proguard-%s.jar",
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
PROGUARD_CONFIG_DEST = "template.pro",
PROGUARD_API_CONFIG = "api.pro",
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
PROGUARD_EXPORT_PATH = "proguard_out.jar",
PROGUARD_MAPPING_DIR = "mapping",
ARTIFACT_STANDARD = "%s-%s.jar",
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
ARTIFACT_API = "%s-api-%s.jar",
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
ARTIFACT_FORGE_UNOPTIMIZED = "%s-unoptimized-forge-%s.jar",
ARTIFACT_FORGE_API = "%s-api-forge-%s.jar",
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar",
ARTIFACT_FABRIC_UNOPTIMIZED = "%s-unoptimized-fabric-%s.jar",
ARTIFACT_FABRIC_API = "%s-api-fabric-%s.jar",
ARTIFACT_FABRIC_STANDALONE = "%s-standalone-fabric-%s.jar";
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
protected String artifactName, artifactVersion;
protected final Path
protected Path
artifactPath,
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
proguardOut;
@Input
@Optional
protected String compType = null;
public String getCompType() {
return compType;
}
public void setCompType(String compType) {
this.compType = compType;
}
public BaritoneGradleTask() {
this.artifactName = getProject().getName();
this.artifactVersion = getProject().getVersion().toString();
this.artifactName = getProject().getRootProject().getProperties().get("archives_base_name").toString();
}
public void doFirst() {
if (compType != null) {
this.artifactVersion = compType + "-" + getProject().getVersion();
} else {
this.artifactVersion = getProject().getVersion().toString();
}
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
if (getProject().hasProperty("baritone.forge_build")) {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
} else if (getProject().hasProperty("baritone.fabric_build")) {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FABRIC_STANDALONE));
} else {
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
}
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
}
@@ -99,7 +108,11 @@ 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(getProject().getBuildDir(), file).getAbsolutePath());
}
protected Path getRootRelativeFile(String file) {
return Paths.get(new File(getProject().getRootDir(), file).getAbsolutePath());
}
protected Path getTemporaryFile(String file) {
@@ -107,6 +120,10 @@ class BaritoneGradleTask extends DefaultTask {
}
protected Path getBuildFile(String file) {
return getRelativeFile("build/libs/" + file);
return getRelativeFile("libs/" + file);
}
protected String addCompTypeFirst(String string) {
return compType == null ? string : compType + "-" + string;
}
}

View File

@@ -21,7 +21,9 @@ import org.gradle.api.tasks.TaskAction;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.List;
@@ -39,15 +41,16 @@ public class CreateDistTask extends BaritoneGradleTask {
@TaskAction
protected void exec() throws Exception {
super.doFirst();
super.verifyArtifacts();
// Define the distribution file paths
Path api = getRelativeFile("dist/" + getFileName(artifactApiPath));
Path standalone = getRelativeFile("dist/" + getFileName(artifactStandalonePath));
Path unoptimized = getRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
Path api = getRootRelativeFile("dist/" + getFileName(artifactApiPath));
Path standalone = getRootRelativeFile("dist/" + getFileName(artifactStandalonePath));
Path unoptimized = getRootRelativeFile("dist/" + getFileName(artifactUnoptimizedPath));
// NIO will not automatically create directories
Path dir = getRelativeFile("dist/");
Path dir = getRootRelativeFile("dist/");
if (!Files.exists(dir)) {
Files.createDirectory(dir);
}
@@ -59,35 +62,21 @@ public class CreateDistTask extends BaritoneGradleTask {
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
// Calculate all checksums and format them like "shasum"
List<String> shasum = getAllDistJars().stream()
.filter(Files::exists)
List<String> shasum = Files.list(getRootRelativeFile("dist/"))
.filter(e -> e.getFileName().toString().endsWith(".jar"))
.map(path -> sha1(path) + " " + path.getFileName().toString())
.collect(Collectors.toList());
shasum.forEach(System.out::println);
// Write the checksums to a file
Files.write(getRelativeFile("dist/checksums.txt"), shasum);
Files.write(getRootRelativeFile("dist/checksums.txt"), shasum);
}
private static String getFileName(Path p) {
return p.getFileName().toString();
}
private List<Path> getAllDistJars() {
return Arrays.asList(
getRelativeFile("dist/" + formatVersion(ARTIFACT_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FABRIC_UNOPTIMIZED)),
getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_UNOPTIMIZED))
);
}
private static synchronized String sha1(Path path) {
try {
if (SHA1_DIGEST == null) {

View File

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

View File

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

103
fabric/build.gradle Normal file
View File

@@ -0,0 +1,103 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
plugins {
id "com.github.johnrengelman.shadow" version "8.0.0"
}
archivesBaseName = archivesBaseName + "-fabric"
unimined.minecraft {
fabric {
loader project.fabric_version
}
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
}
dependencies {
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
if (sourceSet == rootProject.sourceSets.schematica_api) continue
common sourceSet.output
shadowCommon sourceSet.output
}
include "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
configurations = [project.configurations.shadowCommon]
archiveClassifier.set "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}
jar {
archiveClassifier.set "dev"
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
task proguard(type: ProguardTask) {
proguardVersion "7.2.1"
compType "fabric"
}
task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "fabric"
}
build.finalizedBy(createDist)
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

View File

@@ -11,7 +11,8 @@
],
"contact": {
"homepage": "https://github.com/cabaletta/baritone",
"sources": "https://github.com/cabaletta/baritone"
"sources": "https://github.com/cabaletta/baritone",
"issues": "https://github.com/cabaletta/baritone/issues"
},
"license": "LGPL-3.0",
@@ -21,11 +22,18 @@
"entrypoints": {
},
"mixins": [
"mixins.baritone.json"
"mixins.baritone.json"
],
"depends": {
"fabricloader": ">=0.11.0",
"minecraft": "1.18.x"
"minecraft": "1.19.4"
},
"custom": {
"modmenu": {
"links": {
"modmenu.discord": "https://discord.gg/s6fRBAUpmr"
}
}
}
}
}

124
forge/build.gradle Normal file
View File

@@ -0,0 +1,124 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
plugins {
id "com.github.johnrengelman.shadow" version "8.0.0"
}
archivesBaseName = archivesBaseName + "-forge"
unimined.minecraft {
mappings {
devFallbackNamespace "intermediary"
}
forge {
loader project.forge_version
mixinConfig ["mixins.baritone.json"]
}
}
//loom {
// forge {
// mixinConfig 'mixins.baritone.json'
// }
//}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
}
dependencies {
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
if (sourceSet == rootProject.sourceSets.schematica_api) continue
common sourceSet.output
shadowCommon sourceSet.output
}
shadowCommon "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
shadowJar {
configurations = [project.configurations.shadowCommon]
archiveClassifier.set "dev-shadow"
}
remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}
jar {
archiveClassifier.set "dev"
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone',
'Implementation-Version': version,
)
}
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
task proguard(type: ProguardTask) {
proguardVersion "7.2.1"
compType "forge"
}
task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "forge"
}
build.finalizedBy(createDist)
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

18
forge/gradle.properties Normal file
View File

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

View File

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

View File

@@ -15,7 +15,7 @@ issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
# The modid of the mod
modId="baritoe" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${file.jarVersion}" #mandatory
version="${version}" #mandatory
# A display name for the mod
displayName="Baritone" #mandatory
# A URL for the "homepage" for this mod, displayed in the mod UI
@@ -31,3 +31,10 @@ description='''
A Minecraft pathfinder bot.
'''
[[dependencies.baritoe]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.19.4]"
ordering="NONE"
side="BOTH"

View File

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

View File

@@ -1,13 +1,20 @@
org.gradle.jvmargs=-Xmx2048M
org.gradle.jvmargs=-Xmx4G
mod_version=1.8.4
mod_version=1.9.5
maven_group=baritone
archives_base_name=baritone
minecraft_version=1.18.2
forge_version=1.18.2-40.0.0
fabric_version=0.13.1
java_version=17
# # un comment for forge debugging default (as opposed to fabric)
# baritone.forge_build=true
# loom.platform=forge
minecraft_version=1.19.4
forge_version=45.0.43
fabric_version=0.14.11
nether_pathfinder_version=1.4.1
// These dependencies are used for common and tweaker
// while mod loaders usually ship their own version
mixin_version=0.8.5
asm_version=9.3

View File

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

2
gradlew vendored
View File

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

4
jitpack.yml Normal file
View File

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

View File

@@ -54,6 +54,11 @@
-dontwarn baritone.utils.schematic.schematica.**
-dontwarn baritone.utils.schematic.litematica.**
# nether-pathfinder uses JNI to acess its own classes
# and some of our builds include it before running proguard
# conservatively keep all of it, even though only PathSegment.<init> is needed
-keep,allowoptimization class dev.babbaj.pathfinder.** { *; }
# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class * {
@@ -341,6 +346,4 @@
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
-printmapping mapping.txt
}

View File

@@ -17,26 +17,34 @@
pluginManagement {
repositories {
maven { url "https://maven.architectury.dev/" }
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/snapshots'
}
maven {
name = 'ForgeMaven'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
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()
gradlePluginPortal() {
content {
excludeGroup "org.apache.logging.log4j"
}
}
}
}
rootProject.name = 'baritone'
include("tweaker")
if (System.getProperty("Baritone.enabled_platforms") == null) {
System.setProperty("Baritone.enabled_platforms", "fabric,forge")
}
for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) {
include(platform)
}

View File

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

View File

@@ -22,6 +22,7 @@ import baritone.api.command.ICommand;
import baritone.api.command.ICommandSystem;
import baritone.api.schematic.ISchematicSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import java.util.List;
@@ -82,6 +83,22 @@ public interface IBaritoneProvider {
return null;
}
/**
* Provides the {@link IBaritone} instance for the player with the specified connection.
*
* @param connection The connection
* @return The {@link IBaritone} instance.
*/
default IBaritone getBaritoneForConnection(ClientPacketListener connection) {
for (IBaritone baritone : this.getAllBaritones()) {
final LocalPlayer player = baritone.getPlayerContext().player();
if (player != null && player.connection == connection) {
return baritone;
}
}
return null;
}
/**
* Creates and registers a new {@link IBaritone} instance using the specified {@link Minecraft}. The existing
* instance is returned if already registered.

View File

@@ -17,18 +17,24 @@
package baritone.api;
import baritone.api.utils.Helper;
import baritone.api.utils.NotificationHelper;
import baritone.api.utils.SettingsUtil;
import baritone.api.utils.TypeUtils;
import baritone.api.utils.gui.BaritoneToast;
import net.minecraft.client.GuiMessageTag;
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.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -37,8 +43,9 @@ import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -48,6 +55,7 @@ import java.util.function.Consumer;
* @author leijurv
*/
public final class Settings {
private static final Logger LOGGER = LoggerFactory.getLogger("Baritone");
/**
* Allow Baritone to break blocks
@@ -69,6 +77,16 @@ public final class Settings {
*/
public final Setting<Boolean> allowPlace = new Setting<>(true);
/**
* Allow Baritone to place blocks in fluid source blocks
*/
public final Setting<Boolean> allowPlaceInFluidsSource = new Setting<>(true);
/**
* Allow Baritone to place blocks in flowing fluid
*/
public final Setting<Boolean> allowPlaceInFluidsFlow = new Setting<>(true);
/**
* Allow Baritone to move items in your inventory to your hotbar
*/
@@ -167,6 +185,13 @@ public final class Settings {
* <p>
* Defaults to false because this fails on constantiam. Please let me know if this is ever disabled. Please.
*/
public final Setting<Boolean> allowJumpAtBuildLimit = new Setting<>(false);
/**
* Just here so mods that use the API don't break. Does nothing.
*/
@Deprecated
@JavaOnly
public final Setting<Boolean> allowJumpAt256 = new Setting<>(false);
/**
@@ -380,6 +405,12 @@ public final class Settings {
*/
public final Setting<Float> blockReachDistance = new Setting<>(4.5f);
/**
* How many ticks between breaking a block and starting to break the next block. Default in game is 6 ticks.
* Values under 1 will be clamped. The delay only applies to non-instant (1-tick) breaks.
*/
public final Setting<Integer> blockBreakSpeed = new Setting<>(6);
/**
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
*/
@@ -738,6 +769,26 @@ public final class Settings {
*/
public final Setting<Boolean> blockFreeLook = new Setting<>(false);
/**
* Automatically elytra fly without having to force the client-sided rotations.
*/
public final Setting<Boolean> elytraFreeLook = new Setting<>(true);
/**
* Forces the client-sided yaw rotation to an average of the last {@link #smoothLookTicks} of server-sided rotations.
*/
public final Setting<Boolean> smoothLook = new Setting<>(false);
/**
* Same as {@link #smoothLook} but for elytra flying.
*/
public final Setting<Boolean> elytraSmoothLook = new Setting<>(false);
/**
* The number of ticks to average across for {@link #smoothLook};
*/
public final Setting<Integer> smoothLookTicks = new Setting<>(5);
/**
* When true, the player will remain with its existing look direction as often as possible.
* Although, in some cases this can get it stuck, hence this setting to disable that behavior.
@@ -806,6 +857,11 @@ public final class Settings {
*/
public final Setting<Boolean> shortBaritonePrefix = new Setting<>(false);
/**
* Use a modern message tag instead of a prefix when logging to chat
*/
public final Setting<Boolean> useMessageTag = new Setting<>(false);
/**
* Echo commands to chat when they are run
*/
@@ -873,6 +929,13 @@ public final class Settings {
*/
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
/**
* Mine will not scan for or remember more than this many target locations.
* Note that the number of locations retrieved from cache is additionaly
* limited by {@link #maxCachedWorldScanCount}.
*/
public final Setting<Integer> mineMaxOreLocationsCount = new Setting<>(64);
/**
* Sets the minimum y level whilst mining - set to 0 to turn off.
* if world has negative y values, subtract the min world height to get the value to put here
@@ -930,6 +993,11 @@ public final class Settings {
*/
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
/**
* Farming will scan for at most this many blocks.
*/
public final Setting<Integer> farmMaxScanSize = new Setting<>(256);
/**
* When the cache scan gives less blocks than the maximum threshold (but still above zero), scan the main world too.
* <p>
@@ -1021,6 +1089,11 @@ public final class Settings {
*/
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
/**
* Multiply the cost of placing a block that's incorrect in the builder's schematic by this coefficient
*/
public final Setting<Double> placeIncorrectBlockPenaltyMultiplier = new Setting<>(2d);
/**
* When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
*/
@@ -1036,6 +1109,28 @@ public final class Settings {
*/
public final Setting<Boolean> schematicOrientationZ = new Setting<>(false);
/**
* Rotates the schematic before building it.
* Possible values are
* <ul>
* <li> NONE - No rotation </li>
* <li> CLOCKWISE_90 - Rotate 90° clockwise </li>
* <li> CLOCKWISE_180 - Rotate 180° clockwise </li>
* <li> COUNTERCLOCKWISE_90 - Rotate 270° clockwise </li>
* </ul>
*/
public final Setting<Rotation> buildSchematicRotation = new Setting<>(Rotation.NONE);
/**
* Mirrors the schematic before building it.
* Possible values are
* <ul>
* <li> FRONT_BACK - mirror the schematic along its local x axis </li>
* <li> LEFT_RIGHT - mirror the schematic along its local z axis </li>
* </ul>
*/
public final Setting<Mirror> buildSchematicMirror = new Setting<>(Mirror.NONE);
/**
* The fallback used by the build command when no extension is specified. This may be useful if schematics of a
* particular format are used often, and the user does not wish to have to specify the extension with every usage.
@@ -1147,6 +1242,11 @@ public final class Settings {
*/
public final Setting<Integer> followRadius = new Setting<>(3);
/**
* The maximum distance to the entity you're following
*/
public final Setting<Integer> followTargetMaxDistance = new Setting<>(0);
/**
* Turn this on if your exploration filter is enormous, you don't want it to check if it's done,
* and you are just fine with it just hanging on completion
@@ -1181,7 +1281,14 @@ public final class Settings {
* {@link Setting#value};
*/
@JavaOnly
public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
public final Setting<Consumer<Component>> logger = new Setting<>((msg) -> {
try {
final GuiMessageTag tag = useMessageTag.value ? Helper.MESSAGE_TAG : null;
Minecraft.getInstance().gui.getChat().addMessage(msg, null, tag);
} catch (Throwable t) {
LOGGER.warn("Failed to log message to chat: " + msg.getString(), t);
}
});
/**
* The function that is called when Baritone will send a desktop notification. This function can be added to
@@ -1329,6 +1436,120 @@ public final class Settings {
*/
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);
/**
* The number of ticks of elytra movement to simulate while firework boost is not active. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraSimulationTicks = new Setting<>(20);
/**
* The maximum allowed deviation in pitch from a direct line-of-sight to the flight target. Higher values are
* computationally more expensive.
*/
public final Setting<Integer> elytraPitchRange = new Setting<>(25);
/**
* The minimum speed that the player can drop to (in blocks/tick) before a firework is automatically deployed.
*/
public final Setting<Double> elytraFireworkSpeed = new Setting<>(1.2);
/**
* The delay after the player's position is set-back by the server that a firework may be automatically deployed.
* Value is in ticks.
*/
public final Setting<Integer> elytraFireworkSetbackUseDelay = new Setting<>(15);
/**
* The minimum padding value that is added to the player's hitbox when considering which point to fly to on the
* path. High values can result in points not being considered which are otherwise safe to fly to. Low values can
* result in flight paths which are extremely tight, and there's the possibility of crashing due to getting too low
* to the ground.
*/
public final Setting<Double> elytraMinimumAvoidance = new Setting<>(0.2);
/**
* If enabled, avoids using fireworks when descending along the flight path.
*/
public final Setting<Boolean> elytraConserveFireworks = new Setting<>(false);
/**
* Renders the raytraces that are performed by the elytra fly calculation.
*/
public final Setting<Boolean> elytraRenderRaytraces = new Setting<>(false);
/**
* Renders the raytraces that are used in the hitbox part of the elytra fly calculation.
* Requires {@link #elytraRenderRaytraces}.
*/
public final Setting<Boolean> elytraRenderHitboxRaytraces = new Setting<>(false);
/**
* Renders the best elytra flight path that was simulated each tick.
*/
public final Setting<Boolean> elytraRenderSimulation = new Setting<>(true);
/**
* Automatically path to and jump off of ledges to initiate elytra flight when grounded.
*/
public final Setting<Boolean> elytraAutoJump = new Setting<>(false);
/**
* The seed used to generate chunks for long distance elytra path-finding in the nether.
* Defaults to 2b2t's nether seed.
*/
public final Setting<Long> elytraNetherSeed = new Setting<>(146008555100680L);
/**
* Whether nether-pathfinder should generate terrain based on {@link #elytraNetherSeed}.
* If false all chunks that haven't been loaded are assumed to be air.
*/
public final Setting<Boolean> elytraPredictTerrain = new Setting<>(false);
/**
* Automatically swap the current elytra with a new one when the durability gets too low
*/
public final Setting<Boolean> elytraAutoSwap = new Setting<>(true);
/**
* The minimum durability an elytra can have before being swapped
*/
public final Setting<Integer> elytraMinimumDurability = new Setting<>(5);
/**
* The minimum fireworks before landing early for safety
*/
public final Setting<Integer> elytraMinFireworksBeforeLanding = new Setting<>(5);
/**
* Automatically land when elytra is almost out of durability, or almost out of fireworks
*/
public final Setting<Boolean> elytraAllowEmergencyLand = new Setting<>(true);
/**
* Time between culling far away chunks from the nether pathfinder chunk cache
*/
public final Setting<Long> elytraTimeBetweenCacheCullSecs = new Setting<>(TimeUnit.MINUTES.toSeconds(3));
/**
* Maximum distance chunks can be before being culled from the nether pathfinder chunk cache
*/
public final Setting<Integer> elytraCacheCullDistance = new Setting<>(5000);
/**
* Should elytra consider nether brick a valid landing block
*/
public final Setting<Boolean> elytraAllowLandOnNetherFortress = new Setting<>(false);
/**
* Has the user read and understood the elytra terms and conditions
*/
public final Setting<Boolean> elytraTermsAccepted = new Setting<>(false);
/**
* Verbose chat logging in elytra mode
*/
public final Setting<Boolean> elytraChatSpam = new Setting<>(false);
/**
* A map of lowercase setting field names to their respective setting
*/

View File

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

View File

@@ -19,11 +19,12 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import java.util.stream.Stream;
public enum EntityClassById implements IDatatypeFor<EntityType> {
INSTANCE;
@@ -31,7 +32,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
EntityType entity;
if ((entity = Registry.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");
}
return entity;
@@ -40,7 +41,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(Registry.ENTITY_TYPE.stream().map(Object::toString))
.append(BuiltInRegistries.ENTITY_TYPE.stream().map(Object::toString))
.filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically()
.stream();

View File

@@ -20,7 +20,7 @@ package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.Property;
@@ -77,7 +77,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
properties = parts[1];
}
Block block = Registry.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
if (block == null) {
// This block doesn't exist so there's no properties to complete.
return Stream.empty();

View File

@@ -0,0 +1,53 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.command.datatypes;
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import java.util.stream.Stream;
public enum ItemById implements IDatatypeFor<Item> {
INSTANCE;
@Override
public Item get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
Item item;
if ((item = BuiltInRegistries.ITEM.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("No item found by that id");
}
return item;
}
@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(
BuiltInRegistries.BLOCK.keySet()
.stream()
.map(ResourceLocation::toString)
)
.filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically()
.stream();
}
}

View File

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

View File

@@ -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 java.awt.*;
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;
import net.minecraft.network.chat.MutableComponent;
public class Paginator<E> implements Helper {
@@ -74,7 +75,7 @@ public class Paginator<E> implements Helper {
}
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
boolean hasNextPage = commandPrefix != null && validPage(page + 1);
BaseComponent prevPageComponent = new TextComponent("<<");
MutableComponent prevPageComponent = Component.literal("<<");
if (hasPrevPage) {
prevPageComponent.setStyle(prevPageComponent.getStyle()
.withClickEvent(new ClickEvent(
@@ -83,26 +84,23 @@ public class Paginator<E> implements Helper {
))
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to view previous page")
Component.literal("Click to view previous page")
)));
} else {
prevPageComponent.setStyle(prevPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
}
BaseComponent nextPageComponent = new TextComponent(">>");
MutableComponent nextPageComponent = Component.literal(">>");
if (hasNextPage) {
nextPageComponent.setStyle(nextPageComponent.getStyle()
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format("%s %d", commandPrefix, page + 1)
))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", commandPrefix, page + 1)))
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to view next page")
Component.literal("Click to view next page")
)));
} else {
nextPageComponent.setStyle(nextPageComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
}
BaseComponent pagerComponent = new TextComponent("");
MutableComponent pagerComponent = Component.literal("");
pagerComponent.setStyle(pagerComponent.getStyle().withColor(ChatFormatting.GRAY));
pagerComponent.append(prevPageComponent);
pagerComponent.append(" | ");

View File

@@ -212,7 +212,12 @@ public class TabCompleteHelper {
* @return This {@link TabCompleteHelper}
*/
public TabCompleteHelper filterPrefixNamespaced(String prefix) {
return filterPrefix(new ResourceLocation(prefix).toString());
ResourceLocation loc = ResourceLocation.tryParse(prefix);
if (loc == null) {
stream = Stream.empty();
return this;
}
return filterPrefix(loc.toString());
}
/**

View File

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

View File

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

View File

@@ -18,7 +18,7 @@
package baritone.api.event.events;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import org.joml.Matrix4f;
/**
* @author Brady

View File

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

View File

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

View File

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

View File

@@ -44,7 +44,7 @@ public class GoalRunAway implements Goal {
public GoalRunAway(double distance, Integer maintainY, BlockPos... from) {
if (from.length == 0) {
throw new IllegalArgumentException();
throw new IllegalArgumentException("Positions to run away from must not be empty");
}
this.from = from;
this.distanceSq = (int) (distance * distance);

View File

@@ -24,6 +24,7 @@ import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.BlockState;
import java.io.File;
import java.util.List;
import java.util.Optional;
/**
* @author Brady
@@ -74,4 +75,17 @@ public interface IBuilderProcess extends IBaritoneProcess {
* cause it to give up. This is updated every tick, but only while the builder process is active.
*/
List<BlockState> getApproxPlaceable();
/**
* Returns the lower bound of the current mining layer if mineInLayers is true.
* If mineInLayers is false, this will return an empty optional.
* @return The lower bound of the current mining layer
*/
Optional<Integer> getMinLayer();
/**
* Returns the upper bound of the current mining layer if mineInLayers is true.
* If mineInLayers is false, this will return an empty optional.
* @return The upper bound of the current mining layer
*/
Optional<Integer> getMaxLayer();
}

View File

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

View File

@@ -0,0 +1,50 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.process;
import baritone.api.pathing.goals.Goal;
import net.minecraft.core.BlockPos;
public interface IElytraProcess extends IBaritoneProcess {
void repackChunks();
/**
* @return Where it is currently flying to, null if not active
*/
BlockPos currentDestination();
void pathTo(BlockPos destination);
void pathTo(Goal destination);
/**
* Resets the state of the process but will maintain the same destination and will try to keep flying
*/
void resetState();
/**
* @return {@code true} if the native library loaded and elytra is actually usable
*/
boolean isLoaded();
/*
* FOR INTERNAL USE ONLY. MAY BE REMOVED AT ANY TIME.
*/
boolean isSafeToCancel();
}

View File

@@ -17,9 +17,11 @@
package baritone.api.process;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.world.entity.Entity;
/**
* @author Brady
@@ -34,6 +36,13 @@ public interface IFollowProcess extends IBaritoneProcess {
*/
void follow(Predicate<Entity> filter);
/**
* Try to pick up any items matching this predicate
*
* @param filter the predicate
*/
void pickup(Predicate<ItemStack> filter);
/**
* @return The entities that are currently being followed. null if not currently following, empty if nothing matches the predicate
*/

View File

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

View File

@@ -21,6 +21,7 @@ import baritone.api.command.registry.Registry;
import baritone.api.schematic.format.ISchematicFormat;
import java.io.File;
import java.util.List;
import java.util.Optional;
/**
@@ -41,4 +42,9 @@ public interface ISchematicSystem {
* @return The corresponding format for the file, {@link Optional#empty()} if no candidates were found.
*/
Optional<ISchematicFormat> getByFile(File file);
/**
* @return A list of file extensions used by supported formats
*/
List<String> getFileExtensions();
}

View File

@@ -0,0 +1,114 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Mirror;
import java.util.List;
import java.util.stream.Collectors;
public class MirroredSchematic implements ISchematic {
private final ISchematic schematic;
private final Mirror mirror;
public MirroredSchematic(ISchematic schematic, Mirror mirror) {
this.schematic = schematic;
this.mirror = mirror;
}
@Override
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(
mirrorX(x, widthX(), mirror),
y,
mirrorZ(z, lengthZ(), mirror),
mirror(currentState, mirror)
);
}
@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return mirror(schematic.desiredState(
mirrorX(x, widthX(), mirror),
y,
mirrorZ(z, lengthZ(), mirror),
mirror(current, mirror),
mirror(approxPlaceable, mirror)
), mirror);
}
@Override
public void reset() {
schematic.reset();
}
@Override
public int widthX() {
return schematic.widthX();
}
@Override
public int heightY() {
return schematic.heightY();
}
@Override
public int lengthZ() {
return schematic.lengthZ();
}
private static int mirrorX(int x, int sizeX, Mirror mirror) {
switch (mirror) {
case NONE:
case LEFT_RIGHT:
return x;
case FRONT_BACK:
return sizeX - x - 1;
}
throw new IllegalArgumentException("Unknown mirror");
}
private static int mirrorZ(int z, int sizeZ, Mirror mirror) {
switch (mirror) {
case NONE:
case FRONT_BACK:
return z;
case LEFT_RIGHT:
return sizeZ - z - 1;
}
throw new IllegalArgumentException("Unknown mirror");
}
private static BlockState mirror(BlockState state, Mirror mirror) {
if (state == null) {
return null;
}
return state.mirror(mirror);
}
private static List<BlockState> mirror(List<BlockState> states, Mirror mirror) {
if (states == null) {
return null;
}
return states.stream()
.map(s -> mirror(s, mirror))
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,136 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.schematic;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Rotation;
import java.util.List;
import java.util.stream.Collectors;
public class RotatedSchematic implements ISchematic {
private final ISchematic schematic;
private final Rotation rotation;
private final Rotation inverseRotation;
public RotatedSchematic(ISchematic schematic, Rotation rotation) {
this.schematic = schematic;
this.rotation = rotation;
// I don't think a 14 line switch would improve readability
this.inverseRotation = rotation.getRotated(rotation).getRotated(rotation);
}
@Override
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(
rotateX(x, z, widthX(), lengthZ(), inverseRotation),
y,
rotateZ(x, z, widthX(), lengthZ(), inverseRotation),
rotate(currentState, inverseRotation)
);
}
@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return rotate(schematic.desiredState(
rotateX(x, z, widthX(), lengthZ(), inverseRotation),
y,
rotateZ(x, z, widthX(), lengthZ(), inverseRotation),
rotate(current, inverseRotation),
rotate(approxPlaceable, inverseRotation)
), rotation);
}
@Override
public void reset() {
schematic.reset();
}
@Override
public int widthX() {
return flipsCoordinates(rotation) ? schematic.lengthZ() : schematic.widthX();
}
@Override
public int heightY() {
return schematic.heightY();
}
@Override
public int lengthZ() {
return flipsCoordinates(rotation) ? schematic.widthX() : schematic.lengthZ();
}
/**
* Wether {@code rotation} swaps the x and z components
*/
private static boolean flipsCoordinates(Rotation rotation) {
return rotation == Rotation.CLOCKWISE_90 || rotation == Rotation.COUNTERCLOCKWISE_90;
}
/**
* The x component of x,y after applying the rotation
*/
private static int rotateX(int x, int z, int sizeX, int sizeZ, Rotation rotation) {
switch (rotation) {
case NONE:
return x;
case CLOCKWISE_90:
return sizeZ - z - 1;
case CLOCKWISE_180:
return sizeX - x - 1;
case COUNTERCLOCKWISE_90:
return z;
}
throw new IllegalArgumentException("Unknown rotation");
}
/**
* The z component of x,y after applying the rotation
*/
private static int rotateZ(int x, int z, int sizeX, int sizeZ, Rotation rotation) {
switch (rotation) {
case NONE:
return z;
case CLOCKWISE_90:
return x;
case CLOCKWISE_180:
return sizeZ - z - 1;
case COUNTERCLOCKWISE_90:
return sizeX - x - 1;
}
throw new IllegalArgumentException("Unknown rotation");
}
private static BlockState rotate(BlockState state, Rotation rotation) {
if (state == null) {
return null;
}
return state.rotate(rotation);
}
private static List<BlockState> rotate(List<BlockState> states, Rotation rotation) {
if (states == null) {
return null;
}
return states.stream()
.map(s -> rotate(s, rotation))
.collect(Collectors.toList());
}
}

View File

@@ -23,6 +23,7 @@ import baritone.api.schematic.IStaticSchematic;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* The base of a {@link ISchematic} file format
@@ -42,4 +43,9 @@ public interface ISchematicFormat {
* @return Whether or not the specified file matches this schematic format
*/
boolean isFileType(File file);
/**
* @return A list of file extensions used by this format
*/
List<String> getFileExtensions();
}

View File

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

View File

@@ -21,20 +21,30 @@ import baritone.api.utils.accessor.IItemStack;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.netty.util.concurrent.ThreadPerTaskExecutor;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.*;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.packs.*;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Unit;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.CustomSpawner;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
@@ -42,8 +52,13 @@ 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 sun.misc.Unsafe;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -51,6 +66,7 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -64,7 +80,7 @@ public final class BlockOptionalMeta {
private final Set<BlockState> blockstates;
private final Set<Integer> stateHashes;
private final Set<Integer> stackHashes;
private static LootTables manager;
private static LootTables lootTables;
private static PredicateManager predicate = new PredicateManager();
private static Map<Block, List<Item>> drops = new HashMap<>();
@@ -191,21 +207,37 @@ public final class BlockOptionalMeta {
return stackHashes;
}
private static Method getVanillaServerPack;
private static VanillaPackResources getVanillaServerPack() {
if (getVanillaServerPack == null) {
getVanillaServerPack = Arrays.stream(ServerPacksSource.class.getDeclaredMethods()).filter(field -> field.getReturnType() == VanillaPackResources.class).findFirst().orElseThrow();
getVanillaServerPack.setAccessible(true);
}
try {
return (VanillaPackResources) getVanillaServerPack.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static LootTables getManager() {
if (manager == null) {
PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource());
rpl.reload();
PackResources thePack = rpl.getAvailablePacks().iterator().next().open();
if (lootTables == null) {
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
manager = new LootTables(predicate);
resourceManager.registerReloadListener(manager);
lootTables = new LootTables(predicate);
resourceManager.registerReloadListener(lootTables);
try {
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get();
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
return manager;
return lootTables;
}
public static PredicateManager getPredicateManager() {
@@ -219,20 +251,55 @@ public final class BlockOptionalMeta {
return Collections.emptyList();
} else {
List<Item> items = new ArrayList<>();
// the other overload for generate doesnt work in forge because forge adds code that requires a non null world
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder((ServerLevel) null)
.withRandom(new Random())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK),
try {
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder(ServerLevelStub.fastCreate())
.withRandom(RandomSource.create())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK),
stack -> items.add(stack.getItem())
);
);
} catch (Exception e) {
e.printStackTrace();
}
return items;
}
});
}
private static class ServerLevelStub extends ServerLevel {
private static Minecraft client = Minecraft.getInstance();
private static Unsafe unsafe = getUnsafe();
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10) {
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10);
}
@Override
public FeatureFlagSet enabledFeatures() {
assert client.level != null;
return client.level.enabledFeatures();
}
public static ServerLevelStub fastCreate() {
try {
return (ServerLevelStub) unsafe.allocateInstance(ServerLevelStub.class);
} catch (InstantiationException e) {
throw new RuntimeException(e);
}
}
public static Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

View File

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

View File

@@ -18,12 +18,13 @@
package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.utils.gui.BaritoneToast;
import baritone.api.Settings;
import net.minecraft.ChatFormatting;
import net.minecraft.client.GuiMessageTag;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import java.util.Arrays;
import java.util.Calendar;
import java.util.stream.Stream;
@@ -49,15 +50,20 @@ public interface Helper {
@Deprecated
Minecraft mc = Minecraft.getInstance();
/**
* The tag to assign to chat messages when {@link Settings#useMessageTag} is {@code true}.
*/
GuiMessageTag MESSAGE_TAG = new GuiMessageTag(0xFF55FF, null, Component.literal("Baritone message."), "Baritone");
static Component getPrefix() {
// Inner text component
final Calendar now = Calendar.getInstance();
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");
MutableComponent baritone = Component.literal(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone");
baritone.setStyle(baritone.getStyle().withColor(ChatFormatting.LIGHT_PURPLE));
// Outer brackets
BaseComponent prefix = new TextComponent("");
MutableComponent prefix = Component.literal("");
prefix.setStyle(baritone.getStyle().withColor(ChatFormatting.DARK_PURPLE));
prefix.append("[");
prefix.append(baritone);
@@ -83,7 +89,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(Component.literal(title), Component.literal(message));
}
/**
@@ -92,7 +98,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(), Component.literal(message));
}
/**
@@ -160,9 +166,11 @@ public interface Helper {
* @param components The components to send
*/
default void logDirect(boolean logAsToast, Component... components) {
BaseComponent component = new TextComponent("");
component.append(getPrefix());
component.append(new TextComponent(" "));
MutableComponent component = Component.literal("");
if (!logAsToast && !BaritoneAPI.getSettings().useMessageTag.value) {
component.append(getPrefix());
component.append(Component.literal(" "));
}
Arrays.asList(components).forEach(component::append);
if (logAsToast) {
logToast(getPrefix(), component);
@@ -190,7 +198,7 @@ public interface Helper {
*/
default void logDirect(String message, ChatFormatting color, boolean logAsToast) {
Stream.of(message.split("\n")).forEach(line -> {
BaseComponent component = new TextComponent(line.replace("\t", " "));
MutableComponent component = Component.literal(line.replace("\t", " "));
component.setStyle(component.getStyle().withColor(color));
logDirect(logAsToast, component);
});
@@ -227,4 +235,11 @@ public interface Helper {
default void logDirect(String message) {
logDirect(message, BaritoneAPI.getSettings().logAsToast.value);
}
default void logUnhandledException(final Throwable exception) {
HELPER.logDirect("An unhandled exception occurred. " +
"The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues",
ChatFormatting.RED);
exception.printStackTrace();
}
}

View File

@@ -89,12 +89,24 @@ public interface IPlayerContext {
return new Vec3(player().position().x, player().position().y + player().getEyeHeight(), player().position().z);
}
default Vec3 playerMotion() {
return player().getDeltaMovement();
}
BetterBlockPos viewerPos();
default Rotation playerRotations() {
return new Rotation(player().getYRot(), player().getXRot());
}
/**
* Returns the player's eye height, taking into account whether or not the player is sneaking.
*
* @param ifSneaking Whether or not the player is sneaking
* @return The player's eye height
* @deprecated Use entity.getEyeHeight(Pose.CROUCHING) instead
*/
@Deprecated
static double eyeHeight(boolean ifSneaking) {
return ifSneaking ? 1.27 : 1.62;
}

View File

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

View File

@@ -18,6 +18,7 @@
package baritone.api.utils;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
@@ -51,7 +52,8 @@ public final class RayTraceUtils {
} else {
start = entity.getEyePosition(1.0F); // do whatever is correct
}
Vec3 direction = RotationUtils.calcVector3dFromRotation(rotation);
Vec3 direction = RotationUtils.calcLookDirectionFromRotation(rotation);
Vec3 end = start.add(
direction.x * blockReachDistance,
direction.y * blockReachDistance,
@@ -61,6 +63,6 @@ public final class RayTraceUtils {
}
public static Vec3 inferSneakingEyePosition(Entity entity) {
return new Vec3(entity.getX(), entity.getY() + IPlayerContext.eyeHeight(true), entity.getZ());
return new Vec3(entity.getX(), entity.getY() + entity.getEyeHeight(Pose.CROUCHING), entity.getZ());
}
}

View File

@@ -19,7 +19,6 @@ package baritone.api.utils;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import java.util.Optional;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -33,6 +32,8 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.Optional;
/**
* @author Brady
* @since 9/25/2018
@@ -43,11 +44,13 @@ public final class RotationUtils {
* Constant that a degree value is multiplied by to get the equivalent radian value
*/
public static final double DEG_TO_RAD = Math.PI / 180.0;
public static final float DEG_TO_RAD_F = (float) DEG_TO_RAD;
/**
* Constant that a radian value is multiplied by to get the equivalent degree value
*/
public static final double RAD_TO_DEG = 180.0 / Math.PI;
public static final float RAD_TO_DEG_F = (float) RAD_TO_DEG;
/**
* Offsets from the root block position to the center of each side.
@@ -128,12 +131,17 @@ public final class RotationUtils {
* @param rotation The input rotation
* @return Look vector for the rotation
*/
public static Vec3 calcVector3dFromRotation(Rotation rotation) {
float f = Mth.cos(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f1 = Mth.sin(-rotation.getYaw() * (float) DEG_TO_RAD - (float) Math.PI);
float f2 = -Mth.cos(-rotation.getPitch() * (float) DEG_TO_RAD);
float f3 = Mth.sin(-rotation.getPitch() * (float) DEG_TO_RAD);
return new Vec3((double) (f1 * f2), (double) f3, (double) (f * f2));
public static Vec3 calcLookDirectionFromRotation(Rotation rotation) {
float flatZ = Mth.cos((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI);
float flatX = Mth.sin((-rotation.getYaw() * DEG_TO_RAD_F) - (float) Math.PI);
float pitchBase = -Mth.cos(-rotation.getPitch() * DEG_TO_RAD_F);
float pitchHeight = Mth.sin(-rotation.getPitch() * DEG_TO_RAD_F);
return new Vec3(flatX * pitchBase, pitchHeight, flatZ * pitchBase);
}
@Deprecated
public static Vec3 calcVec3dFromRotation(Rotation rotation) {
return calcLookDirectionFromRotation(rotation);
}
/**

View File

@@ -23,9 +23,13 @@ import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -79,6 +83,10 @@ public class SettingsUtil {
String settingName = matcher.group("setting").toLowerCase();
String settingValue = matcher.group("value");
// TODO remove soonish
if ("allowjumpat256".equals(settingName)) {
settingName = "allowjumpatbuildlimit";
}
try {
parseAndApply(settings, settingName, settingValue);
} catch (Exception ex) {
@@ -148,7 +156,7 @@ public class SettingsUtil {
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName());
}
return io.toString(new ParserContext(setting), value);
return io.toString(setting.getType(), value);
}
public static String settingValueToString(Settings.Setting setting) throws IllegalArgumentException {
@@ -195,7 +203,7 @@ public class SettingsUtil {
}
Class intendedType = setting.getValueClass();
ISettingParser ioMethod = Parser.getParser(setting.getType());
Object parsed = ioMethod.parse(new ParserContext(setting), settingValue);
Object parsed = ioMethod.parse(setting.getType(), settingValue);
if (!intendedType.isInstance(parsed)) {
throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass());
}
@@ -204,26 +212,13 @@ public class SettingsUtil {
private interface ISettingParser<T> {
T parse(ParserContext context, String raw);
T parse(Type type, String raw);
String toString(ParserContext context, T value);
String toString(Type type, T value);
boolean accepts(Type type);
}
private static class ParserContext {
private final Settings.Setting<?> setting;
private ParserContext(Settings.Setting<?> setting) {
this.setting = setting;
}
private Settings.Setting<?> getSetting() {
return this.setting;
}
}
private enum Parser implements ISettingParser {
DOUBLE(Double.class, Double::parseDouble),
@@ -232,7 +227,8 @@ public class SettingsUtil {
FLOAT(Float.class, Float::parseFloat),
LONG(Long.class, Long::parseLong),
STRING(String.class, String::new),
DIRECTION(Direction.class, Direction::byName),
MIRROR(Mirror.class, Mirror::valueOf, Mirror::name),
ROTATION(Rotation.class, Rotation::valueOf, Rotation::name),
COLOR(
Color.class,
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
@@ -250,26 +246,26 @@ 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?
item -> Registry.ITEM.getKey(item).toString()
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {
@Override
public Object parse(ParserContext context, String raw) {
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Parser parser = Parser.getParser(type);
public Object parse(Type type, String raw) {
Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];
Parser parser = Parser.getParser(elementType);
return Stream.of(raw.split(","))
.map(s -> parser.parse(context, s))
.map(s -> parser.parse(elementType, s))
.collect(Collectors.toList());
}
@Override
public String toString(ParserContext context, Object value) {
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Parser parser = Parser.getParser(type);
public String toString(Type type, Object value) {
Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];
Parser parser = Parser.getParser(elementType);
return ((List<?>) value).stream()
.map(o -> parser.toString(context, o))
.map(o -> parser.toString(elementType, o))
.collect(Collectors.joining(","));
}
@@ -280,26 +276,26 @@ public class SettingsUtil {
},
MAPPING() {
@Override
public Object parse(ParserContext context, String raw) {
Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
public Object parse(Type type, String raw) {
Type keyType = ((ParameterizedType) type).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) type).getActualTypeArguments()[1];
Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType);
return Stream.of(raw.split(",(?=[^,]*->)"))
.map(s -> s.split("->"))
.collect(Collectors.toMap(s -> keyParser.parse(context, s[0]), s -> valueParser.parse(context, s[1])));
.collect(Collectors.toMap(s -> keyParser.parse(keyType, s[0]), s -> valueParser.parse(valueType, s[1])));
}
@Override
public String toString(ParserContext context, Object value) {
Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1];
public String toString(Type type, Object value) {
Type keyType = ((ParameterizedType) type).getActualTypeArguments()[0];
Type valueType = ((ParameterizedType) type).getActualTypeArguments()[1];
Parser keyParser = Parser.getParser(keyType);
Parser valueParser = Parser.getParser(valueType);
return ((Map<?, ?>) value).entrySet().stream()
.map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue()))
.map(o -> keyParser.toString(keyType, o.getKey()) + "->" + valueParser.toString(valueType, o.getValue()))
.collect(Collectors.joining(","));
}
@@ -330,14 +326,14 @@ public class SettingsUtil {
}
@Override
public Object parse(ParserContext context, String raw) {
public Object parse(Type type, String raw) {
Object parsed = this.parser.apply(raw);
Objects.requireNonNull(parsed);
return parsed;
}
@Override
public String toString(ParserContext context, Object value) {
public String toString(Type type, Object value) {
return this.toString.apply(value);
}

View File

@@ -18,6 +18,7 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkArray;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -27,24 +28,28 @@ import net.minecraft.world.level.chunk.LevelChunk;
@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkCache$Storage")
public abstract class MixinChunkArray implements IChunkArray {
@Final
@Shadow
private AtomicReferenceArray<LevelChunk> chunks;
AtomicReferenceArray<LevelChunk> chunks;
@Final
@Shadow
private int chunkRadius;
int chunkRadius;
@Final
@Shadow
private int viewRange;
@Shadow
private int viewCenterX;
int viewCenterX;
@Shadow
private int viewCenterZ;
int viewCenterZ;
@Shadow
private int chunkCount;
int chunkCount;
@Shadow
protected abstract boolean inRange(int x, int z);
abstract boolean inRange(int x, int z);
@Shadow
protected abstract int getIndex(int x, int z);
abstract int getIndex(int x, int z);
@Shadow
protected abstract void replace(int index, LevelChunk chunk);

View File

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

View File

@@ -19,7 +19,6 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.ChatEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.type.EventState;
@@ -40,23 +39,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LocalPlayer.class)
public class MixinClientPlayerEntity {
@Inject(
method = "chat",
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);
if (baritone == null) {
return;
}
baritone.getGameEventHandler().onSendChatMessage(event);
if (event.isCancelled()) {
ci.cancel();
}
}
@Inject(
method = "tick",
at = @At(
@@ -123,4 +105,19 @@ public class MixinClientPlayerEntity {
((LookBehavior) baritone.getLookBehavior()).pig();
}
}
@Redirect(
method = "aiStep",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/player/LocalPlayer;tryToStartFallFlying()Z"
)
)
private boolean tryToStartFallFlying(final LocalPlayer instance) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(instance);
if (baritone != null && baritone.getPathingBehavior().isPathing()) {
return false;
}
return instance.tryToStartFallFlying();
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.utils.accessor.IFireworkRocketEntity;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.OptionalInt;
@Mixin(FireworkRocketEntity.class)
public abstract class MixinFireworkRocketEntity extends Entity implements IFireworkRocketEntity {
@Shadow
@Final
private static EntityDataAccessor<OptionalInt> DATA_ATTACHED_TO_TARGET;
@Shadow
private LivingEntity attachedToEntity;
@Shadow
public abstract boolean isAttachedToEntity();
private MixinFireworkRocketEntity(Level level) {
super(EntityType.FIREWORK_ROCKET, level);
}
@Override
public LivingEntity getBoostedEntity() {
if (this.isAttachedToEntity() && this.attachedToEntity == null) { // isAttachedToEntity checks if the optional is present
final Entity entity = this.level.getEntity(this.entityData.get(DATA_ATTACHED_TO_TARGET).getAsInt());
if (entity instanceof LivingEntity) {
this.attachedToEntity = (LivingEntity) entity;
}
}
return this.attachedToEntity;
}
}

View File

@@ -39,7 +39,7 @@ public abstract class MixinItemStack implements IItemStack {
private int baritoneHash;
@Shadow
protected abstract int getDamageValue();
public abstract int getDamageValue();
private void recalculateHash() {
baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue();

View File

@@ -35,8 +35,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Optional;
import static org.objectweb.asm.Opcodes.GETFIELD;
/**
* @author Brady
* @since 9/10/2018
@@ -53,7 +51,7 @@ public abstract class MixinLivingEntity extends Entity {
@Unique
private RotationMoveEvent elytraRotationEvent;
public MixinLivingEntity(EntityType<?> entityTypeIn, Level worldIn) {
private MixinLivingEntity(EntityType<?> entityTypeIn, Level worldIn) {
super(entityTypeIn, worldIn);
}
@@ -102,11 +100,11 @@ public abstract class MixinLivingEntity extends Entity {
method = "travel",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/Entity.move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V",
target = "net/minecraft/world/entity/LivingEntity.move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V",
shift = At.Shift.AFTER
)
)
private void onPostElytraMove(float strafe, float vertical, float forward, CallbackInfo ci) {
private void onPostElytraMove(Vec3 direction, CallbackInfo ci) {
if (this.elytraRotationEvent != null) {
this.setYRot(this.elytraRotationEvent.getOriginal().getYaw());
this.setXRot(this.elytraRotationEvent.getOriginal().getPitch());

View File

@@ -30,9 +30,11 @@ import net.minecraft.client.player.LocalPlayer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BiFunction;
@@ -49,6 +51,9 @@ public class MixinMinecraft {
@Shadow
public ClientLevel level;
@Unique
private BiFunction<EventState, TickEvent.Type, TickEvent> tickProvider;
@Inject(
method = "<init>",
at = @At("RETURN")
@@ -57,31 +62,53 @@ public class MixinMinecraft {
BaritoneAPI.getProvider().getPrimaryBaritone();
}
@Inject(
method = "tick",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;",
ordinal = 4,
shift = At.Shift.BY,
by = -3
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "net/minecraft/client/Minecraft.screen:Lnet/minecraft/client/gui/screens/Screen;",
ordinal = 0,
shift = At.Shift.BEFORE
),
slice = @Slice(
from = @At(
value = "FIELD",
opcode = Opcodes.PUTFIELD,
target = "net/minecraft/client/Minecraft.missTime:I"
)
)
)
private void runTick(CallbackInfo ci) {
final BiFunction<EventState, TickEvent.Type, TickEvent> tickProvider = TickEvent.createNextProvider();
this.tickProvider = TickEvent.createNextProvider();
for (IBaritone baritone : BaritoneAPI.getProvider().getAllBaritones()) {
TickEvent.Type type = baritone.getPlayerContext().player() != null && baritone.getPlayerContext().world() != null
? TickEvent.Type.IN
: TickEvent.Type.OUT;
baritone.getGameEventHandler().onTick(tickProvider.apply(EventState.PRE, type));
baritone.getGameEventHandler().onTick(this.tickProvider.apply(EventState.PRE, type));
}
}
@Inject(
method = "tick",
at = @At("RETURN")
)
private void postRunTick(CallbackInfo ci) {
if (this.tickProvider == null) {
return;
}
for (IBaritone baritone : BaritoneAPI.getProvider().getAllBaritones()) {
TickEvent.Type type = baritone.getPlayerContext().player() != null && baritone.getPlayerContext().world() != null
? TickEvent.Type.IN
: TickEvent.Type.OUT;
baritone.getGameEventHandler().onPostTick(this.tickProvider.apply(EventState.POST, type));
}
this.tickProvider = null;
}
@Inject(
method = "tick",
at = @At(
@@ -93,6 +120,8 @@ public class MixinMinecraft {
private void postUpdateEntities(CallbackInfo ci) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(this.player);
if (baritone != null) {
// Intentionally call this after all entities have been updated. That way, any modification to rotations
// can be recognized by other entity code. (Fireworks and Pigs, for example)
baritone.getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST));
}
}

View File

@@ -26,6 +26,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import org.spongepowered.asm.mixin.Final;
@@ -53,14 +54,14 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("HEAD")
)
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
if (this.receiving != PacketFlow.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));
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, packet));
}
}
}
@@ -69,14 +70,14 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("RETURN")
)
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
if (this.receiving != PacketFlow.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));
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, packet));
}
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.utils.accessor.IPalettedContainer.IData;
import net.minecraft.util.BitStorage;
import net.minecraft.world.level.chunk.Palette;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(targets = "net/minecraft/world/level/chunk/PalettedContainer$Data")
public abstract class MixinPalettedContainer$Data<T> implements IData<T> {
@Accessor
public abstract Palette<T> getPalette();
@Accessor
public abstract BitStorage getStorage();
}

View File

@@ -18,12 +18,12 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IPalettedContainer;
import baritone.utils.accessor.IPalettedContainer.IData;
import net.minecraft.util.BitStorage;
import net.minecraft.world.level.chunk.Palette;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
@@ -38,10 +38,12 @@ public abstract class MixinPalettedContainer<T> implements IPalettedContainer<T>
// Mixin has no way of referring to the data field and we can't use inheritance
// tricks to determine its name, so we use this ugly workaround instead.
// Classloading is a bit brittle here and chances are if you mess up you will get
// an IllegalClassLoadError instead of the intended exception because generating
// the error message attempts to classload a mixin class.
// When I tested this a lot of exceptions was discarded silently.
// Classloading is hell here and causes accessor mixins (@Mixin interfaces with
// only @Accessor and @Invoker methods) to break on use and proguard hates method
// handles and on top of that mojang decided that error messages during world
// load are not needed so if you want to debug this you'll probably need an extra
// mixin just to display the error and hard quit the game before follow up errors
// blow up your log file.
// Mumphrey, please add the shadow classes you promised 5 years ago.
static {
Field dataField = null;
@@ -84,7 +86,8 @@ public abstract class MixinPalettedContainer<T> implements IPalettedContainer<T>
@Unique
private IData<T> data() {
try {
return (IData<T>) DATA_GETTER.invoke((PalettedContainer<T>) (Object) this);
// cast to Object first so the method handle doesn't hide the interface usage from proguard
return (IData<T>) (Object) DATA_GETTER.invoke((PalettedContainer<T>) (Object) this);
} catch (Throwable t) {
throw sneaky(t, RuntimeException.class);
}
@@ -94,14 +97,4 @@ public abstract class MixinPalettedContainer<T> implements IPalettedContainer<T>
private static <T extends Throwable> T sneaky(Throwable t, Class<T> as) throws T {
throw (T) t;
}
@Mixin(targets = "net.minecraft.world.level.chunk.PalettedContainer.Data")
private static interface IData<T> {
@Accessor
Palette<T> getPalette();
@Accessor
BitStorage getStorage();
}
}

View File

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

View File

@@ -17,12 +17,22 @@
package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.ChatEvent;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Style;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.net.URI;
import net.minecraft.client.gui.screens.Screen;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@Mixin(Screen.class)
public abstract class MixinScreen implements IGuiScreen {
@@ -30,4 +40,24 @@ public abstract class MixinScreen implements IGuiScreen {
@Override
@Invoker("openLink")
public abstract void openLinkInvoker(URI url);
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {
ClickEvent clickEvent = style.getClickEvent();
if (clickEvent == null) {
return;
}
String command = clickEvent.getValue();
if (command == null || !command.startsWith(FORCE_COMMAND_PREFIX)) {
return;
}
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
if (baritone != null) {
baritone.getGameEventHandler().onSendChatMessage(new ChatEvent(command));
}
cir.setReturnValue(true);
cir.cancel();
}
}

View File

@@ -21,11 +21,11 @@ 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 net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;

View File

@@ -1,11 +1,11 @@
{
"required": true,
"package": "baritone.launch.mixins",
"refmap": "mixins.baritone.refmap.json",
"compatibilityLevel": "JAVA_17",
"verbose": false,
"injectors": {
"maxShiftBy": 2
"maxShiftBy": 2,
"defaultRequire": 1
},
"client": [
"MixinChunkArray",
@@ -15,15 +15,16 @@
"MixinCommandSuggestionHelper",
"MixinEntity",
"MixinEntityRenderManager",
"MixinFireworkRocketEntity",
"MixinItemStack",
"MixinLivingEntity",
"MixinLootContext",
"MixinMinecraft",
"MixinNetworkManager",
"MixinPalettedContainer",
"MixinPalettedContainer$IData",
"MixinPalettedContainer$Data",
"MixinPlayerController",
"MixinScreen",
"MixinWorldRenderer"
]
}
}

View File

@@ -1,6 +0,0 @@
{
"pack": {
"description": "baritoe",
"pack_format": 5
}
}

View File

@@ -23,6 +23,7 @@ import baritone.api.Settings;
import baritone.api.behavior.IBehavior;
import baritone.api.event.listener.IEventBus;
import baritone.api.process.IBaritoneProcess;
import baritone.api.process.IElytraProcess;
import baritone.api.utils.IPlayerContext;
import baritone.behavior.*;
import baritone.cache.WorldProvider;
@@ -40,6 +41,8 @@ import net.minecraft.client.Minecraft;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -76,6 +79,7 @@ public class Baritone implements IBaritone {
private final ExploreProcess exploreProcess;
private final FarmProcess farmProcess;
private final InventoryPauserProcess inventoryPauserProcess;
private final IElytraProcess elytraProcess;
private final PathingControlManager pathingControlManager;
private final SelectionManager selectionManager;
@@ -118,6 +122,7 @@ public class Baritone implements IBaritone {
this.exploreProcess = this.registerProcess(ExploreProcess::new);
this.farmProcess = this.registerProcess(FarmProcess::new);
this.inventoryPauserProcess = this.registerProcess(InventoryPauserProcess::new);
this.elytraProcess = this.registerProcess(ElytraProcess::create);
this.registerProcess(BackfillProcess::new);
}
@@ -230,6 +235,11 @@ public class Baritone implements IBaritone {
return this.commandManager;
}
@Override
public IElytraProcess getElytraProcess() {
return this.elytraProcess;
}
@Override
public void openClick() {
new Thread(() -> {

View File

@@ -28,6 +28,8 @@ import baritone.api.utils.Rotation;
import baritone.behavior.look.ForkableRandom;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Optional;
public final class LookBehavior extends Behavior implements ILookBehavior {
@@ -51,14 +53,19 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
private final AimProcessor processor;
private final Deque<Float> smoothYawBuffer;
private final Deque<Float> smoothPitchBuffer;
public LookBehavior(Baritone baritone) {
super(baritone);
this.processor = new AimProcessor(baritone.getPlayerContext());
this.smoothYawBuffer = new ArrayDeque<>();
this.smoothPitchBuffer = new ArrayDeque<>();
}
@Override
public void updateTarget(Rotation rotation, boolean blockInteract) {
this.target = new Target(rotation, blockInteract);
this.target = new Target(rotation, Target.Mode.resolve(ctx, blockInteract));
}
@Override
@@ -75,19 +82,19 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
@Override
public void onPlayerUpdate(PlayerUpdateEvent event) {
if (this.target == null) {
return;
}
switch (event.getState()) {
case PRE: {
if (this.target.mode == Target.Mode.NONE) {
// Just return for PRE, we still want to set target to null on POST
return;
}
if (this.target.mode == Target.Mode.SERVER) {
this.prevRotation = new Rotation(ctx.player().getYRot(), ctx.player().getXRot());
}
this.prevRotation = new Rotation(ctx.player().getYRot(), ctx.player().getXRot());
final Rotation actual = this.processor.peekRotation(this.target.rotation);
ctx.player().setYRot(actual.getYaw());
ctx.player().setXRot(actual.getPitch());
@@ -96,8 +103,25 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
case POST: {
// Reset the player's rotations back to their original values
if (this.prevRotation != null) {
ctx.player().setYRot(this.prevRotation.getYaw());
ctx.player().setXRot(this.prevRotation.getPitch());
this.smoothYawBuffer.addLast(this.target.rotation.getYaw());
while (this.smoothYawBuffer.size() > Baritone.settings().smoothLookTicks.value) {
this.smoothYawBuffer.removeFirst();
}
this.smoothPitchBuffer.addLast(this.target.rotation.getPitch());
while (this.smoothPitchBuffer.size() > Baritone.settings().smoothLookTicks.value) {
this.smoothPitchBuffer.removeFirst();
}
if (this.target.mode == Target.Mode.SERVER) {
ctx.player().setYRot(this.prevRotation.getYaw());
ctx.player().setXRot(this.prevRotation.getPitch());
} else if (ctx.player().isFallFlying() ? Baritone.settings().elytraSmoothLook.value : Baritone.settings().smoothLook.value) {
ctx.player().setYRot((float) this.smoothYawBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getYaw()));
if (ctx.player().isFallFlying()) {
ctx.player().setXRot((float) this.smoothPitchBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getPitch()));
}
}
//ctx.player().xRotO = prevRotation.getPitch();
//ctx.player().yRotO = prevRotation.getYaw();
this.prevRotation = null;
}
// The target is done being used for this game tick, so it can be invalidated
@@ -278,7 +302,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
private float mouseToAngle(double mouseDelta) {
// casting float literals to double gets us the precise values used by mc
final double f = ctx.minecraft().options.sensitivity * (double) 0.6f + (double) 0.2f;
final double f = ctx.minecraft().options.sensitivity().get() * (double) 0.6f + (double) 0.2f;
return (float) (mouseDelta * f * f * f * 8.0d) * 0.15f; // yes, one double and one float scaling factor
}
}
@@ -288,9 +312,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
public final Rotation rotation;
public final Mode mode;
public Target(Rotation rotation, boolean blockInteract) {
public Target(Rotation rotation, Mode mode) {
this.rotation = rotation;
this.mode = Mode.resolve(blockInteract);
this.mode = mode;
}
enum Mode {
@@ -309,22 +333,26 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
*/
NONE;
static Mode resolve(boolean blockInteract) {
static Mode resolve(IPlayerContext ctx, boolean blockInteract) {
final Settings settings = Baritone.settings();
final boolean antiCheat = settings.antiCheatCompatibility.value;
final boolean blockFreeLook = settings.blockFreeLook.value;
final boolean freeLook = settings.freeLook.value;
if (!freeLook) return CLIENT;
if (!blockFreeLook && blockInteract) return CLIENT;
if (ctx.player().isFallFlying()) {
// always need to set angles while flying
return settings.elytraFreeLook.value ? SERVER : CLIENT;
} else if (settings.freeLook.value) {
// Regardless of if antiCheatCompatibility is enabled, if a blockInteract is requested then the player
// rotation needs to be set somehow, otherwise Baritone will halt since objectMouseOver() will just be
// whatever the player is mousing over visually. Let's just settle for setting it silently.
if (blockInteract) {
return blockFreeLook ? SERVER : CLIENT;
}
return antiCheat ? SERVER : NONE;
}
// Regardless of if antiCheatCompatibility is enabled, if a blockInteract is requested then the player
// rotation needs to be set somehow, otherwise Baritone will halt since objectMouseOver() will just be
// whatever the player is mousing over visually. Let's just settle for setting it silently.
if (antiCheat || blockInteract) return SERVER;
// Pathing regularly without antiCheatCompatibility, don't set the player rotation
return NONE;
// all freeLook settings are disabled so set the angles
return CLIENT;
}
}
}

View File

@@ -33,6 +33,7 @@ import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.PathExecutor;
import baritone.process.ElytraProcess;
import baritone.utils.PathRenderer;
import baritone.utils.PathingCommandContext;
import baritone.utils.pathing.Favoring;
@@ -238,11 +239,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (current != null) {
switch (event.getState()) {
case PRE:
lastAutoJump = ctx.minecraft().options.autoJump;
ctx.minecraft().options.autoJump = false;
lastAutoJump = ctx.minecraft().options.autoJump().get();
ctx.minecraft().options.autoJump().set(false);
break;
case POST:
ctx.minecraft().options.autoJump = lastAutoJump;
ctx.minecraft().options.autoJump().set(lastAutoJump);
break;
default:
break;
@@ -264,7 +265,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (goal == null) {
return false;
}
if (goal.isInGoal(ctx.playerFeet()) || goal.isInGoal(expectedSegmentStart)) {
if (goal.isInGoal(ctx.playerFeet())) {
return false;
}
synchronized (pathPlanLock) {
@@ -308,7 +309,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
public boolean isSafeToCancel() {
return current == null || safeToCancel;
if (current == null) {
return !baritone.getElytraProcess().isActive() || baritone.getElytraProcess().isSafeToCancel();
}
return safeToCancel;
}
public void requestPause() {
@@ -351,7 +355,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
// just cancel the current path
private void secretInternalSegmentCancel() {
public void secretInternalSegmentCancel() {
queuePathEvent(PathEvent.CANCELED);
synchronized (pathPlanLock) {
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
@@ -549,7 +553,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
});
}
private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
private AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
Goal transformed = goal;
if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) {
BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
@@ -558,7 +562,14 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
}
Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
BetterBlockPos feet = ctx.playerFeet();
var realStart = new BetterBlockPos(start);
var sub = feet.subtract(realStart);
if (feet.getY() == realStart.getY() && Math.abs(sub.getX()) <= 1 && Math.abs(sub.getZ()) <= 1) {
realStart = feet;
}
return new AStarPathFinder(realStart, start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
}
@Override

View File

@@ -25,10 +25,10 @@ import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.Helper;
import baritone.utils.BlockStateInterface;
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;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.level.block.BedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BedPart;
@@ -70,12 +70,12 @@ public class WaypointBehavior extends Behavior {
return;
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
BaseComponent component = new TextComponent("Death position saved.");
MutableComponent component = Component.literal("Death position saved.");
component.setStyle(component.getStyle()
.withColor(ChatFormatting.WHITE)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to goto death")
Component.literal("Click to goto death")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,

View File

@@ -218,7 +218,7 @@ public final class CachedChunk {
// nether roof is always unbreakable
return Blocks.BEDROCK.defaultBlockState();
}
if (y < 5 && dimension.natural()) {
if (y < -59 && dimension.natural()) {
// solid blocks below 5 are commonly bedrock
// however, returning bedrock always would be a little yikes
// discourage paths that include breaking blocks below 5 a little more heavily just so that it takes paths breaking what's known to be stone (at 5 or above) instead of what could maybe be bedrock (below 5)

View File

@@ -44,7 +44,7 @@ public final class CachedRegion implements ICachedRegion {
/**
* Magic value to detect invalid cache files, or incompatible cache files saved in an old version of Baritone
*/
private static final int CACHED_REGION_MAGIC = 456022910;
private static final int CACHED_REGION_MAGIC = 456022911;
/**
* All of the chunks in this region: A 32x32 array of them.
@@ -167,7 +167,7 @@ public final class CachedRegion implements ICachedRegion {
out.writeShort(entry.getValue().size());
for (BlockPos pos : entry.getValue()) {
out.writeByte((byte) (pos.getZ() << 4 | pos.getX()));
out.writeByte((byte) (pos.getY()));
out.writeInt(pos.getY()-dimension.minY());
}
}
}
@@ -271,8 +271,8 @@ public final class CachedRegion implements ICachedRegion {
byte xz = in.readByte();
int X = xz & 0x0f;
int Z = (xz >>> 4) & 0x0f;
int Y = in.readByte() & 0xff;
locs.add(new BlockPos(X, Y, Z));
int Y = in.readInt();
locs.add(new BlockPos(X, Y+dimension.minY(), Z));
}
}
}

View File

@@ -23,12 +23,11 @@ import baritone.api.IBaritone;
import baritone.api.cache.ICachedWorld;
import baritone.api.cache.IWorldData;
import baritone.api.utils.Helper;
import com.google.common.cache.CacheBuilder;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
@@ -38,7 +37,6 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
/**
@@ -72,7 +70,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
* All chunk positions pending packing. This map will be updated in-place if a new update to the chunk occurs
* while waiting in the queue for the packer thread to get to it.
*/
private final Map<ChunkPos, LevelChunk> toPackMap = new ConcurrentHashMap<>();
private final Map<ChunkPos, LevelChunk> toPackMap = CacheBuilder.newBuilder().softValues().<ChunkPos, LevelChunk>build().asMap();
private final DimensionType dimension;
@@ -198,9 +196,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ();
double dist = Math.sqrt(distX * distX + distZ * distZ);
if (dist > 1024) {
if (!Baritone.settings().censorCoordinates.value) {
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
}
logDebug("Deleting cached region from ram");
cachedRegions.remove(getRegionID(region.getX(), region.getZ()));
}
}

View File

@@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.phys.Vec3;
@@ -83,7 +84,7 @@ public final class ChunkPacker {
Block block = state.getBlock();
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
String name = BlockUtils.blockToString(block);
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z));
}
}
}
@@ -172,7 +173,7 @@ public final class ChunkPacker {
if (dimension.ultraWarm()) {
return Blocks.NETHERRACK.defaultBlockState();
}
if (dimension.createDragonFight()) {
if (dimension.effectsLocation().equals(BuiltinDimensionTypes.END_EFFECTS)) {
return Blocks.END_STONE.defaultBlockState();
}
default:

View File

@@ -20,6 +20,7 @@ package baritone.cache;
import baritone.api.cache.ICachedWorld;
import baritone.api.cache.IWorldScanner;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.BlockOptionalMeta;
import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext;
import baritone.utils.accessor.IPalettedContainer;
@@ -37,6 +38,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.Palette;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.chunk.SingleValuePalette;
import java.util.ArrayList;
import java.util.List;
@@ -45,6 +47,9 @@ import java.util.stream.Stream;
public enum FasterWorldScanner implements IWorldScanner {
INSTANCE;
private static final BlockState[] PALETTE_REGISTRY_SENTINEL = new BlockState[0];
@Override
public List<BlockPos> scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius) {
assert ctx.world() != null;
@@ -151,7 +156,7 @@ public enum FasterWorldScanner implements IWorldScanner {
long chunkX = (long) pos.x << 4;
long chunkZ = (long) pos.z << 4;
int playerSectionY = ctx.playerFeet().y >> 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4;
return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream();
}
@@ -187,7 +192,29 @@ public enum FasterWorldScanner implements IWorldScanner {
return;
}
boolean[] isInFilter = getIncludedFilterIndices(lookup, ((IPalettedContainer<BlockState>) sectionContainer).getPalette());
int yOffset = section.bottomBlockY();
Palette<BlockState> palette = ((IPalettedContainer<BlockState>) sectionContainer).getPalette();
if (palette instanceof SingleValuePalette) {
// single value palette doesn't have any data
if (lookup.has(palette.valueFor(0))) {
// TODO this is 4k hits, maybe don't return all of them?
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 16; ++y) {
for (int z = 0; z < 16; ++z) {
blocks.add(new BlockPos(
(int) chunkX + x,
yOffset + y,
(int) chunkZ + z
));
}
}
}
}
return;
}
boolean[] isInFilter = getIncludedFilterIndices(lookup, palette);
if (isInFilter.length == 0) {
return;
}
@@ -198,9 +225,6 @@ public enum FasterWorldScanner implements IWorldScanner {
int bitsPerEntry = array.getBits();
long maxEntryValue = (1L << bitsPerEntry) - 1L;
int yOffset = section.bottomBlockY();
for (int i = 0, idx = 0; i < longArray.length && idx < arraySize; ++i) {
long l = longArray[i];
for (int offset = 0; offset <= (64 - bitsPerEntry) && idx < arraySize; offset += bitsPerEntry, ++idx) {
@@ -208,9 +232,9 @@ public enum FasterWorldScanner implements IWorldScanner {
if (isInFilter[value]) {
//noinspection DuplicateExpressions
blocks.add(new BlockPos(
chunkX + ((idx & 255) & 15),
(int) chunkX + ((idx & 255) & 15),
yOffset + (idx >> 8),
chunkZ + ((idx & 255) >> 4)
(int) chunkZ + ((idx & 255) >> 4)
));
}
}
@@ -219,13 +243,18 @@ public enum FasterWorldScanner implements IWorldScanner {
private boolean[] getIncludedFilterIndices(BlockOptionalMetaLookup lookup, Palette<BlockState> palette) {
boolean commonBlockFound = false;
IdMapper<BlockState> paletteMap = getPalette(palette);
int size = paletteMap.size();
BlockState[] paletteMap = getPalette(palette);
if (paletteMap == PALETTE_REGISTRY_SENTINEL) {
return getIncludedFilterIndicesFromRegistry(lookup);
}
int size = paletteMap.length;
boolean[] isInFilter = new boolean[size];
for (int i = 0; i < size; i++) {
BlockState state = paletteMap.byId(i);
BlockState state = paletteMap[i];
if (lookup.has(state)) {
isInFilter[i] = true;
commonBlockFound = true;
@@ -240,21 +269,34 @@ public enum FasterWorldScanner implements IWorldScanner {
return isInFilter;
}
private boolean[] getIncludedFilterIndicesFromRegistry(BlockOptionalMetaLookup lookup) {
boolean[] isInFilter = new boolean[Block.BLOCK_STATE_REGISTRY.size()];
for (BlockOptionalMeta bom : lookup.blocks()) {
for (BlockState state : bom.getAllBlockStates()) {
isInFilter[Block.BLOCK_STATE_REGISTRY.getId(state)] = true;
}
}
return isInFilter;
}
/**
* cheats to get the actual map of id -> blockstate from the various palette implementations
*/
private static IdMapper<BlockState> getPalette(Palette<BlockState> palette) {
private static BlockState[] getPalette(Palette<BlockState> palette) {
if (palette instanceof GlobalPalette) {
return Block.BLOCK_STATE_REGISTRY;
// copying the entire registry is not nice so we treat it as a special case
return PALETTE_REGISTRY_SENTINEL;
} else {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
palette.write(buf);
int size = buf.readVarInt();
IdMapper<BlockState> states = new IdMapper<>();
BlockState[] states = new BlockState[size];
for (int i = 0; i < size; i++) {
BlockState state = Block.BLOCK_STATE_REGISTRY.byId(buf.readVarInt());
assert state != null;
states.addMapping(state, i);
states[i] = state;
}
return states;
}

View File

@@ -35,10 +35,8 @@ import baritone.command.argument.CommandArguments;
import baritone.command.manager.CommandManager;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Tuple;
import java.net.URI;
import java.net.URISyntaxException;
@@ -78,12 +76,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
if (settings.echoCommands.value) {
String msg = command + rest;
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
BaseComponent component = new TextComponent(String.format("> %s", toDisplay));
MutableComponent component = Component.literal(String.format("> %s", toDisplay));
component.setStyle(component.getStyle()
.withColor(ChatFormatting.WHITE)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to rerun command")
Component.literal("Click to rerun command")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,

View File

@@ -26,11 +26,13 @@ import baritone.api.command.datatypes.RelativeFile;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.utils.BetterBlockPos;
import baritone.utils.schematic.SchematicSystem;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Stream;
public class BuildCommand extends Command {
@@ -44,10 +46,29 @@ public class BuildCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
File file = args.getDatatypePost(RelativeFile.INSTANCE, schematicsDir).getAbsoluteFile();
final File file0 = args.getDatatypePost(RelativeFile.INSTANCE, schematicsDir).getAbsoluteFile();
File file = file0;
if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) {
file = new File(file.getAbsolutePath() + "." + Baritone.settings().schematicFallbackExtension.value);
}
if (!file.exists()) {
if (file0.exists()) {
throw new CommandInvalidStateException(String.format(
"Cannot load %s because I do not know which schematic format"
+ " that is. Please rename the file to include the correct"
+ " file extension.",
file));
}
throw new CommandInvalidStateException("Cannot find " + file);
}
if (!SchematicSystem.INSTANCE.getByFile(file).isPresent()) {
StringJoiner formats = new StringJoiner(", ");
SchematicSystem.INSTANCE.getFileExtensions().forEach(formats::add);
throw new CommandInvalidStateException(String.format(
"Unsupported schematic format. Reckognized file extensions are: %s",
formats
));
}
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos buildOrigin;
if (args.hasAny()) {
@@ -59,7 +80,7 @@ public class BuildCommand extends Command {
}
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
if (!success) {
throw new CommandInvalidStateException("Couldn't load the schematic. Make sure to use the FULL file name, including the extension (e.g. blah.schematic).");
throw new CommandInvalidStateException("Couldn't load the schematic. Either your schematic is corrupt or this is a bug.");
}
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
}

View File

@@ -53,6 +53,7 @@ public final class DefaultCommands {
new RenderCommand(baritone),
new FarmCommand(baritone),
new FollowCommand(baritone),
new PickupCommand(baritone),
new ExploreFilterCommand(baritone),
new ReloadAllCommand(baritone),
new SaveAllCommand(baritone),
@@ -66,7 +67,8 @@ public final class DefaultCommands {
new WaypointsCommand(baritone),
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
new CommandAlias(baritone, "home", "Path to your home waypoint", "waypoints goto home"),
new SelCommand(baritone)
new SelCommand(baritone),
new ElytraCommand(baritone)
));
ExecutionControlCommands prc = new ExecutionControlCommands(baritone);
commands.add(prc.pauseCommand);

View File

@@ -0,0 +1,225 @@
/*
* 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.command.defaults;
import baritone.Baritone;
import baritone.api.IBaritone;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandInvalidStateException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.pathing.goals.Goal;
import baritone.api.process.ICustomGoalProcess;
import baritone.api.process.IElytraProcess;
import net.minecraft.ChatFormatting;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.level.Level;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
public class ElytraCommand extends Command {
public ElytraCommand(IBaritone baritone) {
super(baritone, "elytra");
}
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
final ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
final IElytraProcess elytra = baritone.getElytraProcess();
if (args.hasExactlyOne() && args.peekString().equals("supported")) {
logDirect(elytra.isLoaded() ? "yes" : unsupportedSystemMessage());
return;
}
if (!elytra.isLoaded()) {
throw new CommandInvalidStateException(unsupportedSystemMessage());
}
if (!args.hasAny()) {
if (Baritone.settings().elytraTermsAccepted.value) {
if (detectOn2b2t()) {
warn2b2t();
}
} else {
gatekeep();
}
Goal iGoal = customGoalProcess.mostRecentGoal();
if (iGoal == null) {
throw new CommandInvalidStateException("No goal has been set");
}
if (ctx.world().dimension() != Level.NETHER) {
throw new CommandInvalidStateException("Only works in the nether");
}
try {
elytra.pathTo(iGoal);
} catch (IllegalArgumentException ex) {
throw new CommandInvalidStateException(ex.getMessage());
}
return;
}
final String action = args.getString();
switch (action) {
case "reset": {
elytra.resetState();
logDirect("Reset state but still flying to same goal");
break;
}
case "repack": {
elytra.repackChunks();
logDirect("Queued all loaded chunks for repacking");
break;
}
default: {
throw new CommandInvalidStateException("Invalid action");
}
}
}
private void warn2b2t() {
if (Baritone.settings().elytraPredictTerrain.value) {
long seed = Baritone.settings().elytraNetherSeed.value;
if (seed != NEW_2B2T_SEED && seed != OLD_2B2T_SEED) {
logDirect(Component.literal("It looks like you're on 2b2t, but elytraNetherSeed is incorrect.")); // match color
logDirect(suggest2b2tSeeds());
}
}
}
private Component suggest2b2tSeeds() {
MutableComponent clippy = Component.literal("");
clippy.append("Within a few hundred blocks of spawn/axis/highways/etc, the terrain is too fragmented to be predictable. Baritone Elytra will still work, just with backtracking. ");
clippy.append("However, once you get more than a few thousand blocks out, you should try ");
MutableComponent olderSeed = Component.literal("the older seed (click here)");
olderSeed.setStyle(olderSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + OLD_2B2T_SEED))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + OLD_2B2T_SEED)));
clippy.append(olderSeed);
clippy.append(". Once you're further out into newer terrain generation (this includes everything up through 1.12), you should try ");
MutableComponent newerSeed = Component.literal("the newer seed (click here)");
newerSeed.setStyle(newerSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + NEW_2B2T_SEED))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + NEW_2B2T_SEED)));
clippy.append(newerSeed);
clippy.append(". Once you get into 1.19 terrain, the terrain becomes unpredictable again, due to custom non-vanilla generation, and you should set #elytraPredictTerrain to false. ");
return clippy;
}
private void gatekeep() {
MutableComponent gatekeep = Component.literal("");
gatekeep.append("To disable this message, enable the setting elytraTermsAccepted\n");
gatekeep.append("Baritone Elytra is an experimental feature. It is only intended for long distance travel in the Nether using fireworks for vanilla boost. It will not work with any other mods (\"hacks\") for non-vanilla boost. ");
MutableComponent gatekeep2 = Component.literal("If you want Baritone to attempt to take off from the ground for you, you can enable the elytraAutoJump setting (not advisable on laggy servers!). ");
gatekeep2.setStyle(gatekeep2.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraAutoJump true"))));
gatekeep.append(gatekeep2);
MutableComponent gatekeep3 = Component.literal("If you want Baritone to go slower, enable the elytraConserveFireworks setting and/or decrease the elytraFireworkSpeed setting. ");
gatekeep3.setStyle(gatekeep3.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraConserveFireworks true\n" + Baritone.settings().prefix.value + "set elytraFireworkSpeed 0.6\n(the 0.6 number is just an example, tweak to your liking)"))));
gatekeep.append(gatekeep3);
MutableComponent gatekeep4 = Component.literal("Baritone Elytra ");
MutableComponent red = Component.literal("wants to know the seed");
red.setStyle(red.getStyle().withColor(ChatFormatting.RED).withUnderlined(true).withBold(true));
gatekeep4.append(red);
gatekeep4.append(" of the world you are in. If it doesn't have the correct seed, it will frequently backtrack. It uses the seed to generate terrain far beyond what you can see, since terrain obstacles in the Nether can be much larger than your render distance. ");
gatekeep.append(gatekeep4);
gatekeep.append("\n");
if (detectOn2b2t()) {
MutableComponent gatekeep5 = Component.literal("It looks like you're on 2b2t. ");
gatekeep5.append(suggest2b2tSeeds());
if (!Baritone.settings().elytraPredictTerrain.value) {
gatekeep5.append(Baritone.settings().prefix.value + "elytraPredictTerrain is currently disabled. ");
} else {
if (Baritone.settings().elytraNetherSeed.value == NEW_2B2T_SEED) {
gatekeep5.append("You are using the newer seed. ");
} else if (Baritone.settings().elytraNetherSeed.value == OLD_2B2T_SEED) {
gatekeep5.append("You are using the older seed. ");
} else {
gatekeep5.append("Defaulting to the newer seed. ");
Baritone.settings().elytraNetherSeed.value = NEW_2B2T_SEED;
}
}
gatekeep.append(gatekeep5);
} else {
if (Baritone.settings().elytraNetherSeed.value == NEW_2B2T_SEED) {
MutableComponent gatekeep5 = Component.literal("Baritone doesn't know the seed of your world. Set it with: " + Baritone.settings().prefix.value + "set elytraNetherSeed seedgoeshere\n");
gatekeep5.append("For the time being, elytraPredictTerrain is defaulting to false since the seed is unknown.");
gatekeep.append(gatekeep5);
Baritone.settings().elytraPredictTerrain.value = false;
} else {
if (Baritone.settings().elytraPredictTerrain.value) {
MutableComponent gatekeep5 = Component.literal("Baritone Elytra is predicting terrain assuming that " + Baritone.settings().elytraNetherSeed.value + " is the correct seed. Change that with " + Baritone.settings().prefix.value + "set elytraNetherSeed seedgoeshere, or disable it with " + Baritone.settings().prefix.value + "set elytraPredictTerrain false");
gatekeep.append(gatekeep5);
} else {
MutableComponent gatekeep5 = Component.literal("Baritone Elytra is not predicting terrain. If you don't know the seed, this is the correct thing to do. If you do know the seed, input it with " + Baritone.settings().prefix.value + "set elytraNetherSeed seedgoeshere, and then enable it with " + Baritone.settings().prefix.value + "set elytraPredictTerrain true");
gatekeep.append(gatekeep5);
}
}
}
logDirect(gatekeep);
}
private boolean detectOn2b2t() {
ServerData data = ctx.minecraft().getCurrentServer();
return data != null && data.ip.toLowerCase().contains("2b2t.org");
}
private static final long OLD_2B2T_SEED = -4100785268875389365L;
private static final long NEW_2B2T_SEED = 146008555100680L;
@Override
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
TabCompleteHelper helper = new TabCompleteHelper();
if (args.hasExactlyOne()) {
helper.append("reset", "repack", "supported");
}
return helper.filterPrefix(args.getString()).stream();
}
@Override
public String getShortDesc() {
return "elytra time";
}
@Override
public List<String> getLongDesc() {
return Arrays.asList(
"The elytra command tells baritone to, in the nether, automatically fly to the current goal.",
"",
"Usage:",
"> elytra - fly to the current goal",
"> elytra reset - Resets the state of the process, but will try to keep flying to the same goal.",
"> elytra repack - Queues all of the chunks in render distance to be given to the native library.",
"> elytra supported - Tells you if baritone ships a native library that is compatible with your PC."
);
}
private static String unsupportedSystemMessage() {
final String osArch = System.getProperty("os.arch");
final String osName = System.getProperty("os.name");
return String.format(
"Failed loading native library. Your CPU is %s and your operating system is %s. " +
"Supported architectures are 64 bit x86, and 64 bit ARM. Supported operating systems are Windows, " +
"Linux, and Mac",
osArch, osName
);
}
}

View File

@@ -27,9 +27,11 @@ import baritone.api.utils.BetterBlockPos;
import baritone.cache.CachedChunk;
import net.minecraft.core.Registry;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.*;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.level.block.Block;
import java.util.ArrayList;
@@ -53,10 +55,10 @@ public class FindCommand extends Command {
toFind.add(args.getDatatypeFor(BlockById.INSTANCE));
}
BetterBlockPos origin = ctx.playerFeet();
BaseComponent[] components = toFind.stream()
Component[] components = toFind.stream()
.flatMap(block ->
ctx.worldData().getCachedWorld().getLocationsOf(
Registry.BLOCK.getKey(block).getPath(),
BuiltInRegistries.BLOCK.getKey(block).getPath(),
Integer.MAX_VALUE,
origin.x,
origin.y,
@@ -65,7 +67,7 @@ public class FindCommand extends Command {
)
.map(BetterBlockPos::new)
.map(this::positionToComponent)
.toArray(BaseComponent[]::new);
.toArray(Component[]::new);
if (components.length > 0) {
Arrays.asList(components).forEach(this::logDirect);
} else {
@@ -73,11 +75,11 @@ public class FindCommand extends Command {
}
}
private BaseComponent positionToComponent(BetterBlockPos pos) {
private Component positionToComponent(BetterBlockPos pos) {
String positionText = String.format("%s %s %s", pos.x, pos.y, pos.z);
String command = String.format("%sgoal %s", FORCE_COMMAND_PREFIX, positionText);
BaseComponent baseComponent = new TextComponent(pos.toString());
BaseComponent hoverComponent = new TextComponent("Click to set goal to this position");
MutableComponent baseComponent = Component.literal(pos.toString());
MutableComponent hoverComponent = Component.literal("Click to set goal to this position");
baseComponent.setStyle(baseComponent.getStyle()
.withColor(ChatFormatting.GRAY)
.withInsertion(positionText)
@@ -91,7 +93,7 @@ public class FindCommand extends Command {
return new TabCompleteHelper()
.append(
CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream()
.map(Registry.BLOCK::getKey)
.map(BuiltInRegistries.BLOCK::getKey)
.map(Object::toString)
)
.filterPrefixNamespaced(args.getString())

View File

@@ -31,6 +31,7 @@ import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
@@ -84,7 +85,7 @@ public class FollowCommand extends Command {
} else {
logDirect("Following these types of entities:");
classes.stream()
.map(Registry.ENTITY_TYPE::getKey)
.map(BuiltInRegistries.ENTITY_TYPE::getKey)
.map(Objects::requireNonNull)
.map(ResourceLocation::toString)
.forEach(this::logDirect);

View File

@@ -25,16 +25,18 @@ import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandNotFoundException;
import baritone.api.command.helpers.Paginator;
import baritone.api.command.helpers.TabCompleteHelper;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@@ -58,17 +60,17 @@ public class HelpCommand extends Command {
command -> {
String names = String.join("/", command.getNames());
String name = command.getNames().get(0);
TextComponent shortDescComponent = new TextComponent(" - " + command.getShortDesc());
MutableComponent shortDescComponent = Component.literal(" - " + command.getShortDesc());
shortDescComponent.setStyle(shortDescComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
TextComponent namesComponent = new TextComponent(names);
MutableComponent namesComponent = Component.literal(names);
namesComponent.setStyle(namesComponent.getStyle().withColor(ChatFormatting.WHITE));
TextComponent hoverComponent = new TextComponent("");
MutableComponent hoverComponent = Component.literal("");
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
hoverComponent.append(namesComponent);
hoverComponent.append("\n" + command.getShortDesc());
hoverComponent.append("\n\nClick to view full help");
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
TextComponent component = new TextComponent(name);
MutableComponent component = Component.literal(name);
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(shortDescComponent);
component.setStyle(component.getStyle()
@@ -88,7 +90,7 @@ public class HelpCommand extends Command {
logDirect("");
command.getLongDesc().forEach(this::logDirect);
logDirect("");
BaseComponent returnComponent = new TextComponent("Click to return to the help menu");
MutableComponent returnComponent = Component.literal("Click to return to the help menu");
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + label

View File

@@ -34,18 +34,9 @@ public class LitematicaCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
int schematic = 0;
if (args.hasAny()) {
args.requireMax(1);
if (args.is(Integer.class)) {
schematic = args.getAs(Integer.class) - 1;
}
}
try {
baritone.getBuilderProcess().buildOpenLitematic(schematic);
} catch (IndexOutOfBoundsException e) {
logDirect("Pleas provide a valid index.");
}
args.requireMax(1);
int schematic = args.hasAny() ? args.getAs(Integer.class) - 1 : 0;
baritone.getBuilderProcess().buildOpenLitematic(schematic);
}
@Override

View File

@@ -0,0 +1,82 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.command.defaults;
import baritone.api.IBaritone;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.datatypes.ItemById;
import baritone.api.command.exception.CommandException;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
public class PickupCommand extends Command {
public PickupCommand(IBaritone baritone) {
super(baritone, "pickup");
}
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
Set<Item> collecting = new HashSet<>();
while (args.hasAny()) {
Item item = args.getDatatypeFor(ItemById.INSTANCE);
collecting.add(item);
}
if (collecting.isEmpty()) {
baritone.getFollowProcess().pickup(stack -> true);
logDirect("Picking up all items");
} else {
baritone.getFollowProcess().pickup(stack -> collecting.contains(stack.getItem()));
logDirect("Picking up these items:");
collecting.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).forEach(this::logDirect);
}
}
@Override
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
while (args.has(2)) {
if (args.peekDatatypeOrNull(ItemById.INSTANCE) == null) {
return Stream.empty();
}
args.get();
}
return args.tabCompleteDatatype(ItemById.INSTANCE);
}
@Override
public String getShortDesc() {
return "Pickup items";
}
@Override
public List<String> getLongDesc() {
return Arrays.asList(
"Usage:",
"> pickup - Pickup anything",
"> pickup <item1> <item2> <...> - Pickup certain items"
);
}
}

View File

@@ -37,13 +37,13 @@ public class RenderCommand extends Command {
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
BetterBlockPos origin = ctx.playerFeet();
int renderDistance = (ctx.minecraft().options.renderDistance + 1) * 16;
int renderDistance = (ctx.minecraft().options.renderDistance().get() + 1) * 16;
ctx.minecraft().levelRenderer.setBlocksDirty(
origin.x - renderDistance,
0,
ctx.world().getMinBuildHeight(),
origin.z - renderDistance,
origin.x + renderDistance,
255,
ctx.world().getMaxBuildHeight(),
origin.z + renderDistance
);
logDirect("Done");

View File

@@ -227,12 +227,7 @@ public class SelCommand extends Command {
}
}
}
ISchematic schematic = new StaticSchematic() {{
states = blockstates;
x = size.getX();
y = size.getY();
z = size.getZ();
}};
ISchematic schematic = new StaticSchematic(blockstates);
composite.put(schematic, min.x - origin.x, min.y - origin.y, min.z - origin.z);
}
clipboard = composite;

View File

@@ -31,10 +31,10 @@ import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.SettingsUtil;
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.ClickEvent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import java.util.Arrays;
import java.util.List;
@@ -92,19 +92,19 @@ public class SetCommand extends Command {
: String.format("All %ssettings:", viewModified ? "modified " : "")
),
setting -> {
TextComponent typeComponent = new TextComponent(String.format(
MutableComponent typeComponent = Component.literal(String.format(
" (%s)",
settingTypeToString(setting)
));
typeComponent.setStyle(typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
TextComponent hoverComponent = new TextComponent("");
MutableComponent hoverComponent = Component.literal("");
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
hoverComponent.append(setting.getName());
hoverComponent.append(String.format("\nType: %s", settingTypeToString(setting)));
hoverComponent.append(String.format("\n\nValue:\n%s", settingValueToString(setting)));
hoverComponent.append(String.format("\n\nDefault Value:\n%s", settingDefaultToString(setting)));
String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName());
TextComponent component = new TextComponent(setting.getName());
MutableComponent component = Component.literal(setting.getName());
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(typeComponent);
component.setStyle(component.getStyle()
@@ -185,12 +185,12 @@ public class SetCommand extends Command {
settingValueToString(setting)
));
}
BaseComponent oldValueComponent = new TextComponent(String.format("Old value: %s", oldValue));
MutableComponent oldValueComponent = Component.literal(String.format("Old value: %s", oldValue));
oldValueComponent.setStyle(oldValueComponent.getStyle()
.withColor(ChatFormatting.GRAY)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to set the setting back to this value")
Component.literal("Click to set the setting back to this value")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,

View File

@@ -44,7 +44,7 @@ public class TunnelCommand extends Command {
int width = Integer.parseInt(args.getArgs().get(1).getValue());
int depth = Integer.parseInt(args.getArgs().get(2).getValue());
if (width < 1 || height < 2 || depth < 1 || height > 255) {
if (width < 1 || height < 2 || depth < 1 || height > ctx.world().getMaxBuildHeight()){
logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit.");
cont = false;
}

View File

@@ -40,11 +40,11 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@@ -63,13 +63,13 @@ public class WaypointsCommand extends Command {
throw new CommandInvalidTypeException(args.consumed(), "an action");
}
BiFunction<IWaypoint, Action, Component> toComponent = (waypoint, _action) -> {
BaseComponent component = new TextComponent("");
BaseComponent tagComponent = new TextComponent(waypoint.getTag().name() + " ");
MutableComponent component = Component.literal("");
MutableComponent tagComponent = Component.literal(waypoint.getTag().name() + " ");
tagComponent.setStyle(tagComponent.getStyle().withColor(ChatFormatting.GRAY));
String name = waypoint.getName();
BaseComponent nameComponent = new TextComponent(!name.isEmpty() ? name : "<empty>");
MutableComponent nameComponent = Component.literal(!name.isEmpty() ? name : "<empty>");
nameComponent.setStyle(nameComponent.getStyle().withColor(!name.isEmpty() ? ChatFormatting.GRAY : ChatFormatting.DARK_GRAY));
BaseComponent timestamp = new TextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
MutableComponent timestamp = Component.literal(" @ " + new Date(waypoint.getCreationTimestamp()));
timestamp.setStyle(timestamp.getStyle().withColor(ChatFormatting.DARK_GRAY));
component.append(tagComponent);
component.append(nameComponent);
@@ -77,7 +77,7 @@ public class WaypointsCommand extends Command {
component.setStyle(component.getStyle()
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to select")
Component.literal("Click to select")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
@@ -143,7 +143,7 @@ public class WaypointsCommand extends Command {
args.requireMax(0);
IWaypoint waypoint = new Waypoint(name, tag, pos);
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);
BaseComponent component = new TextComponent("Waypoint added: ");
MutableComponent component = Component.literal("Waypoint added: ");
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(toComponent.apply(waypoint, Action.INFO));
logDirect(component);
@@ -159,7 +159,7 @@ public class WaypointsCommand extends Command {
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
}
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
BaseComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
MutableComponent textComponent = Component.literal(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -240,7 +240,7 @@ public class WaypointsCommand extends Command {
if (action == Action.INFO) {
logDirect(transform.apply(waypoint));
logDirect(String.format("Position: %s", waypoint.getLocation()));
BaseComponent deleteComponent = new TextComponent("Click to delete this waypoint");
MutableComponent deleteComponent = Component.literal("Click to delete this waypoint");
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -251,7 +251,7 @@ public class WaypointsCommand extends Command {
waypoint.getCreationTimestamp()
)
)));
BaseComponent goalComponent = new TextComponent("Click to set goal to this waypoint");
MutableComponent goalComponent = Component.literal("Click to set goal to this waypoint");
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -262,7 +262,7 @@ public class WaypointsCommand extends Command {
waypoint.getCreationTimestamp()
)
)));
BaseComponent recreateComponent = new TextComponent("Click to show a command to recreate this waypoint");
MutableComponent recreateComponent = Component.literal("Click to show a command to recreate this waypoint");
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.SUGGEST_COMMAND,
String.format(
@@ -276,7 +276,7 @@ public class WaypointsCommand extends Command {
waypoint.getLocation().z
)
)));
BaseComponent backComponent = new TextComponent("Click to return to the waypoints list");
MutableComponent backComponent = Component.literal("Click to return to the waypoints list");
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -292,7 +292,7 @@ public class WaypointsCommand extends Command {
} else if (action == Action.DELETE) {
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
TextComponent textComponent = new TextComponent("That waypoint has successfully been deleted, click to restore it");
MutableComponent textComponent = Component.literal("That waypoint has successfully been deleted, click to restore it");
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(

View File

@@ -23,9 +23,13 @@ import baritone.api.event.events.type.EventState;
import baritone.api.event.listener.IEventBus;
import baritone.api.event.listener.IGameEventListener;
import baritone.api.utils.Helper;
import baritone.api.utils.Pair;
import baritone.cache.CachedChunk;
import baritone.cache.WorldProvider;
import baritone.utils.BlockStateInterface;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import java.util.List;
@@ -60,6 +64,11 @@ public final class GameEventHandler implements IEventBus, Helper {
listeners.forEach(l -> l.onTick(event));
}
@Override
public void onPostTick(TickEvent event) {
listeners.forEach(l -> l.onPostTick(event));
}
@Override
public final void onPlayerUpdate(PlayerUpdateEvent event) {
listeners.forEach(l -> l.onPlayerUpdate(event));
@@ -76,13 +85,10 @@ public final class GameEventHandler implements IEventBus, Helper {
}
@Override
public final void onChunkEvent(ChunkEvent event) {
public void onChunkEvent(ChunkEvent event) {
EventState state = event.getState();
ChunkEvent.Type type = event.getType();
boolean isPostPopulate = state == EventState.POST
&& (type == ChunkEvent.Type.POPULATE_FULL || type == ChunkEvent.Type.POPULATE_PARTIAL);
Level world = baritone.getPlayerContext().world();
// Whenever the server sends us to another dimension, chunks are unloaded
@@ -92,7 +98,7 @@ public final class GameEventHandler implements IEventBus, Helper {
&& type == ChunkEvent.Type.UNLOAD
&& world.getChunkSource().getChunk(event.getX(), event.getZ(), null, false) != null;
if (isPostPopulate || isPreUnload) {
if (event.isPostPopulate() || isPreUnload) {
baritone.getWorldProvider().ifWorldLoaded(worldData -> {
LevelChunk chunk = world.getChunk(event.getX(), event.getZ());
worldData.getCachedWorld().queueForPacking(chunk);
@@ -103,6 +109,25 @@ public final class GameEventHandler implements IEventBus, Helper {
listeners.forEach(l -> l.onChunkEvent(event));
}
@Override
public void onBlockChange(BlockChangeEvent event) {
if (Baritone.settings().repackOnAnyBlockChange.value) {
final boolean keepingTrackOf = event.getBlocks().stream()
.map(Pair::second).map(BlockState::getBlock)
.anyMatch(CachedChunk.BLOCKS_TO_KEEP_TRACK_OF::contains);
if (keepingTrackOf) {
baritone.getWorldProvider().ifWorldLoaded(worldData -> {
final Level world = baritone.getPlayerContext().world();
ChunkPos pos = event.getChunkPos();
worldData.getCachedWorld().queueForPacking(world.getChunk(pos.x, pos.z));
});
}
}
listeners.forEach(l -> l.onBlockChange(event));
}
@Override
public final void onRenderPass(RenderEvent event) {
listeners.forEach(l -> l.onRenderPass(event));

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