Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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]

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.