Jump to content

[1.5.2] Item rendering on in game gui not working.


_bau5

Recommended Posts

My problem is: I'm trying to render some ItemStacks on the in game gui when looking at one of my entities. Now it works, but it seems that it isn't rendering the texture, as the pale-blue backdrop can be seen through where the render is supposed to be.

h7BtYMH.png

Above you can see, circled in red, the problem. The stone on the left is rendered using the exact same call, but from the GuiIngame class, while the block on the right, that isn't being rendered correctly, is being called from outside the GuiIngame class.

I am terrible, terrible at the OpenGL stuff, and am verging on scrapping this idea.

 

Any ideas as to why this would be happening? My guess is it's due to differing states of the OpenGL render, but I've fiddled with it and can't get the textures to show.

 

Here is the pertinent code.

 

@ForgeSubscribe
public void onCraftingFrameHighlight(DrawBlockHighlightEvent ev){
	if(ev.target.entityHit instanceof EntityCraftingFrame && ((EntityCraftingFrame)ev.target.entityHit).getCurrentRecipe() != null){
		RecipeItem rec = ((EntityCraftingFrame)ev.target.entityHit).getCurrentRecipe();
		if(rec != null){
			Minecraft mc = FMLClientHandler.instance().getClient();
			if(rec.alternatives().size() == 0)
				return;
			ItemStack[] stacksToDraw = rec.alternatives().get(0);
			RenderItem itemRenderer = new RenderItem();

			mc.entityRenderer.setupOverlayRendering();
			GL11.glDisable(GL11.GL_BLEND);
			GL11.glEnable(GL12.GL_RESCALE_NORMAL);
	        RenderHelper.enableGUIStandardItemLighting();
			for(int i = 0; i < stacksToDraw.length; i++){
	        	GL11.glPushMatrix();
		        FontRenderer font = stacksToDraw[i].getItem().getFontRenderer(stacksToDraw[i]);
		        if (font == null) font = mc.fontRenderer;
				itemRenderer.renderItemAndEffectIntoGUI(font, mc.renderEngine, stacksToDraw[i], 125, 221 /*9 + xPos + (i * 16), yPos+2*/);
		        itemRenderer.renderItemOverlayIntoGUI(font, mc.renderEngine, stacksToDraw[i],125, 221 /*9 + xPos + (i * 16), yPos+2*/, Integer.toString(stacksToDraw[i].stackSize));
		        GL11.glPopMatrix();
	        }
			RenderHelper.disableStandardItemLighting();
	        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
		}
	}
}

 

[embed=425,349][/embed]

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.

×
×
  • Create New...

Important Information

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