Résolu Erreur "n must be positive" lors de la création d'un menu
-
Bonjour,
J’ai une erreur lorsque je créé mon menu et que je lance le client.
J’ai ça :[10:11:00] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [10:11:01] [Client thread/FATAL]: Unreported exception thrown! java.lang.IllegalArgumentException: n must be positive at java.util.Random.nextInt(Unknown Source) ~[?:1.7.0_55] at fr.ewearys.mod.GuiCustomMainMenu.<init>(GuiCustomMainMenu.java:89) ~[GuiCustomMainMenu.class:?] at fr.ewearys.mod.ModCustomMenu.onTickClient(ModCustomMenu.java:43) ~[ModCustomMenu.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_ModCustomMenu_onTickClient_ClientTickEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.onPostClientTick(FMLCommonHandler.java:310) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2161) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1035) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_55] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_55] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] –-- Minecraft Crash Report ---- // Uh... Did I do that? Time: 29/06/14 10:11 Description: Unexpected error java.lang.IllegalArgumentException: n must be positive at java.util.Random.nextInt(Unknown Source) at fr.ewearys.mod.GuiCustomMainMenu.<init>(GuiCustomMainMenu.java:89) at fr.ewearys.mod.ModCustomMenu.onTickClient(ModCustomMenu.java:43) at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_ModCustomMenu_onTickClient_ClientTickEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.onPostClientTick(FMLCommonHandler.java:310) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2161) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1035) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:112) 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.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (x86) version 6.1 Java Version: 1.7.0_55, Oracle Corporation Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation Memory: 932562056 bytes (889 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.01-pre FML v7.2.116.1024 Minecraft Forge 10.12.0.1024 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available FML{7.2.116.1024} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available Forge{10.12.0.1024} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available Ewearys{1.0} [Ewearys] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: GeForce 210/PCIe/SSE2 GL version 3.3.0, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: null Anisotropic Filtering: Off (1) #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Kamil\Desktop\Overworld\Modding\launcher 1.7\Launcher crack\forge 1.7.2 (1024)\eclipse\.\crash-reports\crash-2014-06-29_10.11.01-client.txt AL lib: (EE) alc_cleanup: 1 device not closed
Seriez-vous m’aider et me dire quelle est l’erreur ?
Cordialement,
PS : Si vous voulez les codes, je vous les fournis.</init></init>
-
Les codes s’il te plaît Apparemment, il y a une valeur négative donnée par un random à la ligne 89 du GuiCustomMainMenu alors qu’elle devrait être positive
-
Salut, merci de ta réponse.
C’est ça mon code de ligne 89public GuiCustomMainMenu() { BufferedReader bufferedreader = null; try { ArrayList arraylist = new ArrayList(); bufferedreader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(splashTexts).getInputStream(), Charsets.UTF_8)); String s; while ((s = bufferedreader.readLine()) != null) { } do { this.splashText = ((String)arraylist.get(rand.nextInt(arraylist.size()))); } while (this.splashText.hashCode() == 125780783); }
Cordialement,
-
Il faut ajouter ta variable s à l’ArrayList, sinon la taille de cette liste est de 0 donc une valeur non positive (en maths anglais)
-
Si je mets ça :
{ String s = s.trim(); if (!s.isEmpty()) { arraylist.add(s); } }
Je dois renommer
string s
en s1
Cela renomme tout en s1
Mais aprèss.trim();
J’ai cette erreur : “the local variable s1 may not have been initialized.”
je dois faire quoi?Cordialement,
-
Bah non tu fais String s1 = s.trim() et après tu fait arrayList.add(s1)
-
Merci de ton aide
-
Oh mais de rien Ravi de t’avoir aidé