Jump to content

Recommended Posts

Posted

Having an odd issue with custom Item Renderers in my Inventory.

 

Basically when the item is in certain slots, the background around the item is orange instead of the default inventory color.

 

Any ideas?

 

 

I followed the setup in this tutorial

 

http://www.minecraftforge.net/wiki/Custom_2D_Inventory_Item_Renderer

 

 

code for the inventory part:

 

 

            // Setup Render

                RenderItem renderItem = new RenderItem();

               

                // set Texture

                IIcon icon = item.getIconIndex();

                               

                // Render

                renderItem.renderIcon(0, 0, icon, 16, 16);

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I don't think you really need a custom item renderer to achieve this.

 

On each render go through all of the slots (or atleast the slots you want to have the orange background), and check if they have your item. If they do, draw the orange slot.

Kain

Posted

@TLHPoE

 

You missed the OP's point. They were asking if you knew WHY the background was being rendered orange - they don't WANT to render it orange.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

In case it is confusing.

 

I have a custom rendor for an item.  It has a unique Model for it.  The Forge method for doing that utilizes a method similar to the tutorial I listed.  1st person and 3rd person work great and do exactly what I want it to do.

 

When the item is rendered in an inventory slot, it uses the peice of code I supplied.  The item renders fine, but the 'void' area around it (I use Gimp to ensure there is nothing there) renders with a wierd orage color when it is in certain slots in my inventory.  It is very repeatable and it happens if it is the default inventory GUI or a custom one.  In both cases, it is the same slot everytime.

 

I've looked through the minecraft code, the forge code, as well as my own and I can't find anything that would be impacting the color, much less only for specific slots.

 

Anybody experienced something like this?

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Hi

 

Which slots in particular?  Perhaps you could show a screenshot?  Perhaps it is the first slot that gets rendered after rendering something else, so it might perhaps be due to an OpenGL render setting such as the colour, lighting, ALPHA_TEST or BLEND, that the vanilla slot code sets to something normal.  You could try tracing through the vanilla for the first item render and see what commands it uses, then copy those in front of your render code.

 

This class might be of interest to you

https://github.com/TheGreyGhost/SpeedyTools/blob/Working/src/speedytools/common/Utilities/OpenGLdebugging.java

 

I've used it in the past to check what the OpenGL settings are; it's not complete, but dumpAllIsEnabled() works and has showed up problems for me before- dump for a good render, dump for a bad render, and spot the difference.  Doesn't show everything but you might be lucky.

 

-TGG

 

 

Posted

I'll take some tonight.  The 2nd and 3rd hotbar slots.  The 2nd inventory starting from top, and then something like the 13th and 18th.  They aren't in line or next to each other except for the first 2.

 

I'm assuming (as you suggested) that  some openGL setting is leaking over.  I've checked all my stuff and its enclosed in pop/push except for this because its getting some settings from outside.  I might try enclosing it as well.

 

I looked at your link and I'm having a little trouble figuring out how to use it.  Do you have an example where you used it?

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Took some screenshots and noticed a pattern.

 

If one of my custom items is after another one, it seems to happens to it.  The hammers happen no matter what, but it is a different color.  It doesn't happen to the items that are armor.

 

width=384 height=168https://sites.google.com/site/clandoolittle/home/dimension-manager/Capture1.PNG?attredirects=0[/img]

 

width=377 height=169https://sites.google.com/site/clandoolittle/home/dimension-manager/Capture2.PNG?attredirects=0[/img]

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I'll take some tonight.  The 2nd and 3rd hotbar slots.  The 2nd inventory starting from top, and then something like the 13th and 18th.  They aren't in line or next to each other except for the first 2.

 

I'm assuming (as you suggested) that  some openGL setting is leaking over.  I've checked all my stuff and its enclosed in pop/push except for this because its getting some settings from outside.  I might try enclosing it as well.

 

I looked at your link and I'm having a little trouble figuring out how to use it.  Do you have an example where you used it?

 

Hi

 

I just copied the entire class into an appropriate package, then called dumpAllIsEnabled().  It prints out all the openGL settings you can turn on/off.

In this case I would suggest something like

 


static int delay;  // put this as a static field in your render class

if (++delay % 100 == 0) {  // only print once every 100 calls
  OpenGLdebugging.dumpAllIsEnabled();
}
renderItem.renderIcon(0, 0, icon, 16, 16);

Then put your item in a good slot, wait till it prints the flags, then put your item in an orange slot, wait till it prints the flags, then compare the two.

No guarantees it will show a difference, but it might.  My guess would be

 

            GL11.glEnable(GL11.GL_ALPHA_TEST);

 

but perhaps also

                GL11.glDisable(GL11.GL_LIGHTING);

 

-TGG

 

 

 

 

 

 

 

Posted

You my friend are a freaking genius.

 

GL11.glEnable(GL11.GL_ALPHA_TEST);

 

After looking with your tool, that was the difference.

Long time Bukkit & Forge Programmer

Happy to try and help

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.