1.12.2 Erreur metatdata avec "item.RegistryName()"



  • Bonjour, bonsoir,
    aujourd'hui j'ai voulu rajouter un item à mon mod en 1.12.2 mais dans la partie metatdata, RegistryName a affiché une erreur.
    Pour re-situer l'endroit:

    @SideOnly(Side.CLIENT)
        public static void registerModel(Item item, int metadata)
        {
            if (metadata < 0) metadata = 0;
            String resourceName = item.getRegistryName();
            if (metadata > 0) resourceName += "_m" + String.valueOf(metadata);
    
            ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(resourceName, "inventory"));
    
     }
    
    item.getRegistryName();
    

    Quand je veux "réparer" cette erreur, je passe mon curseur dessus, éclipse me dit:
    Change type of 'ResourceName' to 'ResourceLocation'.
    J'ai essayé mais c'est la ligne du dessous qui indique une erreur et me demande de remettre comme c'était.
    Je me suis dit que mon IDE avait un problème d'affichage, j'ai essayé de lancer le jeu malgré tout mais ça n'a pas fonctionné: le jeu a crash.
    ici le crash report si ça peut être utile:

    ---- Minecraft Crash Report ----
    // I bet Cylons wouldn't have this problem.
    
    Time: 5/23/20 5:25 PM
    Description: Initializing game
    
    java.lang.Error: Unresolved compilation problem: 
    	Type mismatch: cannot convert from ResourceLocation to String
    
    	at fr.reilov18.mineria.items.MineriaItems.registerModel(MineriaItems.java:37)
    	at fr.reilov18.mineria.items.MineriaItems.registerItemModels(MineriaItems.java:29)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_MineriaItems_registerItemModels_ModelRegistryEvent.invoke(.dynamic)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    	at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1062)
    	at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:764)
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:631)
    	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:514)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:422)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	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:25)
    
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Thread: Client thread
    Stacktrace:
    	at fr.reilov18.mineria.items.MineriaItems.registerModel(MineriaItems.java:37)
    	at fr.reilov18.mineria.items.MineriaItems.registerItemModels(MineriaItems.java:29)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_MineriaItems_registerItemModels_ModelRegistryEvent.invoke(.dynamic)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    	at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1062)
    	at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:764)
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:631)
    	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:514)
    
    -- Initialization --
    Details:
    Stacktrace:
    	at net.minecraft.client.Minecraft.run(Minecraft.java:422)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	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:25)
    
    -- System Details --
    Details:
    	Minecraft Version: 1.12.2
    	Operating System: Windows 7 (amd64) version 6.1
    	Java Version: 1.8.0_241, Oracle Corporation
    	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    	Memory: 728513168 bytes (694 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    	FML: MCP 9.42 Powered by Forge 14.23.5.2847 6 mods loaded, 6 mods active
    	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    
    	| State | ID            | Version      | Source                           | Signature |
    	|:----- |:------------- |:------------ |:-------------------------------- |:--------- |
    	| LCH   | minecraft     | 1.12.2       | minecraft.jar                    | None      |
    	| LCH   | mcp           | 9.42         | minecraft.jar                    | None      |
    	| LCH   | FML           | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2847.jar | None      |
    	| LCH   | forge         | 14.23.5.2847 | forgeSrc-1.12.2-14.23.5.2847.jar | None      |
    	| LCH   | examplemod    | 1.0          | bin                              | None      |
    	| LCH   | mineriathemod | 1.0          | bin                              | None      |
    
    	Loaded coremods (and transformers): 
    	GL info: ' Vendor: 'NVIDIA Corporation' Version: '3.1 NVIDIA 188.17' Renderer: 'GeForce G105M/PCI/SSE2'
    	Launched Version: 1.12.2
    	LWJGL: 2.9.4
    	OpenGL: GeForce G105M/PCI/SSE2 GL version 3.1 NVIDIA 188.17, NVIDIA Corporation
    	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: Yes
    	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)
    	CPU: 4x Intel(R) Core(TM) i3 CPU M 330 @ 2.13GHz
    

    Merci d'avance pour votre réponse,
    Cordialement,
    Reilov.


  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonsoir,
    Remplaces new ModelResourceLocation(resourceName, "inventory") par new ModelResourceLocation(resourceName.toString(), "inventory") ?



  • Salut,
    Remplaces new ModelResourceLocation(resourceName, "inventory") par new ModelResourceLocation(new ResourceLocation(TON_MODID, resourceName), "inventory")



  • Je vais essayer dès que possible merci!



  • Bonjour,
    désolé j'ai eu quelques problèmes de pc mais j'ai finalement pu essayer vos deux techniques et celle de Eno_gamer10 a marché!
    Merci ^^


Log in to reply