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

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

Hi

 

I don't understand your question, perhaps you could explain in more detail

- what you want to see

- what you are actually seeing

 

-TGG

  • Author

what i am trying to do is to render the amount of uses that an item has left and for some reason it does not render over the item

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.