title: NullPointerException when trying to set item texture - minecraft 1.8 modding
body: <p>I'm learning how to java and trying to build a minecraft mod. </p>
  
  <p>The problem is I'm having trouble with the 1.8 item texture adding system and even though Google is my best friend I still haven't found what I should do to fix this NPE. </p>
  
  <p>Here is the Base Mod class:</p>
  
  <pre><code>package rocha.sekai;
  
  import net.minecraftforge.fml.common.Mod;
  import net.minecraftforge.fml.common.Mod.EventHandler;
  import net.minecraftforge.fml.common.Mod.Instance;
  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.minecraftforge.fml.common.event.FMLInitializationEvent;
  import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
  import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  import net.minecraftforge.fml.relauncher.Side;
  
  @Mod(modid=sekai.MODID, name=sekai.MODNAME, version=sekai.MODVER)
  public class sekai{
  
      //items variable
      public static Item testIngot;
  
  
      //Set the ID of the mod (Should be lower case).
      public static final String MODID = "sekairocha";
      //Set the "Name" of the mod.
      public static final String MODNAME = "sekai";
      //Set the version of the mod.
      public static final String MODVER = "0.0.1";
  
      @Instance(value = sekai.MODID) //Tell Forge what instance to use.
      public static sekai instance;
  
      @EventHandler
      public void preInit(FMLPreInitializationEvent event){
          testIngot = new testItem();
          if(event.getSide() == Side.CLIENT){
              RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    line 41-&gt; renderItem.getItemModelMesher().register(testIngot, 0, new ModelResourceLocation("sekai:" + ((testItem) testIngot).getName(), "inventory"));
          }
  
  }
  
  
      @EventHandler
      public void load(FMLInitializationEvent event)
      {
  
      }
  
      @EventHandler
      public void postInit(FMLPostInitializationEvent event)
      {
      }
  }
  </code></pre>
  
  <p>Here is the item class:</p>
  
  <pre><code>package rocha.sekai;
  
  import net.minecraft.item.Item;
  import net.minecraft.creativetab.CreativeTabs;
  import net.minecraftforge.fml.common.registry.GameRegistry;
  
  public class testItem extends Item{
  
      private final String name = "testIngot";
  
      public testItem(){
          GameRegistry.registerItem(this, name);
          maxStackSize = 64;
          setCreativeTab(CreativeTabs.tabMisc);
          setUnlocalizedName("testIngot");
  
      }
  
      public String getName(){
          return name;
      }
  }
  </code></pre>
  
  <p>And here is the error report:</p>
  
  <pre><code>java.lang.NullPointerException: Initializing game
      at rocha.sekai.sekai.preInit(sekai.java:41)
      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:536)
      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)
  </code></pre>
  
  <p>line 41 is marked in the Base Mod class wiht "line 41->" right before the code. I'll also transcribe it here:</p>
  
  <pre><code>renderItem.getItemModelMesher().register(testIngot, 0, new ModelResourceLocation("sekai:" + ((testItem) testIngot).getName(), "inventory"));
  </code></pre>