Résolu Crash lors du craft
-
Bonjour, je me présente ,Eryah, moddeur débutant et maladroit.
Je réalise le mod UsefulThings ( Progression ici : http://forum.minecraft-france.fr/threads/usefulthings-project.28533/ ). J’ai codée mon Item “Moteur”, et il peut être crafter. Mais lorsque je le craft, que je pose mon curseur sur l’item dans la table de craft, mon jeu crash.Code du moteur
package eryah.usefulthings.init; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; import eryah.usefulthings.Reference; import eryah.usefulthings.UsefulthingsMod; public class Engine { public static Item engine; public static void init(){ engine = new Item().setUnlocalizedName("engine").setCreativeTab(UsefulthingsMod.UTTab); } public static void register() { GameRegistry.registerItem(engine, engine.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(engine); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } }
Partie du code dans le .java de base qui gère le craft
@EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); GameRegistry.addRecipe(new ItemStack(engine), new Object[]{" R ", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston}); }
Le crash dans le log
:::
[16:12:26] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Eryah\Documents\Mods\1.8 Useful Things\eclipse.\crash-reports\crash-2015-05-31_16.12.26-client.txt[16:12:26] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[16:12:26] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
:::Le Crash Report
:::
–-- Minecraft Crash Report ----// You’re mean.
Time: 31/05/15 16:12
Description: Rendering screenjava.lang.NullPointerException: Rendering screen
at net.minecraft.item.ItemStack.getTooltip(ItemStack.java:872)
at net.minecraft.client.gui.GuiScreen.renderToolTip(GuiScreen.java:163)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:186)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114)
at net.minecraft.client.Minecraft.run(Minecraft.java:376)
at net.minecraft.client.main.Main.main(Main.java:117)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)A detailed walkthrough of the error, its code path and all known details is as follows:
– Head –
Stacktrace:
at net.minecraft.item.ItemStack.getTooltip(ItemStack.java:872)
at net.minecraft.client.gui.GuiScreen.renderToolTip(GuiScreen.java:163)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:186)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)– Screen render details –
Details:
Screen name: net.minecraft.client.gui.inventory.GuiCrafting
Mouse location: Scaled: (309, 102). Absolute: (927, 528)
Screen size: Scaled: (534, 279). Absolute: (1600, 837). Scale factor of 3– Affected level –
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP[‘Player498’/54, l=‘MpServer’, x=176,61, y=64,00, z=237,54]]
Chunk stats: MultiplayerChunkCache: 25, 25
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options:
Level spawn location: 182,00,4,00,237,00 - World: (182,4,237), Chunk: (at 6,0,13 in 11,14; contains blocks 176,0,224 to 191,255,239), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 313580 game time, 6000 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: 18 total; [EntityChicken[‘Poule’/35, l=‘MpServer’, x=191,72, y=64,00, z=203,53], EntityRabbit[‘Lapin’/36, l=‘MpServer’, x=197,28, y=64,00, z=266,63], EntityCow[‘Vache’/38, l=‘MpServer’, x=211,81, y=64,00, z=261,19], EntityChicken[‘Poule’/10, l=‘MpServer’, x=152,53, y=64,00, z=202,72], EntityItem[‘item.item.egg’/11, l=‘MpServer’, x=151,81, y=64,00, z=202,28], EntityChicken[‘Poule’/17, l=‘MpServer’, x=190,63, y=64,00, z=195,59], EntityItemFrame[‘entity.ItemFrame.name’/18, l=‘MpServer’, x=182,97, y=65,50, z=239,50], EntityItemFrame[‘entity.ItemFrame.name’/21, l=‘MpServer’, x=182,97, y=65,50, z=253,50], EntityItemFrame[‘entity.ItemFrame.name’/22, l=‘MpServer’, x=182,97, y=65,50, z=255,50], EntityPlayerSP[‘Player498’/54, l=‘MpServer’, x=176,61, y=64,00, z=237,54], EntityItemFrame[‘entity.ItemFrame.name’/23, l=‘MpServer’, x=182,97, y=65,50, z=245,50], EntityItemFrame[‘entity.ItemFrame.name’/24, l=‘MpServer’, x=182,97, y=65,50, z=247,50], EntityItemFrame[‘entity.ItemFrame.name’/25, l=‘MpServer’, x=182,97, y=65,50, z=241,50], EntityItemFrame[‘entity.ItemFrame.name’/26, l=‘MpServer’, x=182,97, y=65,50, z=243,50], EntityItemFrame[‘entity.ItemFrame.name’/27, l=‘MpServer’, x=182,97, y=65,50, z=249,50], EntityItemFrame[‘entity.ItemFrame.name’/28, l=‘MpServer’, x=182,97, y=65,50, z=251,50], EntityItemFrame[‘entity.ItemFrame.name’/29, l=‘MpServer’, x=182,97, y=65,50, z=257,50], EntityItemFrame[‘entity.ItemFrame.name’/30, l=‘MpServer’, x=182,97, y=65,50, z=259,50]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2613)
at net.minecraft.client.Minecraft.run(Minecraft.java:398)
at net.minecraft.client.main.Main.main(Main.java:117)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)– System Details –
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_45, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 784184504 bytes (747 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.99.8.1412 Minecraft Forge 11.14.1.1412 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{8.99.8.1412} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{11.14.1.1412} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
ut{Beta 1.0} [Useful Things] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Loaded coremods (and transformers):
GL info: ’ Vendor: ‘ATI Technologies Inc.’ Version: ‘4.2.12420 Compatibility Profile Context 13.151.0.0’ Renderer: ‘AMD Radeon HD 8240’
Launched Version: 1.8
LWJGL: 2.9.1
OpenGL: AMD Radeon HD 8240 GL version 4.2.12420 Compatibility Profile Context 13.151.0.0, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.Using VBOs: No
Is Modded: Definitely; Client brand changed to ‘fml,forge’
Type: Client (map_client.txt)
Resource Packs: []
Current Language: Français (France)
Profiler Position: N/A (disabled)
::: -
Salut,
Ton item semble être null au moment où tu enregistre la recette. Tu dois d’abord initialiser l’item et l’enregistrer puis enregistrer la recette. -
Je ne comprend pas trop ce que vous voulea dire par l’initianliser, et par il est ‘null’
Voici mon .java de base en entierpackage eryah.usefulthings; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import eryah.usefulthings.blocks.ResinLeaves; import eryah.usefulthings.init.Engine; import eryah.usefulthings.init.ResinTree; import eryah.usefulthings.init.UTResin; import eryah.usefulthings.proxy.CommonProxy; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class UsefulthingsMod { @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; public static final CreativeTab UTTab = new CreativeTab("UTTab"); public static final Item UTresin = new Item(); public static final Item engine = new Item(); @EventHandler public void preInit(FMLPreInitializationEvent event) { ResinTree.init(); ResinTree.register(); UTResin.init(); UTResin.register(); Engine.init(); Engine.register(); ResinLeaves.init(); ResinLeaves.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); GameRegistry.addRecipe(new ItemStack(engine), new Object[]{" R ", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston}); } @EventHandler public void PostInit(FMLPostInitializationEvent event) {
-
Les deux lignes :
public static final Item UTresin = new Item(); public static final Item engine = new Item();
ne devrait pas exister.
Et tu aurai du mettre :GameRegistry.addRecipe(new ItemStack(Engine.engine), new Object[]{" R ", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston});
avec l’organisation que tu utilises actuellement. D’ailleurs je ne vois pas l’intérêt d’organiser les classes de la façon dont tu le fais. Il serait mieux de mettre les déclarations d’items dans la classe principale, ou alors dans une même classe pour tous les items, mais une classe par item je ne vois vraiment pas l’intérêt. Ça fragmente plus qu’autre chose le code.
Et un peu de programmation en général :
l’initialisation, c’est quand tu affectes une première valeur à une variable.
Par exemple, cette variable :public static String[] array;
est null, car elle n’a pas été initialisé.
Par contre celle-ci :public static String[] array = new String[]{"une valeur", "une deuxième", "oui, plusieurs valeurs comme c'est un tableau ;)"};
est initialisé.
Lorsqu’on fait appel à une méthode d’un objet non initialisé (donc null) une erreur du type NullPointerException est levé. -
Bah je suis incapable de faire un code par moi même(même si je commence a tenter des choses) , je cherche donc des tutos sur youtube et sur internet. C’est le code de MRCrayfish, sauf que le tuto est en 1.7
-
Cette ligne
GameRegistry.addRecipe(new ItemStack(engine), new Object[]{" R ", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston});
Pour moi le
new ItemStack(engine)
je suis obligé de l’écrire comme ca :
new ItemStack(engine, QUANTITE)
Donc que tu désire mettre (1 à 64) sinon mon jeu ne ce lance même pas, me demande pas pourquoi x).
Ensuite ça :
{" R ", "PRP","RRR"
C’est exactement pareil je doit l’écrire d’un certaine facon comme :
{"NRN", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston});
N pour moi signifie Null.
Edit: J’ai écrit le post au même moment que Robin désolé :3
-
C’est bon , ça marche merci Robin