Jump to content

changes to Gui Overlay in 1.8?


Wooden_Brick

Recommended Posts

Hello,

Im trying to understand the basics of OverlayEvents, and I've come across 3 problems with the tutorial mod in mcforge:

 

public class SampleEventReceiver

{

    @SubscribeEvent(priority = EventPriority.NORMAL)

   

    public void eventHandler(RenderGameOverlayEvent event)  //for some reason it says i have to add a "{" here

   

   

//and a "}" here

 

}

 

 

 

I've also changed the @ForgeSubscribe into @SubscribeEvent.

 

The other problem is i dont know where to put this line :(

 

  MinecraftForge.EVENT_BUS.register(new SampleEventReceiver());

 

 

 

 

and the last problem is in my GuiBuffBar: it says      this.mc.renderEngine.bindTexture("/gui/inventory.png");     

iint the type TextureManager is not applicable for arguments(String)

 

 

 

 

 

Whole class:

 

 

 

 

 

 

public class GuiBuffBar extends Gui

{

  private Minecraft mc;

 

  public GuiBuffBar(Minecraft mc)

  {

    super();

   

    // We need this to invoke the render engine.

    this.mc = mc;

  }

 

  private static final int BUFF_ICON_SIZE = 18;

  private static final int BUFF_ICON_SPACING = BUFF_ICON_SIZE + 2; // 2 pixels between buff icons

  private static final int BUFF_ICON_BASE_U_OFFSET = 0;

  private static final int BUFF_ICON_BASE_V_OFFSET = 198;

  private static final int BUFF_ICONS_PER_ROW = 8;

 

  //

  // This event is called by GuiIngameForge during each frame by

  // GuiIngameForge.pre() and GuiIngameForce.post().

  //

  @SubscribeEvent(priority = EventPriority.NORMAL)

  public void onRenderExperienceBar(RenderGameOverlayEvent event)

  {

    //

    // We draw after the ExperienceBar has drawn.  The event raised by GuiIngameForge.pre()

    // will return true from isCancelable.  If you call event.setCanceled(true) in

    // that case, the portion of rendering which this event represents will be canceled.

    // We want to draw *after* the experience bar is drawn, so we make sure isCancelable() returns

    // false and that the eventType represents the ExperienceBar event.

    if(event.isCancelable() || event.type != ElementType.EXPERIENCE)

    {     

      return;

    }

 

    // Starting position for the buff bar - 2 pixels from the top left corner.

    int xPos = 2;

    int yPos = 2;

    Collection collection = this.mc.thePlayer.getActivePotionEffects();

    if (!collection.isEmpty())

    {

      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

      GL11.glDisable(GL11.GL_LIGHTING);     

      this.mc.renderEngine.bindTexture("/gui/inventory.png");     

 

      for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects()

          .iterator(); iterator.hasNext(); xPos += BUFF_ICON_SPACING)

      {

        PotionEffect potioneffect = (PotionEffect) iterator.next();

        Potion potion = Potion.potionTypes[potioneffect.getPotionID()];

 

        if (potion.hasStatusIcon())

        {

          int iconIndex = potion.getStatusIconIndex();

          this.drawTexturedModalRect(

              xPos, yPos,

              BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,

              BUFF_ICON_SIZE, BUFF_ICON_SIZE);

 

 

 

 

 

Main Mod Class:

 

 

 

 

 

@Mod(modid = References.MOD_ID, name = References.MOD_NAME, version = References.VERSION)

public class TutorialMod {

 

 

 

@SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

 

 

public static final ModTab tabMod = new ModTab("tabMod");

 

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

TutorialBlocks.init();

TutorialBlocks.register();

TutorialItems.init();

TutorialItems.register();

TutorialItems.registerRecipes();

}

@EventHandler

public void init(FMLInitializationEvent event){

proxy.registerRenders();

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

    MinecraftForge.EVENT_BUS.register(new GuiBuffBar(Minecraft.getMinecraft()));

 

 

}

 

 

}

 

Link to comment
Share on other sites

Either im doing something wrong, or dont know how to use spoilers or code boxes, sorry if this way is still confusing, code is inside comment markers.

 

 

 

 

Hello,

Im trying to understand the basics of OverlayEvents, and I've come across 3 problems with the tutorial mod in mcforge:

 

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public class SampleEventReceiver

{

    @SubscribeEvent(priority = EventPriority.NORMAL)

   

    public void eventHandler(RenderGameOverlayEvent event)  //for some reason it says i have to add a "{" here

     

   

//and a "}" here

 

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

I've also changed the @ForgeSubscribe into @SubscribeEvent.

 

The other problem is i dont know where to put this line :(

 

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

  MinecraftForge.EVENT_BUS.register(new SampleEventReceiver());

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

and the last problem is in my GuiBuffBar: it says:

 

 

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

this.mc.renderEngine.bindTexture("/gui/inventory.png");     

the type TextureManager is not applicable for arguments(String)

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

Whole mod class :

 

 

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

public class GuiBuffBar extends Gui

{

  private Minecraft mc;

 

  public GuiBuffBar(Minecraft mc)

  {

    super();

   

    // We need this to invoke the render engine.

    this.mc = mc;

  }

 

  private static final int BUFF_ICON_SIZE = 18;

  private static final int BUFF_ICON_SPACING = BUFF_ICON_SIZE + 2; // 2 pixels between buff icons

  private static final int BUFF_ICON_BASE_U_OFFSET = 0;

  private static final int BUFF_ICON_BASE_V_OFFSET = 198;

  private static final int BUFF_ICONS_PER_ROW = 8;

 

  //

  // This event is called by GuiIngameForge during each frame by

  // GuiIngameForge.pre() and GuiIngameForce.post().

  //

  @SubscribeEvent(priority = EventPriority.NORMAL)

  public void onRenderExperienceBar(RenderGameOverlayEvent event)

  {

    //

    // We draw after the ExperienceBar has drawn.  The event raised by GuiIngameForge.pre()

    // will return true from isCancelable.  If you call event.setCanceled(true) in

    // that case, the portion of rendering which this event represents will be canceled.

    // We want to draw *after* the experience bar is drawn, so we make sure isCancelable() returns

    // false and that the eventType represents the ExperienceBar event.

    if(event.isCancelable() || event.type != ElementType.EXPERIENCE)

    {     

      return;

    }

 

    // Starting position for the buff bar - 2 pixels from the top left corner.

    int xPos = 2;

    int yPos = 2;

    Collection collection = this.mc.thePlayer.getActivePotionEffects();

    if (!collection.isEmpty())

    {

      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

      GL11.glDisable(GL11.GL_LIGHTING);     

      this.mc.renderEngine.bindTexture("/gui/inventory.png");     

 

      for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects()

          .iterator(); iterator.hasNext(); xPos += BUFF_ICON_SPACING)

      {

        PotionEffect potioneffect = (PotionEffect) iterator.next();

        Potion potion = Potion.potionTypes[potioneffect.getPotionID()];

 

        if (potion.hasStatusIcon())

        {

          int iconIndex = potion.getStatusIconIndex();

          this.drawTexturedModalRect(

              xPos, yPos,

              BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,

              BUFF_ICON_SIZE, BUFF_ICON_SIZE);

 

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

Main mod class:

 

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

@Mod(modid = References.MOD_ID, name = References.MOD_NAME, version = References.VERSION)

public class TutorialMod {

 

 

 

  @SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS)

      public static CommonProxy proxy;

 

 

 

  public static final ModTab tabMod = new ModTab("tabMod"); 

 

 

 

  @EventHandler

  public void preInit(FMLPreInitializationEvent event){

      TutorialBlocks.init();

      TutorialBlocks.register();

      TutorialItems.init();

      TutorialItems.register();

      TutorialItems.registerRecipes();

  }

  @EventHandler

  public void init(FMLInitializationEvent event){

      proxy.registerRenders();

     

  } 

 

  @EventHandler

  public void postInit(FMLPostInitializationEvent event){

 

      MinecraftForge.EVENT_BUS.register(new GuiBuffBar(Minecraft.getMinecraft()));

 

     

 

 

}

Link to comment
Share on other sites

Hello,

Im trying to understand the basics of OverlayEvents, and I've come across 3 problems with the tutorial mod in mcforge:

 

http://pastebin.com/6PtmTJQ7

 

I've also changed the @ForgeSubscribe into @SubscribeEvent.

 

The other problem is i dont know where to put this line :(

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////

  MinecraftForge.EVENT_BUS.register(new SampleEventReceiver());

/////////////////////////////////////////////////////////////////////////////////////////////////

 

 

and the last problem is in my GuiBuffBar, it says 

 

///////////////////////////////////////////////////////////////////////////////////////////

this.mc.renderEngine.bindTexture("/gui/inventory.png");     

the type TextureManager is not applicable for arguments(String)

///////////////////////////////////////////////////////////////////////////////////////////

 

 

 

GuiBuffBar class:

http://pastebin.com/tN2R2QLk

 

 

Main Mod Class:

http://pastebin.com/x6nfz1pi

 

hope finally readable :((

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.