Ejemplo n.º 1
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.º 2
0
 public static org.bukkit.entity.Entity spawnCustomEntity(
     org.bukkit.World world, Location at, Class<? extends Entity> clazz, EntityType type) {
   World handle = ((CraftWorld) world).getHandle();
   Entity entity = null;
   try {
     Constructor<?> constructor = getCustomEntityConstructor(clazz, type);
     entity = (Entity) constructor.newInstance(handle);
   } catch (Exception e) {
     Messaging.logTr(Messages.ERROR_SPAWNING_CUSTOM_ENTITY, e.getMessage());
     return null;
   }
   handle.addEntity(entity);
   entity.setLocation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
   return entity.getBukkitEntity();
 }
Ejemplo n.º 3
0
 public static void trySwim(LivingEntity entity, float power) {
   Entity handle = getHandle(entity);
   if (RANDOM.nextFloat() < 0.8F && inWater(entity)) {
     handle.motY += power;
   }
 }