Jump to content

[1.8][SOLVED] Custom HUD rendering enchantment glint onto items


Jedispencer21

Recommended Posts

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:

 

 

14119id.png

 

 

 

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();

}

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.