Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

Random IndexOutOfBoundsException while opening enchanting table.

MajsterTynek opened this issue · 6 comments

commented

Some information

Operating system: Windows 10; 21H2 build 19044.1620
Java version: 1.8.0_51
Minecraft version: 1.12.2
Baritone version: 1.2.15
Other mods (if used):
AdvancedMacros, MoreAdvancedMacros

Exception, error or logs

crash-2022-05-14_23.11.04-client.txt

How to reproduce

Unknown. It usually happens when clicking entities
and blocks with inventory that is not the regular chest.

Modified settings

allowBreak, allowPlace, chatControl, containerMemory

Final

I would blame containerMemory for causing it.

commented

... so it has happened once again ...
This time I was constantly placing bookshelves and enchanting tables,
including testing their bookshelf power in meanwhile from time to time.
crash-2022-05-17_20.07.43-client.txt

commented

... and again, and again ...
crash-2022-05-17_21.29.32-client.txt

commented

I guess I will need to write my own containerMemory if Baritone's one is crashing ...

commented

Actually the one in Baritone has been removed so new versions won't crash from this anymore (though as of now the latest release v1.2.15 still does so).

If you really want to fix the old implementation I suggest you have a look at

items.addAll(ctx.player().openContainer.getInventory().subList(0, size));
, which seems to be the throwing line (not sure at all though because the stacktrace is obfuscated). The problem seems to be (0 evidence, pure guessing based on the code) that Baritone sometimes already has the inventory "remembered" with a higher slot count. Might be because of a race condition between the packet thread creating the inventory in
public synchronized void setup(BlockPos pos, int windowId, int slotCount) {
and the main thread accessing it to store the contents.

Also sorry for only having a look at this after such a long time that it probably won't be of use for anyone anymore.

commented

I have been reporting this since like 2 years, but OK.
Did you just say that containerMemory got removed in never versions?

More like it tries to get slots for container that it should not track at all.
It randomly crashes at opening enchants, anvils and villagers (all I do remeber).

(not sure at all though because the stacktrace is obfuscated)

Not my fault open source build is obfuscated ¯\_(ツ)_/¯
I cannot even write scripts with hidden classes... :c

commented

Did you just say that containerMemory got removed in never versions?

Yes, the CI builds don't have it anymore. (The latest release still has it)

Not my fault open source build is obfuscated ¯_(ツ)_/¯

It's not the kind of obfuscation you use if you don't want people to reconstruct the code; in that case I'd have no chance.
Baritone has all names shortened and some bytecode optimizations applied, which gives a little performance at the cost of debuggability.