Search in sources :

Example 1 with IRunicArmor

use of thaumcraft.api.IRunicArmor in project BloodMagic by WayofTime.

the class BoundArmour method getRunicCharge.

@Override
@Optional.Method(modid = "Thaumcraft")
public int getRunicCharge(ItemStack itemstack) {
    ItemStack[] inv = this.getInternalInventory(itemstack);
    int shardLevel = this.getMaxBloodShardLevel(itemstack);
    int count = 0;
    int harden = 0;
    if (inv == null) {
        return 0;
    }
    for (ItemStack stack : inv) {
        if (count >= shardLevel) {
            break;
        }
        if (stack == null || !(stack.getItem() instanceof ArmourUpgrade)) {
            continue;
        }
        if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).armorType != this.armorType) {
            continue;
        }
        if (stack.hasTagCompound()) {
            NBTTagCompound tag = stack.getTagCompound();
            int enchLvl = tag.getByte("RS.HARDEN");
            if (stack.getItem() instanceof IRunicArmor) {
                enchLvl += ((IRunicArmor) stack.getItem()).getRunicCharge(stack);
            }
            if (enchLvl > 0) {
                harden += enchLvl;
                if (((ArmourUpgrade) stack.getItem()).isUpgrade()) {
                    count += 1;
                }
            }
        }
    }
    return harden;
}
Also used : ItemArmor(net.minecraft.item.ItemArmor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ArmourUpgrade(WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade) ItemStack(net.minecraft.item.ItemStack) IRunicArmor(thaumcraft.api.IRunicArmor)

Aggregations

ArmourUpgrade (WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade)1 ItemArmor (net.minecraft.item.ItemArmor)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 IRunicArmor (thaumcraft.api.IRunicArmor)1