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

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...

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.