Résolu [Résolu]Petit problème
-
Pas complètement ^^.
Maintenant, je sais faire un item, mais j’ai vu que dans l’un des tutos de checconio, on pouvait le faire sur une seule page pour que ce soit moins le bordel ^^.
Du coup je pense tenter, mais j’ai quelques erreurs, si certains savent pourquoi?:
(et on y arrive je pense qu’il serait judicieux de mettre mon truc en exemple en 1.8 pour faciliter le copiage de la programmation :))package com.modzoic.init; import com.modzoic.Reference; import net.minecraft.item.Item; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class meatdino { public static Item meatdino; public static void init() { meatdino = new Meatdino().setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(meatdino, meatdino.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(meatdino); } public static void registerRender(Item item) { RenderItem registerMesher = Minecraft.getMinecraft().getRenderItem(); registerMesher.getItemModelMesher().register(item, 0, new ModelResourceLocation("modzoic" + ":meatdino", "inventory")); } }
Erreurs:
1:The declared package “com.modzoic.init” does not match the expected package “fr.minecraftforgefrance.modzoic.common”
2:The import com.modzoic cannot be resolved
3:Meatdino cannot be resolved to a type -
1 Aprend le java, 2 apprend le java, 3 apprend à relire ton code avant de poser des questions.
Alors les réponses :
1 Tu as mal déclaré ton package, tu as juste à faire “change package déclaration to”. 2 ctrl + shift + o pour organiser les imports. 3 Tu as mis un nom sans majuscule à ta classe. -
Le java c’est long à apprendre. Et je sais qu’il y a une vidéo pour ça sauf qu’elle dure une heure et que tout n’est pas toujours dedans, juste le plus important ^^'. Mais ce week end j’aurai plus le temps, je pourrai largement plus m’y consacrer.Me reste une erreur:
The method setCreativeTab(CreativeTabs) is undefined for the type meatdino
-
Normal, ce n’est pas un item. Apprends le java, ou au moins la POO et suit tous les tutoriels sur le forum ou sur la chaîne youtube (personnellement je te conseille de regarder le tuto en vidéo et ensuite de lire la version texte pour mieux comprendre) et ensuite reviens sur le sujet car on risque pas d’avancer si tu ne sais pas ce que tu fais
-
–-- Minecraft Crash Report ---- // Surprise! Haha. Well, this is awkward. Time: 30/03/16 22:42 Description: Initializing game java.lang.NullPointerException: Can't add null-object to the registry, name modzoic:meatEpanterias. at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.add(FMLControlledNamespacedRegistry.java:421) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:133) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:128) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:150) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:138) at organisation.dinomeat.register(dinomeat.java:20) at fr.minecraftforgefrance.modzoic.common.Modzoic.preInit(Modzoic.java:34) 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.preinitializeMods(Loader.java:548) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:240) at net.minecraft.client.Minecraft.startGame(Minecraft.java:451) 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 net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.add(FMLControlledNamespacedRegistry.java:421) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:133) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:128) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:150) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:138) at organisation.dinomeat.register(dinomeat.java:20) at fr.minecraftforgefrance.modzoic.common.Modzoic.preInit(Modzoic.java:34) 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.preinitializeMods(Loader.java:548) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:240) at net.minecraft.client.Minecraft.startGame(Minecraft.java:451) -- 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: 895696856 bytes (854 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.1650 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 UCH mcp{9.18} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.8-11.15.0.1650-1.8.8.jar) UCH Forge{11.15.0.1650} [Minecraft Forge] (forgeSrc-1.8.8-11.15.0.1650-1.8.8.jar) UCE 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
Quelqu’un comprend pourquoi j’ai crash svp?
Retest avec modifications ça donne ça:
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.preinitializeMods(Loader.java:548) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:240) at net.minecraft.client.Minecraft.startGame(Minecraft.java:451) 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 net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.add(FMLControlledNamespacedRegistry.java:421) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:133) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:128) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:150) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:138) at organisation.dinomeat.register(dinomeat.java:20) at fr.minecraftforgefrance.modzoic.common.Modzoic.preInit(Modzoic.java:34) 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.preinitializeMods(Loader.java:548) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:240) at net.minecraft.client.Minecraft.startGame(Minecraft.java:451) -- 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: 894488856 bytes (853 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.1650 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 UCH mcp{9.18} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.8-11.15.0.1650-1.8.8.jar) UCH Forge{11.15.0.1650} [Minecraft Forge] (forgeSrc-1.8.8-11.15.0.1650-1.8.8.jar) UCE 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
Je cherche l’erreur mais clairement je comprends pas pourquoi ça ne veut pas :/.
-
at organisation.dinomeat.register(dinomeat.java:20)
Tu peux envoyer la classe dinomeat ?
Tu enregistres l’item alors qu’il est null, c’est pour ça que ça crash. -
Voilà:
package organisation; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class dinomeat { public static Item dinomeat; public static void init() { dinomeat = new Item().setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(dinomeat, "dinomeat"); } public static void registerRenders() { registerRender(dinomeat); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("modzoic" + ":dinomeat" + item.getUnlocalizedName().substring(5), "inventory")); } }
-
Bon en fait il me faut la classe principale x)
-
package fr.minecraftforgefrance.modzoic.common; import fr.minecraftforgefrance.modzoic.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; 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; import organisation.dinomeat; @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().setCreativeTab(CreativeTabs.tabFood); GameRegistry.registerItem(meatEpanterias, "meatEpanterias"); dinomeat.register(); dinomeat.init(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
-
Définition de initialisation : “Donner une valeur initiale à.”. Alors pourquoi tu register ton item avant de l’initialiser, alors qu’il n’a pas de valeur ?
Il faut que tu inverses les appels de “dinomeat;register();” et "dinomeat.init();’ -
Ah oui il fallait juste faire ça x’). J’aurai pas cru que cela puisse avoir une telle incidence, je l’avais même pas remarqué que j’avais inversé. J’aurai pu chercher longtemps x). Merci beaucoup! Maintenant je peux faire items illimités. Et n’hésitez pas à prendre mes codes comme modèle pour le tuto 1.8, ça pourrait aider, vous en pensez quoi?
Sinon je laisse mon post ouvert pour mes prochains problèmes que je pourrai rencontrer ultérieurement (notamment quand je vais créer mon premier mob :))
-
Enregistrer directement dans la classe dans l’item ou enregistrer dans la classe principale ne change pas tellement de choses, mais tu auras plus de fonctions dans les classes de tes items et presque autant de lignes dans ta classe principale. Personellement je préfère tout centraliser dans une classe (j’ai une classe BlockRegistry, ItemRegistry…) mais après à chacun sa manière de faire ça.
-
J’ai déjà un modèle de prévu pour les tutoriels 1.8.
Organisation du type :- classe principale
- classe commune (common proxy)
- classe client (client proxy)
- classe serveur (server proxy)
- classe blocs (avec toutes les déclarations de blocs dedans)
- classe items (avec toutes les déclarations d’items dedans)
- classe entité (avec toutes les fonctions d’enregistrement d’entité)
C’est quelque chose de mieux organisé que ce qui est utilisé dans les tuto 1.7
-
Par contre il se nomme item.null.basic
Comment je dois lui donner une valeur ou un nom (pour remplacer le “null” après je sais faire pour les dossiers lang)?
Et il ne veut pas prendre sa texture ni son model. Je crois que j’ai fait une faute dans mon “dinomeat”, vous la voyez?
nom du model: dinomeat.json
nom du texture: dinomeat.pgn -
Pour le nom tu fais .setUnlicalizedName(lenom) comme avec le .setCreativeTab.
Tu appelé bien ta fonction d’enregistrement des rendus dans ton proxy. -
Le nom c’est bon, mais les textures et les ressources ça veut pas.
Voici ce que j’ai actuellement sur clientproxy: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.creativetab.CreativeTabs; import net.minecraft.client.renderer.entity.RenderItem; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderItem registerMesher = Minecraft.getMinecraft().getRenderItem(); registerMesher.getItemModelMesher().register(Modzoic.meatEpanterias, 0, new ModelResourceLocation("modzoic" + ":meatEpanterias", "inventory")); } }
Sur principal:
package fr.minecraftforgefrance.modzoic.common; import fr.minecraftforgefrance.modzoic.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; 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; import organisation.dinomeat; @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().setCreativeTab(CreativeTabs.tabFood); GameRegistry.registerItem(meatEpanterias, "meatEpanterias"); dinomeat.init(); dinomeat.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
et sur dinomeat:
package organisation; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class dinomeat { public static Item dinomeat; public static void init() { dinomeat = new Item().setUnlocalizedName("dinomeat").setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(dinomeat, "dinomeat"); } public static void registerRenders() { registerRender(dinomeat); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("modzoic" + ":dinomeat" + item.getUnlocalizedName().substring(5), "inventory")); } }
Sinon, je tiens à préciser que pour faire tout ça j’ai suivi un tuto sur youtube (checconio).
Et lui ne va pas du tout sur proxy du coup je suppose qu’il faut rien rajouter dans proxy.
Cependant, pour en être sûr, j’ai rajouté ça à l’endroit qui aurait pu être approprié:registerMesher.getItemModelMesher().register(Modzoic.*dinomeat*, 0, new ModelResourceLocation("modzoic" + ":dinomeat", "inventory"));
Ici, le mot souligné m’a causé des soucis d’erreurs, me demandant, pour la réparer, de faire public static Item dinomeat;
sauf que du coup ensuite c’était dinomeat.init(); dinomeat.register(); en erreur. Du coup je fais comment x’)? -
Pour le rendu, t’appelle où la fonction registerRenders ? Et pour l’histoire du proxy, il y a d’autre méthodes qui peuvent ne pas passer par lui.
Pour ton rendu, la variable n’es pas déclaré dans ModZoic mais directement dans la classe de ton Item. -
Du coup je fais comment?
Si je bouge ma variable ça casse tout…
Je suis un peu coincé là.
Après si je modifie tout va être croix rouge…et plus rien ne marchera tout court. Y’a pas une solution, après tout ce n’est qu’une texture…?Sinon j’ai essayé ça:
package organisation; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class dinomeat { public static Item dinomeat; public static void init() { dinomeat = new Item().setUnlocalizedName("dinomeat").setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(dinomeat, "dinomeat"); } public static void registerRenders() { } public static void registerRender() { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(dinomeat, 0, new ModelResourceLocation("modzoic" + ":dinomeat" + dinomeat.getUnlocalizedName().substring(5), "inventory")); } }
Rappel de mon ancienne version:
package organisation; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class dinomeat { public static Item dinomeat; public static void init() { dinomeat = new Item().setUnlocalizedName("dinomeat").setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(dinomeat, "dinomeat"); } public static void registerRenders() { registerRender(dinomeat); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation("modzoic" + ":dinomeat" + item.getUnlocalizedName().substring(5), "inventory")); } } ``` (on voit ici en bas registerRender et registerRenders) Mais aucun changement... De même avec : dinomeat.registerRenders(); dans clientproxy
-
Bah c’est bon tu n’as plus de problème avec ta variable (du moins j’en vois pas), tu as juste à appeler registerRenders dans ton proxy.
-
Je comprends pas… J’ai tout essayé ça veut pas:
package organisation; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class dinomeat { public static Item dinomeat; public static void init() { dinomeat = new Item().setUnlocalizedName("dinomeat").setCreativeTab(CreativeTabs.tabFood); } public static void register() { GameRegistry.registerItem(dinomeat, "dinomeat"); } public static void registerRenders() { } public static void registerRender() { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(dinomeat, 0, new ModelResourceLocation("modzoic" + ":dinomeat" + dinomeat.getUnlocalizedName().substring(5), "inventory")); } }
package fr.minecraftforgefrance.modzoic.common; import fr.minecraftforgefrance.modzoic.proxy.CommonProxy; import net.minecraft.creativetab.CreativeTabs; 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; import organisation.dinomeat; @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().setCreativeTab(CreativeTabs.tabFood); GameRegistry.registerItem(meatEpanterias, "meatEpanterias"); dinomeat.init(); dinomeat.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
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.creativetab.CreativeTabs; import organisation.dinomeat; import net.minecraft.client.renderer.entity.RenderItem; import organisation.dinomeat; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderItem registerMesher = Minecraft.getMinecraft().getRenderItem(); registerMesher.getItemModelMesher().register(Modzoic.meatEpanterias, 0, new ModelResourceLocation("modzoic" + ":meatEpanterias", "inventory")); dinomeat.registerRenders(); } }
(j’ai aussi essayé registerMesher.getItemModelMesher().register(Modzoic.dinomeat, 0, new ModelResourceLocation(“modzoic” + “:dinomeat”, “inventory”)); dans clientproxy mais ça me fait la même erreur que tout à l’heure)…