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.

[1.14.3] Drawing vanilla item on IngameGui

Featured Replies

Posted

Hello,

I am currently trying to draw the texture of the current held item by the player somewhere else on the inGameGui. I am using the RenderGameOverlayEvent.post and i can easily drawString but i don't know how to draw texture.

I tried using the blit method but i don't know how to get the TextureAtlasSprite of an item (wich is needed for the method). I can get the ResourceLocation of the item but i have no clue for the TextureAtlasSprite.

Could i also have explanation on the bindTexture(ResourceLocation resource) method ?

 

Thank you for any reply.

Edited by JOB

  • Author

Resolved my issue.

To get the TextureAtlasSprite of an item i use :


public static final Minecraft MC = Minecraft.getInstance();
public static final PlayerEntity player = MC.player;

TextureAtlasSprite texture = MC.getTextureMap().getSprite(player.getHeldItemMainHand().getItem().getRegistryName());

 

3 hours ago, JOB said:

MC.getTextureMap().getSprite(player.getHeldItemMainHand().getItem().getRegistryName());

Don’t use that... that will break completely for anything that isn’t 100% standard. In 1.12.2 you would use RenderItem#renderStack. I’m not sure what the 1.14 replacement is, but it should be pretty easy to find by looking at the ingame GUI renderer or the item group renderer.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author

Thank you,

You were right i looked more deeply in the way that the inventory is generated on the GUI and found this method :

renderItemIntoGUI(ItemStack stack, int x, int y)

in the ItemRenderer class and it is really easy to use. For example i use it like this :

public static finale Minecraft MC = Minecraft.getInstance();

MC.getItemRenderer().renderItemIntoGUI(MC.player.getHeldItemMainhand(), 200, 200);

 

For some reasons when i first read the ItemRenderer class i completely passed over it.

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.