use of net.minecraft.server.v1_16_R2.EntityLiving in project Village_Defense by Plajer.
the class RidableIronGolem method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bt();
if (entityliving == null) {
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
P = 0.5f;
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
final float yaw = entityliving.yaw;
this.yaw = yaw;
lastYaw = yaw;
pitch = entityliving.pitch * 0.5f;
setYawPitch(this.yaw, pitch);
final float yaw2 = this.yaw;
aM = yaw2;
aO = yaw2;
f = entityliving.bd * 0.75F;
f1 = entityliving.be;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = 1.0F;
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project solinia3-core by mixxit.
the class EntityUtils method PSetHPChange.
public static void PSetHPChange(LivingEntity targetToDamage, Double hpchange, LivingEntity sourceEntityOfChange, boolean playHurtSound) {
if (targetToDamage instanceof ArmorStand || sourceEntityOfChange instanceof ArmorStand)
return;
if (hpchange == 0)
return;
// This will check both their invulnerability from minecraft and godmode from essentials
if (hpchange < 0 && EntityUtils.IsInvulnerable(targetToDamage))
return;
float cur_hp = ((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).getHealth();
float max_hp = ((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).getMaxHealth();
float hp = cur_hp + hpchange.floatValue();
if (hp >= max_hp)
cur_hp = max_hp;
else
cur_hp = hp;
((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).setHealth(cur_hp);
float soundVolume = 1.0F;
if (hpchange < 0) {
DamageSource damagesource = net.minecraft.server.v1_15_R1.DamageSource.mobAttack(((EntityLiving) ((CraftLivingEntity) sourceEntityOfChange).getHandle()));
DamageCause damagecause = DamageCause.ENTITY_ATTACK;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(sourceEntityOfChange, targetToDamage, damagecause, hpchange);
((CraftLivingEntity) targetToDamage).setLastDamage(hpchange.doubleValue());
((CraftLivingEntity) targetToDamage).setLastDamageCause(event);
((CraftLivingEntity) targetToDamage).setNoDamageTicks(20);
((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).hurtDuration = 10;
((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).hurtTicks = ((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).hurtDuration;
((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).getCombatTracker().trackDamage(damagesource, cur_hp, hpchange.floatValue());
if (((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).getHealth() <= 0.0F) {
targetToDamage.getWorld().playSound(targetToDamage.getLocation(), Sound.ENTITY_GENERIC_DEATH, soundVolume, GetSoundPitch(((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle())));
((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle()).die(damagesource);
} else {
if (targetToDamage instanceof Player) {
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftPlayer) targetToDamage).getHandle(), 1);
((CraftPlayer) targetToDamage).getHandle().playerConnection.sendPacket(packet);
}
if (playHurtSound)
targetToDamage.getWorld().playSound(targetToDamage.getLocation(), Sound.ENTITY_GENERIC_HURT, soundVolume, GetSoundPitch(((EntityLiving) ((CraftLivingEntity) targetToDamage).getHandle())));
}
}
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project Ublisk by Derkades.
the class V1_14_R1 method setTargetToClosestPlayer.
@Override
public void setTargetToClosestPlayer(final Creature creature, final Player player) {
final CraftLivingEntity craftLiving = (CraftLivingEntity) player;
final EntityLiving entityLiving = craftLiving.getHandle();
((CraftCreature) creature).getHandle().setGoalTarget(entityLiving, TargetReason.CLOSEST_PLAYER, false);
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project Citizens2 by CitizensDev.
the class NMSImpl method attack.
@Override
public void attack(LivingEntity attacker, LivingEntity btarget) {
EntityLiving handle = getHandle(attacker);
EntityLiving target = getHandle(btarget);
if (handle instanceof EntityPlayer) {
EntityPlayer humanHandle = (EntityPlayer) handle;
humanHandle.attack(target);
PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
return;
}
AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
int i = 0;
if (target instanceof EntityLiving) {
f += EnchantmentManager.a(handle.bA(), target.getMonsterType());
i += EnchantmentManager.a(handle);
}
boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
if (!flag)
return;
if (i > 0) {
target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
handle.motX *= 0.6D;
handle.motZ *= 0.6D;
}
int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
if (fireAspectLevel > 0) {
target.setOnFire(fireAspectLevel * 4);
}
}
use of net.minecraft.server.v1_16_R2.EntityLiving in project Citizens2 by CitizensDev.
the class CitizensBlockBreaker method strengthMod.
private float strengthMod(Block block) {
ItemStack itemstack = getCurrentItem();
float f = itemstack.a(block);
if (getHandle() instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) getHandle();
if (f > 1.0F) {
int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
if (i > 0) {
f += i * i + 1;
}
}
if (handle.hasEffect(MobEffectList.FASTER_DIG)) {
f *= (1.0F + (handle.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F);
}
if (handle.hasEffect(MobEffectList.SLOWER_DIG)) {
float f1 = 1.0F;
switch(handle.getEffect(MobEffectList.SLOWER_DIG).getAmplifier()) {
case 0:
f1 = 0.3F;
break;
case 1:
f1 = 0.09F;
break;
case 2:
f1 = 0.0027F;
break;
case 3:
default:
f1 = 8.1E-4F;
}
f *= f1;
}
if (handle.a(Material.WATER) && !EnchantmentManager.j(handle)) {
f /= 5.0F;
}
}
if (!getHandle().onGround) {
f /= 5.0F;
}
return f;
}
Aggregations