Jump to content

[SOLVED][1.7.2] Rendering icon in inventory turns completely grey


Recommended Posts

This is an icon with numbers rendered over the top of it, which renders perfectly fine until there is a damaged ItemStack preceding its position in the inventory, at which point it turns completely grey.


Never had this problem in 1.6.4, and after spending some time poking around in the updated rendering code and trying some things I'm no closer to a solution...


Here's my IItemRenderer:

public class RenderItemBombBag implements IItemRenderer
/** Defines the zLevel of rendering of item on GUI. */
public float zLevel;

public RenderItemBombBag() {}

public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return type == ItemRenderType.INVENTORY;

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	return false;

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	if (type == ItemRenderType.INVENTORY) {
		Tessellator tessellator = Tessellator.instance;
		for (int i = 0; i < 3; ++i) {
			IIcon icon = item.getItem().getIcon(item, i);
			tessellator.addVertexWithUV(0, 16, zLevel, icon.getMinU(), icon.getMaxV());
			tessellator.addVertexWithUV(16, 16, zLevel, icon.getMaxU(), icon.getMaxV());
			tessellator.addVertexWithUV(16, 0, zLevel, icon.getMaxU(), icon.getMinV());
			tessellator.addVertexWithUV(0, 0, zLevel, icon.getMinU(), icon.getMinV());

Link to comment
Share on other sites

It's really strange, the icons render perfectly fine if any of the preceding slots are highlighted with the mouse, whether or not a damaged stack is preceding, or if a non-damaged stack is preceding, but turns totally grey when a damaged stack is in a preceding slot with no slots or only empty slots in between and no highlighted slots.


I've tried manually setting the color and zLevel as well as some other probably useless things, to no avail. Is this perhaps a bug with 1.7.2 or Forge version 1024, or am I doing something stupid here?

Link to comment
Share on other sites

Sadly, no, it turns grey like the gui background, except one of the digits will still render.


I wasn't able to take a screenshot with the inventory screen open, but the effect is the same if I remove the stone block and highlight the slot instead, and if neither of the bags will render correctly if nothing intervenes between them and a damaged stack.

Link to comment
Share on other sites



I reckon this is almost certainly a problem with OpenGL or the Tessellator settings carrying over from previous renders - but I'm not sure what.


Does the grey background still appear even if you do nothing in your render?  If not, perhaps your texture hasn't been bound properly.


You might try rendering a vanilla icon on the slot (by calling the vanilla code) and then rendering your icon over the top of the vanilla icon.  If that fixes it, then it shouldn't be too hard to track down the setting that's the problem.


Strange huh



Link to comment
Share on other sites

That's what I figure is going on as well; somehow the rendering of the damage bar over the ItemStack is screwing up the colors, but no matter what I try I can't seem to get it to normalize... Here's an interesting picture when I change it to just render the first icon:




Note how the background is brownish colored for the bags; that goes away if I highlight the bag slot or any slot intervening the bag and the damaged stack.


Very odd. Rendering multiple icons of course makes it turn grey like the previous screenshot. I've been looking through the inventory render code to see if they do anything prior to rendering each stack, such as enable/disable standard lighting, etc., but none of those have had any effect when I've tried them... the search continues :/

Link to comment
Share on other sites



Man I hate this type of bug.


This class might perhaps be of some help



It's something I put together to help figure out which OpenGL settings vanilla has modified before calling my rendering code.  If you run it for the "good" vs "bad" renders you might be able to spot the difference.


dumpAllIsEnabled() currently works.  The rest isn't fully functional yet but I reckon you've got the skills to tweak it so it gives you useful information :-)


Was based on this very useful link







Link to comment
Share on other sites

Mwa ha ha ha!!! I finally tracked it down in RenderItem.renderItemOverlayIntoGUI(args...)

if (par3ItemStack.isItemDamaged())
                int j1 = (int)Math.round(13.0D - (double)par3ItemStack.getItemDamageForDisplay() * 13.0D / (double)par3ItemStack.getMaxDamage());
                int k = (int)Math.round(255.0D - (double)par3ItemStack.getItemDamageForDisplay() * 255.0D / (double)par3ItemStack.getMaxDamage());

// HERE: alpha and blend are disabled:
                Tessellator tessellator = Tessellator.instance;
                int l = 255 - k << 16 | k << 8;
                int i1 = (255 - k) / 4 << 16 | 16128;
                this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
                this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1);
                this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l);
