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

The constant bouncing (item in hand moving up and down) when using durability as a timer is pretty annoying and looks bad, is there a way to keep it from doing this?

 

This applies to most of the items I'm making, so here's an example of one of the item classes that needs it:

 

public class ItemAirTalisman extends ItemArcaneArtifact
{
IIcon[] icons;
public ItemAirTalisman()
{
	super();
	setUnlocalizedName("airTalisman");
	setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
	setMaxStackSize(1);
	setMaxDamage(512);
}

@Override
public void registerIcons(IIconRegister iconRegister)
{
	icons = new IIcon[512];
	for(int i = 0; i < icons.length; i++)
	{
		icons[i] = iconRegister.registerIcon(Reference.MODID + ":" + (this.getUnlocalizedName().substring(5)) + i);
	}
}

@Override
public IIcon getIconFromDamage(int index)
{
	return icons[index];
}


@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player)
{
	if(!NBTHelper.hasNBT(stack))
	{
		NBTHelper.initNBT(stack);
		NBTHelper.setInt(stack, "Damage", 0);
		NBTHelper.setBool(stack, "Active", false);
		NBTHelper.setBool(stack, "Recharging", false);
		NBTHelper.setBool(stack, "Used", false);
	}
}


@Override
public void onUpdate(ItemStack stack, World world, Entity player, int slot, boolean hahanope)
{
	if(!NBTHelper.hasNBT(stack))
	{
		NBTHelper.initNBT(stack);
		NBTHelper.setInt(stack, "Damage", 0);
		NBTHelper.setBool(stack, "Active", false);
		NBTHelper.setBool(stack, "Recharging", false);
		NBTHelper.setBool(stack, "Used", false);
	}

	if(NBTHelper.hasNBT(stack))
	{
		if(player.isInWater())
		{
			NBTHelper.setBool(stack, "Active", true);
		}
		else
		{
			NBTHelper.setBool(stack, "Active", false);
		}


		if(NBTHelper.getBool(stack, "Active") && !NBTHelper.getBool(stack, "Recharging") && !NBTHelper.getBool(stack, "Used") && NBTHelper.getInt(stack, "Damage") < this.getMaxDamage() - 2)
		{
			NBTHelper.setBool(stack, "Recharging", false);
			NBTHelper.incrementIntSetDamage(stack, "Damage");
			player.setAir(300);
		}
		else if(NBTHelper.getInt(stack, "Damage") > 0 && !NBTHelper.getBool(stack, "Active"))
		{
			NBTHelper.decrementIntSetDamage(stack, "Damage");
		}


		if(NBTHelper.getInt(stack, "Damage") == 0)
		{
			NBTHelper.setBool(stack, "Used", false);
			NBTHelper.setBool(stack, "Recharging", false);
		}


		if(!NBTHelper.getBool(stack, "Used") && NBTHelper.getInt(stack, "Damage") > this.getMaxDamage() - 12)
		{
			NBTHelper.setBool(stack, "Used", true);
		}

		NBTHelper.boundMin(stack, "Damage");
		NBTHelper.boundMax(stack, "Damage", this.getMaxDamage() - 1);
	}
}}

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.