Basically I'm trying to recreate Magic Armour from Zelda games where you're invincible if you have Rupees, but your amount of Rupees drains at a rate of like 2 per second and when it's gone you're unable to move or anything.
I got it all working except the money part.
I'm not sure how to set it so the amount decreases by 1 every 10 ticks.
Right now it just decreases by 1 every tick since I can't figure out how to slow it.
Anyone want to point me in the right direction?
My code if that matters:
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
if(player.getCurrentArmor(3) != null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null)
ItemStack crown = player.getCurrentArmor(3);
ItemStack armour = player.getCurrentArmor(2);
ItemStack mail = player.getCurrentArmor(1);
//If player is wearing all 3 armour pieces
if(crown.getItem() == Main.MagicCrown && armour.getItem() == Main.MagicArmour && mail.getItem() == Main.MagicChainmail)
//If player has Rupees in their inventory they become invincible and Rupees are drained
player.addPotionEffect(new PotionEffect(Potion.resistance.getId(), 1, 5));
//If player doesn't have Rupees, they are slowed, can't use items and are no longer invincible
//If player is wearing Megaton Boots they are slowed and knockback is prevented
//Rupees are irrelevant for these
if(player.getCurrentArmor(0) != null)
ItemStack boots = player.getCurrentArmor(0);
if(boots.getItem() == Main.MegatonBoots)
1) Minecraft doesn't initialise separate items from the item class. That's why ItemStack exists. Therefore, if I have 100 people on the server, each wearing 1 piece of armor, 't' is gonna increase by 100 each tick.
2, or actually 1a) The more armor you have, the faster it decreases (Not sure if intended)
Solution: You have two ways of doing this - The best one is to use NBT Data to store 't' per itemstack. Increase 't' by 1 every tick using the NBT data.
The other way is to store a static HashMap of player names/UUID's to 't', and save and load it, etc.