public static int func_77512_a(InventoryPlayer p_77512_0_, EntityLiving p_77512_1_) {
   field_77521_c.field_77495_a = 0;
   field_77521_c.field_77494_b = p_77512_1_;
   func_77518_a(field_77521_c, p_77512_0_.func_70448_g());
   return field_77521_c.field_77495_a > 0
       ? 1 + field_77522_a.nextInt(field_77521_c.field_77495_a)
       : 0;
 }
  private static void func_77516_a(IEnchantmentModifier p_77516_0_, ItemStack[] p_77516_1_) {
    ItemStack[] var2 = p_77516_1_;
    int var3 = p_77516_1_.length;

    for (int var4 = 0; var4 < var3; ++var4) {
      ItemStack var5 = var2[var4];
      func_77518_a(p_77516_0_, var5);
    }
  }