Jump to content

Recommended Posts

Posted

There's no texture under resource folder, because I want to use item's texture instead.

I override the IForgeEffect#renderHUDEffect but it'll show a broken texture in the background.

2020-05-19_22_55_01.png.016438b5c66d5b967f4264066e7ad167.png

 

I tried to cover it, but failed.

@OnlyIn(Dist.CLIENT)
@Override
public void renderHUDEffect(EffectInstance effect, AbstractGui gui, int x, int y, float z, float alpha){
	/* Cover original icon */
	Minecraft minecraft = Minecraft.getInstance();
	minecraft.getTextureManager().bindTexture(ContainerScreen.INVENTORY_BACKGROUND);
	gui.blit(x, y, 141, 166, 24, 24);

	/* Show custom icon */
	ItemRenderer itemRenderer = minecraft.getItemRenderer();
	itemRenderer.zLevel = z;
	itemRenderer.renderItemAndEffectIntoGUI(new ItemStack((Ingredients.getIngredientByName(this.getIngredientName())).asItem())
		, x + 4, y + 4);
}

 

But I also override the IForgeEffect#renderInventoryEffect and do it with very similar way, and it worked.

2020-05-19_22_55_05.png.9aa16366d006fc3337c9521040142e9e.png

@OnlyIn(Dist.CLIENT)
@Override
public void renderInventoryEffect(EffectInstance effect, DisplayEffectsScreen<?> gui, int x, int y, float z){
	/* Cover original icon */
	Minecraft minecraft = gui.getMinecraft();
	minecraft.getTextureManager().bindTexture(ContainerScreen.INVENTORY_BACKGROUND);
	gui.blit(x + 6, y, 6, 166, 18, 32);

	/* Show custom icon */
	ItemRenderer itemRenderer = minecraft.getItemRenderer();
	itemRenderer.zLevel = z;
	itemRenderer.renderItemAndEffectIntoGUI(new ItemStack((Ingredients.getIngredientByName(this.getIngredientName())).asItem())
		, x + 6, y + 7);
}

 

I tried a lot, like using static blit method instead of non-static blit and pass in z, gui.getBlitOffset(), z + 10, gui.getBlitOffset() + 100 etc....

I think maybe I don't really know what does blitOffset and zlevel mean, but I can't find a way to blit a layer over that broken texture.

 

I also read code in IngameGui#renderPotionEffects, and I found that it construct a List<Runnable> and run them after EffectInstance#renderHUDEffect.

Why blit can't cover the broken texture, but ItemRenderer can?

 

Can anyone help me? thx.

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.