Jump to content

[1.11.2] GUI Drawing messing up durability bar


61352151511

Recommended Posts

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

 

2017-12-11_13.24.11.png

2017-12-11_13.24.21.png

2017-12-11_13.24.41.png

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.

Announcements



×
×
  • Create New...

Important Information

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