// HERE: they are not re-enabled
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

EDIT: disabling blend and alpha_test screws up the creative tab rendering; just enabling them is enough

Re-enabling them before I draw my icons (and then re-disabling them afterwards) brings everything back to normal :D


Seems like an oversight / bug on the part of Mojang there. I wonder if it will or has been fixed in versions after 1.7.2?

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have a problem, I am trying to put two different effects to two different armors but when I run it only the emerald armor effect works. This is the code public class ModArmorItem extends ArmorItem{ private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.OBSIDIAN, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); public ModArmorItem(ArmorMaterial pMaterial, Type pType, Properties pProperties) { super(pMaterial, pType, pProperties); } @Override public void onArmorTick(ItemStack stack, Level world, Player player){ if (!world.isClientSide()) { if (hasFullSuitOfArmorOn(player)) { evaluateArmorEffects(player); } } } private void evaluateArmorEffects(Player player) { for (Map.Entry<ArmorMaterial,MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()){ ArmorMaterial mapArmorMaterial = entry.getKey(); MobEffectInstance mapStatusEffect = entry.getValue(); if (hasCorrectArmorOn(mapArmorMaterial, player)) { addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect); } } } private void addStatusEffectForMaterial(Player player, ArmorMaterial mapArmorMaterial, MobEffectInstance mapStatusEffect) { boolean hasPlayerEffect = player.hasEffect(mapStatusEffect.getEffect()); if (hasCorrectArmorOn(mapArmorMaterial, player) && !hasPlayerEffect) { player.addEffect(new MobEffectInstance(mapStatusEffect)); } } private boolean hasCorrectArmorOn(ArmorMaterial material, Player player) { for (ItemStack armorStack : player.getInventory().armor){ if (!(armorStack.getItem() instanceof ArmorItem)) { return false; } } ArmorItem helmet = ((ArmorItem)player.getInventory().getArmor(3).getItem()); ArmorItem breastplace = ((ArmorItem)player.getInventory().getArmor(2).getItem()); ArmorItem leggins = ((ArmorItem)player.getInventory().getArmor(1).getItem()); ArmorItem boots = ((ArmorItem)player.getInventory().getArmor(0).getItem()); return helmet.getMaterial() == material && breastplace.getMaterial() == material && leggins.getMaterial() == material && boots.getMaterial() == material; } private boolean hasFullSuitOfArmorOn(Player player){ ItemStack helmet = player.getInventory().getArmor(3); ItemStack breastplace = player.getInventory().getArmor(2); ItemStack leggins = player.getInventory().getArmor(1); ItemStack boots = player.getInventory().getArmor(0); return !helmet.isEmpty() && !breastplace.isEmpty() && !leggins.isEmpty() && !boots.isEmpty(); } } Also when I place two effects on the same armor, the game crashes. Here is the crash file. The code is the same, only this part is different   private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); I hope you guys can help me. Thanks.
    • I removed all related embeddium and oculus mods, i just tested it by disconnecting and the error happened again. heres the report https://pastebin.com/1kcR5wAt   EDIT: i tried removing xaeros and also smoothboot thinking there may be an issue there, nothing, heres that report too. https://pastebin.com/zQS7i9rM
    • Hi, I need suggestions. I am a beginner in Minecraft Modding. I would like to apply custom effects to some armors, something like: more chance to drop seeds, change zombie awareness, drop more pieces of wood when chopping logs, and things like that. How would you recommend me to do it, is there any library that has something similar and which ones would you recommend me?.
    • "downloading minecraft server failed, invalid Checksum. try again, or manually place server.jar to skip download"    
    • You have to create an Entity class called PlayerPart and use multiple of them to make the different parts of the player. See EnderDragonPart.java source code. The green hitboxes of the dragon are all EnderDragonParts
  • Topics

  • Create New...

Important Information

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