Jedispencer21 Posted June 21, 2015 Posted June 21, 2015 When an Item is enchanted in your inventory, hotbar and such, it has the enchantment glint on it, but when I attempt to render the glint onto the item in the hud, I cannot get it to render. This is what is showing ATM: This is my rendering code: public void renderItemTexture(int x, int y, ItemStack stack, int width, int height) { IBakedModel ibakedmodel = mc.getRenderItem().getItemModelMesher().getItemModel(new ItemStack(stack.getItem())); if (stack.getItem() == Item.getItemFromBlock(Blocks.standing_banner) || Block.getBlockFromItem(stack.getItem()) != null) return; TextureAtlasSprite textureAtlasSprite = mc.getTextureMapBlocks().getAtlasSprite(ibakedmodel.getTexture().getIconName()); mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); if (stack.getItem().isDamageable()) // Renders the durability bar under item { GlStateManager.pushMatrix(); double damage = stack.getItem().getDurabilityForDisplay(stack); int j1 = (int) Math.round(13.0D - damage * 13.0D); int k = (int) Math.round(255.0D - damage * 255.0D); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); int l = 255 - k << 16 | k << 8; int i1 = (255 - k) / 4 << 16 | 16128; drawRect(worldrenderer, x + 6, y + 9, 13, 2, 0); drawRect(worldrenderer, x + 6, y + 9, 12, 1, i1); drawRect(worldrenderer, x + 6, y + 9, j1, 1, l); GlStateManager.enableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableDepth(); GlStateManager.popMatrix(); } if (stack.hasEffect()) { // Enchantment glint rendering here? } renderTexture(x, y, textureAtlasSprite, width, height, 0); // Renders the texture to the screen GlStateManager.pushMatrix(); GlStateManager.scale(0.5F, 0.5F, 0.5F); int y1 = y; y1 += y; mc.fontRendererObj.drawString(getDamageString(stack), x + 12, y1 + 10, 16777215); // draws durability GlStateManager.popMatrix(); } Quote
coolAlias Posted June 21, 2015 Posted June 21, 2015 You should be able to just call the RenderItem method renderItem directly and it will do it for you: Minecraft.getMinecraft().getRenderItem().renderItemModel(stack); If that is not sufficient, then look at RenderItem#renderEffect to see how the enchanted glint is handled, and copy that (or use Reflection) into your render class. Quote http://i.imgur.com/NdrFdld.png[/img]
Jedispencer21 Posted June 21, 2015 Author Posted June 21, 2015 renderItemModel creates a very weird effect with scaled HUD everywhere across my screen, and I have tried RenderItem#renderEffect but that requires about 6 or 7 different methods to work. I have tried adding all of the methods, but it still doesn't render the enchantment glow Quote
coolAlias Posted June 21, 2015 Posted June 21, 2015 renderItemModel creates a very weird effect with scaled HUD everywhere across my screen, and I have tried RenderItem#renderEffect but that requires about 6 or 7 different methods to work. I have tried adding all of the methods, but it still doesn't render the enchantment glow So either copy all of them into a static Utility-type class, or use Reflection to call #renderEffect with the RenderItem instance you can retrieve from Minecraft. EDIT: And why are you scaling your HUD? If you look at GuiContainer, it never calls scale. In fact, that's where I would look to see how to render an item with enchanted glow, or just an item in general, into your HUD. Quote http://i.imgur.com/NdrFdld.png[/img]
Jedispencer21 Posted June 21, 2015 Author Posted June 21, 2015 I am scaling it so the items are not so large on the screen, and also I found the correct method, it was RenderItem#renderItemIntoGUI Quote
coolAlias Posted June 21, 2015 Posted June 21, 2015 I am scaling it so the items are not so large on the screen, and also I found the correct method, it was RenderItem#renderItemIntoGUI Ah yes, that's the one! Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.