Résolu Register Block et Item
-
@‘Dylem’:
Tu devrais utiliser les events pour tes modèles aussi. En attendant de faire un tutoriel, je te mets ma classe d’items pour que tu puisses t’en inspirer :
package net.dylem.test_mod.init; import java.util.HashSet; import net.dylem.test_mod.client.renderer.MeshDefinitionFix; import net.dylem.test_mod.item.ItemBasic; import net.dylem.test_mod.item.ItemTestMod; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.registries.IForgeRegistry; /* * Déclare et instancie les items du mod */ public class ModItems { public static final ItemBasic ITEM_BASIC = new ItemBasic("item_basic"); /* * Contient tous les items enregistrés * HashSet -> pas de doublons */ public static final HashSet <itemtestmod>REGISTERED_ITEMS = new HashSet(); /* * Enregistre les items * Classe automatiquement abonnée à MinecraftForge.EVENT_BUS */ @Mod.EventBusSubscriber public static class RegistrationHandler { /* * Enregistre les items * @param event L'évènement */ @SubscribeEvent public static void registerItems(final RegistryEvent.Register event) { // Contient tous les items du mod, pas encore enregistrés final ItemTestMod[] items = { ITEM_BASIC, }; final IForgeRegistry registry = event.getRegistry(); /* * Pour chaque item, on l'enregistre à l'aide de l'évènement * Puis on l'ajoute au set d'item enregistrés, pour plus tard enregistrer son modèle */ for(final ItemTestMod item : items) { registry.register(item); REGISTERED_ITEMS.add(item); } } } /* * Enregistre les modèles des items * Classe automatiquement abonnée à MinecraftForge.EVENT_BUS côté CLIENT */ @Mod.EventBusSubscriber(Side.CLIENT) public static class ModelHandler { private static final ModelHandler INSTANCE = new ModelHandler(); /* * Enregistre les modèles des items * @Param event L'évènement */ @SubscribeEvent public static void registerItemModels(final ModelRegistryEvent event) { REGISTERED_ITEMS.forEach(item -> INSTANCE.registerItemModel(item, item.getStringRegistryName())); } /* * Enregistre le modèle d'un item * Etape 1 : Transforme le paramètre modelLocation en localisation complète de l'item * @Param item L'item * @Param modelLocation Le nom de l'item dans le registre */ private void registerItemModel(final ItemTestMod item, final String modelLocation) { final ModelResourceLocation fullModelLocation = new ModelResourceLocation(modelLocation, "inventory"); registerItemModel(item, fullModelLocation); } /* * Enregistre le modèle d'un item * Permet de récupérer la meshDefinition de l'item * @Param item L'item * @Param modelLocation la localisation complète de l'item */ private void registerItemModel(final ItemTestMod item, final ModelResourceLocation fullModelLocation) { ModelBakery.registerItemVariants(item, fullModelLocation); registerItemModel(item, MeshDefinitionFix.create(stack -> fullModelLocation)); } /* * Enregistre le modèle d'un item * @Param item L'item * @Param meshDefinition la meshDefinition de l'item */ private void registerItemModel(final ItemTestMod item, final ItemMeshDefinition meshDefinition) { ModelLoader.setCustomMeshDefinition(item, meshDefinition); } } } ```</itemtestmod>
Désolé mais j’arrive pas à comprendre comment on utilise les events…
Même si là tu me donnes un exemple j’arrive pas à comprendre ce que je dois utiliser et comment l’adapter à ma situation
Je préférais la pédagogie de Robin pour m’aider, il m’indique l’erreur, me montre ce que je dois ajouter ou modifier avec un exemple appliquer à mon cas puis je modifie tout les autres cas etc…
Avec ça je comprend beaucoup mieux et c’est plus avec la répétition d’une tâche, que je vais comprendre et savoir faire de moi même. (c’est comme ça que j’ai compris comment fonctionnait le faite de créer des objets, les modifier etc…)
Je sais pas du coup si tu as le temps ou si Robin pourrait me montrer un exemple appliquer à un de mes Items et l’un de mes blocks ?
Et du coup il va falloir que je modifie mes proxy client si je change ma façon de render les items non ?
Désolé encore mais j’utilise quasiment jamais les events et j’en avais jamais eu vraiment besoins jusque là donc je suis un peu perdu dans leurs utilisations -
Bon, pour faire simple en reprenant ton code :
1 - Dans ItemsMod, Remplace :
public static void registerRenders(final ModelRegistryEvent event) {
Par
@SideOnly(Side.CLIENT) @SubscribeEvent public static void registerRenders(final ModelRegistryEvent event)
2 - Dans BlocksMod, Remplace :
@SideOnly (Side.CLIENT) public static void registerItemBlockModels () {
Par :
@SideOnly (Side.CLIENT) @SubscribeEvent public static void registerItemBlockModels (final ModelRegistryEvent event){
3 - Dans ClientProxy, enlève ces deux lignes :
BlocksMod.registerItemBlockModels(); ItemsMod.registerRenders();
-
@‘Dylem’:
Bon, pour faire simple en reprenant ton code :
1 - Dans ItemsMod, Remplace :
public static void registerRenders(final ModelRegistryEvent event) {
Par
@SideOnly(Side.CLIENT) @SubscribeEvent public static void registerRenders(final ModelRegistryEvent event)
2 - Dans BlocksMod, Remplace :
@SideOnly (Side.CLIENT) public static void registerItemBlockModels () {
Par :
@SideOnly (Side.CLIENT) @SubscribeEvent public static void registerItemBlockModels (final ModelRegistryEvent event){
3 - Dans ClientProxy, enlève ces deux lignes :
BlocksMod.registerItemBlockModels(); ItemsMod.registerRenders();
Merci beaucoup à toi, c’est très gentil d’avoir pris le temps de m’aider ^^
Un dernier petit truc, je pensais que les crafts passaient maintenant uniquement par des fichiers json dans les assets avec le dossier recipies, mais apparemment je me trompe, ou en tout cas il faut autre chose, ou j’ai fait une erreur. Si tu as la solution et que tu as le temps de check vite fait, ou de me donner la nouvelle méthode pour les faire ça serait très gentil à toiSinon +2 pour ta réputation ^^
-
Merci pour la réput
Juste un truc, avant @SidedProxy (dans ta classe principale), ajoute :
@Instance(Reference.MOD_ID) public static TestMod Instance;
Ca permet au mod d’instancier les annotations @Mod directement.
Pour les recettes, tu dois ajouter les json dans assets/modid/recipes
Tu peux t’inspirer des recettes de Minecraft (dans assets/minecraft/recipes), rajoute juste minecraft: devant crafting_shaped.
Et…. C’est tout ! Les recettes sont automatiquement load et enregistrées par forge.Petit exemple quand même en imaginant que ton mod crée une hache en émeraude :
{ "type": "minecraft:crafting_shaped", "pattern": [ "XX", "X#", " #" ], "key": { "#": { "item": "minecraft:stick" }, "X": { "item": "minecraft:emerald" } }, "result": { "item": "modid:emerald_axe" } }
-
@‘Dylem’:
Merci pour la réput
Juste un truc, avant @SidedProxy (dans ta classe principale), ajoute :
@Instance(Reference.MOD_ID) public static TestMod Instance;
Ca permet au mod d’instancier les annotations @Mod directement.
Pour les recettes, tu dois ajouter les json dans assets/modid/recipes
Tu peux t’inspirer des recettes de Minecraft (dans assets/minecraft/recipes), rajoute juste minecraft: devant crafting_shaped.
Et…. C’est tout ! Les recettes sont automatiquement load et enregistrées par forge.Petit exemple quand même en imaginant que ton mod crée une hache en émeraude :
{ "type": "minecraft:crafting_shaped", "pattern": [ "XX", "X#", " #" ], "key": { "#": { "item": "minecraft:stick" }, "X": { "item": "minecraft:emerald" } }, "result": { "item": "modid:emerald_axe" } }
J’ai déjà créer les json mais c’est gentil quand même ah ah.
Bon par contre quand je met ton “@Instance(Reference.MOD_ID)” au dessus du “@SidedProxy”, et bien ça fait crash le jeu
voilà le crash log:
2017-07-15 00:04:10,897 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-15 00:04:10,899 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [00:04:11] [main/INFO] [GradleStart]: Extra: [] [00:04:11] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/Zules perrin/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [00:04:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [00:04:11] [main/INFO] [FML]: Forge Mod Loader version 14.21.1.2410 for Minecraft 1.12 loading [00:04:11] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_121, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_121 [00:04:11] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [00:04:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [00:04:11] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [00:04:11] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [00:04:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [00:04:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper 2017-07-15 00:04:11,480 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-15 00:04:11,760 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-07-15 00:04:11,761 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [00:04:12] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [00:04:12] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [00:04:12] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [00:04:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [00:04:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [00:04:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [00:04:13] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [00:04:14] [main/INFO]: Setting user: Player659 [00:04:17] [main/WARN]: Skipping bad option: lastServer: [00:04:17] [main/INFO]: LWJGL Version: 2.9.4 [00:04:19] [main/INFO] [FML]: – System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 728148984 bytes (694 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 384.76' Renderer: 'GeForce GTX 1060 6GB/PCIe/SSE2' [00:04:19] [main/INFO] [FML]: MinecraftForge v14.21.1.2410 Initialized [00:04:19] [main/INFO] [FML]: Replaced 921 ore ingredients [00:04:19] [main/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [00:04:19] [main/INFO] [FML]: Searching C:\Users\Zules perrin\Desktop\AdamantiumMod\run\mods for mods [00:04:20] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load [00:04:21] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, adamantium] at CLIENT [00:04:21] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, adamantium] at SERVER [00:04:21] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 73165886 nanos [00:04:21] [main/FATAL] [FML]: Fatal errors were detected during the transition from CONSTRUCTING to PREINITIALIZATION. Loading cannot continue [00:04:21] [main/FATAL] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC minecraft{1.12} [Minecraft] (minecraft.jar) UC mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UC FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2410.jar) UC forge{14.21.1.2410} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2410.jar) UE adamantium{1.0.0} [Adamantium] (bin) [00:04:21] [main/FATAL] [FML]: The following problems were captured during this phase [00:04:21] [main/ERROR] [FML]: Caught exception from adamantium (java.lang.IllegalArgumentException: Can not set static fr.jules552.mod.proxy.CommonProxy field fr.jules552.mod.Adamantium.proxy to fr.jules552.mod.Adamantium) [00:04:21] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:630]: –-- Minecraft Crash Report ---- // Don't be sad. I'll do better next time, I promise! Time: 7/15/17 12:04 AM Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Adamantium (adamantium) Caused by: java.lang.IllegalArgumentException: Can not set static fr.jules552.mod.proxy.CommonProxy field fr.jules552.mod.Adamantium.proxy to fr.jules552.mod.Adamantium at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeStaticObjectFieldAccessorImpl.set(Unknown Source) at java.lang.reflect.Field.set(Unknown Source) at net.minecraftforge.fml.common.FMLModContainer.parseSimpleFieldAnnotation(FMLModContainer.java:514) at net.minecraftforge.fml.common.FMLModContainer.processFieldAnnotations(FMLModContainer.java:444) at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:608) 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.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:252) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:230) 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.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147) at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:570) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:227) at net.minecraft.client.Minecraft.init(Minecraft.java:508) at net.minecraft.client.Minecraft.run(Minecraft.java:416) 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:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.12 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 765958160 bytes (730 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.40 Powered by Forge 14.21.1.2410 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC minecraft{1.12} [Minecraft] (minecraft.jar) UC mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UC FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2410.jar) UC forge{14.21.1.2410} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2410.jar) UE adamantium{1.0.0} [Adamantium] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 384.76' Renderer: 'GeForce GTX 1060 6GB/PCIe/SSE2' [00:04:21] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:630]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Zules perrin\Desktop\AdamantiumMod\run\.\crash-reports\crash-2017-07-15_00.04.21-client.txt Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
et donc ma class principale si tu veux voir comment j’ai procédé:
package fr.jules552.mod; import fr.jules552.mod.WorldGeneration.GenerationHelper; import fr.jules552.mod.init.BlocksMod; import fr.jules552.mod.init.ItemsMod; import fr.jules552.mod.proxy.CommonProxy; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; 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 net.minecraftforge.oredict.OreDictionary; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION) public class Adamantium { @Instance(Reference.MOD_ID) @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } @EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
-
t’as oublié le
public static TestMod Instance;
Relis mon message
-
@‘Dylem’:
t’as oublié le
public static TestMod Instance;
Relis mon message
Bon effectivement je suis un peu bête et précipité parfois ah ah,
par contre ça ne charge toujours pas les crafts (sauf genre pour les items pour la hache, mais là le block d’adamantium ça fonctionne pas :/)voilà un exemple d’un de mes fichiers json:
{ "type": "minecraft:crafting_shaped", "pattern": [ "###", "###", "###" ], "key": { "#": { "item": "adamantium:adamantium_ingot" } }, "result": { "item": "adamantium:adamantium_block", } }
Je n’y vois aucune erreur et pourtant, si tu veux la log indique ça:
[01:05:27] [main/ERROR] [FML]: Parsing error loading recipe adamantium:adamantium_block com.google.gson.JsonParseException: com.google.gson.stream.MalformedJsonException: Expected name at line 15 column 4 path $.result.item at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:439) ~[JsonUtils.class:?] at net.minecraft.util.JsonUtils.fromJson(JsonUtils.java:485) ~[JsonUtils.class:?] at net.minecraftforge.common.crafting.CraftingHelper.lambda$loadRecipes$21(CraftingHelper.java:699) ~[CraftingHelper.class:?] at net.minecraftforge.common.crafting.CraftingHelper.findFiles(CraftingHelper.java:790) ~[CraftingHelper.class:?] at net.minecraftforge.common.crafting.CraftingHelper.loadRecipes(CraftingHelper.java:659) ~[CraftingHelper.class:?] at java.util.ArrayList.forEach(Unknown Source) [?:1.8.0_121] at net.minecraftforge.common.crafting.CraftingHelper.loadRecipes(CraftingHelper.java:614) [CraftingHelper.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:779) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:343) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:576) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:416) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: com.google.gson.stream.MalformedJsonException: Expected name at line 15 column 4 path $.result.item at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559) ~[JsonReader.class:?] at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:505) ~[JsonReader.class:?] at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:414) ~[JsonReader.class:?] at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:738) ~[TypeAdapters$29.class:?] at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739) ~[TypeAdapters$29.class:?] at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714) ~[TypeAdapters$29.class:?] at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.java:910) ~[TypeAdapters$35$1.class:?] at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:435) ~[JsonUtils.class:?] … 23 moreradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?]
il m’indique l’erreur à la ligne 15 mais ce n’est juste qu’un crochet la ligne 15 donc et la synthaxe est directement copié de celle du block de diamant donc ça me parait bizarre, tu aurais une solution pour ça ?
-
“item”: “adamantium:adamantium_block”,
Retires la virgule ici.
Un outil utile : https://jsonlint.com/ -
@‘robin4002’:
“item”: “adamantium:adamantium_block”,
Retires la virgule ici.
Un outil utile : https://jsonlint.com/Merci à vous deux de votre aide !
Je cloture ce sujet ^^