use of com.minecolonies.coremod.entity.CustomArrowEntity in project minecolonies by ldtteam.
the class RangerCombatAI method calculateDamage.
/**
* Calculates the ranged attack damage
*
* @param arrow
* @return the attack damage
*/
private double calculateDamage(final AbstractArrowEntity arrow) {
int damage = user.getCitizenData().getCitizenSkillHandler().getLevel(Skill.Agility) / 5;
final ItemStack heldItem = user.getItemInHand(Hand.MAIN_HAND);
damage += EnchantmentHelper.getDamageBonus(heldItem, target.getMobType()) / 2.5;
damage += EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, heldItem);
damage += user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARCHER_DAMAGE);
if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARCHER_USE_ARROWS) > 0) {
int slot = InventoryUtils.findFirstSlotInItemHandlerWith(user.getInventoryCitizen(), item -> item.getItem() instanceof ArrowItem);
if (slot != -1) {
if (!ItemStackUtils.isEmpty(user.getInventoryCitizen().extractItem(slot, 1, true))) {
damage += ARROW_EXTRA_DAMAGE;
((CustomArrowEntity) arrow).setOnHitCallback(entityRayTraceResult -> {
final int arrowSlot = InventoryUtils.findFirstSlotInItemHandlerWith(user.getInventoryCitizen(), item -> item.getItem() instanceof ArrowItem);
if (arrowSlot != -1) {
user.getInventoryCitizen().extractItem(arrowSlot, 1, false);
}
return true;
});
}
}
}
if (user.getHealth() <= user.getMaxHealth() * 0.2D) {
damage *= 2;
}
return (RANGER_BASE_DMG + damage) * MineColonies.getConfig().getServer().rangerDamageMult.get();
}
use of com.minecolonies.coremod.entity.CustomArrowEntity in project minecolonies by ldtteam.
the class RaiderRangedAI method doAttack.
@Override
protected void doAttack(final LivingEntity target) {
user.getNavigation().stop();
// Setup arrow
AbstractArrowEntity arrowEntity = CombatUtils.createArrowForShooter(user);
arrowEntity.setBaseDamage(user.getAttribute(MOB_ATTACK_DAMAGE).getValue());
if (flightCounter > 5) {
((CustomArrowEntity) arrowEntity).setPlayerArmorPierce();
arrowEntity.setSecondsOnFire(200);
arrowEntity.setBaseDamage(10);
}
if (user.getDifficulty() > ARROW_PIERCE_DIFFICULTY) {
arrowEntity.setPierceLevel((byte) 2);
}
// Shoot arrow
CombatUtils.shootArrow(arrowEntity, target, 10.0f);
// Visuals
user.swing(Hand.MAIN_HAND);
SoundEvent attackSound = SoundEvents.SKELETON_SHOOT;
if (arrowEntity instanceof ICustomAttackSound) {
attackSound = ((ICustomAttackSound) arrowEntity).getAttackSound();
}
user.playSound(attackSound, (float) 1.0D, (float) getRandomPitch());
}
use of com.minecolonies.coremod.entity.CustomArrowEntity in project minecolonies by Minecolonies.
the class RaiderRangedAI method doAttack.
@Override
protected void doAttack(final LivingEntity target) {
user.getNavigation().stop();
// Setup arrow
AbstractArrowEntity arrowEntity = CombatUtils.createArrowForShooter(user);
arrowEntity.setBaseDamage(user.getAttribute(MOB_ATTACK_DAMAGE).getValue());
if (flightCounter > 5) {
((CustomArrowEntity) arrowEntity).setPlayerArmorPierce();
arrowEntity.setSecondsOnFire(200);
arrowEntity.setBaseDamage(10);
}
if (user.getDifficulty() > ARROW_PIERCE_DIFFICULTY) {
arrowEntity.setPierceLevel((byte) 2);
}
// Shoot arrow
CombatUtils.shootArrow(arrowEntity, target, 10.0f);
// Visuals
user.swing(Hand.MAIN_HAND);
SoundEvent attackSound = SoundEvents.SKELETON_SHOOT;
if (arrowEntity instanceof ICustomAttackSound) {
attackSound = ((ICustomAttackSound) arrowEntity).getAttackSound();
}
user.playSound(attackSound, (float) 1.0D, (float) getRandomPitch());
}
use of com.minecolonies.coremod.entity.CustomArrowEntity in project minecolonies by Minecolonies.
the class RangerCombatAI method calculateDamage.
/**
* Calculates the ranged attack damage
*
* @param arrow
* @return the attack damage
*/
private double calculateDamage(final AbstractArrowEntity arrow) {
int damage = user.getCitizenData().getCitizenSkillHandler().getLevel(Skill.Agility) / 5;
final ItemStack heldItem = user.getItemInHand(Hand.MAIN_HAND);
damage += EnchantmentHelper.getDamageBonus(heldItem, target.getMobType()) / 2.5;
damage += EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, heldItem);
damage += user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARCHER_DAMAGE);
if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARCHER_USE_ARROWS) > 0) {
int slot = InventoryUtils.findFirstSlotInItemHandlerWith(user.getInventoryCitizen(), item -> item.getItem() instanceof ArrowItem);
if (slot != -1) {
if (!ItemStackUtils.isEmpty(user.getInventoryCitizen().extractItem(slot, 1, true))) {
damage += ARROW_EXTRA_DAMAGE;
((CustomArrowEntity) arrow).setOnHitCallback(entityRayTraceResult -> {
final int arrowSlot = InventoryUtils.findFirstSlotInItemHandlerWith(user.getInventoryCitizen(), item -> item.getItem() instanceof ArrowItem);
if (arrowSlot != -1) {
user.getInventoryCitizen().extractItem(arrowSlot, 1, false);
}
return true;
});
}
}
}
if (user.getHealth() <= user.getMaxHealth() * 0.2D) {
damage *= 2;
}
return (RANGER_BASE_DMG + damage) * MineColonies.getConfig().getServer().rangerDamageMult.get();
}
Aggregations