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

Hello,

I am trying to render an icon on the screen. I've read https://forums.minecraftforge.net/topic/107635-1165-mcp-render-overlay-errorbackground-black/ and thought this should be easily appliable to my code, but I only get a black square. Furthermore, I've read https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/modification-development/1437340-drawing-texture-with-drawtexturedmodalrect-is-too where they say the icon has to be 256x256, so I increased the size of the icon from 16x16 to 256x256.

My code is:

private static final ResourceLocation SS_ICON = new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png");

@SubscribeEvent
public void onRenderGameOverlayEventPost(RenderGameOverlayEvent.Post event) {
    if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
        TextureManager textureManager = Minecraft.getInstance().getTextureManager();
        textureManager.bind(SS_ICON);
        GuiUtils.drawTexturedModalRect(event.getMatrixStack(), 50, 50, 0, 0, 8, 8, 0);
    }
}

This is the icon gXFgH89.png This icon is from another mod, sereneseasons and it is inside its assets/sereneseasons/textures/item folder.

What am I missing here? And can someone explain the 4. and 5. parameter that are 0 in my code above?

 

Edited by Ctwx

  • Author
34 minutes ago, diesieben07 said:

You should use AbstractGui.blit instead of drawTexturedModalRect. I recommend Parchment so that you get proper parameter names.

Thank you. I'll check Parchment out.

What does blit do? Without Parchment I see a bunch of different Parameters but all of them just use int and float. Perhaps that will be more clear when I use Parchment.

Edited by Ctwx

  • Author

Okay, Parchment works, and blit also. But still, it is black on the screen:

private static final ResourceLocation SS_ICON = new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png");

@SubscribeEvent
public void onRenderGameOverlayEventPost(RenderGameOverlayEvent.Post pEvent) {
    if (pEvent.getType() == RenderGameOverlayEvent.ElementType.ALL) {
        Minecraft.getInstance().getTextureManager().bind(SS_ICON);
        AbstractGui.blit(pEvent.getMatrixStack(), 50, 50, 0f, 0f, 8, 8, 16, 16);
    }
}

The icon is black in game (when I make it bigger, it is this black/magenta squared texture):

qym7zsQ.png

I also tried it with a different ResourceLocation which works fine: new ResourceLocation("textures/gui/book.png");

I am not sure why it is not able to locate the resource. I also tried to copy it in my src/resources/assets folder, but that does not seem to work either. Do I have to register the resources first?

Edited by Ctwx

  • Author
36 minutes ago, diesieben07 said:

From that screenshot I can tell you have not correctly added Parchment. Did you reimport the project after adding it?

My bad. I checked the additional FAQ, prefixing my parameters with "p" fixed Parchment, but not the icon issue in my answer above. :) Thanks

Edited by Ctwx

  • Author

Okay, I fixed it. Thank you very much for the recommendations for Parchment and blit.

The issue that I still had was this:

// I had this:
new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png");
// but I needed this:
new ResourceLocation("sereneseasons", "textures/item/ss_icon.png");

I checked the sereneseasons.jar and the textures where in assets/sereneseasons, so I thought I needed the extra folder name above. Now it works.

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.