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

I'm trying to render a block in my GUI, but it seems to have no lighting like it normally does in the inventory. Any idea what I need to do?

 

Spoiler

    private void drawItemStack(ItemStack stack, int x, int y)
    {
        GlStateManager.enableLighting();
        GlStateManager.translate(0.0F, 0.0F, 32.0F);
        GL11.glScalef(4.0F, 4.0F, 0.0F);
        this.zLevel = 200.0F;
        this.itemRender.zLevel = 200.0F;
        net.minecraft.client.gui.FontRenderer font = stack.getItem().getFontRenderer(stack);
        if (font == null) font = fontRenderer;
        this.itemRender.renderItemIntoGUI(stack, x, y);
        this.itemRender.renderItemOverlayIntoGUI(font, stack, x, y, "");
        GlStateManager.disableLighting();
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        this.zLevel = 0.0F;
        this.itemRender.zLevel = 0.0F;
    }

 

 

Not sure why this image looks faded, but you can see the difference between the one in the inventory down at the bottom, and the one I'm trying to render up at the top. Also sorry for the extra image at the bottom. Apparently you can't delete an image once you've attached it to the post.

 

image.png.d660dd2962b078f3ad0a80867d1bc2f5.png

 

image.png

Edited by Daeruin

RenderHelper.disableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
....
Your rendering code
....
RenderHelper.enableStandardItemLighting();

 

  • Author

Yes, that worked! Although it doesn't quite look the same as in the inventory. The lighting is a bit different. Anyway, thanks for the help. I'm in the dark with this rendering stuff.


Should I be rendering this in the foreground or background layer? When I do it in the foreground, I can no longer see items when I pick them up with the mouse. When I do it in the background, the basket appears clear in the upper left corner of the screen, and all my foreground stuff disappears. I have no idea what's going on with that.

 

Another weird thing is that now I'm noticing the front left wall of the basket is missing.

You are most likely messing up some GL state. For example...

27 minutes ago, Daeruin said:

GL11.glScalef(4.0F, 4.0F, 0.0F);

...

27 minutes ago, Daeruin said:

GL11.glScalef(1.0F, 1.0F, 1.0F);

This is not how GL scaling works. Scaling by 1,1,1 is doing nothing. Think of it as currentScale * passedVector. If you scale by 1 then you are doing currentScale * 1 which is currentScale. In order to scale back use 1 / scaleUsed, in your case this would be 1 / 4 = 0.25.

The rendering layer doesn't matter. It is all done in one method, but the background is rendered first.

 

13 minutes ago, Daeruin said:

The lighting is a bit different.

Experiment with enable/disable lighting and OpenGlHelper.setLightmapTextureCoords

 

13 minutes ago, Daeruin said:

Another weird thing is that now I'm noticing the front left wall of the basket is missing.

Experiment with depthtest(GlStateManager.enable/disableDepth). I can't remember of the top of my head whether MC uses depth testing for rendering items or not.

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.