Jump to content

[1.6.2]Drawing an icon


shucke

Recommended Posts

How can i draw an icon on a guiScreen properly?

i am familliar with the method and all but there is just a little problem.

when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet.

so it doesnt draw anything visible.

do i need to bind the icon somehow to make it work?

 

this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16);

 

Link to comment
Share on other sites

How can i draw an icon on a guiScreen properly?

i am familliar with the method and all but there is just a little problem.

when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet.

so it doesnt draw anything visible.

do i need to bind the icon somehow to make it work?

 

this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16);

 

 

You are way off for gui screens there buddy. Use this:

 

Static:

public ResourceLocation guiLocation = new ResourceLocation(Core.DirTexPre + Core.DirGui + "CyphScapeLogo" + Core.DirEnd);

 

 

DrawScreen

public void drawScreen(int i,int j, float f)
{
drawDefaultBackground();

/** 
* Renders Images
* */
this.mc.func_110434_K().func_110577_a(this.guiLocation);
int posX2 = (this.width - xSizeOfTexture) / 1;
int posY2 = (this.height - ySizeOfTexture) / 3;
drawTexturedModalRect(posX2 - 100, posY2 - 45, 0, 0, xSizeOfTexture, ySizeOfTexture);

Link to comment
Share on other sites

How can i draw an icon on a guiScreen properly?

i am familliar with the method and all but there is just a little problem.

when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet.

so it doesnt draw anything visible.

do i need to bind the icon somehow to make it work?

 

 

this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16);

 

 

You are way off for gui screens there buddy. Use this:

 

Static:

public ResourceLocation guiLocation = new ResourceLocation("PIC LOCATION HERE");

 

 

DrawScreen

public void drawScreen(int i,int j, float f)
{

drawDefaultBackground();

/** 
* Renders Images
* */
this.mc.func_110434_K().func_110577_a(this.guiLocation);
int posX2 = (this.width - xSizeOfTexture) / 1;
int posY2 = (this.height - ySizeOfTexture) / 3;
drawTexturedModalRect(posX2 - 100, posY2 - 45, 0, 0, xSizeOfTexture, ySizeOfTexture);

 

 

Edit: Just take the icon and save it to a 256x256 picture and align to the top right. Then go in here and change the x and y to 16. that should load it.

Crap sorry wrong button. I forgot this:

 

public final int xSizeOfTexture = 256;  //The x value of the picture

public final int ySizeOfTexture = 100;  // The y value of the picture.

 

put them above the draw background.

Link to comment
Share on other sites

that doesnt seem very usefull...

i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working.

 

if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3.

Link to comment
Share on other sites

that doesnt seem very usefull...

i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working.

 

if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3.

lol?

i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class.

it has to work somehow i just dont know how.

Link to comment
Share on other sites

that doesnt seem very usefull...

i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working.

 

if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3.

lol?

i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class.

it has to work somehow i just dont know how.

 

... Do what I just told you. Make a new picture and put the icon there! Otherwise go look at the source for ee3.

Link to comment
Share on other sites

This will bind the blocks atlas

this.mc.func_110434_K().func_110577_a(TextureMap.field_110575_b);

 

This will bind the items atlas

this.mc.func_110434_K().func_110577_a(TextureMap.field_110576_c);

 

After binding one of those you can use an icon with drawTexturedModelRectFromIcon

 

That only seems to work with the default blocks and items though, as it wouldn't draw the correct icon for any of my stuff.

I figure there is another atlas for mod stuff but with nothing named I couldn't find it.

 

So I wrote a simple work around. (its based off of drawTextureModelRectFromIcon)

/**
* Draws a texture at the given location, with the specified size
* @param x Location X
* @param y Location Y
* @param w Draw Width
* @param h Draw Height
*/
public void drawTexture(int x, int y, int w, int h)
{
    GL11.glColor4f(1F, 1F, 1F, 1F);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(x + 0, y + h, this.zLevel, 0D, 1D);
    tessellator.addVertexWithUV(x + w, y + h, this.zLevel, 1D, 1D);
    tessellator.addVertexWithUV(x + w, y + 0, this.zLevel, 1D, 0D);
    tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, 0D, 0D);
    tessellator.draw();
}

 

 

