Jump to content

Item overlay rendering


Fergoman007

Recommended Posts

hi need some help

 

im try to get the damage value of the an item onto the item in the inventory but it unfortunately is rendering

 

UseCount 3 Class

package fergoman007.mods.usecount;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.InstanceFactory;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import fergoman007.mods.usecount.handlers.PacketHandler;
import fergoman007.mods.usecount.lib.Reference;
import fergoman007.mods.usecount.renderer.ItemRender;

@Mod(modid = Reference.modid, name = Reference.name, version = Reference.version)
@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {Reference.channel}, packetHandler = PacketHandler.class)
public class UseCount3 {

@Instance(Reference.modid)
public static UseCount3 instance;

public static ItemRender renderer;

public void renderUseCountOverLay(FontRenderer fontRenderer, TextureManager manager, ItemStack itemstack, int par1, int par2)
{
	int uses = itemstack.getMaxDamage() - itemstack.getItemDamageForDisplay() +1;

	int dmg = itemstack.getItemDamageForDisplay();
	int initialColour = (int) Math.round(255.0D - dmg * 255.0D / itemstack.getMaxDamage());
	int colour = 0xFFFFFF;
	if(itemstack.getItemDamageForDisplay() != 0);
	{
		colour = 255 - initialColour << 16 | initialColour << 8;
	}

	if(itemstack.getMaxDamage() > 0)
	{
		String s = String.valueOf(uses);
		GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glDisable(GL11.GL_DEPTH_TEST);
		GL11.glScaled(0.5f, 0.5f, 0.5f);
		int width = fontRenderer.getStringWidth(s);
		fontRenderer.drawStringWithShadow(s, (par1 +  * 2 + 1 + (width / 2) - (width), (par2 + 9) * 2, colour);
		GL11.glScalef(2f, 2f, 2f);
		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
	}
}

@EventHandler
public void load(FMLInitializationEvent evt)
{
	renderer = new ItemRender();
}
}

 

ItemRender Class

package fergoman007.mods.usecount.renderer;

import fergoman007.mods.usecount.UseCount3;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;

public class ItemRender extends RenderItem {

@Override
public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
{
	UseCount3 uc = new UseCount3();
	uc.renderUseCountOverLay(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
}

}

 

if anyone can help i thank you in advance

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.



×
×
  • Create New...

Important Information

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