MrCrayfish's Vehicle Mod

MrCrayfish's Vehicle Mod

12M Downloads

Scrolling backward through the vehicle workshop block (left arrow from Aluminium boat) causes crash

astocky opened this issue ยท 1 comments

commented

Scrolling backward through the vehicle workshop block (left arrow from Aluminium boat) causes crash. Scrolling forward works. I think that scrolling backward works until the Aluminium boat.

Crash log is:
---- Minecraft Crash Report ----
// Uh... Did I do that?

Time: 14/08/20 7:10 PM
Description: mouseClicked event handler

java.lang.ArrayIndexOutOfBoundsException: -1
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.loadVehicle(WorkstationScreen.java:256) ~[?:0.45.0-1.16.1] {re:classloading}
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.lambda$init$3(WorkstationScreen.java:104) ~[?:0.45.0-1.16.1] {re:classloading}
at net.minecraft.client.gui.widget.button.Button.func_230930_b_(SourceFile:33) ~[?:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.gui.widget.button.AbstractButton.func_230982_a_(SourceFile:16) ~[?:?] {re:classloading}
at net.minecraft.client.gui.widget.Widget.func_231044_a_(Widget.java:136) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.gui.INestedGuiEventHandler.func_231044_a_(SourceFile:27) ~[?:?] {re:classloading}
at net.minecraft.client.gui.screen.inventory.ContainerScreen.func_231044_a_(ContainerScreen.java:283) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.func_231044_a_(WorkstationScreen.java:247) ~[?:0.45.0-1.16.1] {re:classloading}
at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.gui.screen.Screen.func_231153_a_(Screen.java:421) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.MouseHelper.func_198023_a(MouseHelper.java:85) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:175) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(SourceFile:94) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B}
at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:174) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {}
at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
at com.mojang.blaze3d.systems.RenderSystem.flipFrame(SourceFile:102) ~[?:?] {re:classloading}
at net.minecraft.client.MainWindow.func_227802_e_(MainWindow.java:304) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:971) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMinecraft,pl:mixin:A,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:582) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMinecraft,pl:mixin:A,pl:runtimedistcleaner:A}
at net.minecraft.client.main.Main.main(Main.java:184) ~[1.16.1-forge-32.0.108.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211] {}
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211] {}
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211] {}
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_211] {}
at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) ~[forge-1.16.1-32.0.108.jar:32.0] {}
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-6.1.1.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-6.1.1.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-6.1.1.jar:?] {}
at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-6.1.1.jar:?] {}
at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-6.1.1.jar:?] {}

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Thread: Render thread
Stacktrace:
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.loadVehicle(WorkstationScreen.java:256)
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.lambda$init$3(WorkstationScreen.java:104)
at net.minecraft.client.gui.widget.button.Button.func_230930_b_(SourceFile:33)
at net.minecraft.client.gui.widget.button.AbstractButton.func_230982_a_(SourceFile:16)
at net.minecraft.client.gui.widget.Widget.func_231044_a_(Widget.java:136)
at net.minecraft.client.gui.INestedGuiEventHandler.func_231044_a_(SourceFile:27)
at net.minecraft.client.gui.screen.inventory.ContainerScreen.func_231044_a_(ContainerScreen.java:283)
at com.mrcrayfish.vehicle.client.screen.WorkstationScreen.func_231044_a_(WorkstationScreen.java:247)
at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87)

-- Affected screen --
Details:
Screen name: com.mrcrayfish.vehicle.client.screen.WorkstationScreen
Stacktrace:
at net.minecraft.client.gui.screen.Screen.func_231153_a_(Screen.java:421)
at net.minecraft.client.MouseHelper.func_198023_a(MouseHelper.java:85)
at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:175)
at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(SourceFile:94)
at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:174)
at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36)
at org.lwjgl.system.JNI.invokeV(Native Method)
at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
at com.mojang.blaze3d.systems.RenderSystem.flipFrame(SourceFile:102)

