use of net.minecraft.server.v1_14_R1.EntityLiving in project Village_Defense by Plajer.
the class RidableIronGolem method a.
public void a(float f, float f1, float f2) {
EntityLiving entityliving = null;
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.P = 0.5F;
this.aR = 0.02F;
this.k((float) 0.12);
super.a(f, f1, f2);
return;
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aO = this.aM = this.yaw;
f = entityliving.be * 0.5F * 0.75F;
f2 = entityliving.bg;
if (f2 <= 0.0f) {
f2 *= 0.25F;
}
k(0.12f);
super.a(f, f1, f2);
P = (float) 1.0;
}
use of net.minecraft.server.v1_14_R1.EntityLiving in project Warlords by ebicep.
the class WarlordsPlayer method addDamageInstance.
private void addDamageInstance(WarlordsDamageHealingEvent event) {
WarlordsPlayer attacker = event.getAttacker();
String ability = event.getAbility();
float min = event.getMin();
float max = event.getMax();
int critChance = event.getCritChance();
int critMultiplier = event.getCritMultiplier();
boolean ignoreReduction = event.isIgnoreReduction();
boolean isLastStandFromShield = event.isIsLastStandFromShield();
boolean isMeleeHit = ability.isEmpty();
boolean isFallDamage = ability.equals("Fall");
// Spawn Protection / Undying Army / Game State
if ((dead && !cooldownManager.checkUndyingArmy(false)) || getGameState() != getGame().getState()) {
return;
}
int initialHealth = health;
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.doBeforeReductionFromSelf(event);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.doBeforeReductionFromAttacker(event);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
critChance = abstractCooldown.addCritChanceFromAttacker(event, critChance);
critMultiplier = abstractCooldown.addCritMultiplierFromAttacker(event, critMultiplier);
}
// crit
float damageValue = (int) ((Math.random() * (max - min)) + min);
int crit = (int) ((Math.random() * (100)));
boolean isCrit = false;
if (crit <= critChance && attacker.canCrit) {
isCrit = true;
damageValue *= critMultiplier / 100f;
}
final float damageHealValueBeforeReduction = damageValue;
addAbsorbed(Math.abs(damageValue - (damageValue *= 1 - spec.getDamageResistance() / 100f)));
if (attacker == this && (isFallDamage || isMeleeHit)) {
if (isMeleeHit) {
// True damage
sendMessage(GIVE_ARROW + ChatColor.GRAY + " You took " + ChatColor.RED + Math.round(min) + ChatColor.GRAY + " melee damage.");
regenTimer = 10;
if (health - min <= 0 && !cooldownManager.checkUndyingArmy(false)) {
if (entity instanceof Player) {
PacketUtils.sendTitle((Player) entity, ChatColor.RED + "YOU DIED!", ChatColor.GRAY + "You took " + ChatColor.RED + Math.round(min) + ChatColor.GRAY + " melee damage and died.", 0, 40, 0);
}
health = 0;
die(attacker);
} else {
health -= min;
playHurtAnimation(this.entity, attacker);
}
} else {
// Fall Damage
sendMessage(GIVE_ARROW + ChatColor.GRAY + " You took " + ChatColor.RED + Math.round(damageValue) + ChatColor.GRAY + " fall damage.");
regenTimer = 10;
if (health - damageValue < 0 && !cooldownManager.checkUndyingArmy(false)) {
// Title card "YOU DIED!"
if (entity instanceof Player) {
PacketUtils.sendTitle((Player) entity, ChatColor.RED + "YOU DIED!", ChatColor.GRAY + "You took " + ChatColor.RED + Math.round(damageValue) + ChatColor.GRAY + " fall damage and died.", 0, 40, 0);
}
health = 0;
die(attacker);
} else {
health -= damageValue;
playHurtAnimation(entity, attacker);
}
addAbsorbed(Math.abs(damageValue * spec.getDamageResistance() / 100));
}
cancelHealingPowerUp();
return;
}
// Reduction before Intervene.
if (!ignoreReduction) {
// Flag carrier multiplier.
damageValue *= getFlagDamageMultiplier();
// Checks whether the player is standing in a Hammer of Light.
if (!HammerOfLight.standingInHammer(attacker, entity)) {
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
damageValue = abstractCooldown.modifyDamageBeforeInterveneFromSelf(event, damageValue);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
damageValue = abstractCooldown.modifyDamageBeforeInterveneFromAttacker(event, damageValue);
}
}
}
// Intervene
Optional<RegularCooldown> optionalInterveneCooldown = new CooldownFilter<>(this, RegularCooldown.class).filterCooldownClass(Intervene.class).filter(regularCooldown -> regularCooldown.getFrom() != this).findFirst();
if (optionalInterveneCooldown.isPresent() && !HammerOfLight.standingInHammer(attacker, entity) && isEnemy(attacker)) {
Intervene intervene = (Intervene) optionalInterveneCooldown.get().getCooldownObject();
WarlordsPlayer intervenedBy = optionalInterveneCooldown.get().getFrom();
damageValue *= .5;
intervenedBy.addAbsorbed(damageValue);
intervenedBy.setRegenTimer(10);
intervene.addDamagePrevented(damageValue);
intervenedBy.addDamageInstance(attacker, "Intervene", damageValue, damageValue, isCrit ? 100 : -1, 100, false);
Location loc = getLocation();
// EFFECTS + SOUNDS
Utils.playGlobalSound(loc, "warrior.intervene.block", 2, 1);
playHitSound(attacker);
entity.playEffect(EntityEffect.HURT);
intervenedBy.getEntity().playEffect(EntityEffect.HURT);
// Red line particle if the player gets hit
EffectUtils.playParticleLinkAnimation(getLocation(), intervenedBy.getLocation(), 255, 0, 0, 2);
// Remove horses.
removeHorse();
intervenedBy.removeHorse();
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onInterveneFromAttacker(event, damageValue);
}
} else {
// Damage reduction after Intervene
if (!ignoreReduction) {
if (!HammerOfLight.standingInHammer(attacker, entity)) {
// Example: .8 = 20% reduction.
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
damageValue = abstractCooldown.modifyDamageAfterInterveneFromSelf(event, damageValue);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
damageValue = abstractCooldown.modifyDamageAfterInterveneFromAttacker(event, damageValue);
}
}
}
// Arcane Shield
List<ArcaneShield> arcaneShields = new CooldownFilter<>(this, RegularCooldown.class).filterCooldownClassAndMapToObjectsOfClass(ArcaneShield.class).collect(Collectors.toList());
if (!arcaneShields.isEmpty() && isEnemy(attacker) && !HammerOfLight.standingInHammer(attacker, entity)) {
ArcaneShield arcaneShield = arcaneShields.get(0);
// adding dmg to shield
arcaneShield.addShieldHealth(-damageValue);
// check if broken
if (arcaneShield.getShieldHealth() < 0) {
if (entity instanceof Player) {
((EntityLiving) ((CraftPlayer) entity).getHandle()).setAbsorptionHearts(0);
}
cooldownManager.removeCooldown(arcaneShield);
addDamageInstance(new WarlordsDamageHealingEvent(this, attacker, ability, -arcaneShield.getShieldHealth(), -arcaneShield.getShieldHealth(), isCrit ? 100 : -1, 100, false, true, true));
addAbsorbed(-(arcaneShield.getShieldHealth()));
return;
} else {
if (entity instanceof Player) {
((EntityLiving) ((CraftPlayer) entity).getHandle()).setAbsorptionHearts((float) (arcaneShield.getShieldHealth() / (maxHealth * .5) * 20));
}
if (isMeleeHit) {
sendMessage(GIVE_ARROW + ChatColor.GRAY + " You absorbed " + attacker.getName() + "'s melee " + ChatColor.GRAY + "hit.");
attacker.sendMessage(RECEIVE_ARROW + ChatColor.GRAY + " Your melee hit was absorbed by " + name);
} else {
sendMessage(GIVE_ARROW + ChatColor.GRAY + " You absorbed " + attacker.getName() + "'s " + ability + " " + ChatColor.GRAY + "hit.");
attacker.sendMessage(RECEIVE_ARROW + ChatColor.GRAY + " Your " + ability + " was absorbed by " + name + ChatColor.GRAY + ".");
}
addAbsorbed(Math.abs(damageHealValueBeforeReduction));
}
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onShieldFromSelf(event, damageValue, isCrit);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onShieldFromAttacker(event, damageValue, isCrit);
}
playHurtAnimation(this.entity, attacker);
if (!isMeleeHit) {
playHitSound(attacker);
}
removeHorse();
} else {
boolean debt = getCooldownManager().hasCooldownFromName("Spirits Respite");
if (isEnemy(attacker)) {
hitBy.put(attacker, 10);
cancelHealingPowerUp();
removeHorse();
regenTimer = 10;
sendDamageMessage(attacker, this, ability, damageValue, isCrit, isMeleeHit);
if (spec instanceof Vindicator) {
((SoulShackle) spec.getRed()).addToShacklePool(damageValue);
}
// Repentance
if (spec instanceof Spiritguard) {
((Repentance) spec.getBlue()).addToPool(damageValue);
}
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onDamageFromSelf(event, damageValue, isCrit);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onDamageFromAttacker(event, damageValue, isCrit);
}
}
updateJimmyHealth();
// debt and healing
if (!debt && takeDamage) {
this.health -= Math.round(damageValue);
}
attacker.addDamage(damageValue);
playHurtAnimation(this.entity, attacker);
recordDamage.add(damageValue);
// The player died.
if (this.health <= 0 && !cooldownManager.checkUndyingArmy(false)) {
if (attacker.entity instanceof Player) {
((Player) attacker.entity).playSound(attacker.getLocation(), Sound.ORB_PICKUP, 500f, 1);
((Player) attacker.entity).playSound(attacker.getLocation(), Sound.ORB_PICKUP, 500f, 0.5f);
}
attacker.addKill();
sendMessage(ChatColor.GRAY + "You were killed by " + attacker.getColoredName());
attacker.sendMessage(ChatColor.GRAY + "You killed " + getColoredName());
gameState.getGame().forEachOnlinePlayer((p, t) -> {
if (p != this.entity && p != attacker.entity) {
p.sendMessage(getColoredName() + ChatColor.GRAY + " was killed by " + attacker.getColoredName());
}
});
for (WarlordsPlayer enemy : PlayerFilter.playingGame(game).enemiesOf(this).stream().collect(Collectors.toList())) {
for (AbstractCooldown<?> abstractCooldown : enemy.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onDeathFromEnemies(event, damageValue, isCrit, enemy == attacker);
}
}
// Title card "YOU DIED!"
if (this.entity instanceof Player) {
PacketUtils.sendTitle((Player) entity, ChatColor.RED + "YOU DIED!", ChatColor.GRAY + attacker.getName() + " killed you.", 0, 40, 0);
}
die(attacker);
} else {
if (!isMeleeHit && this != attacker && damageValue != 0) {
playHitSound(attacker);
}
}
}
}
for (AbstractCooldown<?> abstractCooldown : getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onEndFromSelf(event, damageValue, isCrit);
}
for (AbstractCooldown<?> abstractCooldown : attacker.getCooldownManager().getCooldownsDistinct()) {
abstractCooldown.onEndFromAttacker(event, damageValue, isCrit);
}
getCooldownManager().getCooldowns().removeAll(new CooldownFilter<>(attacker, DamageHealCompleteCooldown.class).stream().collect(Collectors.toList()));
attacker.getCooldownManager().getCooldowns().removeAll(new CooldownFilter<>(attacker, DamageHealCompleteCooldown.class).stream().collect(Collectors.toList()));
// WarlordsDamageHealingFinalEvent finalEvent = new WarlordsDamageHealingFinalEvent(
// this,
// attacker,
// ability,
// initialHealth,
// damageValue,
// critChance,
// critMultiplier,
// isCrit,
// true);
// secondStats.addDamageHealingEventAsSelf(finalEvent);
// attacker.getSecondStats().addDamageHealingEventAsAttacker(finalEvent);
//
// checkForAchievementsDamage(attacker);
}
use of net.minecraft.server.v1_14_R1.EntityLiving in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_14_R1 method show.
@Override
public void show(@NotNull Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
if (connections.contains(connection))
throw new IllegalArgumentException();
connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
connection.sendPacket(new PacketPlayOutEntityVelocity(cache, new Vec3D(motion.getX(), motion.getY(), motion.getZ())));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
// Inject the player's packet connection into this listener, so we can
// show the player position/velocity/rotation changes
connections.add(connection);
}
use of net.minecraft.server.v1_14_R1.EntityLiving in project MechanicsMain by WeaponMechanics.
the class v1_9_R2 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_9_R2.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_14_R1.EntityLiving in project MechanicsMain by WeaponMechanics.
the class v1_11_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_11_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);
}
Aggregations