The Meaning of Life, the Universe, and Everything.
Join Date:
4/24/2014
Posts:
108
Member Details
I'm a bit new to the whole NBT thing... please forgive me. I'm trying to make a staff that has a current amount of mana that regenerates every tick, and a maximum amount of mana. Every time it's used, the current amount will go down according to what scroll is in the staff's inventory. How would I go about subtracting the value of the scroll's cost from the current mana cost..?
Current Code:
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
if(itemstack.getTagCompound().getInteger("CurrentMana")>=itemstack.getTagCompound().getInteger("EquippedScrollCost"))
{
// funny stuff here
}
return itemstack;
}
It would be faster and simpler to store the tag compound in a variable and for consistency sake (or at least what I, just a suggestion) you might want to make CurrentMana and EquippedScrollCost into constant strings.
It would faster and simpler to store the tag compound in a variable and for consistency sake (or at least what I, just a suggestion) you might want to make CurrentMana and EquippedScrollCost into constant strings.
I'm a bit new to the whole NBT thing... please forgive me. I'm trying to make a staff that has a current amount of mana that regenerates every tick, and a maximum amount of mana. Every time it's used, the current amount will go down according to what scroll is in the staff's inventory. How would I go about subtracting the value of the scroll's cost from the current mana cost..?
Current Code:
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
if(itemstack.getTagCompound().getInteger("CurrentMana")>=itemstack.getTagCompound().getInteger("EquippedScrollCost"))
{
// funny stuff here
}
return itemstack;
}
I've tried doing
itemstack.getTagCompound().getInteger("CurrentMana") - itemstack.getTagCompound.getInteger("EquippedScrollCost"));
But it doesn't seem to work. What should I be using? Thanks.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
SOLUTION:
Okay, so I think I found how to do it...
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
if(itemstack.getTagCompound().getInteger("CurrentMana")>=itemstack.getTagCompound().getInteger("EquippedScrollCost"))
{
itemstack.getTagCompound().setInteger("CurrentMana", itemstack.getTagCompound().getInteger("CurrentMana") - itemstack.getTagCompound().getInteger("EquippedScrollCost"));
}
return itemstack;
}
The solution area is marked in red.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
It would be faster and simpler to store the tag compound in a variable and for consistency sake (or at least what I, just a suggestion) you might want to make CurrentMana and EquippedScrollCost into constant strings.
I may be crazy, or maybe you're the crazy one, time will spill it soon enough
click us, or we die
how can I do this?
like this
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.