baritone icon indicating copy to clipboard operation
baritone copied to clipboard

`IndexOutOfBoundsException` in `ElytraBehavior`

Open ZacSharp opened this issue 8 months ago • 2 comments

Some information

Operating system: Linux Java version: 21 Minecraft version: 1.21.1 + Neoforge 21.1.162 Baritone version: aff430ac5, unoptimized neoforge build Other mods (if used): None

Exception, error or logs

log excerpt
[02:06:35] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] > thisway 1000
[02:06:35] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Goal: GoalXZ{x=-474,z=-897}
[02:06:36] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] > elytra
Saving region 0,-1 to disk /home/user/Downloads/PrismLauncher-Linux-Qt6-Portable-9.4/instances/1.21.1/minecraft/saves/New World/./baritone/minecraft/the_nether_128/cache
Saving region 0,0 to disk /home/user/Downloads/PrismLauncher-Linux-Qt6-Portable-9.4/instances/1.21.1/minecraft/saves/New World/./baritone/minecraft/the_nether_128/cache
Saving region -1,0 to disk /home/user/Downloads/PrismLauncher-Linux-Qt6-Portable-9.4/instances/1.21.1/minecraft/saves/New World/./baritone/minecraft/the_nether_128/cache
Saving region -1,-1 to disk /home/user/Downloads/PrismLauncher-Linux-Qt6-Portable-9.4/instances/1.21.1/minecraft/saves/New World/./baritone/minecraft/the_nether_128/cache
Saved region successfully
Saved region successfully
Saved region successfully
Saved region successfully
World save took 274ms
[02:07:17] [Render thread/INFO] [minecraft/AdvancementTree]: Loaded 35 advancements
java.lang.IndexOutOfBoundsException: Index -9 out of bounds for length 26
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
	at java.base/java.util.Objects.checkIndex(Objects.java:385)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at TRANSFORMER/[email protected]/baritone.process.elytra.NetherPath.get(NetherPath.java:42)
	at TRANSFORMER/[email protected]/baritone.process.elytra.ElytraBehavior$PathManager.lambda$pathNextSegment$5(ElytraBehavior.java:236)
	at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:726)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:111)
	at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.runTick(Minecraft.java:1155)
	at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.run(Minecraft.java:807)
	at TRANSFORMER/[email protected]/net.minecraft.client.main.Main.main(Main.java:230)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:136)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:124)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonClientLaunchHandler.runService(CommonClientLaunchHandler.java:32)
	at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.lambda$launchService$4(CommonLaunchHandler.java:118)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:103)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:74)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
	at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.run(BootstrapLauncher.java:210)
	at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:69)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.github.zekerzhayard.forgewrapper.installer.Main.main(Main.java:67)
	at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:105)
	at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129)
	at org.prismlauncher.EntryPoint.main(EntryPoint.java:70)
[02:07:17] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] An unhandled exception occurred. The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues
[02:07:19] [Server thread/INFO] [minecraft/MinecraftServer]: Player has completed the challenge [Hot Tourist Destinations]
[02:07:19] [Render thread/INFO] [minecraft/AdvancementTree]: Loaded 35 advancements
[02:07:22] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Path complete, picking a nearby safe landing spot...
[02:07:28] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Above the landing spot, landing...
[02:07:32] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:32] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:32] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:32] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:33] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:33] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Landed, but still moving, waiting for velocity to die down... 
[02:07:33] [Render thread/INFO] [minecraft/ChatComponent]: [CHAT] [Baritone] Done :)

How to reproduce

When I was testing with the standalone build I got an exception during a 1k block long elytra flight so I switched to unoptimized and had it happen again, which is where the log above comes from. It does however not seem to be reliable since after I added printouts to the methods in question the exception was not thrown again.

Modified settings

elytraTermsAccepted true

Final checklist

  • [x] I know how to properly use check boxes
  • [x] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
  • [x] I have included logs, exceptions and / or steps to reproduce the issue.
  • [x] I have not changed the amount of OwO's or UwU's in this issue.

ZacSharp avatar Apr 25 '25 00:04 ZacSharp

I kinda deal with this in the Overworld elytra PR here: https://github.com/cabaletta/baritone/blob/75a3acd840b600b45e73d5a6b1bc4c67e1d796f4/src/main/java/baritone/process/elytra/ElytraBehavior.java#L235

Its really just dealing with the symptom though I'm not too sure why it happens since reading the code naturally I don't think before should end up larger than the path, but I'd guess some concurrent calls lead to the situation.

underscore-zi avatar Apr 25 '25 04:04 underscore-zi

I spent far too much time hunting this "race condition". https://github.com/cabaletta/baritone/blob/d74420b2653e092b1936881d42aba2f7375159ee/src/main/java/baritone/process/elytra/UnpackedSegment.java#L52-L71

ZacSharp avatar Apr 25 '25 16:04 ZacSharp