Créer un item simple
-
Tu enregistres le ModelMesher avant que l’item soit initialisé, c’est surement ça la cause du crash.
Tu peux envoyer ta classe principale ?La balise de code c’est celle en rouge :
Tu peux aussi l’entrer manuellement avec :ton copier/coller ici[/ code]
sans l'espace entre / et code Il y a aussi la balise java qui s'utilise de la même façon (en vert sur mon image) pour le code java. -
Ma classe principal c’est “modzoic” je crois.
–-- Minecraft Crash Report ---- // My bad. Time: 28/03/16 16:53 Description: Initializing game java.lang.NullPointerException: Initializing game at fr.minecraftforgefrance.modzoic.proxy.ClientProxy.registerRender(ClientProxy.java:15) at fr.minecraftforgefrance.modzoic.common.Modzoic.init(Modzoic.java:36) 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.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:559) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:729) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:307) at net.minecraft.client.Minecraft.startGame(Minecraft.java:532) at net.minecraft.client.Minecraft.run(Minecraft.java:360) at net.minecraft.client.main.Main.main(Main.java:116) 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 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.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at fr.minecraftforgefrance.modzoic.proxy.ClientProxy.registerRender(ClientProxy.java:15) at fr.minecraftforgefrance.modzoic.common.Modzoic.init(Modzoic.java:36) 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.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:559) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:729) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:307) at net.minecraft.client.Minecraft.startGame(Minecraft.java:532) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:360) at net.minecraft.client.main.Main.main(Main.java:116) 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 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.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.8.8 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.8.0_77, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 846585352 bytes (807 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 9.18 Powered by Forge 11.15.0.1655 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHI mcp{9.18} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.8-11.15.0.1655.jar) UCHI Forge{11.15.0.1655} [Minecraft Forge] (forgeSrc-1.8.8-11.15.0.1655.jar) UCHE modzoic{1.0.0} [Modzoic] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'Intel' Version: '4.0.0 - Build 10.18.10.3308' Renderer: 'Intel(R) HD Graphics' Launched Version: 1.8.8 LWJGL: 2.9.4 OpenGL: Intel(R) HD Graphics GL version 4.0.0 - Build 10.18.10.3308, Intel 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) CPU: 2x Intel(R) Pentium(R) CPU 2020M @ 2.40GHz -
Oui c’est Modzoic, il me faudrait le code de cette dernière.
-
Quel code?
Tiens si ça peut t’aider (classe principale, du nom de Modzoic.java):package fr.minecraftforgefrance.modzoic.common; import fr.minecraftforgefrance.modzoic.proxy.CommonProxy; import net.minecraft.item.Item; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; 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; @Mod(modid = "modzoic", name = "Modzoic", version = "1.0.0") public class Modzoic { @Instance("modzoic") public static Modzoic instance; @SidedProxy(clientSide = "fr.minecraftforgefrance.modzoic.proxy.ClientProxy", serverSide = "fr.minecraftforgefrance.modzoic.proxy.CommonProxy") public static CommonProxy proxy; public static Item meatEpanterias; @EventHandler public void preInit(FMLPreInitializationEvent event) { meatEpanterias = new MeatEpanterias(); GameRegistry.registerItem(meatEpanterias, "MeatEpanterias"); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } -
Ton proxy est bien appelé après avoir init l’item, envoie ton proxy en entier (avec balise java (la tasse) svp), ça doit être registerMesher qui est null
-
client
package fr.minecraftforgefrance.modzoic.proxy; import fr.minecraftforgefrance.modzoic.common.MeatEpanterias; import fr.minecraftforgefrance.modzoic.common.Modzoic; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.renderer.entity.RenderItem; public class ClientProxy extends CommonProxy { RenderItem registerMesher = Minecraft.getMinecraft().getRenderItem(); @Override public void registerRender() { registerMesher.getItemModelMesher().register(Modzoic.meatEpanterias, 0, new ModelResourceLocation("modid" + ":MeatEpanterias", "inventory")); } }common
package fr.minecraftforgefrance.modzoic.proxy; public class CommonProxy { public void registerRender() { } } -
Mets la ligne RenderItem registerMesher = …
à l’intérieur de la fonction registerRender -
Comme ça?
Cela me met pleins de croix rouges. -
Whaaaaatttt, non pas entre les () mais entre les {}, ce qu’il y a entre les () c’est les paramètres, pas le fonction en elle même
-
À l’intérieur de la fonction c’est entre les accolades. Entre les parenthèse ce sont les arguments.
Je te conseil de lire le tutoriel ou regarder la vidéo sur la base de java. -
Mais y’a déjà registerMesher.getItemModelMesher().register(Modzoic.meatEpanterias, 0, new ModelResourceLocation(“modid” + “:MeatEpanterias”, “inventory”)); entre les {} :/…
Les tutos je les ai vu mais j’ai pas tout retenu -
Tu peux mettre plusieurs instructions dans une fonction
-
Je regarderai de nouveau la vidéo sur java quand j’aurai le temps.
Comme cela?Error:
registerMesher cannot be resolved -
Non il faut que tu inverses les 2 lignes ^^ Si tu veux apprendre le java je peux tu conseiller de regarder les tutos d’openclassrooms sur le java, il sont bien expliqués et complets.
-
C’est fait! Et le jeu a démarré et marche. Comment trouve t-on notre item?
Et apparemment j’ai eu un problème de texture.[20:58:47] [Client thread/INFO]: Created: 512x512 textures-atlas
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: The following texture errors were found.
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: DOMAIN modzoic
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: –------------------------------------------------
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: domain modzoic is missing 1 texture
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: domain modzoic has 1 location:
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: mod modzoic resources at C:\Users\Conqueror\Documents\Modding\forge-1.8.8\bin
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: –-----------------------
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: The missing resources for domain modzoic are:
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: textures/items/meatEpanterias.png
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: –-----------------------
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: No other errors exist for domain modzoic
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
[20:58:48] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= -
Pour trouver ton Item, il faut le mettre dans une créative tab. Et pour la texture, il faut que tu la mettes dans src/main/ressources/assets/tonmodid/textures/items/meatEpanterias
-
Le mettre dans une creative tab? C’est quoi déjà?
Et pour la texture c’était déjà bien rangé mais je croyais qu’il fallait marquer “resources” et item". Du coup j’ai modifié
-
setCreativeTab(CreativeTabs.celleQueTuVeux);
A placer soit dans le constructeur, soit lors de l’initialisation de ton item :
tonitem = new Item().setCreativeTab(…)//par-exemple -
@‘Plaigon’:
setCreativeTab(CreativeTabs.celleQueTuVeux);
A placer soit dans le constructeur, soit lors de l’initialisation de ton item :
tonitem = new Item().setCreativeTab(…)//par-exemple“celleQueTuVeux”= c’est à dire? Un numéro ou un mot spécial?
“(…)//par-exemple”= Je visualise mal :/…
Et ça me met croix rouge:
Multiple markers at this line
- CreativeTabs cannot be resolved to a
variable
- Syntax error on token “.1”, delete this
tokenSinon pour le changement de nom (resources,item >ressources,items) maintenant ça ne marche plus ça me met ça puis ça:
(c’est compliqué je trouve pour un seul pauvre item :/…)
-
La première erreur -> tu as une erreur dans ton code donc il te demande confirmation avant de lancer car le programme risque de planter
La deuxième -> Il faut sélectionner le projet ou une classe du projet avant de cliquer sur lancer.