Ejemplo n.º 1
0
 public static void updateAI(EntityLiving entity) {
   updateSenses(entity);
   entity.getNavigation().e();
   entity.getControllerMove().c();
   entity.getControllerLook().a();
   entity.getControllerJump().b();
 }
Ejemplo n.º 2
0
 public static void updateNavigationWorld(LivingEntity entity, org.bukkit.World world) {
   if (NAVIGATION_WORLD_FIELD == null) return;
   EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
   World worldHandle = ((CraftWorld) world).getHandle();
   try {
     NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
   } catch (Exception e) {
     Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
   }
 }
Ejemplo n.º 3
0
  public static void setHeadYaw(EntityLiving handle, float yaw) {
    while (yaw < -180.0F) {
      yaw += 360.0F;
    }

    while (yaw >= 180.0F) {
      yaw -= 360.0F;
    }
    handle.aA = yaw;
    if (!(handle instanceof EntityHuman)) handle.ay = yaw;
    handle.aB = yaw;
  }
Ejemplo n.º 4
0
  public static void attack(EntityLiving handle, Entity target) {
    int damage = handle instanceof EntityMonster ? ((EntityMonster) handle).c(target) : 2;

    if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
      damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
    }

    if (handle.hasEffect(MobEffectList.WEAKNESS)) {
      damage -= 2 << handle.getEffect(MobEffectList.WEAKNESS).getAmplifier();
    }

    int knockbackLevel = 0;

    if (target instanceof EntityLiving) {
      damage += EnchantmentManager.a(handle, (EntityLiving) target);
      knockbackLevel +=
          EnchantmentManager.getKnockbackEnchantmentLevel(handle, (EntityLiving) target);
    }

    boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage);

    if (!success) return;
    if (knockbackLevel > 0) {
      target.g(
          -MathHelper.sin((float) (handle.yaw * Math.PI / 180.0F)) * knockbackLevel * 0.5F,
          0.1D,
          MathHelper.cos((float) (handle.yaw * Math.PI / 180.0F)) * knockbackLevel * 0.5F);
      handle.motX *= 0.6D;
      handle.motZ *= 0.6D;
    }

    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);

    if (fireAspectLevel > 0) target.setOnFire(fireAspectLevel * 4);
  }
Ejemplo n.º 5
0
 public static void updateSenses(EntityLiving entity) {
   entity.aD().a();
 }
Ejemplo n.º 6
0
 public static void look(LivingEntity bukkitEntity, float yaw, float pitch) {
   EntityLiving handle = getHandle(bukkitEntity);
   handle.yaw = yaw;
   setHeadYaw(handle, yaw);
   handle.pitch = pitch;
 }
Ejemplo n.º 7
0
 public static void look(EntityLiving handle, Entity target) {
   handle.getControllerLook().a(target, 10.0F, handle.bs());
 }
Ejemplo n.º 8
0
 public static boolean inWater(LivingEntity entity) {
   EntityLiving mcEntity = getHandle(entity);
   return mcEntity.G() || mcEntity.I();
 }