use of net.minecraft.server.v1_16_R3.DamageSource in project Denizen by DenizenScript.
the class EntityHelperImpl method getDamageTo.
@Override
public double getDamageTo(LivingEntity attacker, Entity target) {
EnumMonsterType monsterType;
if (target instanceof LivingEntity) {
monsterType = ((CraftLivingEntity) target).getHandle().getMonsterType();
} else {
monsterType = EnumMonsterType.UNDEFINED;
}
double damage = 0;
AttributeInstance attrib = attacker.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
if (attrib != null) {
damage = attrib.getValue();
}
if (attacker.getEquipment() != null && attacker.getEquipment().getItemInMainHand() != null) {
damage += EnchantmentManager.a(CraftItemStack.asNMSCopy(attacker.getEquipment().getItemInMainHand()), monsterType);
}
if (damage <= 0) {
return 0;
}
if (target != null) {
DamageSource source;
if (attacker instanceof Player) {
source = DamageSource.playerAttack(((CraftPlayer) attacker).getHandle());
} else {
source = DamageSource.mobAttack(((CraftLivingEntity) attacker).getHandle());
}
net.minecraft.server.v1_16_R3.Entity nmsTarget = ((CraftEntity) target).getHandle();
if (nmsTarget.isInvulnerable(source)) {
return 0;
}
if (!(nmsTarget instanceof EntityLiving)) {
return damage;
}
EntityLiving livingTarget = (EntityLiving) nmsTarget;
damage = CombatMath.a((float) damage, (float) livingTarget.getArmorStrength(), (float) livingTarget.getAttributeInstance(GenericAttributes.ARMOR_TOUGHNESS).getValue());
int enchantDamageModifier = EnchantmentManager.a(livingTarget.getArmorItems(), source);
if (enchantDamageModifier > 0) {
damage = CombatMath.a((float) damage, (float) enchantDamageModifier);
}
}
return damage;
}
use of net.minecraft.server.v1_16_R3.DamageSource in project MechanicsMain by WeaponMechanics.
the class v1_16_R3 method logDamage.
@Override
public void logDamage(LivingEntity victim, LivingEntity source, double health, double damage, boolean isMelee) {
DamageSource damageSource;
if (isMelee) {
if (source instanceof Player) {
damageSource = DamageSource.playerAttack(((org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) source).getHandle());
} else {
damageSource = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
} else {
damageSource = DamageSource.projectile(null, ((CraftLivingEntity) source).getHandle());
}
EntityLiving nms = ((CraftLivingEntity) victim).getHandle();
nms.combatTracker.trackDamage(damageSource, (float) damage, (float) health);
}
use of net.minecraft.server.v1_16_R3.DamageSource in project MechanicsMain by WeaponMechanics.
the class v1_10_R1 method logDamage.
@Override
public void logDamage(LivingEntity victim, LivingEntity source, double health, double damage, boolean isMelee) {
DamageSource damageSource;
if (isMelee) {
if (source instanceof Player) {
damageSource = DamageSource.playerAttack(((org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) source).getHandle());
} else {
damageSource = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
} else {
damageSource = DamageSource.projectile(null, ((CraftLivingEntity) source).getHandle());
}
EntityLiving nms = ((CraftLivingEntity) victim).getHandle();
nms.combatTracker.trackDamage(damageSource, (float) damage, (float) health);
}
use of net.minecraft.server.v1_16_R3.DamageSource in project MechanicsMain by WeaponMechanics.
the class v1_15_R1 method logDamage.
@Override
public void logDamage(LivingEntity victim, LivingEntity source, double health, double damage, boolean isMelee) {
DamageSource damageSource;
if (isMelee) {
if (source instanceof Player) {
damageSource = DamageSource.playerAttack(((CraftPlayer) source).getHandle());
} else {
damageSource = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
} else {
damageSource = DamageSource.projectile(null, ((CraftLivingEntity) source).getHandle());
}
EntityLiving nms = ((CraftLivingEntity) victim).getHandle();
nms.combatTracker.trackDamage(damageSource, (float) damage, (float) health);
}
Aggregations