title: Creating Instance of a Gui (Minecraft modding with ModLoader)
body: <p>First off, I'm really just messing around trying to learn Java. All I want to do at this point is display a string to the screen;</p>
  
  <p>So I have my mod_Bite class and my BiteGui class. (Bite is just a random name, I was eating at the time)</p>
  
  <pre><code>//mod_Bite.java
  package net.minecraft.src;
  
  import net.minecraft.client.Minecraft;
  
  public class mod_Bite extends BaseMod {
  
      @Override
      public String getVersion() {
          return "1.0";
      }
  
      @Override
      public void load() {
          ModLoader.setInGameHook(this, true, true);
      }
  
      public mod_Bite() {
      }
  
      @Override
      public boolean onTickInGame(float tick, Minecraft mc)
      {
          return true;
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>//BiteGui.java
  package net.minecraft.src;
  import net.minecraft.client.Minecraft;
  
  public class BiteGui extends Gui {
  
      private Minecraft mc;
  
      public BiteGui(){
          drawBiteGui();
      }
  
      public void drawBiteGui() {
          FontRenderer fr = this.mc.fontRenderer;
          drawString(fr, "Testing!", 5, 5, 0xffffff);
      }
  }
  </code></pre>
  
  <p>What I don't understand is how to create it. I tried creating an object of BiteGui in the onTickInGame method (even though I don't think it should create it every tick)</p>
  
  <pre><code>public boolean onTickInGame(float tick, Minecraft mc)
  {
      BiteGui biteObj = new BiteGui();
      return true;
  }
  </code></pre>
  
  <p>But it says there's a null pointer exception, which to my knowledge means that I'm trying to use something that's not been assigned any value or it's pointing at nothing.
  I'm obviously not doing something right here.</p>
  
  <hr>
  
  <p>Edit: I changed the code and it works except the text flashes with each tick instead of staying on the screen. It's obviously because I'm creating the object in the onTickInGame method but I don't know how to initialize Minecraft from anywhere else.</p>
  
  <pre><code>package net.minecraft.src;
  
  import net.minecraft.client.Minecraft;
  
  public class mod_Bite extends BaseMod {
  
      @Override
      public String getVersion() {
          return "1.0";
      }
  
      @Override
      public void load() {
          ModLoader.setInGameHook(this, true, true);
      }
  
      public mod_Bite() {
  
      }
  
      @Override
      public boolean onTickInGame(float tick, Minecraft mc)
      {
          BiteGui biteObj = new BiteGui(mc);
          return true;
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>package net.minecraft.src;
  import net.minecraft.client.Minecraft;
  
  public class BiteGui extends Gui {
  
      private Minecraft mc;
  
      public BiteGui(Minecraft minecraft) {
          this.mc = minecraft;
          drawBiteGui();
      }
  
      public void drawBiteGui() {
          FontRenderer fr = this.mc.fontRenderer;
          drawString(fr, "Testing!", 5, 5, 0xffffff);
      }
  }
  </code></pre>