Jump to content

Recommended Posts

Posted

I'm making an addon to IC2, and I need to make a chargeable item (eu) that also holds plasma (I have a way to charge it).  I think a need to implement IElectricItem and IItemHudInfo, but I also think I need to mess with how the itemStack renders (with two damage bars instead on one), which I have no idea how to do.  Any help will be appreciated.

Posted

You can't store 2 damage values on a weapon. The damage value is  123:1234/ItemID:DamageValue The only way I know of is NBT data. So look up some tutorials on that. Unfortunately it increases the complication by a large amount. But thats what you have to do. As for the rendering, you would have to look into the openGL, create your own custom renderer for the bars , which shouldn't be too hard. Unless you mean add two numbers to the item in the inventory slot. Which is a little bit different. I'm not sure on any of the IC2 specific stuff though.

The difference between stupidity and genius is that genius has its limits. - Albert Einstein

Posted

I already have both the values I need (through item nbt) I just need the renderer.  I think I need to implement IItemRenderer and use MinecraftForgeClient.registerItemRenderer(), but how do I draw an overlay?  Also, do you know where I can find some tutorials on drawing with OpenGL, because I have absolutely no experience?

Posted

MinecraftForgeClient.registerItemRenderer(...) ?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Create a class implementing IItemRenderer

 

register it with:

 

MinecraftForgeClient.registerItemRenderer(int itemID, IItemRenderer renderer);.

 

 

your IItemRenderer class will have several methods to define, one of which is the important one:

 

@Override

public void renderItem(ItemRenderType type, ItemStack item, Object... data)

  {

  //do your render stuff here...you will need to render your own icon, use openGL draw calls to render the damage-bars.

  //you can render...well...pretty much anything here

  }

 

the Object... data  input array contains information such as the World, delta-tick time...etc...it varies by render-type.

 

the other methods help determine _when_ to use the custom renderer.

 

Posted

Using LWJGL OpenGL is very complicated when it's your first time.

 

I will help you a little bit :

To render you have the option : use Minecraft Tesselator or use directly OpenGL.

 

With Minecraft Tesselator :

Tesselator t = Tesselator.instance

after to draw use :

t.startDrawingQuads(); // Starts drawing an OpenGL quad

t.addVertex(x, y, z); // Adds a vertex to your quad. Your quad need 4 verticies to be rendered, otherwise you will throm some OpenGL Rendering errors.

t.draw(); // Send your verticies to OpenGL and let your GPU renders it at your screen !

 

Example : Renders the StoneLine Rolplay decorative bar :

                glDisable(GL_TEXTURE_2D);

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glColor4f(0, 0, 0, 26);

                Tessellator t = Tessellator.instance;

t.startDrawingQuads();

t.addVertex(0, 0, 0);

t.addVertex(0, 20, 0);

t.addVertex(Minecraft.getMinecraft().displayWidth, 20, 0);

t.addVertex(Minecraft.getMinecraft().displayWidth, 0, 0);

t.draw();

 

With OpenGL directly :

Replace uses of Tesselator by glVertex3f (not glVertex2f : that will crash OpenGL due to 3D game not 2D game)

glBegin(GL_QUADS); // Starts drawing an OpenGL quad

glVertex3f(x, y, z); // Like tesselator.addVertex, you need to call that 4 times because you have 4 angles in your quad otherwise it's not a quad !

glEnd(); // Send your verticies to your Graphic card and let your screen display that !

 

 

If you don't know what is vertex, i'm sorry but vertex is the BASE of all games ! Don't hope you will arrive to make good mods without knowing what is vertices ! A vertex represents the coords of angles of an object to render (it not mean colision ; colision are math algoryth to check if an object vertex is touching another object vertex).

 

 

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.