Search in sources :

Example 26 with NBTTagFloat

use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.

the class ItemElectricAxeMP method getElectricityStored.

@Override
public float getElectricityStored(ItemStack itemStack) {
    if (!itemStack.hasTagCompound()) {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    float energyStored = 0f;
    if (itemStack.getTagCompound().hasKey("Electricity")) {
        NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
        if (obj instanceof NBTTagDouble) {
            energyStored = ((NBTTagDouble) obj).getFloat();
        } else if (obj instanceof NBTTagFloat) {
            energyStored = ((NBTTagFloat) obj).getFloat();
        }
    }
    itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
    return energyStored;
}
Also used : NBTTagFloat(net.minecraft.nbt.NBTTagFloat) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagDouble(net.minecraft.nbt.NBTTagDouble)

Example 27 with NBTTagFloat

use of net.minecraft.nbt.NBTTagFloat in project MorePlanets by SteveKunG.

the class ItemElectricPickaxeMP method getElectricityStored.

@Override
public float getElectricityStored(ItemStack itemStack) {
    if (!itemStack.hasTagCompound()) {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    float energyStored = 0f;
    if (itemStack.getTagCompound().hasKey("Electricity")) {
        NBTBase obj = itemStack.getTagCompound().getTag("Electricity");
        if (obj instanceof NBTTagDouble) {
            energyStored = ((NBTTagDouble) obj).getFloat();
        } else if (obj instanceof NBTTagFloat) {
            energyStored = ((NBTTagFloat) obj).getFloat();
        }
    }
    itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
    return energyStored;
}
Also used : NBTTagFloat(net.minecraft.nbt.NBTTagFloat) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagDouble(net.minecraft.nbt.NBTTagDouble)

Aggregations

NBTTagFloat (net.minecraft.nbt.NBTTagFloat)27 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)24 NBTTagDouble (net.minecraft.nbt.NBTTagDouble)21 NBTBase (net.minecraft.nbt.NBTBase)18 NBTTagList (net.minecraft.nbt.NBTTagList)13 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)9 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)9 NBTTagString (net.minecraft.nbt.NBTTagString)9 NBTTagByte (net.minecraft.nbt.NBTTagByte)8 NBTTagInt (net.minecraft.nbt.NBTTagInt)8 NBTTagLong (net.minecraft.nbt.NBTTagLong)8 NBTTagShort (net.minecraft.nbt.NBTTagShort)7 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Map (java.util.Map)3 TByteArrayList (gnu.trove.list.array.TByteArrayList)2 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2