[BUG] Crash when adding a variable to a non-full arithmetic logic machine
Hawk777 opened this issue · 0 comments
Describe the bug
Manipulating boolean variables in an arithmetic logic machine that does not have all four slots filled crashes.
To Reproduce
Steps to reproduce the behavior:
- Create an arithmetic logic machine.
- Put a single Logic Circuit in the first item slot. Leave the other three item slots empty.
- Switch to the tab for the logic circuit.
- Click the plus to add a new variable.
- Click the Apply button.
Expected behavior
Not a crash.
Logs
java.lang.IndexOutOfBoundsException: Index: 11, Size: 10
at java.util.ArrayList.rangeCheck(ArrayList.java:659)
at java.util.ArrayList.get(ArrayList.java:435)
at pl.pabilo8.immersiveintelligence.client.gui.arithmetic_logic_machine.GuiArithmeticLogicMachineEdit.func_73866_w_(GuiArithmeticLogicMachineEdit.java:175)
at pl.pabilo8.immersiveintelligence.client.gui.arithmetic_logic_machine.GuiArithmeticLogicMachineEdit.changeDataTypePage(GuiArithmeticLogicMachineEdit.java:569)
at pl.pabilo8.immersiveintelligence.client.gui.arithmetic_logic_machine.GuiArithmeticLogicMachineEdit.func_146284_a(GuiArithmeticLogicMachineEdit.java:251)
at net.minecraft.client.gui.GuiScreen.func_73864_a(GuiScreen.java:443)
at net.minecraft.client.gui.inventory.GuiContainer.func_73864_a(GuiContainer.java:323)
at pl.pabilo8.immersiveintelligence.client.gui.arithmetic_logic_machine.GuiArithmeticLogicMachineEdit.func_73864_a(GuiArithmeticLogicMachineEdit.java:466)
at net.minecraft.client.gui.GuiScreen.func_146274_d(GuiScreen.java:533)
at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:501)
at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1759)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)
at net.minecraft.client.main.Main.main(SourceFile:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
On line 175 you’re grabbing elements 11 and 12 of buttonList
and assuming they’re the buttons you just added. But if some of the item slots are empty, then back on lines 123 through 130 you didn’t add those buttons, so the list is shorter and the newly created buttons are in earlier positions. There are also a couple of references by list position on lines 320 through 331.
Environment
- OS: Linux
- Minecraft version: 1.12.2
- Forge version: 14.23.5.2854
- Immersive Intelligence version: 0.1.1
- Immersive Engineering version: 0.12-98