use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.
the class ItemDarkSteelSword method hitEntity.
@Override
public boolean hitEntity(@Nonnull ItemStack stack, @Nonnull EntityLivingBase entity, @Nonnull EntityLivingBase playerEntity) {
if (playerEntity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) playerEntity;
ItemStack sword = player.getHeldItemMainhand();
// Durability damage
EnergyUpgradeHolder eu = EnergyUpgradeManager.loadFromItem(stack);
if (eu != null && eu.getUpgrade().isAbsorbDamageWithPower() && eu.getEnergy() > 0) {
eu.extractEnergy(powerPerDamagePoint, false);
} else {
super.hitEntity(stack, entity, playerEntity);
}
// sword hit
if (eu != null) {
eu.writeToItem(sword, this);
if (eu.getEnergy() > Config.darkSteelSwordPowerUsePerHit) {
extractInternal(player.getHeldItemMainhand(), Config.darkSteelSwordPowerUsePerHit);
entity.getEntityData().setBoolean(HIT_BY_DARK_STEEL_SWORD, true);
}
}
}
return true;
}
use of crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade.EnergyUpgradeHolder in project EnderIO by SleepyTrousers.
the class EnergyUpgradeManager method setPowerFull.
public static void setPowerFull(@Nonnull ItemStack container, @Nonnull IDarkSteelItem item) {
if (!itemHasAnyPowerUpgrade(container)) {
return;
}
EnergyUpgradeHolder eu = loadFromItem(container);
eu.setEnergy(eu.getCapacity());
eu.writeToItem(container, item);
}
Aggregations