Posted July 31, 20169 yr I am looking for an example of code that renders item into hud and uses alpha channel to how much transparent it is. Ultimately want to add a bit of code that fades the item out of HUD after a bit of time. When I just need to render item into GUI I use RenderItem.renderItemIntoGUI, but that internally renders it with alpha set to 1f so I will need to get part of its code to render my item semi transparently. However in trying this out I wasn't able to figure out what exactly. I made sure that enableBlend is called, passed value of less than 1f to alpha parameter of color method and messed around with blendFunc parameters, but wasn't able to figure this out. I used RenderItem.renderItem to render the item in GUI, which in my tries would either get me the 1f alpha channel item in HUD or a glow in the shape of the item (definitely not the transparent one). I guess this is likely very easy for someone with more opengl knowledge than I have. Would you be able to point me to an example of code that does this? Or point out the OpenGL commands that need to be run to achieve semi transparent item in HUD?
July 31, 20169 yr I know Quark does this - when you press 'B' to toggle the 1.10 auto-jump, it displays a little icon which fades after a couple of seconds. Probably worth looking at how Vazkii handles that.
July 31, 20169 yr Author Vazkii does fairly simple stuff. GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.color(1F, 1F, 1F, alpha); mc.renderEngine.bindTexture(autojumpEnabled ? AUTOJUMP_ON : AUTOJUMP_OFF); Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 32, 32, 32, 32); GlStateManager.popMatrix(); I have tried this combination with the exception of replacing Gui.drawModalRectWithCustomSizedTexture with RenderItem.renderItem as I can't simply draw a texture because the item has tint indexes that colors get applied to. Based on this I guess something in the renderItem is messing the transparency rendering.
August 1, 20169 yr Why not just make a modified version of renderItem? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.