use of com.minecolonies.api.entity.combat.threat.IThreatTableEntity in project minecolonies by ldtteam.
the class KnightCombatAI method doAttack.
@Override
protected void doAttack(final LivingEntity target) {
if (user.distanceTo(target) > 1) {
moveInAttackPosition(target);
}
user.swing(Hand.MAIN_HAND);
user.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(user.getRandom()));
final double damageToBeDealt = getAttackDamage();
final DamageSource source = new NamedDamageSource(user.getName().getString(), user);
if (MineColonies.getConfig().getServer().pvp_mode.get() && target instanceof PlayerEntity) {
source.bypassArmor();
}
final int fireLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FIRE_ASPECT, user.getItemInHand(Hand.MAIN_HAND));
if (fireLevel > 0) {
target.setSecondsOnFire(fireLevel * 80);
}
if (user.level.getGameTime() - lastAoeUseTime > KNOCKBACK_COOLDOWN) {
doAoeAttack(source, damageToBeDealt);
}
target.hurt(source, (float) damageToBeDealt);
target.setLastHurtByMob(user);
if (target instanceof MobEntity && user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(KNIGHT_TAUNT) > 0) {
((MobEntity) target).setTarget(user);
if (target instanceof IThreatTableEntity) {
((IThreatTableEntity) target).getThreatTable().addThreat(user, 5);
}
}
user.stopUsingItem();
user.decreaseSaturationForContinuousAction();
user.getCitizenData().setVisibleStatus(KNIGHT_COMBAT);
user.getCitizenItemHandler().damageItemInHand(Hand.MAIN_HAND, 1);
}
use of com.minecolonies.api.entity.combat.threat.IThreatTableEntity in project minecolonies by Minecolonies.
the class KnightCombatAI method doAttack.
@Override
protected void doAttack(final LivingEntity target) {
if (user.distanceTo(target) > 1) {
moveInAttackPosition(target);
}
user.swing(Hand.MAIN_HAND);
user.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(user.getRandom()));
final double damageToBeDealt = getAttackDamage();
final DamageSource source = new NamedDamageSource(user.getName().getString(), user);
if (MineColonies.getConfig().getServer().pvp_mode.get() && target instanceof PlayerEntity) {
source.bypassArmor();
}
final int fireLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FIRE_ASPECT, user.getItemInHand(Hand.MAIN_HAND));
if (fireLevel > 0) {
target.setSecondsOnFire(fireLevel * 80);
}
if (user.level.getGameTime() - lastAoeUseTime > KNOCKBACK_COOLDOWN) {
doAoeAttack(source, damageToBeDealt);
}
target.hurt(source, (float) damageToBeDealt);
target.setLastHurtByMob(user);
if (target instanceof MobEntity && user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(KNIGHT_TAUNT) > 0) {
((MobEntity) target).setTarget(user);
if (target instanceof IThreatTableEntity) {
((IThreatTableEntity) target).getThreatTable().addThreat(user, 5);
}
}
user.stopUsingItem();
user.decreaseSaturationForContinuousAction();
user.getCitizenData().setVisibleStatus(KNIGHT_COMBAT);
user.getCitizenItemHandler().damageItemInHand(Hand.MAIN_HAND, 1);
}
Aggregations