CraftTweaker

CraftTweaker

151M Downloads

java.lang.ArrayIndexOutOfBoundsException when trying to fill a Associative Array via for loop

Guinaro opened this issue ยท 0 comments

commented

Issue Description:

I cannot use a for loop to fill an Associative Array.

What happens:

java.lang.ArrayIndexOutOfBoundsException when trying to use a for loop to fill up a Associative Array aka Map.
My script contains an IItemstack[] array, filled with some existing IItemstacks.
Creating an empty {} Associative Array as string[IItemstack] and filling it manually with an IItemstack: string pair works properly.
When trying to do the same via a for loop. By iterating over the itemstack array (for thisItemStack in itemArray{}) and using the key thisItemStack as new key for the Associative map and a value of a standard string be it "string" or a variable cast as string fails!
In short filling Maps in loops is impossible. Tried this with variations like string[string], ICraftingRecipe[][string], ICraftingRecipe[][IItemstack]. Always the same ArrayIndexOutOfBoundsException.

What you expected to happen:

Being able to fill Associative Arrays via for loops.

Script used:

https://gist.github.com/Guinaro/e92a06eb451ac60a450c7f0d3dbef030

Minetweaker.log file:

https://gist.github.com/Guinaro/9f3b7438744eb4ca69c2263d559e65e0


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 14.23.2.2618
  • Crafttweaker: 1.12-4.1.5

Your most recent log file where the issue was present:

https://gist.github.com/Guinaro/29b8f96abe0973f5a455fdda9ab64962