To use

this.mc.func_110434_K().func_110577_a(  resource location of wanted texture  );
drawTexture(this.xPosition+3, this.yPosition+3, 16, 16);

 

 

Edit:

Forgot to point out a few things.

 

You do not need a new texture, just reuse your current one.

 

The size field in drawTexture is the size you want it to be drawn not the size of the icon, the icon itself is scaled to this size.

Link to comment
Share on other sites

that doesnt seem very usefull...

i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working.

 

if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3.

lol?

i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class.

it has to work somehow i just dont know how.

 

... Do what I just told you. Make a new picture and put the icon there! Otherwise go look at the source for ee3.

uhm... got a few reasons why i shouldnt do it like that.

like a said earlier ....

 

This will bind the blocks atlas

this.mc.func_110434_K().func_110577_a(TextureMap.field_110575_b);

 

This will bind the items atlas

this.mc.func_110434_K().func_110577_a(TextureMap.field_110576_c);

 

After binding one of those you can use an icon with drawTexturedModelRectFromIcon

 

That only seems to work with the default blocks and items though, as it wouldn't draw the correct icon for any of my stuff.

I figure there is another atlas for mod stuff but with nothing named I couldn't find it.

 

So I wrote a simple work around. (its based off of drawTextureModelRectFromIcon)

/**
* Draws a texture at the given location, with the specified size
* @param x Location X
* @param y Location Y
* @param w Draw Width
* @param h Draw Height
*/
public void drawTexture(int x, int y, int w, int h)
{
    GL11.glColor4f(1F, 1F, 1F, 1F);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(x + 0, y + h, this.zLevel, 0D, 1D);
    tessellator.addVertexWithUV(x + w, y + h, this.zLevel, 1D, 1D);
    tessellator.addVertexWithUV(x + w, y + 0, this.zLevel, 1D, 0D);
    tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, 0D, 0D);
    tessellator.draw();
}

 

 

To use

this.mc.func_110434_K().func_110577_a(  resource location of wanted texture  );
drawTexture(this.xPosition+3, this.yPosition+3, 16, 16);

 

 

Edit:

Forgot to point out a few things.

 

You do not need a new texture, just reuse your current one.

 

The size field in drawTexture is the size you want it to be drawn not the size of the icon, the icon itself is scaled to this size.

 

it worked :)

i was struggling with this problem for a while now so thx alot!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ratuasia77 adalah bocoran slot rekomendasi gacor dari Ratuasia77 yang bisa anda temukan di SLOT Ratuasia77. Situs SLOT Ratuasia77 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ratuasia77 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ratuasia77 merupakan SLOT Ratuasia77 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ratuasia77. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ratuasia77 hari ini yang telah disediakan SLOT Ratuasia77. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ratuasia77 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ratuasia77 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ratuasia77 di link SLOT Ratuasia77.
    • 20 SLOT DEMO GRATIS PRAGMATIC PLAY x500 RUPIAH ANTI LAG & 20 DEMO SLOT MAHJONG WAYS PG SOFT GRATIS ANTI RUNGKAD KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • BOCORAN POLA SLOT GACOR MAHJONG WAYS MAXWIN x500 PETIR MERAH HARI INI HINGGA MALAM INI KLIK DISINI DAFTAR SLOT VVIP << KLIK DISINI DAFTAR SLOT VVIP << KLIK DISINI DAFTAR SLOT VVIP << KLIK DISINI DAFTAR SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • Museumbola merupakan wadah judi online terkhusus untuk sbobet atau judi bola. Dengan daftar dan deposit menggunakan BANK BCA, Anda berkesempatan mendapatkan prediksi jitu pertandingan secara update setiap hari yang bisa anda jadikan acuan untuk bermain judi bola. Hanya dengan 10 ribu rupiah dan anda bermain Mix Parlay menggunakan prediksi yang telah di sediakan oleh kami, anda akan memenangkan jutaan rupiah. Yuk segera klik DAFTAR sekarang juga.
    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
  • Topics

×
×
  • Create New...

Important Information

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