Résolu Keybinding + Gui qui bug
-
salut a tous c’est encore moi j’ai un énorme bug concernant mon keyBinding:
il y a 4 GUI:
playerFR
playerEN
AdminFR
AdminENmais problème, seul les GUI player s’ouvre (même a la place des GUI Admin), et si je n’est pas d’item en main le jeu crash
mes code:
GuiHandler: http://pastebin.com/DAJ1VGtN
la fonction keyUp: http://pastebin.com/Cv3HVGUy
le crash quand on a pas d’item: http://pastebin.com/sWEvwRCn
de plus j’aimerai savoir comment on fait pour savoir si un joueur vise une entité(mob, joueur)
-
Normal que cela crash quant tu n’as pas d’item en main, tu as oublié de checker quand l’item est null.
-
if(kb.keyCode == questKey.keyCode && mc.currentScreen == null && player.getCurrentEquippedItem().getItem() != null && player.getCurrentEquippedItem().getItem()== CoeQuestMain.quest)
Toujours mettre un null check.
et pour le else :
else if(kb.keyCode == questKey.keyCode && mc.currentScreen == null)
Parce que sinon ça ne fonctionnera jamais.Et pourquoi faire quatre gui ? o_O. Deux gui suffit, il existe des fonctions pour traduire des string depuis les fichiers lang …
-
oue tu as raison robin, je vais utiliser les I8nString plutôt.
EDIT:
j’ai encore une erreur, ca crash quand ya pas d’item:@Override public void keyUp(EnumSet <ticktype>types, KeyBinding kb, boolean tickEnd) { EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; Minecraft mc = Minecraft.getMinecraft(); if(kb.keyCode == questKey.keyCode && mc.currentScreen == null && player.getCurrentEquippedItem().getItem() != null && player.getCurrentEquippedItem().getItem()== CoeQuestMain.quest)//partie ADMIN { FMLNetworkHandler.openGui(player, CoeQuestMain.instance, 2, player.worldObj, (int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)); } else if(kb.keyCode == questKey.keyCode && mc.currentScreen == null) { FMLNetworkHandler.openGui(player, CoeQuestMain.instance, 1, player.worldObj, (int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)); } }
erreur: NPE
:::
–-- Minecraft Crash Report ----
// Why is it breakingTime: 16/06/14 15:27
Description: Unexpected errorjava.lang.NullPointerException
at CoeQuest.KeyBindQuest.keyUp(KeyBindQuest.java:42)
at cpw.mods.fml.client.registry.KeyBindingRegistry$KeyHandler.keyTick(KeyBindingRegistry.java:129)
at cpw.mods.fml.client.registry.KeyBindingRegistry$KeyHandler.tickStart(KeyBindingRegistry.java:102)
at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)
at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)
at cpw.mods.fml.common.FMLCommonHandler.onRenderTickStart(FMLCommonHandler.java:372)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)
at net.minecraft.client.Minecraft.run(Minecraft.java:838)
at net.minecraft.client.main.Main.main(Main.java:93)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)A detailed walkthrough of the error, its code path and all known details is as follows:
– Head –
Stacktrace:
at CoeQuest.KeyBindQuest.keyUp(KeyBindQuest.java:42)
at cpw.mods.fml.client.registry.KeyBindingRegistry$KeyHandler.keyTick(KeyBindingRegistry.java:129)
at cpw.mods.fml.client.registry.KeyBindingRegistry$KeyHandler.tickStart(KeyBindingRegistry.java:102)
at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)
at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)– Affected level –
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP[‘isador34’/7, l=‘MpServer’, x=1144,02, y=5,62, z=222,90]]
Chunk stats: MultiplayerChunkCache: 441
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options:
Level spawn location: World: (1121,4,239), Chunk: (at 1,0,15 in 70,14; contains blocks 1120,0,224 to 1135,255,239), Region: (2,0; contains chunks 64,0 to 95,31, blocks 1024,0,0 to 1535,255,511)
Level time: 280264 game time, 12355 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 8 total; [MobtestEntity[‘entity.Testmob.name’/0, l=‘MpServer’, x=1141,31, y=4,00, z=223,69], MobtestEntity[‘entity.Testmob.name’/1, l=‘MpServer’, x=1151,31, y=4,00, z=226,31], MobtestEntity[‘entity.Testmob.name’/2, l=‘MpServer’, x=1151,31, y=4,00, z=226,31], MobtestEntity[‘entity.Testmob.name’/3, l=‘MpServer’, x=1151,31, y=4,00, z=226,69], MobtestEntity[‘entity.Testmob.name’/4, l=‘MpServer’, x=1151,69, y=4,00, z=226,69], MobtestEntity[‘entity.Testmob.name’/5, l=‘MpServer’, x=1151,69, y=4,00, z=226,69], MobtestEntity[‘entity.Testmob.name’/6, l=‘MpServer’, x=1151,69, y=4,00, z=226,31], EntityClientPlayerMP[‘isador34’/7, l=‘MpServer’, x=1144,02, y=5,62, z=222,90]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2312)
at net.minecraft.client.Minecraft.run(Minecraft.java:863)
at net.minecraft.client.main.Main.main(Main.java:93)
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:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)– System Details –
Details:
Minecraft Version: 1.6.4
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_45, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 760117536 bytes (724 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 9639 (539784 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v8.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 13 mods loaded, 13 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{6.4.45.953} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{9.11.1.953} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coeblock{1.0.0} [Coe Block] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coebordure{1.0.0} [Coe Bordure] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coecore{1.0.0} [CoeCore] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coemob{1.0.0} [Coemob] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coequest{1.0.0} [CoeQuest] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coespell{1.0.0} [CoeSpell] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
coeweapon{1.0.0} [CoeWeapon] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
crusadegui{2.0.0} [COE gui] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
mineralherb{1.0.1} [Mineralherb] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
PM{V.1.0.0} [Portal WoW] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GTX 660/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to ‘fml,forge’
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: Français (France)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 103 (5768 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used:::</ticktype>
-
C’est de ma faute, c’est player.getCurrentEquippedItem() != null et non player.getCurrentEquippedItem().getItem() != null
-
merci ca marche