[1.7.10] Un liquid qui me fait crash...



  • Bonjour / Bonsoir a toutes et a tous, voila mon problème :
    J'ai ce crash-report lors du lancement du jeu.

    java.lang.NullPointerException: Initializing game
    	at com.novatech.mod.common.ModTutoriel.preInit(ModTutoriel.java:77)
    

    Le problème c'est qu'a la ligne "77" il n'y a que cela :

    if(antiWater.getBlock() == null)
    

    Depuis ma classe principale :

    package com.novatech.mod.common;
    import com.novatech.mod.client.TextureEvent;
    import com.novatech.mod.proxy.CommonProxy;
    
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.Mod.Instance;
    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 net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    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.MinecraftForge;
    import net.minecraftforge.common.util.EnumHelper;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidContainerRegistry;
    import net.minecraftforge.fluids.FluidRegistry;
    
    @Mod(modid = "modtutoriel", name = "Mod NovaTech", version = "1.0.0")
    
    public class ModTutoriel
    {   
        @Instance("modtutoriel")
        public static ModTutoriel instance;
        public static final String MODID = "modtutoriel";
        
        @SidedProxy(clientSide = "com.novatech.mod.proxy.ClientProxy", serverSide = "com.novatech.mod.proxy.CommonProxy")
        public static CommonProxy proxy;
        
        public static Block antiWaterBlock;
        public static Fluid antiWater;
        public static Item antiWaterBucket;
        
        public static Item nikraniumIngot, angelicRing, demonicRing;
        public static Item nikraniumHelmet, nikraniumChestplate, nikraniumLeggings, nikraniumBoots;
        public static Item nikraniumSword, nikraniumPickaxe, nikraniumAxe, nikraniumShovel;
        
        public static Block nikraniumOre, nikraniumBlock;
        
        public static ArmorMaterial nikraniumArmor = EnumHelper.addArmorMaterial("nikraniumArmor", 25, new int[] {5, 7, 6, 5}, 30);
        public static ToolMaterial nikraniumTool = EnumHelper.addToolMaterial("nikraniumTool", 2, 1600, 12.0F, 5.0F, 25);
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {       
                    
            //Fluid
            antiWater = new Fluid("antiwater").setDensity(4000).setViscosity(500).setTemperature(286).setLuminosity(10).setUnlocalizedName("antiWater");
            FluidRegistry.registerFluid(antiWater);
            antiWater = FluidRegistry.getFluid("antiWater");
            
            if(antiWater.getBlock() == null)
            {
                antiWaterBlock = new BlockFluidTutorial(antiWater, Material.water).setBlockName("antiWater");
                GameRegistry.registerBlock(antiWaterBlock, "antiWater");
                antiWater.setBlock(antiWaterBlock);
            }
            else
            {
                antiWaterBlock = antiWater.getBlock();
            }
            
            //Items
            antiWaterBucket = new ItemBucketPoison(antiWaterBlock).setUnlocalizedName("bucketTutorial").setTextureName("modtutoriel:bucketTutorial");
            nikraniumIngot = new NikraniumIngot().setUnlocalizedName("nikraniumIngot").setTextureName(ModTutoriel.MODID + ":nikraniumIngot").setCreativeTab(CreativeTabs.tabMaterials);
            angelicRing = new AngelicRing().setUnlocalizedName("angelicRing").setTextureName(ModTutoriel.MODID + ":angelicRing").setCreativeTab(CreativeTabs.tabMaterials);
            demonicRing = new DemonicRing().setUnlocalizedName("demonicRing").setTextureName(ModTutoriel.MODID + ":demonicRing").setCreativeTab(CreativeTabs.tabMaterials);
            nikraniumHelmet = new NikraniumArmor(nikraniumArmor, 0).setUnlocalizedName("nikraniumHelmet").setTextureName(MODID + ":nikraniumHelmet");
            nikraniumChestplate = new NikraniumArmor(nikraniumArmor, 1).setUnlocalizedName("nikraniumChestplate").setTextureName(MODID + ":nikraniumChestplate");
            nikraniumLeggings = new NikraniumArmor(nikraniumArmor, 2).setUnlocalizedName("nikraniumLeggings").setTextureName(MODID + ":nikraniumLeggings");
            nikraniumBoots = new NikraniumArmor(nikraniumArmor, 3).setUnlocalizedName("nikraniumBoots").setTextureName(MODID + ":nikraniumBoots");
            nikraniumSword = new NikraniumSword(nikraniumTool).setUnlocalizedName("nikraniumSword").setTextureName(MODID + ":nikraniumSword");
            nikraniumPickaxe = new NikraniumPickaxe(nikraniumTool).setUnlocalizedName("nikraniumPickaxe").setTextureName(MODID + ":nikraniumPickaxe");
            nikraniumAxe = new NikraniumAxe(nikraniumTool).setUnlocalizedName("nikraniumAxe").setTextureName(MODID + ":nikraniumAxe");
            nikraniumShovel = new NikraniumShovel(nikraniumTool).setUnlocalizedName("nikraniumShovel").setTextureName(MODID + ":nikraniumShovel");
            
            //Blocks
            nikraniumOre = new NikraniumOre(Material.rock).setBlockName("nikraniumOre").setBlockTextureName(MODID + ":nikraniumOre").setCreativeTab(CreativeTabs.tabBlock).setHardness(1.5F).setResistance(10.0F);
            nikraniumBlock = new NikraniumBlock(Material.rock).setBlockName("nikraniumBlock").setBlockTextureName(MODID + ":nikraniumBlock").setCreativeTab(CreativeTabs.tabBlock).setHardness(1.5F).setResistance(10.0F);
            
            
            GameRegistry.registerBlock(nikraniumOre, "nikraniumOre");
            GameRegistry.registerBlock(nikraniumBlock, "nikraniumBlock");
            
            GameRegistry.registerItem(nikraniumIngot, "nikraniumIngot");
            GameRegistry.registerItem(angelicRing, "angelicRing");
            GameRegistry.registerItem(demonicRing, "demonicRing");
            GameRegistry.registerItem(nikraniumHelmet, "nikraniumHelmet");
            GameRegistry.registerItem(nikraniumChestplate, "nikraniumChestplate");
            GameRegistry.registerItem(nikraniumLeggings, "nikraniumLeggings");
            GameRegistry.registerItem(nikraniumBoots, "nikraniumBoots");
            GameRegistry.registerItem(nikraniumSword, "nikraniumSword");
            GameRegistry.registerItem(nikraniumPickaxe, "nikraniumPickaxe");
            GameRegistry.registerItem(nikraniumAxe, "nikraniumAxe");
            GameRegistry.registerItem(nikraniumShovel, "nikraniumShovel");
            GameRegistry.registerItem(antiWaterBucket, "antiWaterBucket");
            
            FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("antiWater", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(antiWaterBucket), FluidContainerRegistry.EMPTY_BUCKET);
        }
        
        @EventHandler
        public void Init(FMLInitializationEvent event)
        {
            proxy.registerRender();
            MinecraftForge.EVENT_BUS.register(new LivingEventHandler());
            MinecraftForge.EVENT_BUS.register(new TextureEvent());
            MinecraftForge.EVENT_BUS.register(new BucketEvent());
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event)
        {
            
        }
    }
    

    Je n'arrives pas a mettre le doigt sur le problème car je ne vois absolument pas ce a quoi il est dû. J'espère que vous pourrez éclairer ma lanterne sur ce point, merci bien 😊



  • package com.novatech.mod.common;
    import com.novatech.mod.client.TextureEvent;
    import com.novatech.mod.proxy.CommonProxy;
    
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.Mod.Instance;
    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 net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    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.MinecraftForge;
    import net.minecraftforge.common.util.EnumHelper;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidContainerRegistry;
    import net.minecraftforge.fluids.FluidRegistry;
    
    @Mod(modid = "modtutoriel", name = "Mod NovaTech", version = "1.0.0")
    
    public class ModTutoriel
    {   
        @Instance("modtutoriel")
        public static ModTutoriel instance;
        public static final String MODID = "modtutoriel";
        
        @SidedProxy(clientSide = "com.novatech.mod.proxy.ClientProxy", serverSide = "com.novatech.mod.proxy.CommonProxy")
        public static CommonProxy proxy;
        
        public static Block antiWaterBlock;
        public static Fluid antiWater;
        public static Item antiWaterBucket;
        
        public static Item nikraniumIngot, angelicRing, demonicRing;
        public static Item nikraniumHelmet, nikraniumChestplate, nikraniumLeggings, nikraniumBoots;
        public static Item nikraniumSword, nikraniumPickaxe, nikraniumAxe, nikraniumShovel;
        
        public static Block nikraniumOre, nikraniumBlock;
        
        public static ArmorMaterial nikraniumArmor = EnumHelper.addArmorMaterial("nikraniumArmor", 25, new int[] {5, 7, 6, 5}, 30);
        public static ToolMaterial nikraniumTool = EnumHelper.addToolMaterial("nikraniumTool", 2, 1600, 12.0F, 5.0F, 25);
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {       
                    
            //Fluid
            antiWater = new Fluid("antiwater").setDensity(4000).setViscosity(500).setTemperature(286).setLuminosity(10).setUnlocalizedName("antiWater");
            FluidRegistry.registerFluid(antiWater);
            antiWater = FluidRegistry.getFluid("antiWater");
            
            //Items
            antiWaterBucket = new ItemBucketPoison(antiWaterBlock).setUnlocalizedName("bucketTutorial").setTextureName("modtutoriel:bucketTutorial");
            nikraniumIngot = new NikraniumIngot().setUnlocalizedName("nikraniumIngot").setTextureName(ModTutoriel.MODID + ":nikraniumIngot").setCreativeTab(CreativeTabs.tabMaterials);
            angelicRing = new AngelicRing().setUnlocalizedName("angelicRing").setTextureName(ModTutoriel.MODID + ":angelicRing").setCreativeTab(CreativeTabs.tabMaterials);
            demonicRing = new DemonicRing().setUnlocalizedName("demonicRing").setTextureName(ModTutoriel.MODID + ":demonicRing").setCreativeTab(CreativeTabs.tabMaterials);
            nikraniumHelmet = new NikraniumArmor(nikraniumArmor, 0).setUnlocalizedName("nikraniumHelmet").setTextureName(MODID + ":nikraniumHelmet");
            nikraniumChestplate = new NikraniumArmor(nikraniumArmor, 1).setUnlocalizedName("nikraniumChestplate").setTextureName(MODID + ":nikraniumChestplate");
            nikraniumLeggings = new NikraniumArmor(nikraniumArmor, 2).setUnlocalizedName("nikraniumLeggings").setTextureName(MODID + ":nikraniumLeggings");
            nikraniumBoots = new NikraniumArmor(nikraniumArmor, 3).setUnlocalizedName("nikraniumBoots").setTextureName(MODID + ":nikraniumBoots");
            nikraniumSword = new NikraniumSword(nikraniumTool).setUnlocalizedName("nikraniumSword").setTextureName(MODID + ":nikraniumSword");
            nikraniumPickaxe = new NikraniumPickaxe(nikraniumTool).setUnlocalizedName("nikraniumPickaxe").setTextureName(MODID + ":nikraniumPickaxe");
            nikraniumAxe = new NikraniumAxe(nikraniumTool).setUnlocalizedName("nikraniumAxe").setTextureName(MODID + ":nikraniumAxe");
            nikraniumShovel = new NikraniumShovel(nikraniumTool).setUnlocalizedName("nikraniumShovel").setTextureName(MODID + ":nikraniumShovel");
            
            //Blocks
            nikraniumOre = new NikraniumOre(Material.rock).setBlockName("nikraniumOre").setBlockTextureName(MODID + ":nikraniumOre").setCreativeTab(CreativeTabs.tabBlock).setHardness(1.5F).setResistance(10.0F);
            nikraniumBlock = new NikraniumBlock(Material.rock).setBlockName("nikraniumBlock").setBlockTextureName(MODID + ":nikraniumBlock").setCreativeTab(CreativeTabs.tabBlock).setHardness(1.5F).setResistance(10.0F);
            
            if(antiWater.getBlock() == null)
            {
                antiWaterBlock = new BlockFluidTutorial(antiWater, Material.water).setBlockName("antiWater");
                GameRegistry.registerBlock(antiWaterBlock, "antiWater");
                antiWater.setBlock(antiWaterBlock);
            }
            else
            {
                antiWaterBlock = antiWater.getBlock();
            }
            GameRegistry.registerBlock(nikraniumOre, "nikraniumOre");
            GameRegistry.registerBlock(nikraniumBlock, "nikraniumBlock");
            
            GameRegistry.registerItem(nikraniumIngot, "nikraniumIngot");
            GameRegistry.registerItem(angelicRing, "angelicRing");
            GameRegistry.registerItem(demonicRing, "demonicRing");
            GameRegistry.registerItem(nikraniumHelmet, "nikraniumHelmet");
            GameRegistry.registerItem(nikraniumChestplate, "nikraniumChestplate");
            GameRegistry.registerItem(nikraniumLeggings, "nikraniumLeggings");
            GameRegistry.registerItem(nikraniumBoots, "nikraniumBoots");
            GameRegistry.registerItem(nikraniumSword, "nikraniumSword");
            GameRegistry.registerItem(nikraniumPickaxe, "nikraniumPickaxe");
            GameRegistry.registerItem(nikraniumAxe, "nikraniumAxe");
            GameRegistry.registerItem(nikraniumShovel, "nikraniumShovel");
            GameRegistry.registerItem(antiWaterBucket, "antiWaterBucket");
            
            FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("antiWater", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(antiWaterBucket), FluidContainerRegistry.EMPTY_BUCKET);
        }
        
        @EventHandler
        public void Init(FMLInitializationEvent event)
        {
            proxy.registerRender();
            MinecraftForge.EVENT_BUS.register(new LivingEventHandler());
            MinecraftForge.EVENT_BUS.register(new TextureEvent());
            MinecraftForge.EVENT_BUS.register(new BucketEvent());
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event)
        {
            
        }
    }
    

    je m'étais trompé de disposition 😅


Log in to reply