use of net.minecraft.server.v1_9_R2.EntityLiving in project Citizens2 by CitizensDev.
the class NMSImpl method setKnockbackResistance.
@Override
public void setKnockbackResistance(LivingEntity entity, double d) {
EntityLiving handle = NMSImpl.getHandle(entity);
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
use of net.minecraft.server.v1_9_R2.EntityLiving in project Citizens2 by CitizensDev.
the class NMSImpl method setVerticalMovement.
@Override
public void setVerticalMovement(org.bukkit.entity.Entity bukkitEntity, double d) {
if (!bukkitEntity.getType().isAlive())
return;
EntityLiving handle = NMSImpl.getHandle((LivingEntity) bukkitEntity);
handle.be = (float) d;
}
use of net.minecraft.server.v1_9_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.getItemInMainHand(), target.getMonsterType());
i += EnchantmentManager.a(Enchantments.KNOCKBACK, handle);
}
boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
if (!flag)
return;
if (i > 0) {
target.f(-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_9_R2.EntityLiving in project Citizens2 by CitizensDev.
the class CitizensBlockBreaker method strengthMod.
private float strengthMod(IBlockData block) {
ItemStack itemstack = getCurrentItem();
float f = itemstack.a(block);
if (entity instanceof EntityLiving) {
EntityLiving handle = (EntityLiving) entity;
if (f > 1.0F) {
int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
if (i > 0) {
f += i * i + 1;
}
}
if (handle.hasEffect(MobEffects.FASTER_DIG)) {
f *= (1.0F + (handle.getEffect(MobEffects.FASTER_DIG).getAmplifier() + 1) * 0.2F);
}
if (handle.hasEffect(MobEffects.SLOWER_DIG)) {
float f1 = 1.0F;
switch(handle.getEffect(MobEffects.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.i(handle))) {
f /= 5.0F;
}
}
if (!entity.onGround) {
f /= 5.0F;
}
return f;
}
Aggregations