baritone icon indicating copy to clipboard operation
baritone copied to clipboard

Random IndexOutOfBoundsException while opening enchanting table.

Open MajsterTynek opened this issue 2 years ago • 2 comments

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.

MajsterTynek avatar May 14 '22 21:05 MajsterTynek

... 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

MajsterTynek avatar May 17 '22 18:05 MajsterTynek

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

MajsterTynek avatar May 17 '22 19:05 MajsterTynek

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

MajsterTynek avatar Sep 16 '22 15:09 MajsterTynek

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 https://github.com/cabaletta/baritone/blob/861bb7a00a25b1cd08b834d9b52a708689589d35/src/main/java/baritone/cache/ContainerMemory.java#L180, 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 https://github.com/cabaletta/baritone/blob/861bb7a00a25b1cd08b834d9b52a708689589d35/src/main/java/baritone/cache/ContainerMemory.java#L91 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.

ZacSharp avatar Sep 16 '22 22:09 ZacSharp

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

MajsterTynek avatar Sep 17 '22 11:09 MajsterTynek

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.

ZacSharp avatar Sep 17 '22 15:09 ZacSharp