Search in sources :

Example 1 with EnergyUpgradeHolder

use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.

the class ItemDarkSteelArmor method damageArmor.

@Override
public void damageArmor(EntityLivingBase entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) {
    EnergyUpgradeHolder eu = EnergyUpgradeManager.loadFromItem(stack);
    if (eu != null && eu.getUpgrade().isAbsorbDamageWithPower() && eu.getEnergy() > 0) {
        eu.extractEnergy(damage * powerPerDamagePoint, false);
        eu.writeToItem(stack, this);
    } else {
        stack.damageItem(damage, NullHelper.notnullF(entity, "damageArmor() needs an entity"));
    }
}
Also used : EnergyUpgradeHolder(crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder)

Example 2 with EnergyUpgradeHolder

use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.

the class ItemDarkSteelBow method onFovUpdateEvent.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onFovUpdateEvent(FOVUpdateEvent fovEvt) {
    ItemStack currentItem = fovEvt.getEntity().getHeldItemMainhand();
    if (currentItem.getItem() != this || fovEvt.getEntity().getItemInUseCount() <= 0) {
        return;
    }
    int drawDuration = getMaxItemUseDuration(currentItem) - fovEvt.getEntity().getItemInUseCount();
    float ratio = drawDuration / (float) getDrawTime(currentItem);
    if (ratio > 1.0F) {
        ratio = 1.0F;
    } else {
        ratio *= ratio;
    }
    float mult = (float) Config.darkSteelBowFovMultipliers[0];
    EnergyUpgradeHolder upgrade = EnergyUpgradeManager.loadFromItem(currentItem);
    if (upgrade != null && upgrade.getEnergy() > 0) {
        mult = (float) Config.darkSteelBowFovMultipliers[upgrade.getUpgrade().getLevel() + 1];
    }
    fovEvt.setNewfov((1.0F - ratio * mult));
}
Also used : EnergyUpgradeHolder(crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with EnergyUpgradeHolder

use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.

the class ItemDarkSteelPickaxe method absorbDamageWithEnergy.

private boolean absorbDamageWithEnergy(@Nonnull ItemStack stack, int amount) {
    EnergyUpgradeHolder eu = EnergyUpgradeManager.loadFromItem(stack);
    if (eu != null && eu.getUpgrade().isAbsorbDamageWithPower() && eu.getEnergy() > 0) {
        eu.extractEnergy(amount, false);
        eu.writeToItem(stack, this);
        return true;
    } else {
        return false;
    }
}
Also used : EnergyUpgradeHolder(crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder)

Example 4 with EnergyUpgradeHolder

use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.

the class SpeedController method getActiveEnergyUpgrade.

private static EnergyUpgrade getActiveEnergyUpgrade(@Nonnull EntityPlayer player) {
    ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
    EnergyUpgradeHolder energyUpgradeHolder = EnergyUpgradeManager.loadFromItem(leggings);
    if (energyUpgradeHolder != null && energyUpgradeHolder.getEnergy() > 0) {
        return energyUpgradeHolder.getUpgrade();
    }
    return null;
}
Also used : EnergyUpgradeHolder(crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EnergyUpgradeHolder

use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.

the class EnergyUpgradeManager method extractEnergy.

public static int extractEnergy(@Nonnull ItemStack container, @Nonnull IDarkSteelItem item, int maxExtract, boolean simulate) {
    EnergyUpgradeHolder eu = loadFromItem(container);
    if (eu == null) {
        return 0;
    }
    int res = eu.extractEnergy(maxExtract, simulate);
    if (!simulate && res > 0) {
        eu.writeToItem(container, item);
    }
    return res;
}
Also used : EnergyUpgradeHolder(crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder)

Aggregations

EnergyUpgradeHolder (crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder)12 ItemStack (net.minecraft.item.ItemStack)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityArrow (net.minecraft.entity.projectile.EntityArrow)1 ItemArrow (net.minecraft.item.ItemArrow)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1