-- Affected level --
Details:
All players: 2 total; [ClientPlayerEntity['astocky'/124, l='ClientLevel', x=27.96, y=70.00, z=-197.69], RemoteClientPlayerEntity['ntstocky'/35160, l='ClientLevel', x=31.82, y=70.00, z=-198.75]]
Chunk stats: Client Chunk Cache: 841, 574
Level dimension: minecraft:overworld
Level spawn location: World: (160,72,-240), Chunk: (at 0,4,0 in 10,-15; contains blocks 160,0,-240 to 175,255,-225), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
Level time: 893148 game time, 2002540 day time
Server brand: forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.world.ClientWorld.func_72914_a(ClientWorld.java:446)
at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:1973)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:598)
at net.minecraft.client.main.Main.main(Main.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51)
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)

-- System Details --
Details:
Minecraft Version: 1.16.1
Minecraft Version ID: 1.16.1
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_211, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 1826415192 bytes (1741 MB) / 4294967296 bytes (4096 MB) up to 4294967296 bytes (4096 MB)
CPUs: 8
JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
ModLauncher: 6.1.1+74+master.966c698
ModLauncher launch target: fmlclient
ModLauncher naming: srg
ModLauncher services:
/mixin-0.8.jar mixin PLUGINSERVICE
/eventbus-3.0.3-service.jar eventbus PLUGINSERVICE
/forge-1.16.1-32.0.108.jar object_holder_definalize PLUGINSERVICE
/forge-1.16.1-32.0.108.jar runtime_enum_extender PLUGINSERVICE
/accesstransformers-2.2.0-shadowed.jar accesstransformer PLUGINSERVICE
/forge-1.16.1-32.0.108.jar capability_inject_definalize PLUGINSERVICE
/forge-1.16.1-32.0.108.jar runtimedistcleaner PLUGINSERVICE
/mixin-0.8.jar mixin TRANSFORMATIONSERVICE
/forge-1.16.1-32.0.108.jar fml TRANSFORMATIONSERVICE
FML: 32.0
Forge: net.minecraftforge:32.0.108
FML Language Providers:
[email protected]
minecraft@1
Mod List:
forge-1.16.1-32.0.108-client.jar Minecraft {[email protected] DONE}
bettermobgriefinggamerule-1.16.1-8.0.2-alpha.jar Better mobGriefing GameRule {[email protected] DONE}
MouseTweaks-2.13-mc1.16.1.jar Mouse Tweaks {[email protected] DONE}
Compressium-1.0.24.jar Compressium {[email protected] DONE}
Cucumber-1.16.1-4.0.1.jar Cucumber Library {[email protected] DONE}
ImmersiveEngineering-1.16.1-3.1-112.jar Immersive Engineering {[email protected] DONE}
bluepower-1.16.1-0.5.213-alpha-universal.jar Blue Power {[email protected] DONE}
jei-1.16.1-7.0.1.10.jar Just Enough Items {[email protected] DONE}
excavation-1.5.jar Excavation {[email protected] DONE}
invtweaks-1.16.1-1.0.6.jar Inventory Tweaks Renewed {[email protected] DONE}
curios-FORGE-1.16.1-3.0.0.2.jar Curios API {[email protected] DONE}
Botania-1.16-401.jar Botania {[email protected] DONE}
Patchouli-1.16-39.jar Patchouli {[email protected] DONE}
IronJetpacks-1.16.1-4.0.0.jar Iron Jetpacks {[email protected] DONE}
essentials-1.16.1-2.8.3.jar Essentials {[email protected] DONE}
Xaeros_Minimap_20.20.0_Forge_1.16.1.jar Xaero's Minimap {[email protected] DONE}
Waystones_1.16.1-7.0.2.jar Waystones {[email protected] DONE}
pamhc2foodcore-1.16.1-1.0.5.jar Pam's HarvestCraft 2 Food Core {pamhc2foodcore@version DONE}
XaerosWorldMap_1.10.0_Forge_1.16.1.jar Xaero's World Map {[email protected] DONE}
light-overlay-5.4.2.jar Light Overlay Forge {lightoverlay-forge@NONE DONE}
CookingForBlockheads_1.16.1-9.0.2.jar Cooking for Blockheads {[email protected] DONE}
RingOfMiner-1.16.1-1.2.0.jar Ring of Miner {[email protected] DONE}
SimpleStorageNetwork-1.16.1-1.0.0.jar Simple Storage Network {[email protected] DONE}
angelring-1.16.1-1.3.0.jar Angel Ring {[email protected] DONE}
elevatorid-1.16.1-1.7.3.jar Elevator Mod {[email protected] DONE}
obfuscate-0.4.3-1.16.1.jar Obfuscate {[email protected] DONE}
vehicle-0.45.0-mc1.16.1.jar MrCrayfish's Vehicle Mod {[email protected] DONE}
branders-spawnermod-1.16.1-1.6.6.jar Enhanced Mob Spawners {[email protected] DONE}
worldedit-forge-mc1.16.1-7.2.0-beta-03.jar WorldEdit {[email protected]+94ce464 DONE}
constructionwand-1.16-1.1.jar Construction Wand {[email protected] DONE}
cfm-7.0.0-pre18-mc1.16.1.jar MrCrayfish's Furniture Mod {[email protected] DONE}
mobcatcher-3.0.jar Mob Catcher {[email protected] DONE}
Hwyla-forge-1.10.10-B77_1.16.1.jar Waila {[email protected]_1.16.1 DONE}
durabilityViewer-1.16.1-forge32.0.38-1.8.3.jar Giselbaers Durability Viewer {[email protected] DONE}
cloth-config-forge-4.0.2.jar Cloth Config v4 API {[email protected] DONE}
RingOfAttraction-1.16.1-1.2.0.jar Ring of Attraction {[email protected] DONE}
trashcans-1.0.2-mc1.16.jar Trash Cans {[email protected] DONE}
JustEnoughResources-1.16.1-0.11.1.93.jar Just Enough Resources {[email protected] DONE}
forge-1.16.1-32.0.108-universal.jar Forge {[email protected] DONE}
AppleSkin-mc1.16.1-forge-1.0.14.jar AppleSkin {[email protected] DONE}
FastLeafDecay-v23.jar FastLeafDecay {fastleafdecay@v23 DONE}
refinedstorage-1.9.2.jar Refined Storage {[email protected] DONE}
refinedstorageaddons-0.7.jar Refined Storage Addons {[email protected] DONE}
Patchouli open book context: n/a
Launched Version: 1.16.1-forge-32.0.108
Backend library: LWJGL version 3.2.2 build 10
Backend API: GeForce GTX 1060/PCIe/SSE2 GL version 4.6.0 NVIDIA 451.67, NVIDIA Corporation
GL Caps: Using framebuffer using OpenGL 3.0
Using VBOs: Yes
Is Modded: Definitely; Client brand changed to 'forge'
Type: Client (map_client.txt)
Resource Packs:
Current Language: English (US)
CPU: 8x Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz

commented

Came here to report the same issue. To be more specific, the problem is as follows.

The WorkstationScreen back button is assuming that the java % operator is a modulo operator when it is actually a remainder operator.

Basically, the aluminum boat is index 0, so getting the previous index gives -1. If you do -1 % 10, then a modulo operator would result in 9 (the desired result), but a remainder operator (like in java) doesn't work like that and instead results in -1. The solution is simple, if currentVehicle is greater than 0, then return currentVehicle - 1, otherwise return this.vehicleTypes.size() - 1, no need for the % operator.

In other words, instead of this:
this.loadVehicle((currentVehicle - 1) % this.vehicleTypes.size());
The line should be something like:
this.loadVehicle(currentVehicle > 0 ? currentVehicle - 1 : this.vehicleTypes.size() - 1);