61352151511 Posted December 11, 2017 Posted December 11, 2017 I'm trying to add some rendering to the hotbar for when an items ability cools down. All of the rendering code is below. I've attached three files to show the problem, the first is the hotbar without anything additionally drawn. The second is with the pickaxe ability cooled down, and the third it is on cooldown. As you can see the texture is drawn kind of over the durability bar, I want to know what I can do to solve this. I've tried enabling alpha, that didn't seem to change anything. RenderGameOverlayEvent.Pre broke pretty much the rest of the rendering. Any tips are helpful, basically I need the "highlight" to be in-front of the hotbar, but behind the items being drawn. @SubscribeEvent(priority = EventPriority.NORMAL) public void onRender(RenderGameOverlayEvent.Post event) { if (event.isCanceled() || event.getType() != ElementType.EXPERIENCE) return; NonNullList<ItemStack> inventory = minecraft.player.inventory.mainInventory; for (int i = 0; i < 9; i ++) { ItemStack stack = inventory.get(i); if (stack.isEmpty()) continue; if (stack.getItem() instanceof ItemPickaxe) drawHighlight(i, CooldownReference.pickaxe.isCooledDown()); if (stack.getItem() instanceof ItemSword) drawHighlight(i, CooldownReference.sword.isCooledDown()); if (stack.getItem() instanceof ItemAxe) drawHighlight(i, CooldownReference.axe.isCooledDown()); if (stack.getItem() instanceof ItemSpade) drawHighlight(i, CooldownReference.shovel.isCooledDown()); if (stack.getItem() instanceof ItemHoe) drawHighlight(i, CooldownReference.hoe.isCooledDown()); } } private void drawHighlight(int slot, boolean useable) { ScaledResolution scaledResolution = new ScaledResolution(minecraft); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.depthMask(false); minecraft.renderEngine.bindTexture(useable ? highlightResourceGreen : highlightResourceRed); drawModalRectWithCustomSizedTexture(((scaledResolution.getScaledWidth() / 2) - 91) + (slot * 20) + 2, scaledResolution.getScaledHeight() - 20, 0, 0, 18, 18, 16, 16); GlStateManager.depthMask(true); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } Quote
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.