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

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

}

 

 

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.

  • Author

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

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.

  • Author

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

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.