Résolu Crash au lancement du jeu
-
Bonjour,
J’ai un problème avec mon mod, au lancement il plante et en regardant dans le crash report j’ai ça :java.lang.NullPointerException: Initializing game
at com.hybride.mod.init.ItemMod.init(Unknown Source)
at com.hybride.mod.HybrideMod.preInit(Unknown Source)
J’ai regardé dans les class et je n’ai pas trouvé de problème. D’où ça peut venir ?
La class Hybridemod :package com.hybride.mod; import com.hybride.mod.init.BlockMod; import com.hybride.mod.init.ItemMod; import com.hybride.mod.proxy.CommonProxy; import com.hybride.mod.world.WorldRegister; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @Mod (modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class HybrideMod { public static final Object instance = null; @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; public static CreativeTabs HybrideMod = new CreativeTabs("HybrideMod") { @SideOnly(Side.CLIENT) public Item getTabIconItem() { return ItemMod.rubis_ingot; } }; @EventHandler public void preInit(FMLPreInitializationEvent event) { ItemMod.init(); ItemMod.register(); BlockMod.init(); BlockMod.register(); WorldRegister.MainRegistry(); GameRegistry.addRecipe(new ItemStack(ItemMod.rubis_hammer, 1), new Object[] {"#I#","#I#"," P ", '#', BlockMod.rubis_block, 'I', Items.iron_ingot, 'P', Items.stick}); } @EventHandler public void Init(FMLInitializationEvent event) { } @EventHandler public void postInit(FMLPostInitializationEvent event) { } };
Et la class ItemMod :
package com.hybride.mod.init; import com.hybride.mod.HybrideMod; import com.hybride.mod.Reference; import com.hybride.mod.items.AmethystArmor; import com.hybride.mod.items.ItemAgatePickaxe; import com.hybride.mod.items.ItemArmorRubis; import com.hybride.mod.items.ItemFoodMod; import com.hybride.mod.items.rubis_hammer; import com.hybride.mod.items.ItemPickaxeTest; import com.hybride.mod.items.ItemSwordAgate; import com.hybride.mod.items.ItemSwordTest; import com.hybride.mod.tems.ItemMods; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.EnumHelper; public class ItemMod { public static ToolMaterial toolRubis = EnumHelper.addToolMaterial("toolRubis", 3, 2000, 3, 2, 30); public static ToolMaterial toolAgate = EnumHelper.addToolMaterial("toolRubis", 3, 2000, 3, 4, 30); public static ArmorMaterial armorRubis = EnumHelper.addArmorMaterial("armorRubis", 38, new int[] {1, 4, 4, 1}, 25); public static ArmorMaterial armorAmethyst = EnumHelper.addArmorMaterial("armorAmethyst", 38, new int[] {2, 4, 4, 2}, 25); public static Item dynamite, money, amethyst_helmet, amethyst_chestplate, amethyst_leggings, amethyst_boots, amethyst_ingot, orange, agate_pickaxe, agate_sword, rubis_hammer, burger, item_sword, item_pickaxe, casqueArmor, plastronArmor, pantalonArmor, botteArmor, rubis_ingot, speed_boost, agate_bleue_ingot, fraise; public static void init() { EntityRegistry.registerModEntity(EntityDynamite.class, "EntityDynamite", 420, HybrideMod.instance, 32, 20, false); amethyst_helmet = new AmethystArmor(armorAmethyst, 0).setCreativeTab(HybrideMod.HybrideMod).setUnlocalizedName("amethyst_helmet").setTextureName(Reference.MOD_ID+":amethyst_helmet"); amethyst_chestplate = new AmethystArmor(armorAmethyst, 1).setCreativeTab(HybrideMod.HybrideMod).setUnlocalizedName("amethyst_chestplate").setTextureName(Reference.MOD_ID+":amethyst_chestplate"); amethyst_leggings = new AmethystArmor(armorAmethyst, 2).setCreativeTab(HybrideMod.HybrideMod).setUnlocalizedName("amethyst_leggings").setTextureName(Reference.MOD_ID+":amethyst_leggings"); amethyst_boots = new AmethystArmor(armorAmethyst, 3).setCreativeTab(HybrideMod.HybrideMod).setUnlocalizedName("amethyst_boots").setTextureName(Reference.MOD_ID+":amethyst_boots"); rubis_ingot = new Item().setUnlocalizedName("rubis_ingot").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":rubis_ingot"); item_sword = new ItemSwordTest(toolRubis).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":item_sword").setUnlocalizedName("item_pickaxe"); item_pickaxe = new ItemPickaxeTest(ItemMod.toolRubis).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":item_pickaxe").setUnlocalizedName("item_pickaxe"); casqueArmor = new ItemArmorRubis(armorRubis, 0).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":casquearmor").setUnlocalizedName("casqueArmor"); plastronArmor = new ItemArmorRubis(armorRubis, 1).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":plastronarmor").setUnlocalizedName("plastronArmor"); pantalonArmor = new ItemArmorRubis(armorRubis, 2).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":pantalonarmor").setUnlocalizedName("pantalonArmor"); botteArmor = new ItemArmorRubis(armorRubis, 3).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":bottearmor").setUnlocalizedName("botteArmor"); speed_boost = new ItemMods().setUnlocalizedName("speed_boost").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":speed_boost"); agate_bleue_ingot = new Item().setUnlocalizedName("agate_bleue_ingot").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":agate_blue_ingot"); fraise = new ItemFoodMod(1, 0, false).setUnlocalizedName("fraise").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":fraise"); orange = new ItemFoodMod(4, 0, false).setUnlocalizedName("orange").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":orange"); burger = new ItemFoodMod(6, 0, false).setUnlocalizedName("burger").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":burger"); rubis_hammer = new rubis_hammer(toolRubis).setUnlocalizedName("rubis_hammer").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":rubis_hammer"); agate_sword = new ItemSwordAgate(toolAgate).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":agate_sword").setUnlocalizedName("agate_sword"); agate_pickaxe = new ItemAgatePickaxe(ItemMod.toolAgate).setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":agate_pickaxe").setUnlocalizedName("agate_pickaxe"); amethyst_ingot = new Item().setUnlocalizedName("amethyst_ingot").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":amethyst_ingot"); money = new Item().setUnlocalizedName("money").setCreativeTab(HybrideMod.HybrideMod).setTextureName(Reference.MOD_ID+":money"); dynamite = new Dynamite().setUnlocalizedName("dynamite").setTextureName(Reference.MOD_ID+":dynamite"); } public static void register() { GameRegistry.registerItem(orange, "orange"); GameRegistry.registerItem(dynamite, "dynamite"); GameRegistry.registerItem(money, "money"); GameRegistry.registerItem(amethyst_ingot, "amethyst_ingot"); GameRegistry.registerItem(rubis_ingot,"rubis_ingot"); GameRegistry.registerItem(item_sword, "item_sword"); GameRegistry.registerItem(item_pickaxe, "item_pickaxe"); GameRegistry.registerItem(casqueArmor, "casque_armor"); GameRegistry.registerItem(plastronArmor, "plastron_armor"); GameRegistry.registerItem(pantalonArmor, "pantalon_armor"); GameRegistry.registerItem(botteArmor, "botte_armor"); GameRegistry.registerItem(amethyst_helmet, "amethys_thelmet"); GameRegistry.registerItem(amethyst_chestplate, "amet_hystchestplate"); GameRegistry.registerItem(amethyst_leggings, "amethyst_leggings"); GameRegistry.registerItem(amethyst_boots, "amethyst_boots"); GameRegistry.registerItem(speed_boost, "speed_boost"); GameRegistry.registerItem(agate_bleue_ingot, "agate_bleue_ingot"); GameRegistry.registerItem(fraise, "fraise"); GameRegistry.registerItem(burger, "burger"); GameRegistry.registerItem(rubis_hammer, "rubis_hammer"); GameRegistry.registerItem(agate_sword, "agate_sword"); GameRegistry.registerItem(agate_pickaxe, "agate_pickaxe"); GameRegistry.addRecipe(new ItemStack(ItemMod.casqueArmor, 1), new Object[] {"###","# #"," ", '#', ItemMod.rubis_ingot}); GameRegistry.addRecipe(new ItemStack(ItemMod.plastronArmor, 1), new Object[] {"# #","###","###", '#', ItemMod.rubis_ingot}); GameRegistry.addRecipe(new ItemStack(ItemMod.pantalonArmor, 1), new Object[] {"###","# #","# #", '#', ItemMod.rubis_ingot}); GameRegistry.addRecipe(new ItemStack(ItemMod.botteArmor, 1), new Object[] {" ","# #","# #", '#', ItemMod.rubis_ingot}); GameRegistry.addRecipe(new ItemStack(ItemMod.burger, 1), new Object[] {"BBB"," # ","BBB", '#', Items.chicken, 'B', Items.bread}); } }
-
Bonsoir,
Les numéros de ligne n’apparaissent pas du tout ?
Tu as le crash en lançant ton jeu depuis un ide ou uniquement en lançant depuis le launcher de Minecraft ? -
bonjour,
Non il n’y a pas de numéro de ligne. Et en le lançant depuis le launcher. Depuis l’ide il se lance carrément pas. -
Tu as quoi quand tu lances depuis l’ide ?
Tu peux envoyer les logs ? -
Depuis l’IDE j’ai ça :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at org.lwjgl.Sys$1.run(Sys.java:73) at java.security.AccessController.doPrivileged(Native Method) at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) at org.lwjgl.Sys.loadLibrary(Sys.java:95) at org.lwjgl.Sys.<clinit>(Sys.java:112) at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:2818) at net.minecraft.client.main.Main.main(Main.java:79)
le crash report : https://pastebin.com/F0jDTHeL
les logs complet : https://pastebin.com/Q7Dh5esc -
Pour le lancement sur ton ide : la task de génération des fichiers de run a surement merdé car il manque lwjgl dans le classpath.
Et concernant le crash j’ai trouvé, ton instance est null dans la classe principale car il manque le
@Instance(Reference.MOD_ID)
au-dessus. L’enregistrement d’entité ayant besoin d’une instance valide, ça crash quand il arrive sur cette endroit. -
Merci bien, ça fonctionne maintenant. Pour le lancement du coup je peux faire comment ?
-
Relancer le task de ton ide (gradlew eclipse pour eclipse et je ne sais plus quoi pour idea).
-
Je l’ai fais ça fonctionne pas. C’est pas bien grave tant que le mod fonctionne.