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"));
}
}
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));
}
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;
}
}
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;
}
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;
}
Aggregations