Posted July 8, 20196 yr 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 July 8, 20196 yr by JOB
July 8, 20196 yr 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());
July 8, 20196 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
July 9, 20196 yr 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.